diff --git a/src/zm_rtsp.cpp b/src/zm_rtsp.cpp index cdba32a53..0ff0e385f 100644 --- a/src/zm_rtsp.cpp +++ b/src/zm_rtsp.cpp @@ -609,6 +609,7 @@ int RtspThread::run() Debug( 2, "RTSP Rtptime is %ld", rtpTime ); time_t lastKeepalive = time(NULL); + time_t now; message = "GET_PARAMETER "+mUrl+" RTSP/1.0\r\nSession: "+session+"\r\n"; switch( mMethod ) @@ -625,12 +626,14 @@ int RtspThread::run() while( !mStop ) { + now = time(NULL); // Send a keepalive message if the server supports this feature and we are close to the timeout expiration - if ( sendKeepalive && (timeout > 0) && ((time(NULL)-lastKeepalive) > (timeout-5)) ) +Debug(5, "sendkeepalibe %d, timeout %d, now: %d last: %d since: %d", sendKeepalive, timeout, now, lastKeepalive, (now-lastKeepalive) ); + if ( sendKeepalive && (timeout > 0) && ((now-lastKeepalive) > (timeout-5)) ) { if ( !sendCommand( message ) ) return( -1 ); - lastKeepalive = time(NULL); + lastKeepalive = now; } usleep( 100000 ); } @@ -768,11 +771,14 @@ int RtspThread::run() } // Send a keepalive message if the server supports this feature and we are close to the timeout expiration // FIXME: Is this really necessary when using tcp ? - if ( sendKeepalive && (timeout > 0) && ((time(NULL)-lastKeepalive) > (timeout-5)) ) + now = time(NULL); + // Send a keepalive message if the server supports this feature and we are close to the timeout expiration +Debug(5, "sendkeepalibe %d, timeout %d, now: %d last: %d since: %d", sendKeepalive, timeout, now, lastKeepalive, (now-lastKeepalive) ); + if ( sendKeepalive && (timeout > 0) && ((now-lastKeepalive) > (timeout-5)) ) { if ( !sendCommand( message ) ) return( -1 ); - lastKeepalive = time(NULL); + lastKeepalive = now; } buffer.tidy( 1 ); }