Recovering if a stream has died

This forum is about all development around libVLC.
Ultraseamus
Blank Cone
Blank Cone
Posts: 18
Joined: 06 May 2009 18:47

Recovering if a stream has died

Postby Ultraseamus » 06 May 2009 19:07

I am reading a rtsp feed through the following code. The stream itself is working fine, my problem is that if the stream dies (say by unplugging the CAT6 cable) I can not get it to recover without making another call to my init code. This is fine, but I can not even tell when the stream has died, or when it has come back up. Ideally there would be a way for my to get vlc to auto recover, a close second would be if I could somehow monitor the feed, know when the stream died, and know when it has picked back up, allowing me to start displaying the feed again. With my current code the image is frozen on the last valid frame received. I do not know very much about VLC, if any more information is needed please ask. Thanks in advance for any help.

I am coding in C++, Visual Studio, for a program which will be running on embedded windows.

Edit: I see that there are a few other posts here that ask similar questions, how to tell if a stream is dead. But that is only half my issue, I could come up with a couple of ways the see if the stream has died, but I am really not sure of a better way to see when the stream is back up, aside from writing code that constantly checks the packets being sent out. I figure there must be a reason why the feed can not recover on its own, and am curious as to what that reason is.

Code: Select all

/* * Initialise libVLC */ sprintf(clock, "%lld", (long long int)(intptr_t)lock); sprintf(cunlock, "%lld", (long long int)(intptr_t)unlock); sprintf(cdata, "%lld", (long long int)(intptr_t)this); sprintf(width, "%i", VIDEO_WIDTH); sprintf(height, "%i", VIDEO_HEIGHT); sprintf(pitch, "%i", VIDEO_WIDTH * 4); char const *vlc_argv[] = { //"-q", "-vvvvv", "--plugin-path", "plugins", "--ignore-config", "--noaudio", "--no-overlay", "--no-video-title-show", "--no-osd", "--vout", "vmem", "--vmem-width", width, "--vmem-height", height, "--vmem-pitch", pitch, "--vmem-chroma", "RV32", "--vmem-lock", clock, "--vmem-unlock", cunlock, "--vmem-data", cdata, }; int vlc_argc = sizeof (vlc_argv) / sizeof (*vlc_argv); libvlc_exception_init_dll (&ex); m_libvlc = libvlc_new_dll (vlc_argc, vlc_argv, &ex); catchException (&ex); char ipString[50]; strcpy (ipString, "rtsp://"); strcat (ipString, "192.168.1.200"); strcat (ipString, "/Live"); m_media = libvlc_media_new_dll (m_libvlc, ipString, &ex); catchException (&ex); libvlc_media_add_option_dll (m_media, "rtsp-caching=200", &ex); catchException (&ex); m_media_player = libvlc_media_player_new_from_media_dll (m_media, &ex); catchException (&ex); libvlc_media_player_play_dll (m_media_player, &ex); catchException (&ex);

Ultraseamus
Blank Cone
Blank Cone
Posts: 18
Joined: 06 May 2009 18:47

Re: Recovering if a stream has died

Postby Ultraseamus » 30 Jul 2009 00:59

Refresher on what I am trying to do: I am using C++ with vlc to connect to a server that is streaming an RTSP video feed. All of that is working fine, my problem is knowing when the server is not there. I figured out how to do this, it involved setting up an event manager, and listening for certain events. My current issue is that the fail event for both libvlc_media_event_manager and libvlc_media_player_event_manager seem to take a very long time, around a minute or so after connection to the server is lost.

As I see it, this leaves me with 2 options. I could just check for a changed state to libvlc_Playing, and assume if I do not receive this message within x seconds, it is time to try to make the connection again. My other option (which is what I want to do) would be to set the timeout to a much lower value. Is this possible? If I am leaving out any crucial information, or am not being clear, please tell me. I am very new to VLC, and would appreciate any help. Thanks.

mohit839
New Cone
New Cone
Posts: 7
Joined: 27 Apr 2009 13:12

Re: Recovering if a stream has died

Postby mohit839 » 20 Jan 2010 08:49

Can you please tell us what specific events were you listening to capture the condition that the server or the network is down in a stream. Also were you able to fix the latency issue that you have posted?

Idsa
Blank Cone
Blank Cone
Posts: 78
Joined: 22 Oct 2009 10:59

Re: Recovering if a stream has died

Postby Idsa » 20 Jan 2010 09:17

Ultraseamus, I use two events (don't remember their full names) for handling network problems:
1. Error: It is raised if vlc can't connect to the source at recording start
2. Ended: It is raised if there is no signal for more than rtp-timeout seconds


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 6 guests