live555 问题汇总

来源:互联网 发布:mac ps cs4破解版下载 编辑:程序博客网 时间:2024/06/05 18:09

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

 

 

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 诚信答题密码忘了怎么办 我未成年杀了人怎么办 错过了网课考试怎么办? 2018广东省普法考试0分怎么办 小孩错过了小升初的考试怎么办 错过了自主招生考试怎么办? 科目一考试错过了时间怎么办 中学生网瘾怎么办济南远大认真 u盘安装不了系统怎么办 对敏感脆弱的青春期孩子怎么办? 脸变得很交黑怎么办 玩手机长痘痘了怎么办 青少年左侧后背突发疼痛怎么办 纵欲过度导致青少年白发怎么办 20岁了不想长大怎么办 网吧老板跑路了怎么办 网吧玩地下城卡怎么办 个人公积金封存之前厂子欠费怎么办 学生欠了2万块怎么办 玉米去完库存量cool怎么办 幸福蓝海电子券过期怎么办 幸福蓝海国际影城会员怎么办 幸福蓝海会员卡过期了怎么办 电机线圈处于平衡位置怎么办 混联电路求电功率最小怎么办 电脑超出工作频率范围怎么办 手机红外线感应器坏了怎么办 我的世界左右慢怎么办 发电机自动启停装置故障怎么办 如果自动启停没关发动机涉水怎么办 偏激的人不分手怎么办 被极端的人纠缠怎么办 对固执偏激的人怎么办 车子右前轮偏磨怎么办? 轮胎边缘磨黑了怎么办 36周胎儿绕颈一周怎么办 孕中期胎儿偏小怎么办 怀孕34周偏小2周怎么办 胎盘低怎么办6个月了 怀孕四个月胎盘低怎么办 怀孕五个月胎盘低怎么办