live555 问题汇总

1)live555 sendOptionsCommand 发送完命令后如何判断超时; vlc 中有下面的函数

 

/* return true if the RTSP command succeeded */
static bool wait_Live555_response( demux_t *p_demux, int i_timeout = 0 /* ms */ )
{
    TaskToken task;
    demux_sys_t * p_sys = p_demux->p_sys;
    p_sys->event_rtsp = 0;
    if( i_timeout > 0 )
    {
        /* Create a task that will be called if we wait more than timeout ms */
        task = p_sys->scheduler->scheduleDelayedTask( i_timeout*1000,
                                                      TaskInterruptRTSP,
                                                      p_demux );
    }
    p_sys->event_rtsp = 0;
    p_sys->b_error = true;
    p_sys->i_live555_ret = 0;
    p_sys->scheduler->doEventLoop( &p_sys->event_rtsp );
    //here, if b_error is true and i_live555_ret = 0 we didn't receive a response
    if( i_timeout > 0 )
    {
        /* remove the task */
        p_sys->scheduler->unscheduleDelayedTask( task );
    }
    return !p_sys->b_error;
}

2)live555 如何判断网络断开,如何实现重连功能;

live555 断线重连资料--网上搜的

http://www.codeproject.com/Questions/418339/Problem-stopping-and-restarting-a-Live555-RTSP-client

Problem stopping and restarting a Live555 RTSP client

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:
 

 Collapse | Copy Code
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:
 

 Collapse | Copy Code
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:
 

 Collapse | Copy Code
*** 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?

答复:
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?

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....
 
答复2:
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...
:
Soren Madsen


问题2:
Re: Help to understand the rtsp client connection close 2012-06-21 16:50
--Apple-Mail=_62EDA103-E92A-4B63-B588-3CDB0B59FAAD
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
charset=windows-1252

>I am using the LIVE555 livemedia library for my camera recording development.
>
>I have a problem.
>
>1. I started camera recording recording in progress
>2. Camera powered off the RTSP connection got closed. (monitored through net stat)
>3. Program is not come out the play state.
>
>Please help me to understand how to get the rtsp connection closed notification. So that I can re-connect.
>
>Is there any method to automatically reconnect the rtsp client to the rtsp server (camera).

答复:
Sorry, but this question is so ridiculously vague, it's simply impossible to answer.

You'll need to say a *lot* more about what your software does, how it uses the "LIVE555 Streaming Media" software (is is a RTSP client, a RTSP server, or are you using one of

the supplied demo applications?), and what, if any, additional software you have written to work with the LIVE555 code. Also, you'll need to be a lot more specific about what

your problem is.


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/

问题3:
Reconnect after lost connection

>How can I check when the connection to the RTSP server has been
>broken due to network failure?  I have a RTSP client streaming video
>and saving this to disk using a MediaSink.  Is there a way to
>specify a timeout on the RTP socket and then have a callback on this
>timeout?

I suggest using "TaskScheduler::scheduleDelayedTask()" to set up a
'watchdog timer' immediately after you've gotten a response from the
RTSP "PLAY" command, and reset this timer each time new data arrives
in your 'sink' object.  (You can do this by subclassing your sink
class, and redefining the "continuePlaying()" virtual function to
reset the watchdog timer (and then call the parent class's
"continuePlaying()".)

This will check not only for 'network failure', but also for the server dying.

You can reset the watchdog timer using
"TaskScheduler::rescheduleDelayedTask()".

 

 3)WaitForSingleObject/MsgWaitForMultipleObjects 造成live555 死锁

我要实现实现不断的断开码流,然后在接连码流的功能;但是我想等doEventLoop 退出后在重新连接,怎么判断doEventLoop已经退出,我用waitforsingleobject等待信号量或线程结束都不行,死锁在waitforsingleobject;

 

bool NetSdk::StartReceiveVideo(void)
{
 //
 if (m_bPlayFlag)
 {
  TRACE("StartReceiveVideo run false1\n");

  return false;
 }

 if (m_StreamIndex>=CLIENT_STREAM_NUM||m_StreamIndex<0)
 {
  TRACE("StartReceiveVideo run false2\n");

  return false;
 }

 struRtspGlobal[m_StreamIndex].pNetSdk=this;
 struRtspGlobal[m_StreamIndex].pRtspClient=NULL;

 m_ThreadHandle=(HANDLE)_beginthread(ReceiveThread, 0, &struRtspGlobal[m_StreamIndex]);

 m_bPlayFlag=true;

 TRACE("StartReceiveVideo run ok\n");

 return true;

}

//
bool NetSdk::StopReceiveVideo(void)
{
 //
 if (!m_bPlayFlag)
 {
  TRACE("StopReceiveVideo run false\n");
  return false;
 }

 eventLoopWatchVariable=1;
 TRACE("StopReceiveVideo run ok\n");


 if (WaitForSingleObject(m_ThreadHandle,INFINITE)==WAIT_OBJECT_0)
 {
  TRACE("StopReceiveVideo run ok1\n");
 }

 

 return true;
}

 

调用的是在同一个线程中自动实现

StopReceiveVideo和StartReceiveVideo,造成死锁!如果从UI

 

 

你可能感兴趣的:(live555 问题汇总)