Better handling of RTP stream and thread death.

git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@2704 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
stan 2008-12-05 23:14:37 +00:00
parent c83d340ad8
commit bcb7166b75
5 changed files with 13 additions and 3 deletions

View File

@ -173,6 +173,8 @@ int RemoteCameraRtsp::PostCapture( Image &image )
while ( true ) while ( true )
{ {
buffer.clear(); buffer.clear();
if ( rtspThread->stopped() )
break;
if ( rtspThread->getFrame( buffer ) ) if ( rtspThread->getFrame( buffer ) )
{ {
Debug( 3, "Read frame %d bytes", buffer.size() ); Debug( 3, "Read frame %d bytes", buffer.size() );

View File

@ -87,6 +87,7 @@ int RtpDataThread::run()
if ( readable.size() == 0 ) if ( readable.size() == 0 )
{ {
Error( "RTP timed out" ); Error( "RTP timed out" );
mStop = true;
break; break;
} }
for ( Select::CommsList::iterator iter = readable.begin(); iter != readable.end(); iter++ ) for ( Select::CommsList::iterator iter = readable.begin(); iter != readable.end(); iter++ )

View File

@ -487,8 +487,8 @@ int RtspThread::run()
rtpDataThread.stop(); rtpDataThread.stop();
rtpCtrlThread.stop(); rtpCtrlThread.stop();
rtpDataThread.kill( SIGTERM ); //rtpDataThread.kill( SIGTERM );
rtpCtrlThread.kill( SIGTERM ); //rtpCtrlThread.kill( SIGTERM );
rtpDataThread.join(); rtpDataThread.join();
rtpCtrlThread.join(); rtpCtrlThread.join();

View File

@ -124,6 +124,10 @@ public:
{ {
mStop = true; mStop = true;
} }
bool stopped() const
{
return( mStop );
}
}; };
#endif // ZM_RTSP_H #endif // ZM_RTSP_H

View File

@ -211,6 +211,7 @@ int main( int argc, char *argv[] )
alarm_capture_delays[i] = monitors[i]->GetAlarmCaptureDelay(); alarm_capture_delays[i] = monitors[i]->GetAlarmCaptureDelay();
} }
int result = 0;
struct timeval now; struct timeval now;
struct DeltaTimeval delta_time; struct DeltaTimeval delta_time;
while( !zm_terminate ) while( !zm_terminate )
@ -249,12 +250,14 @@ int main( int argc, char *argv[] )
{ {
Error( "Failed to pre-capture monitor %d", i ); Error( "Failed to pre-capture monitor %d", i );
zm_terminate = true; zm_terminate = true;
result = -1;
break; break;
} }
if ( monitors[i]->PostCapture() < 0 ) if ( monitors[i]->PostCapture() < 0 )
{ {
Error( "Failed to post-capture monitor %d", i ); Error( "Failed to post-capture monitor %d", i );
zm_terminate = true; zm_terminate = true;
result = -1;
break; break;
} }
@ -281,5 +284,5 @@ int main( int argc, char *argv[] )
delete [] next_delays; delete [] next_delays;
delete [] last_capture_times; delete [] last_capture_times;
return( 0 ); return( result );
} }