停止Live555重新使用会话

时间:2017-10-18 14:52:19

标签: c++ rtsp live555

我使用Live555从远程连接上的IP网络摄像头提取数据。有时会对流进行短暂的中断(可能是网络QOS问题),但是,每次发生这种情况时,live555都会中断而不是成功重新启动连接。调试输出如下所示:

Closing session, because we stopped receiving packets.itrate=N/A speed=1.37x
Created new TCP socket 3 for connection
Connecting to 10.8.1.14, port 10111 on socket 3...
...remote connection opened
Sending request: PLAY rtsp://mycamera.test/live/ch0/ RTSP/1.0
CSeq: 6
User-Agent: /bin/openRTSP (LIVE555 Streaming Media v2017.07.18)
Session: 1487641045855494467
Range: npt=0.000-

Received 199 new bytes of response data.
Received a complete PLAY response:
RTSP/1.0 500 Internal Server Error
Server: DSS/6.0.3 (Build/526.3; Platform/Linux; Release/Darwin Streaming Server; State/Development; )
Cseq: 6
Session: 1487641045855494467
Connection: Close

Failed to start playing session: 500 Internal Server Error
Created new TCP socket 3 for connection
Connecting to 10.8.1.14, port 10111 on socket 3...
...remote connection opened
Sending request: TEARDOWN rtsp://mycamera.test/live/ch0/ RTSP/1.0
CSeq: 7
User-Agent: /bin/openRTSP (LIVE555 Streaming Media v2017.07.18)
Session: 1487641045855494467

Received 180 new bytes of response data.
Received a complete TEARDOWN response:
RTSP/1.0 200 OK
Server: DSS/6.0.3 (Build/526.3; Platform/Linux; Release/Darwin Streaming Server; State/Development; )
Cseq: 7
Session: 1487641045855494467
Connection: Close

看起来live555失败的原因是因为在尝试重新启动现有会话的流时,摄像头会抛出500错误。由于开始新会话有效,有没有办法告诉live555丢弃现有会话并重新开始而不是放弃?我确实有一个cron作业,可以检测到live555何时停止并重新启动它,但是当我这样做时会出现问题,所以如果我能说服live555补偿相机固件中的错误会更加清晰。

我很高兴修补live555代码并在必要时重建!

1 个答案:

答案 0 :(得分:0)

如果您查看playCommon.cpp的代码,可以看到

void sessionAfterPlaying(void* /*clientData*/) {
  if (!playContinuously) {
    shutdown(0);
  } else {
    // We've been asked to play the stream(s) over again.
    // First, reset state from the current session:
    if (env != NULL) {
      env->taskScheduler().unscheduleDelayedTask(periodicFileOutputTask);
      env->taskScheduler().unscheduleDelayedTask(sessionTimerTask);
      env->taskScheduler().unscheduleDelayedTask(arrivalCheckTimerTask);
      env->taskScheduler().unscheduleDelayedTask(interPacketGapCheckTimerTask);
      env->taskScheduler().unscheduleDelayedTask(qosMeasurementTimerTask);
    }
    totNumPacketsReceived = ~0;

    startPlayingSession(session, initialSeekTime, endTime, scale, continueAfterPLAY);
  }
}

正如您在日志中看到的那样,它会发送一个播放并且不会重新启动会话。 要更改此行为,您需要修改openRTSP的代码。