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.
I haven't used
MediaStreamSourcein 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 -
MediaStreamSourceSampleRequestedEventArgsevent args have aRequestproperty, which is of typeMediaStreamSourceSampleRequest. You can useGetDeferralmethod 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 theReportSampleProgressmethod. When you are done, you can indicate this on the deferral by callingdeferral.Complete().Finally, if you no longer want to provide any samples, just assign the
Sampleproperty tonull.