[Live-devel] Problem stopping and restarting an RTSP client

Mike Miller mike at MillerMicroSystems.com
Mon Jul 9 10:09:20 PDT 2012


I am using a derivative of the testRTSPClient in an application. I am 
detecting stream failure by looking for missing frames. When I detect 
that the stream has been "silent" for too long, I need to close that 
stream and reopen it. I know the stream source is still working because 
other clients are still receiving. I am currently using only a single 
stream, but I left the code to handle multiple streams should I need it.

When I need to restart a stream, I call this function:

short StopAllRtspStreams(void)

{

     *env << "\n\n*** StopAllRtspStreams()\n";

     CaptureEnabled = false;

     if (initialized)

         StopExecThread();

     for (int i = 0; i < rtspClientCount; ++i)

     {

         if (rtspClients[i] != NULL)

         {

             *env << "shutting down " << *rtspClients[i] << "\n";

             shutdownStream(rtspClients[i]);

         }

         rtspClients[i] = NULL;

     }

     rtspClientCount = 0;

     // TODO anything else?

     return 0;

}

Then when restarting the stream, I call:

short StartRtspStream(char * rtspURL,

                       BufferPool_t * videoPool,

                       BufferPool_t * leftPool,

                       BufferPool_t * rightPool,

                       BUFFER_CAPTURE_CALLBACK_PROC callback)

{

     if (!initialized)

         StartExecThread();

     *env << "\n\n*** StartRtspStream(" << rtspURL << ", ...)\n";

     RTSPClient* rtspClient = ourRTSPClient::createNew(*env, rtspURL, RTSP_CLIENT_VERBOSITY_LEVEL, 0, videoPool, leftPool, rightPool, callback);

     if (rtspClient == NULL)

     {

         *env << "Failed to create a RTSP client for URL \"" << rtspURL << "\": " << env->getResultMsg() << "\n";

         return 0;

     }

     rtspClient->sendDescribeCommand(continueAfterDESCRIBE);

     rtspClients[rtspClientCount] = rtspClient;

     ++rtspClientCount;

     return 1;

}

On the restart, the thing gets hung up waiting for the socket to connect:

*** StartRtspStream(rtsp://192.168.233.1/test, ...)
openConnection() entry
Opening connection to 192.168.233.1, port 554, socket 2148...
...connection pending (10035)

My code will detect that it didn't work, shut it down, and try to start 
it again. Over and over again. I'm guessing that I'm not shutting 
something down properly. I just can't figure out what.

Suggestions?

Mike [;-}>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120709/44f7eb99/attachment.html>


More information about the live-devel mailing list