Save 1 or more calls to time(NULL)
This commit is contained in:
parent
8e85338eca
commit
56c82cfbb5
|
@ -609,6 +609,7 @@ int RtspThread::run()
|
||||||
Debug( 2, "RTSP Rtptime is %ld", rtpTime );
|
Debug( 2, "RTSP Rtptime is %ld", rtpTime );
|
||||||
|
|
||||||
time_t lastKeepalive = time(NULL);
|
time_t lastKeepalive = time(NULL);
|
||||||
|
time_t now;
|
||||||
message = "GET_PARAMETER "+mUrl+" RTSP/1.0\r\nSession: "+session+"\r\n";
|
message = "GET_PARAMETER "+mUrl+" RTSP/1.0\r\nSession: "+session+"\r\n";
|
||||||
|
|
||||||
switch( mMethod )
|
switch( mMethod )
|
||||||
|
@ -625,12 +626,14 @@ int RtspThread::run()
|
||||||
|
|
||||||
while( !mStop )
|
while( !mStop )
|
||||||
{
|
{
|
||||||
|
now = time(NULL);
|
||||||
// Send a keepalive message if the server supports this feature and we are close to the timeout expiration
|
// 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 ) )
|
if ( !sendCommand( message ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
lastKeepalive = time(NULL);
|
lastKeepalive = now;
|
||||||
}
|
}
|
||||||
usleep( 100000 );
|
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
|
// 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 ?
|
// 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 ) )
|
if ( !sendCommand( message ) )
|
||||||
return( -1 );
|
return( -1 );
|
||||||
lastKeepalive = time(NULL);
|
lastKeepalive = now;
|
||||||
}
|
}
|
||||||
buffer.tidy( 1 );
|
buffer.tidy( 1 );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue