diff --git a/src/zm_packetqueue.cpp b/src/zm_packetqueue.cpp index 7fd485728..358feb3a9 100644 --- a/src/zm_packetqueue.cpp +++ b/src/zm_packetqueue.cpp @@ -427,7 +427,7 @@ ZMPacket *zm_packetqueue::get_analysis_packet() { ZMPacket *p = *analysis_it; Debug(3, "get_analysis_packet image_index: %d, about to lock packet", p->image_index); while ( !p->trylock() and !zm_terminate ) { - Debug(3,"waiting. Queue size %d analysis_it == end? %d", pktQueue.size(), ( analysis_it == pktQueue.end() ) ); + Debug(3, "waiting. Queue size %d analysis_it == end? %d", pktQueue.size(), ( analysis_it == pktQueue.end() ) ); condition.wait(lck); if ( deleting ) { // packetqueue is being deleted, do not assume we have a lock on the packet diff --git a/src/zm_rtp_source.cpp b/src/zm_rtp_source.cpp index 0ac963947..b6d215f25 100644 --- a/src/zm_rtp_source.cpp +++ b/src/zm_rtp_source.cpp @@ -318,7 +318,7 @@ bool RtpSource::handlePacket(const unsigned char *packet, size_t packetLen) { // What is the point of this for loop? Is it just me, or will it call getUpdatedValue once or twice? Could it not be better written as // if ( ! mFrameProcessed.getUpdatedValue( 1 ) && mFrameProcessed.getUpdatedValue( 1 ) ) return false; - for ( int count = 0; !mFrameProcessed.getUpdatedValue( 1 ); count++ ) + for ( int count = 0; !mFrameProcessed.getUpdatedValue(1); count++ ) if ( count > 1 ) return false; } @@ -352,9 +352,10 @@ bool RtpSource::getFrame(Buffer &buffer) { if ( !mFrameReady.getValueImmediate() ) { Debug(3, "Getting frame but not ready"); // Allow for a couple of spurious returns - for ( int count = 0; !mFrameReady.getUpdatedValue(1); count++ ) + for ( int count = 0; !mFrameReady.getUpdatedValue(1); count++ ) { if ( count > 1 ) return false; + } } buffer = mFrame; mFrameReady.setValueImmediate(false); diff --git a/src/zm_rtsp.cpp b/src/zm_rtsp.cpp index 53452bb94..69a08442f 100644 --- a/src/zm_rtsp.cpp +++ b/src/zm_rtsp.cpp @@ -376,8 +376,8 @@ int RtspThread::run() { try { mSessDesc = new SessionDescriptor( mUrl, sdp ); mFormatContext = mSessDesc->generateFormatContext(); - } catch( const Exception &e ) { - Error( e.getMessage().c_str() ); + } catch ( const Exception &e ) { + Error(e.getMessage().c_str()); return -1; } @@ -411,7 +411,7 @@ int RtspThread::run() { { // Check if control Url is absolute or relative controlUrl = mediaDesc->getControlUrl(); - if (std::equal(trackUrl.begin(), trackUrl.end(), controlUrl.begin())) { + if ( std::equal(trackUrl.begin(), trackUrl.end(), controlUrl.begin()) ) { trackUrl = controlUrl; } else { if ( *trackUrl.rbegin() != '/') { @@ -422,46 +422,36 @@ int RtspThread::run() { } rtpClock = mediaDesc->getClock(); codecId = mFormatContext->streams[i]->codec->codec_id; - // Hackery pokery - //rtpClock = mFormatContext->streams[i]->codec->sample_rate; break; } } } - switch( mMethod ) { + switch ( mMethod ) { case RTP_UNICAST : - { localPorts[0] = requestPorts(); localPorts[1] = localPorts[0]+1; message = "SETUP "+trackUrl+" RTSP/1.0\r\nTransport: RTP/AVP;unicast;client_port="+stringtf( "%d", localPorts[0] )+"-"+stringtf( "%d", localPorts[1] )+"\r\n"; break; - } case RTP_MULTICAST : - { message = "SETUP "+trackUrl+" RTSP/1.0\r\nTransport: RTP/AVP;multicast\r\n"; break; - } case RTP_RTSP : case RTP_RTSP_HTTP : - { message = "SETUP "+trackUrl+" RTSP/1.0\r\nTransport: RTP/AVP/TCP;unicast\r\n"; break; - } default: - { Panic( "Got unexpected method %d", mMethod ); break; - } } - if ( !sendCommand( message ) ) - return( -1 ); - if ( !recvResponse( response ) ) - return( -1 ); + if ( !sendCommand(message) ) + return -1; + if ( !recvResponse(response) ) + return -1; - lines = split( response, "\r\n" ); + lines = split(response, "\r\n"); std::string session; int timeout = 0; char transport[256] = ""; @@ -473,18 +463,18 @@ int RtspThread::run() { if ( sessionLine.size() == 2 ) sscanf( trimSpaces( sessionLine[1] ).c_str(), "timeout=%d", &timeout ); } - sscanf( lines[i].c_str(), "Transport: %s", transport ); + sscanf(lines[i].c_str(), "Transport: %s", transport); } if ( session.empty() ) - Fatal( "Unable to get session identifier from response '%s'", response.c_str() ); + Fatal("Unable to get session identifier from response '%s'", response.c_str()); - Debug( 2, "Got RTSP session %s, timeout %d secs", session.c_str(), timeout ); + Debug(2, "Got RTSP session %s, timeout %d secs", session.c_str(), timeout); if ( !transport[0] ) - Fatal( "Unable to get transport details from response '%s'", response.c_str() ); + Fatal("Unable to get transport details from response '%s'", response.c_str()); - Debug( 2, "Got RTSP transport %s", transport ); + Debug(2, "Got RTSP transport %s", transport); std::string method = ""; int remotePorts[2] = { 0, 0 }; @@ -531,23 +521,23 @@ int RtspThread::run() { Debug( 2, "RTSP Remote Channels are %d/%d", remoteChannels[0], remoteChannels[1] ); message = "PLAY "+mUrl+" RTSP/1.0\r\nSession: "+session+"\r\nRange: npt=0.000-\r\n"; - if ( !sendCommand( message ) ) - return( -1 ); - if ( !recvResponse( response ) ) - return( -1 ); + if ( !sendCommand(message) ) + return -1; + if ( !recvResponse(response) ) + return -1; - lines = split( response, "\r\n" ); + lines = split(response, "\r\n"); std::string rtpInfo; for ( size_t i = 0; i < lines.size(); i++ ) { - if ( ( lines[i].size() > 9 ) && ( lines[i].substr( 0, 9 ) == "RTP-Info:" ) ) - rtpInfo = trimSpaces( lines[i].substr( 9 ) ); - // Check for a timeout again. Some rtsp devices don't send a timeout until after the PLAY command is sent - if ( ( lines[i].size() > 8 ) && ( lines[i].substr( 0, 8 ) == "Session:" ) && ( timeout == 0 ) ) { - StringVector sessionLine = split( lines[i].substr(9), ";" ); + if ( ( lines[i].size() > 9 ) && ( lines[i].substr(0, 9) == "RTP-Info:" ) ) + rtpInfo = trimSpaces(lines[i].substr(9)); + // Check for a timeout again. Some rtsp devices don't send a timeout until after the PLAY command is sent + if ( ( lines[i].size() > 8 ) && ( lines[i].substr(0, 8) == "Session:" ) && ( timeout == 0 ) ) { + StringVector sessionLine = split(lines[i].substr(9), ";"); if ( sessionLine.size() == 2 ) - sscanf( trimSpaces( sessionLine[1] ).c_str(), "timeout=%d", &timeout ); + sscanf(trimSpaces(sessionLine[1]).c_str(), "timeout=%d", &timeout); if ( timeout > 0 ) - Debug( 2, "Got timeout %d secs from PLAY command response", timeout ); + Debug(2, "Got timeout %d secs from PLAY command response", timeout); } }