|
|
|
@ -35,7 +35,7 @@ CustomRTSPClient::CustomRTSPClient( |
|
|
|
int verbosityLevel, |
|
|
|
char const* applicationName, |
|
|
|
portNumBits tunnelOverHTTPPortNum) |
|
|
|
: RTSPClient(env,rtspURL, verbosityLevel, applicationName, tunnelOverHTTPPortNum, -1) , |
|
|
|
: RTSPClient( env, rtspURL, verbosityLevel, applicationName, tunnelOverHTTPPortNum, -1 ), |
|
|
|
session(session){ |
|
|
|
}; |
|
|
|
|
|
|
|
@ -355,6 +355,7 @@ DummySink::DummySink( videoLIVE555Source* session, UsageEnvironment& env, MediaS |
|
|
|
m_pSwsContext = sws_getContext( m_pCodecContext->width, m_pCodecContext->height, m_pCodecContext->pix_fmt, m_nOutWidth, m_nOutHeight, AV_PIX_FMT_BGR24, SWS_BICUBIC, NULL, NULL, NULL); |
|
|
|
m_pRGB = new cv::Mat( m_nOutHeight, m_nOutWidth, CV_8UC3, cv::Scalar( 255, 0, 255 ) ); |
|
|
|
} else { |
|
|
|
LOG("No Decode Frames Mode!"); |
|
|
|
m_pFrame = m_pRGBFrame = NULL; |
|
|
|
m_pSwsContext = NULL; |
|
|
|
m_pRGB = NULL; |
|
|
|
@ -368,7 +369,7 @@ DummySink::DummySink( videoLIVE555Source* session, UsageEnvironment& env, MediaS |
|
|
|
}; |
|
|
|
|
|
|
|
DummySink::~DummySink() { |
|
|
|
|
|
|
|
LOG("Sink Destructor!"); |
|
|
|
if( m_pOutFormatCtx != NULL ) { |
|
|
|
av_write_trailer( m_pOutFormatCtx ); |
|
|
|
avio_close( m_pOutFormatCtx->pb ); |
|
|
|
@ -421,6 +422,7 @@ void DummySink::afterGettingFrame(void* clientData, unsigned frameSize, unsigned |
|
|
|
void DummySink::afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds ) { |
|
|
|
// We've just received a frame of data. (Optionally) print out information about it:
|
|
|
|
//if (strcmp(fSubsession.codecName(),"H264") == 0) {
|
|
|
|
LOG("FRM"); |
|
|
|
if( m_eCodecProbe != AV_CODEC_ID_NONE ) { |
|
|
|
int got_picture; |
|
|
|
|
|
|
|
@ -443,6 +445,7 @@ void DummySink::afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes |
|
|
|
m_iFrameIndex ++; |
|
|
|
}; |
|
|
|
}; |
|
|
|
av_packet_unref( &m_sAvPkt ); |
|
|
|
if ( m_pSession->getWM() & MS_MODE_STREAM_PROXY ) { |
|
|
|
|
|
|
|
if ( m_pSession->getWM() & MS_MODE_OVERLAYED_LOOPS ) { |
|
|
|
@ -648,13 +651,20 @@ videoLIVE555Source::~videoLIVE555Source(){ |
|
|
|
}; |
|
|
|
|
|
|
|
void videoLIVE555Source::m_fThreadProc( void ){ |
|
|
|
LOG("Start Thread"); |
|
|
|
_eventLoopWatchVariable = 0; |
|
|
|
m_bThreadStatus = TH_WORKING; |
|
|
|
//while ( m_bThreadStatus == TH_WORKING ) {
|
|
|
|
m_pScheduler->doEventLoop( &_eventLoopWatchVariable ); |
|
|
|
//streamTimerHandler( m_pRtspClient );
|
|
|
|
//SLEEP(3);
|
|
|
|
//};
|
|
|
|
LOG( "Rtsp event finished" ); |
|
|
|
m_pUsageEnvironment->reclaim(); |
|
|
|
m_pUsageEnvironment = NULL; |
|
|
|
delete m_pScheduler; |
|
|
|
m_pScheduler = NULL; |
|
|
|
//m_pUsageEnvironment->reclaim();
|
|
|
|
//m_pUsageEnvironment = NULL;
|
|
|
|
//delete m_pScheduler;
|
|
|
|
//m_pScheduler = NULL;
|
|
|
|
LOG("End Thread"); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
@ -670,7 +680,7 @@ void videoLIVE555Source::continueAfterDESCRIBE( RTSPClient* rtspClient, int resu |
|
|
|
UsageEnvironment& env = rtspClient->envir(); // alias
|
|
|
|
StreamClientState& scs = MM->getStreamClientState(); // alias
|
|
|
|
|
|
|
|
if (resultCode != 0) { |
|
|
|
if( resultCode != 0 ){ |
|
|
|
MLOG( "Failed to get a SDP description: "); |
|
|
|
MLOG( resultString ); |
|
|
|
delete[] resultString; |
|
|
|
@ -682,9 +692,9 @@ void videoLIVE555Source::continueAfterDESCRIBE( RTSPClient* rtspClient, int resu |
|
|
|
MLOG( sdpDescription ); |
|
|
|
|
|
|
|
// Create a media session object from this SDP description:
|
|
|
|
scs.session = MediaSession::createNew(env, sdpDescription); |
|
|
|
scs.session = MediaSession::createNew( env, sdpDescription ); |
|
|
|
delete[] sdpDescription; // because we don't need it anymore
|
|
|
|
if (scs.session == NULL) { |
|
|
|
if( scs.session == NULL ){ |
|
|
|
MLOG( "Failed to create a MediaSession object from the SDP description:" ); |
|
|
|
MLOG( env.getResultMsg() ); |
|
|
|
break; |
|
|
|
@ -698,7 +708,7 @@ void videoLIVE555Source::continueAfterDESCRIBE( RTSPClient* rtspClient, int resu |
|
|
|
// Then, create and set up our data source objects for the session. We do this by iterating over the session's 'subsessions',
|
|
|
|
// calling "MediaSubsession::initiate()", and then sending a RTSP "SETUP" command, on each one.
|
|
|
|
// (Each 'subsession' will have its own data source.)
|
|
|
|
scs.iter = new MediaSubsessionIterator(*scs.session); |
|
|
|
scs.iter = new MediaSubsessionIterator( *scs.session ); |
|
|
|
ME->setupNextSubsession( rtspClient ); |
|
|
|
return; |
|
|
|
} while (0); |
|
|
|
@ -771,8 +781,8 @@ void videoLIVE555Source::continueAfterSETUP( RTSPClient* rtspClient, int resultC |
|
|
|
}; |
|
|
|
|
|
|
|
MLOG( "Created a data sink for the subsession" ); |
|
|
|
MLOG( streamClientState.subsession->mediumName() ); |
|
|
|
MLOG( streamClientState.subsession->codecName() ); |
|
|
|
//MLOG( streamClientState.subsession->mediumName() );
|
|
|
|
//MLOG( streamClientState.subsession->codecName() );
|
|
|
|
|
|
|
|
streamClientState.subsession->miscPtr = rtspClient; // a hack to let subsession handler functions get the "RTSPClient" from the subsession
|
|
|
|
|
|
|
|
@ -792,10 +802,11 @@ void videoLIVE555Source::continueAfterSETUP( RTSPClient* rtspClient, int resultC |
|
|
|
streamClientState.subsession->rtcpInstance()->setByeHandler( subsessionByeHandler, streamClientState.subsession ); |
|
|
|
} |
|
|
|
|
|
|
|
} while (0); |
|
|
|
} while (0); |
|
|
|
delete[] resultString; |
|
|
|
// Set up the next subsession, if any:
|
|
|
|
ME->setupNextSubsession(rtspClient); |
|
|
|
ME->setupNextSubsession( rtspClient ); |
|
|
|
MLOG("Done ContAfterSetup"); |
|
|
|
}; |
|
|
|
|
|
|
|
void videoLIVE555Source::continueAfterPLAY( RTSPClient* rtspClient, int resultCode, char* resultString){ |
|
|
|
@ -899,7 +910,6 @@ void videoLIVE555Source::streamTimerHandler( void* clientData ){ |
|
|
|
StreamClientState& scs = rtspClient->getStreamClientState(); // alias
|
|
|
|
videoLIVE555Source * ME = (videoLIVE555Source *) rtspClient->getSession(); |
|
|
|
scs.streamTimerTask = NULL; |
|
|
|
|
|
|
|
// Shut down the stream:
|
|
|
|
ME->shutdownStream(rtspClient); |
|
|
|
}; |
|
|
|
@ -967,6 +977,40 @@ void videoLIVE555Source::shutdownStream(RTSPClient* rtspClient, int exitCode ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
MLOG("Shutdown EVT"); |
|
|
|
#endif
|
|
|
|
StreamClientState & streamClientState = MM->getStreamClientState(); // alias
|
|
|
|
//if( resultCode != 0 ){
|
|
|
|
// MLOG( "Failed to set up the subsession:");
|
|
|
|
// MLOG( streamClientState.subsession->mediumName() );
|
|
|
|
// MLOG( streamClientState.subsession->codecName() );
|
|
|
|
// MLOG( resultString );
|
|
|
|
// break;
|
|
|
|
//};
|
|
|
|
UsageEnvironment & env = rtspClient->envir(); |
|
|
|
MLOG( "sendTearDown" ); |
|
|
|
rtspClient->sendTeardownCommand( *streamClientState.session, NULL ); |
|
|
|
MLOG( "Close Client" ); |
|
|
|
Medium::close( rtspClient ); |
|
|
|
MLOG( "SetLOOP" ); |
|
|
|
_eventLoopWatchVariable = 1; |
|
|
|
//MLOG( "Close Session" );
|
|
|
|
//Medium::close( streamClientState.session );
|
|
|
|
//MLOG( "Abort Thread" );
|
|
|
|
//waitThreadEnd( true );
|
|
|
|
// close RTSP client
|
|
|
|
//MLOG( "recalm Env" );
|
|
|
|
//env.reclaim();
|
|
|
|
//MLOG( "Delete Client" );
|
|
|
|
//delete MM;
|
|
|
|
//MLOG( "Delete Sink" );
|
|
|
|
//delete( (DummySink*) streamClientState.subsession->sink );
|
|
|
|
//*/
|
|
|
|
|
|
|
|
MLOG( "Delete Scheduler" ); |
|
|
|
m_pUsageEnvironment->reclaim(); |
|
|
|
m_pUsageEnvironment = NULL; |
|
|
|
delete m_pScheduler; |
|
|
|
m_pScheduler = NULL; |
|
|
|
MLOG( "All Done!" ); |
|
|
|
m_eMediaStatus = MS_CLOSED; |
|
|
|
}; |
|
|
|
|
|
|
|
@ -1011,17 +1055,21 @@ bool videoLIVE555Source::_close( void ){ |
|
|
|
LOG("CLOSE!"); |
|
|
|
return _stop(); |
|
|
|
}; |
|
|
|
|
|
|
|
bool videoLIVE555Source::_stop( void ){ |
|
|
|
LOG("STOP!"); |
|
|
|
shutdownStream( m_pRtspClient ); |
|
|
|
LOG("SHUTDOWN!"); |
|
|
|
_eventLoopWatchVariable = 1; |
|
|
|
basicThread::waitThreadEnd( true ); |
|
|
|
LOG("TH ENDED!"); |
|
|
|
shutdownStream( m_pRtspClient ); |
|
|
|
return true; |
|
|
|
}; |
|
|
|
bool videoLIVE555Source::isFinished( void ){ return false;}; |
|
|
|
MediaStateStatus videoLIVE555Source::getStatus( void ){ return MS_UNDEFINED; }; |
|
|
|
|
|
|
|
bool videoLIVE555Source::isFinished( void ){ |
|
|
|
return (m_eMediaStatus == MS_CLOSED); |
|
|
|
}; |
|
|
|
|
|
|
|
MediaStateStatus videoLIVE555Source::getStatus( void ){ |
|
|
|
return m_eMediaStatus; |
|
|
|
}; |
|
|
|
|
|
|
|
bool videoLIVE555Source::setSize( int Width, int Height ){ return false; }; |
|
|
|
bool videoLIVE555Source::setProportionalByWidth( int Width ){ return false; }; |
|
|
|
bool videoLIVE555Source::setProportionalByHeight( int Height ){ return false; }; |
|
|
|
|