Evgeny Gagua 2 years ago
parent
commit
b50d703e2e
  1. 6
      Projects/la_mojo/build
  2. 7
      lib/App/common/hardwareResourceSerialProvider.cpp
  3. 40
      lib/App/common/kernelModuleEmbedVideo.cpp
  4. 2
      lib/App/mojo/mojoBackend.cpp
  5. 7
      lib/App/mojo/mojoKernel.cpp
  6. 6
      lib/components/base/basicThread.cpp
  7. 35
      lib/data/media/video/videoAVLIBSource.cpp

6
Projects/la_mojo/build

@ -2,10 +2,10 @@
#make clean -e "CFG=Debug" #make clean -e "CFG=Debug"
#make -e "CFG=Debug" -j6
make -e "CFG=Debug" -j6
make clean -e "CFG=Debug86"
make -e "CFG=Debug86" -j4
#make clean -e "CFG=Debug86"
#make -e "CFG=Debug86" -j4
#make clean -e "CFG=Release86" #make clean -e "CFG=Release86"
#make -e "CFG=Release86" -j4 #make -e "CFG=Release86" -j4

7
lib/App/common/hardwareResourceSerialProvider.cpp

@ -869,11 +869,10 @@ bool hardwareResourceSerialProvider::closePort(){
if( RetVal == -1 ){ if( RetVal == -1 ){
setConnectionStatus(CS_DISCONNECTED); setConnectionStatus(CS_DISCONNECTED);
m_nInputBufferSize = 0; m_nInputBufferSize = 0;
//if(!getStatus()) {
m_bThreadBStatus = TH_ENDED; m_bThreadBStatus = TH_ENDED;
//m_bThreadAStatus = TH_ENDED;
//} else SLEEP(100);
LOG_ERROR("Connection Droped on Reception Data");
#ifdef DEBUG_EXTRA
LOG("Connection Droped on Reception Data");
#endif
} else if( m_nInputBufferSize > 0 ){ } else if( m_nInputBufferSize > 0 ){
do{ do{
m_mQueueProtectorMutex.lock(); m_mQueueProtectorMutex.lock();

40
lib/App/common/kernelModuleEmbedVideo.cpp

@ -85,6 +85,7 @@ kernelModuleEmbedVideo::kernelModuleEmbedVideo( uint32_t moduleID ): kernelModul
} else { } else {
LOG_ERROR( "DB Error!" ); LOG_ERROR( "DB Error!" );
}; };
m_bDetached = true;
n_pNoSignalData = NULL; n_pNoSignalData = NULL;
m_nNoSignalSize = 0; m_nNoSignalSize = 0;
#ifdef HAVE_SMAL_PREVIEW_STREAMS #ifdef HAVE_SMAL_PREVIEW_STREAMS
@ -141,23 +142,11 @@ kernelModuleEmbedVideo::~kernelModuleEmbedVideo(){
#ifdef DEBUG #ifdef DEBUG
LOG("Destructor"); LOG("Destructor");
#endif #endif
m_bEnabled = false;
LOG("Locking in Destructor!");
m_mStreamHandlersProtector.lock();
if( m_mapHANDLERS.size() ){
#ifdef DEBUG
LOG("Deleting Stream Handlers!");
#endif
for( mapSTREAMHANDLERS::iterator idx = m_mapHANDLERS.begin(); idx != m_mapHANDLERS.end(); idx++ ){
#ifdef DEBUG
LOG("Deleting Stream Handler");
#endif
delete( (*idx).second );
}
m_mapHANDLERS.clear();
if ( !m_bDetached ) {
stopService( true );
}; };
m_mStreamHandlersProtector.unlock();
//Sanity check
LOG("Sanity check in Destructor!");
waitThreadAEnd( true ); waitThreadAEnd( true );
if( m_vHandlersPool.size() ) { // Kill-Wait Started Probes if( m_vHandlersPool.size() ) { // Kill-Wait Started Probes
@ -1040,7 +1029,7 @@ void kernelModuleEmbedVideo::m_fThreadBProc( void ){
bool kernelModuleEmbedVideo::startService(){ bool kernelModuleEmbedVideo::startService(){
m_bEnabled = true;
m_bDetached = false;
//Create NoSignal Image //Create NoSignal Image
cv::Mat tMat( m_sEmbedVideoData.height, m_sEmbedVideoData.width, CV_8UC3 ); cv::Mat tMat( m_sEmbedVideoData.height, m_sEmbedVideoData.width, CV_8UC3 );
cv::rectangle( tMat, cv::Point( 0, 0 ), cv::Point( m_sEmbedVideoData.width, m_sEmbedVideoData.height ), cv::Scalar( 255, 0, 0 ), cv::FILLED ); cv::rectangle( tMat, cv::Point( 0, 0 ), cv::Point( m_sEmbedVideoData.width, m_sEmbedVideoData.height ), cv::Scalar( 255, 0, 0 ), cv::FILLED );
@ -1200,10 +1189,27 @@ bool kernelModuleEmbedVideo::startService(){
bool kernelModuleEmbedVideo::stopService( bool force ){ bool kernelModuleEmbedVideo::stopService( bool force ){
m_bEnabled = false; m_bEnabled = false;
//Stop Conveyor
m_bDetached = uninit(); m_bDetached = uninit();
#ifdef DEBUG_EXTRA #ifdef DEBUG_EXTRA
LOG("StopService!"); LOG("StopService!");
#endif #endif
m_mStreamHandlersProtector.lock();
if( m_mapHANDLERS.size() ){
#ifdef DEBUG
LOG("Deleting Stream Handlers!");
#endif
for( mapSTREAMHANDLERS::iterator idx = m_mapHANDLERS.begin(); idx != m_mapHANDLERS.end(); idx++ ){
#ifdef DEBUG
LOG("Deleting Stream Handler");
#endif
delete( (*idx).second );
}
m_mapHANDLERS.clear();
};
m_mStreamHandlersProtector.unlock();
if( m_vHandlersPool.size() ) { // Kill-Wait Started Probes if( m_vHandlersPool.size() ) { // Kill-Wait Started Probes
#ifdef DEBUG_EXTRA #ifdef DEBUG_EXTRA
char tB[200]; char tB[200];

2
lib/App/mojo/mojoBackend.cpp

@ -115,7 +115,7 @@ void segfault_sigaction( int signal, siginfo_t *si, void *arg ){
if ( fd ) { if ( fd ) {
pid_t M = getpid(); pid_t M = getpid();
pid_t P = getppid(); pid_t P = getppid();
fprintf(fd, "Caught segfault[%d] at address %p\n PID: %p PPID %p\n Gregs %p\n", signal, si->si_addr, M, P, uc->uc_mcontext.gregs[REG_RIP] );
fprintf(fd, "Caught segfault[%d] at address %p\n PID: %p PPID %p\n Gregs %p\n", signal, si->si_addr, M, P, uc->uc_mcontext.fault_address );
fclose( fd ); fclose( fd );
}; };
exit(27); exit(27);

7
lib/App/mojo/mojoKernel.cpp

@ -1145,6 +1145,9 @@ bool mojoKernel::validateReports( void ){
LOG( tB ); LOG( tB );
#endif #endif
if( m_sSysInfo.disk > tT ){ if( m_sSysInfo.disk > tT ){
#ifdef DEBUG_EXTRA
LOG("Delete Some Reports!");
#endif
// delete some oldest report date // delete some oldest report date
m_pDBC->deleteReportDate( m_pDBC->getFirstEventTS() ); m_pDBC->deleteReportDate( m_pDBC->getFirstEventTS() );
}; };
@ -1203,7 +1206,9 @@ void mojoKernel::cleanUpReportDir( uint32_t days ){
LOG( tB ); LOG( tB );
#endif #endif
if ( oTS <= cTS ) { if ( oTS <= cTS ) {
#ifdef DEBUG_EXTRA
LOG("Deleting Old Reports")
#endif
m_pDBC->deleteReportDate( oTS ); m_pDBC->deleteReportDate( oTS );
}; };
}; };

6
lib/components/base/basicThread.cpp

@ -90,8 +90,10 @@ void basicThread::waitThreadEnd(bool forced){
bool basicThread::uninit( void ){ bool basicThread::uninit( void ){
if( m_bThreadStatus == TH_PRE_INIT ) return true; if( m_bThreadStatus == TH_PRE_INIT ) return true;
waitThreadEnd( true ); waitThreadEnd( true );
#ifdef DEBUG_EXTRA
LOG("UNINIT done!");
#ifndef BTH_NO_LOGGING
#ifdef DEBUG_EXTRA
LOG("UNINIT done!");
#endif
#endif #endif
m_bThreadStatus = TH_PRE_INIT; m_bThreadStatus = TH_PRE_INIT;
return true; return true;

35
lib/data/media/video/videoAVLIBSource.cpp

@ -143,6 +143,7 @@ bool videoAVLIBSource::_close(void){
if ( m_pVideoState == NULL) return true; if ( m_pVideoState == NULL) return true;
m_pMediaDestination = NULL;//??
//_stop(); //stops the Thread //_stop(); //stops the Thread
basicThread::waitThreadEnd( true ); basicThread::waitThreadEnd( true );
@ -801,42 +802,32 @@ void videoAVLIBSource::m_fThreadProc( void ){
m_eMediaStatus = m_pVideoState->m_bStatus = MS_STOPED; m_eMediaStatus = m_pVideoState->m_bStatus = MS_STOPED;
while( m_pMediaDestination == NULL && m_bThreadStatus == TH_WORKING ){ while( m_pMediaDestination == NULL && m_bThreadStatus == TH_WORKING ){
SLEEP(20); SLEEP(20);
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG("Waiting Destination"); LOG("Waiting Destination");
#endif #endif
}; };
m_eMediaStatus = m_pVideoState->m_bStatus = MS_PRESENT; m_eMediaStatus = m_pVideoState->m_bStatus = MS_PRESENT;
if( m_bSrcType == AVLIB_SOURCE_IPSTREAM ){ if( m_bSrcType == AVLIB_SOURCE_IPSTREAM ){
//av_read_play( m_pVideoState->m_pFormatCtx );
av_read_play( m_pVideoState->m_pFormatCtx );
}; };
#ifdef DEBUG #ifdef DEBUG
LOG("Presentation Started."); LOG("Presentation Started.");
#endif #endif
while( m_pVideoState->m_bStatus < MS_CLOSING && m_bThreadStatus != TH_ENDED ){ while( m_pVideoState->m_bStatus < MS_CLOSING && m_bThreadStatus != TH_ENDED ){
//LOG("1");
if ( m_pMediaDestination != NULL ){ if ( m_pMediaDestination != NULL ){
//LOG("2");
dec_ret = av_read_frame( m_pVideoState->m_pFormatCtx, pPacket ); dec_ret = av_read_frame( m_pVideoState->m_pFormatCtx, pPacket );
//LOG("3");
if( dec_ret >= 0 ){ if( dec_ret >= 0 ){
//LOG("4");
if( pPacket->stream_index == m_pVideoState->m_iVideoStreamID ){ if( pPacket->stream_index == m_pVideoState->m_iVideoStreamID ){
//LOG("5");
m_pVideoState->m_bStatus = MS_PRESENT; m_pVideoState->m_bStatus = MS_PRESENT;
dec_ret = avcodec_send_packet( m_pVideoState->m_pCodecCtx, pPacket ); dec_ret = avcodec_send_packet( m_pVideoState->m_pCodecCtx, pPacket );
//LOG("6");
if( dec_ret < 0 && dec_ret != AVERROR(EAGAIN) /* && dec_ret != AVERROR_EOF */ ){ if( dec_ret < 0 && dec_ret != AVERROR(EAGAIN) /* && dec_ret != AVERROR_EOF */ ){
LOG_ERROR( "Error sending video package to decoder" ); LOG_ERROR( "Error sending video package to decoder" );
m_eMediaStatus = m_pVideoState->m_bStatus = MS_CLOSING; m_eMediaStatus = m_pVideoState->m_bStatus = MS_CLOSING;
m_bThreadStatus = TH_ENDED; m_bThreadStatus = TH_ENDED;
} else { } else {
//LOG("7");
while( dec_ret >= 0 && m_bThreadStatus != TH_ENDED ) { while( dec_ret >= 0 && m_bThreadStatus != TH_ENDED ) {
//LOG("8");
dec_ret = avcodec_receive_frame( m_pVideoState->m_pCodecCtx, pFrame ); dec_ret = avcodec_receive_frame( m_pVideoState->m_pCodecCtx, pFrame );
//LOG("9");
if( dec_ret == AVERROR(EAGAIN) || dec_ret == AVERROR_EOF ){ if( dec_ret == AVERROR(EAGAIN) || dec_ret == AVERROR_EOF ){
//LOG("S");
break;//Skip to next data break;//Skip to next data
} else if( dec_ret < 0 ){ } else if( dec_ret < 0 ){
LOG_ERROR("Error decoding video frame"); LOG_ERROR("Error decoding video frame");
@ -844,21 +835,17 @@ void videoAVLIBSource::m_fThreadProc( void ){
m_bThreadStatus = TH_ENDED; m_bThreadStatus = TH_ENDED;
break; break;
}; };
//LOG("10");
sws_scale( m_pVideoState->m_pSwsCtx, (const uint8_t* const*)pFrame->data, pFrame->linesize, 0, m_pVideoState->m_pCodecCtx->height, pFrameBGR->data, pFrameBGR->linesize ); sws_scale( m_pVideoState->m_pSwsCtx, (const uint8_t* const*)pFrame->data, pFrame->linesize, 0, m_pVideoState->m_pCodecCtx->height, pFrameBGR->data, pFrameBGR->linesize );
//LOG("11");
try{ try{
//sprintf( tB, "Try to copy %d[%dx%d] bytes to %d[%dx%d]", pFrameBGR->linesize[0] * m_nHeight, pFrameBGR->width, pFrameBGR->height, mRGB.total() * mRGB.elemSize(), mRGB.cols, mRGB.rows );
//LOG(tB);
memcpy( mRGB.data, pFrameBGR->data[0], pFrameBGR->linesize[0] * m_nOutHeight );
//LOG("P");
if(!m_pMediaDestination->pushFrame( mRGB, m_pOpaque )){
m_pMediaDestination = NULL;
LOG_ERROR("Error Consume Frame by Media Destination!");
m_eMediaStatus = m_pVideoState->m_bStatus = MS_CLOSING;
m_bThreadStatus = TH_ENDED;
if ( m_pMediaDestination ) {
memcpy( mRGB.data, pFrameBGR->data[0], pFrameBGR->linesize[0] * m_nOutHeight );
if (!m_pMediaDestination->pushFrame(mRGB, m_pOpaque)) {
m_pMediaDestination = NULL;
LOG_ERROR("Error Consume Frame by Media Destination!");
m_eMediaStatus = m_pVideoState->m_bStatus = MS_CLOSING;
m_bThreadStatus = TH_ENDED;
};
}; };
//LOG("14");
} catch (cv::Exception & e) { } catch (cv::Exception & e) {
LOG_ERROR( e.msg.c_str() ); LOG_ERROR( e.msg.c_str() );
m_eMediaStatus = m_pVideoState->m_bStatus = MS_CLOSING; m_eMediaStatus = m_pVideoState->m_bStatus = MS_CLOSING;

Loading…
Cancel
Save