0

I'd like to know when the SampleRequested event is fired in UWP. According to the official doc page it

Occurs when the MediaStreamSource request a MediaStreamSample for a specified stream.

but I'd like to know more in more detail when this request occurs. For instance what make this event happen? Every frame change? Every packet received from the RTSP stream?

Furthermore I'd like to know if there is a way to "control" this event, i.e. firing it programmatically since I need to take the MediaStreamSample only in a specific moment and only one time. And it looks like it happens multiple times during my rtsp streaming effecting the latency of my stream (about 4000ms lag).

Thanks.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91
  • It's called once it needs another sample, and it takes some time to first buffer up the beginning of the media being played back, and then it's called on an as-needed basis, once per needed Sample. – Xie Steven Aug 01 '19 at 02:19

1 Answers1

0

I haven't used MediaStreamSource in UWP extensively so I provide just a general suggestion, maybe someone more experienced will provide a more useful answer.

I presume this event is called by the media player control to preload the stream and you cannot control the frequency at which it is called. What you can control however is how soon you provide the response - MediaStreamSourceSampleRequestedEventArgs event args have a Request property, which is of type MediaStreamSourceSampleRequest. You can use GetDeferral method to indicate you need to delay the delivery of the sample and return it only after a specific delay. You can indicate "loading" to the user using the ReportSampleProgress method. When you are done, you can indicate this on the deferral by calling deferral.Complete().

Finally, if you no longer want to provide any samples, just assign the Sample property to null.

Martin Zikmund
  • 38,440
  • 7
  • 70
  • 91