From b97f2fa4f6216d22b0d9eb9716481f679c029940 Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 28 Jan 2015 12:36:11 -0500 Subject: [PATCH] Send an RTCP RR packet when we get a timeout to see if we are really dead. --- src/zm_rtp_ctrl.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/zm_rtp_ctrl.cpp b/src/zm_rtp_ctrl.cpp index 96d4fa2f5..80495fa85 100644 --- a/src/zm_rtp_ctrl.cpp +++ b/src/zm_rtp_ctrl.cpp @@ -302,6 +302,9 @@ int RtpCtrlThread::run() select.addReader( &rtpCtrlServer ); unsigned char buffer[ZM_NETWORK_BUFSIZ]; + + bool timeout = false; // used as a flag that we had a timeout, and then sent an RR to see if we wake back up. Real timeout will happen when this is true. + while ( !mStop && select.wait() >= 0 ) { if ( mStop ) @@ -309,8 +312,21 @@ int RtpCtrlThread::run() Select::CommsList readable = select.getReadable(); if ( readable.size() == 0 ) { - Error( "RTCP timed out" ); - break; + if ( ! timeout ) { + ssize_t nBytes; + unsigned char *bufferPtr = buffer; + bufferPtr += generateRr( bufferPtr, sizeof(buffer)-(bufferPtr-buffer) ); + bufferPtr += generateSdes( bufferPtr, sizeof(buffer)-(bufferPtr-buffer) ); + Debug( 4, "Sending %zd bytes on sd %d", bufferPtr-buffer, rtpCtrlServer.getWriteDesc() ); + Debug( 5, "Sending %s", buffer ); + if ( (nBytes = rtpCtrlServer.send( buffer, bufferPtr-buffer )) < 0 ) + Error( "Unable to send: %s", strerror( errno ) ); + timeout = true; + continue; + } else { + Error( "RTCP timed out" ); + break; + } } for ( Select::CommsList::iterator iter = readable.begin(); iter != readable.end(); iter++ ) {