Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
4.67/5 (3 votes)
See more:
I am using a derivative of the Live555 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:

C#
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:

C#
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 [;-}>
Posted
Comments
SoMad 9-Jul-12 17:07pm    
I see that you have already posted this question on the Live555 developer mailing list and that Ross Finlayson answered. Were you able to use his answer to get any closer to a solution?

Soren Madsen

1 solution

Unfortunately you will not have shown the condition for which is called StartRtspStream method. What does it mean "My code will detect that it didn't work...."?
Please show your code....

Notice , RTSP protocol provides control messages from server to client

Maybe there is a problem in communication between RTSP-server and client.
You are using any sniffer,like Wireshark,for example?
Check all incoming/outgoing messages to/from server...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900