unosquare / ffmediaelement

FFME: The Advanced WPF MediaElement (based on FFmpeg)
https://unosquare.github.io/ffmediaelement/
Other
1.17k stars 240 forks source link

Raise an event in case of ReadTimeout #536

Closed Arestihub closed 3 years ago

Arestihub commented 3 years ago

Raise an event in case of ReadTimeout

Hello.

I am using FFME for RTSP streaming. If the stream is closed in a proper way by the sender there will be an event (MediaEnded or MediaClosed), which can be used to detect the need for stream retry etc.

However if the stream is forced shut by the sender or these is a network error, the only way to detect it seems to be setting ReadTimeout and then looking at the MessageLogged event, which logs an error in case of OnStreamReadInterrupt:

https://github.com/unosquare/ffmediaelement/blob/b449fbb960078b3770b52c4bf26dfb0d2cefc5e6/Unosquare.FFME/Container/MediaContainer.cs

The mediaelement itself doesn't seem to react to the event in any way. The state of the stream is still playing, the bitrate seems to be fine, there is no buffering ended event etc.

Could OnStreamReadInterrupt event be added to MediaEvents? Is there some other way of detecting the timeout?

Issue Categories

Version Information

Steps to Reproduce

  1. Handle OnMediaInitializing event
  2. Set Configuration.ReadTimeout (5 seconds, for instance)
  3. --> The only event raised in case of timeout seems to be the MessageLogged event

Expected Results

Sample Code

C

Media Initializing configuration:

                e.Configuration.GlobalOptions.FlagNoBuffer = true;
                e.Configuration.GlobalOptions.ProbeSize = 32;
                e.Configuration.PrivateOptions["fflags"] = "nobuffer";
                e.Configuration.PrivateOptions["rtbufsize"] = "10M";
                e.Configuration.PrivateOptions["buffer_size"] = "256k";
                e.Configuration.PrivateOptions["rtsp_transport"] = "tcp";
                e.Configuration.ReadTimeout = TimeSpan.FromSeconds(5);
stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Vasilich commented 3 years ago

unstale this in hope that this project isn't abandoned yet..

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Vasilich commented 3 years ago

unstale

mariodivece commented 3 years ago

I've wired it up in the latest commit. Check it out!