Recovering if a stream has died
Posted: 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.
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);