I'm implementing an RTSP player in a Xamarin.Forms app. The video plays in the VideoView for 60 seconds before the stream is stopped. According to the Videolan Command Line Help the default rtsp timeout is 60 seconds. I have been unable to override this using the various option formats provided.
I've already tried adding the following options in both the LibVLC constructor and through the media's AddOptions method using the --, - and : prefixes, all to no avail: --rtsp-tcp --rtsp-timeout=300 --rtsp-stream-timeout=300 --sout-keep
Usage Example below:
readonly LibVLC _libvlc;
public VideoPage()
{
InitializeComponent();
Core.Initialize();
_libvlc = new LibVLC(new string[] { "--rtsp-timeout=300" });
ShowVideo();
}
private void ShowVideo()
{
var stream = "rtsp://1.2.3.4:1234/MyStream";
using (var media = new Media(_libvlc, stream, Media.FromType.FromLocation))
{
var config = new MediaConfiguration();
config.EnableHardwareDecoding();
media.AddOption(":rtsp-timeout=300");
media.AddOption(config);
VideoView0.MediaPlayer = new MediaPlayer(_libvlc);
VideoView0.MediaPlayer.Play(media);
}
}
I expected the stream to remain open and the video to continue playing for the given timeout duration, but it stops after 60 seconds. Any assistance would be appreciated!
EDIT
It seems the server has a 60 second time out. I don't have control over that, so the solution needs to come from the client side. How would I send a keepalive/RR packet that informs the server to keep the connection open?