|
|
|
@ -64,13 +64,10 @@ void someStaticFunc( void * data ){ |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
DummySink::DummySink( videoLIVE555Source* session, UsageEnvironment& env, MediaSubsession& subsession, char const* streamId, int w, int h, int ww, int hh ) |
|
|
|
: MediaSink(env), |
|
|
|
m_pSession(session), |
|
|
|
m_iFrameIndex(0), |
|
|
|
m_sSubSession(subsession) { |
|
|
|
DummySink::DummySink( videoLIVE555Source* session, UsageEnvironment& env, MediaSubsession& subsession, char const* streamId, int w, int h, int ww, int hh ): MediaSink(env), m_pSession(session), m_iFrameIndex(0), m_sSubSession(subsession){ |
|
|
|
|
|
|
|
m_pLog = basicLogCollection::getInstance(); |
|
|
|
m_pStreamId = strDup(streamId); |
|
|
|
m_pStreamId = strDup( streamId ); |
|
|
|
|
|
|
|
m_nCurrentOutFile = 0; |
|
|
|
m_pOutFile[0] = m_pOutFile[1] = NULL; |
|
|
|
@ -98,20 +95,17 @@ DummySink::DummySink( videoLIVE555Source* session, UsageEnvironment& env, MediaS |
|
|
|
|
|
|
|
m_eCodecProbe = AV_CODEC_ID_NONE; |
|
|
|
|
|
|
|
if( strcmp( m_sSubSession.codecName(),"H264") == 0 ){ |
|
|
|
m_eCodecProbe = AV_CODEC_ID_H264; |
|
|
|
}; |
|
|
|
if( strcmp( m_sSubSession.codecName(),"JPEG") == 0 ){ |
|
|
|
m_eCodecProbe = AV_CODEC_ID_MJPEG; |
|
|
|
}; |
|
|
|
if( strcmp( m_sSubSession.codecName(),"H265") == 0 ){ |
|
|
|
} else if( strcmp( m_sSubSession.codecName(),"H264") == 0 ){ |
|
|
|
m_eCodecProbe = AV_CODEC_ID_H264; |
|
|
|
} else if( strcmp( m_sSubSession.codecName(),"H265") == 0 ){ |
|
|
|
m_eCodecProbe = AV_CODEC_ID_HEVC; |
|
|
|
}; |
|
|
|
|
|
|
|
m_pCodec = avcodec_find_decoder( m_eCodecProbe ); |
|
|
|
if( m_pCodec == NULL ) { |
|
|
|
LOG_ERROR( "codec not found!" ); |
|
|
|
|
|
|
|
return; |
|
|
|
}; |
|
|
|
|
|
|
|
@ -340,18 +334,11 @@ DummySink::DummySink( videoLIVE555Source* session, UsageEnvironment& env, MediaS |
|
|
|
//qtOut->startPlaying( NULL, NULL );
|
|
|
|
LOG( "QTFS Started Play" ); |
|
|
|
}; |
|
|
|
} else { |
|
|
|
LOG("No Stream Proxy Mode!"); |
|
|
|
m_pOutCodec = NULL; |
|
|
|
}; |
|
|
|
|
|
|
|
if( m_pSession->getWM() & MS_MODE_DECODE_FRAMES) { |
|
|
|
} else if( m_pSession->getWM() & MS_MODE_DECODE_FRAMES ) { |
|
|
|
//Allocate Mems
|
|
|
|
m_pFrame = av_frame_alloc(); |
|
|
|
m_pRGBFrame = av_frame_alloc(); |
|
|
|
//avpicture_alloc( ( AVPicture *) rgbFrame, AV_PIX_FMT_RGB24, 1920, 1080);
|
|
|
|
//avpicture_alloc( ( AVPicture *) rgbFrame, AV_PIX_FMT_BGR24, 1280, 720 );
|
|
|
|
avpicture_alloc( ( AVPicture *) m_pRGBFrame, AV_PIX_FMT_BGR24, m_nOutWidth, m_nOutHeight ); |
|
|
|
//this->swsContext = sws_getContext( codecContext->width, codecContext->height, codecContext->pix_fmt, 1920, 1080, AV_PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);
|
|
|
|
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 { |
|
|
|
@ -360,46 +347,50 @@ DummySink::DummySink( videoLIVE555Source* session, UsageEnvironment& env, MediaS |
|
|
|
m_pSwsContext = NULL; |
|
|
|
m_pRGB = NULL; |
|
|
|
}; |
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
char tB[128]; |
|
|
|
sprintf( tB, "Created Sink [%dx%d]->[1280x720]", m_pCodecContext->width, m_pCodecContext->height ); |
|
|
|
sprintf( tB, "Created Sink [%dx%d]->[%dx%d]", m_pCodecContext->width, m_pCodecContext->height, m_nOutWidth, m_nOutHeight ); |
|
|
|
LOG( tB ); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
|
|
|
|
DummySink::~DummySink() { |
|
|
|
LOG("Sink Destructor!"); |
|
|
|
if( m_pOutFormatCtx != NULL ) { |
|
|
|
av_write_trailer( m_pOutFormatCtx ); |
|
|
|
avio_close( m_pOutFormatCtx->pb ); |
|
|
|
if( m_pSession->getWM() & MS_MODE_STREAM_PROXY ) { |
|
|
|
if( m_pOutFormatCtx != NULL ){ |
|
|
|
av_write_trailer( m_pOutFormatCtx ); |
|
|
|
avio_close( m_pOutFormatCtx->pb ); |
|
|
|
}; |
|
|
|
if( m_pOutFile[0] != NULL ){ |
|
|
|
fflush( m_pOutFile[0] ); |
|
|
|
pclose( m_pOutFile[0] ); |
|
|
|
}; |
|
|
|
if( m_pOutFile[1] != NULL ){ |
|
|
|
fflush( m_pOutFile[1] ); |
|
|
|
pclose( m_pOutFile[1] ); |
|
|
|
}; |
|
|
|
if( qtOut != NULL ) { |
|
|
|
Medium::close(qtOut); |
|
|
|
qtOut = NULL; |
|
|
|
}; |
|
|
|
} else if( m_pSession->getWM() & MS_MODE_DECODE_FRAMES ){ |
|
|
|
}; |
|
|
|
|
|
|
|
if( qtOut != NULL ) { |
|
|
|
Medium::close(qtOut); |
|
|
|
qtOut = NULL; |
|
|
|
}; |
|
|
|
|
|
|
|
/*Medium::close(qtOut); qtOut = NULL;
|
|
|
|
Medium::close(aviOut); aviOut = NULL; |
|
|
|
Medium::close(aviOut); aviOut = NULL; |
|
|
|
|
|
|
|
if (session == NULL) return; |
|
|
|
MediaSubsessionIterator iter(*session); |
|
|
|
MediaSubsession* subsession; |
|
|
|
while ((subsession = iter.next()) != NULL) { |
|
|
|
Medium::close(subsession->sink); |
|
|
|
subsession->sink = NULL; |
|
|
|
}*/ |
|
|
|
if (session == NULL) return; |
|
|
|
MediaSubsessionIterator iter(*session); |
|
|
|
MediaSubsession* subsession; |
|
|
|
while ((subsession = iter.next()) != NULL) { |
|
|
|
Medium::close(subsession->sink); |
|
|
|
subsession->sink = NULL; |
|
|
|
}*/ |
|
|
|
|
|
|
|
if( m_pOutFile[0] != NULL ){ |
|
|
|
fflush( m_pOutFile[0] ); |
|
|
|
pclose( m_pOutFile[0] ); |
|
|
|
}; |
|
|
|
if( m_pOutFile[1] != NULL ){ |
|
|
|
fflush( m_pOutFile[1] ); |
|
|
|
pclose( m_pOutFile[1] ); |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
if ( m_pFrame ) { |
|
|
|
av_free( m_pFrame ); |
|
|
|
}; |
|
|
|
if ( m_pRGBFrame ) { |
|
|
|
}; |
|
|
|
@ -414,7 +405,7 @@ DummySink::~DummySink() { |
|
|
|
delete[] m_pStreamId; |
|
|
|
} |
|
|
|
|
|
|
|
void DummySink::afterGettingFrame(void* clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds ) { |
|
|
|
void DummySink::afterGettingFrame( void* clientData, unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime, unsigned durationInMicroseconds ) { |
|
|
|
DummySink* sink = (DummySink*) clientData; |
|
|
|
sink->afterGettingFrame( frameSize, numTruncatedBytes, presentationTime, durationInMicroseconds ); |
|
|
|
}; |
|
|
|
@ -568,9 +559,10 @@ Boolean DummySink::continuePlaying() { |
|
|
|
void DummySink::setSprop(u_int8_t const* prop, unsigned size) { |
|
|
|
uint8_t * buf; |
|
|
|
uint8_t * buf_start; |
|
|
|
buf = (uint8_t *) malloc(1004); |
|
|
|
buf_start = buf + 4; |
|
|
|
LOG("setSprop"); |
|
|
|
|
|
|
|
buf = (uint8_t *) malloc(1004); |
|
|
|
buf_start = buf + 4; |
|
|
|
m_sAvPkt.data = buf; |
|
|
|
m_sAvPkt.data[0] = 0; |
|
|
|
m_sAvPkt.data[1] = 0; |
|
|
|
|