diff --git a/Projects/la_mojo/build b/Projects/la_mojo/build index e30c9046..98e25a11 100755 --- a/Projects/la_mojo/build +++ b/Projects/la_mojo/build @@ -5,7 +5,7 @@ #make -e "CFG=Debug" -j6 #make clean -e "CFG=Debug86" -make -e "CFG=Debug86" -j4 +make -e "CFG=Debug86" -j2 #make clean -e "CFG=Release86" #make -e "CFG=Release86" -j4 diff --git a/lib/App/common/kernelModuleEmbedVideo.cpp b/lib/App/common/kernelModuleEmbedVideo.cpp index 90bbd3e8..b5e7aebb 100644 --- a/lib/App/common/kernelModuleEmbedVideo.cpp +++ b/lib/App/common/kernelModuleEmbedVideo.cpp @@ -174,11 +174,11 @@ kernelModuleEmbedVideo::~kernelModuleEmbedVideo(){ LOG("Locking in Destructor!"); m_mStreamHandlersProtector.lock(); if( m_mapHANDLERS.size() ){ -#ifdef DEBUG_EXTRA +#ifdef DEBUG LOG("Deleting Stream Handlers!"); #endif for( mapSTREAMHANDLERS::iterator idx = m_mapHANDLERS.begin(); idx != m_mapHANDLERS.end(); idx++ ){ -#ifdef DEBUG_EXTRA +#ifdef DEBUG LOG("Deleting Stream Handler"); #endif delete( (*idx).second ); @@ -186,15 +186,15 @@ kernelModuleEmbedVideo::~kernelModuleEmbedVideo(){ m_mapHANDLERS.clear(); }; m_mStreamHandlersProtector.unlock(); -#ifdef DEBUG_EXTRA +#ifdef DEBUG LOG("Deleting CAPS"); #endif if( m_mapCAPTURES.size() ) m_mapCAPTURES.clear(); -#ifdef DEBUG_EXTRA +#ifdef DEBUG LOG("Deleting MATS"); #endif if( m_mapMATS.size() ) m_mapMATS.clear(); -#ifdef DEBUG_EXTRA +#ifdef DEBUG LOG("Deleting No Signal"); #endif if( n_pNoSignalData ) free(n_pNoSignalData); @@ -1580,13 +1580,19 @@ bool kernelModuleEmbedVideo::generateSavePicPath( CSTR MD5, CSTR Output ){ }; bool kernelModuleEmbedVideo::registerStream( uint32_t streamID ){ - if( ( m_sEmbedVideoData.output_mode & EVE_OUTPUT_VIDEO ) != EVE_OUTPUT_VIDEO ) return true; + // return true; try { m_mStreamHandlersProtector.lock(); streamHandler * tData = m_mapHANDLERS.at( streamID ); m_mStreamHandlersProtector.unlock(); + //If SH allready exists if( tData!= NULL ) return true; - tData = new streamHandler( this ); + //Create New One + if( ( m_sEmbedVideoData.output_mode & EVE_OUTPUT_VIDEO ) != EVE_OUTPUT_VIDEO ){ + tData = new streamHandler( this, MS_MODE_DECODE_FRAMES ); + } else { + tData = new streamHandler( this, MS_MODE_ENCODE_FRAMES ); + }; if ( tData != NULL ) { if ( tData->create( m_pDBC, streamID ) ) { m_mStreamHandlersProtector.lock(); @@ -1602,7 +1608,12 @@ bool kernelModuleEmbedVideo::registerStream( uint32_t streamID ){ }; } catch (const std::out_of_range& oor ) { m_mStreamHandlersProtector.unlock(); - streamHandler * tSH = new streamHandler( this ); + streamHandler * tSH = NULL; + if( ( m_sEmbedVideoData.output_mode & EVE_OUTPUT_VIDEO ) != EVE_OUTPUT_VIDEO ){ + tSH = new streamHandler( this, MS_MODE_DECODE_FRAMES ); + } else { + tSH = new streamHandler( this, MS_MODE_ENCODE_FRAMES ); + }; if ( tSH != NULL ) { if ( tSH->create( m_pDBC, streamID ) ) { m_mStreamHandlersProtector.lock(); @@ -1718,16 +1729,17 @@ streamHandler::streamHandler( kernelModuleEmbedVideo *ptr, MS_WORK_MODE M ): m_p m_cSourceType = 'A'; memset( &m_sStreamSegmentInfo[0], 0, sizeof(VIDEO_SEGMENT_INFO)); memset( &m_sStreamSegmentInfo[1], 0, sizeof(VIDEO_SEGMENT_INFO)); -#ifdef DIRECT_MJPEG_COMPOSING - m_pOutputFD[0] = NULL; - m_pOutputFD[1] = NULL; -#else // !DIRECT_MJPEG_COMPOSING - #ifdef OPENCV_VIDEO_OUTPUT - m_pEncoderA = NULL; - m_pEncoderB = NULL; + #ifdef DIRECT_MJPEG_COMPOSING + m_pOutputFD[0] = NULL; + m_pOutputFD[1] = NULL; + #else // !DIRECT_MJPEG_COMPOSING + #ifdef OPENCV_VIDEO_OUTPUT + m_pEncoderA = NULL; + m_pEncoderB = NULL; + #endif #endif -#endif #endif //EVE_ENABLE_VIDEO + //if( M == MS_MODE_DECODE_FRAMES ) 1=1; }; streamHandler::~streamHandler(){ @@ -2250,9 +2262,13 @@ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){ #endif #ifdef EVE_ENABLE_VIDEO + // if only decode Video Stream -> Exit + if( m_eWM == MS_MODE_DECODE_FRAMES ){ + m_pMaster->m_mPictureProtector.unlock(); + return true; + }; // encode Video Stream - - + //m_nPreAlarmFrames //m_nPostAlarmFrames //m_nNoAlarmSegmentFrames diff --git a/lib/App/common/kernelModuleEmbedVideo.h b/lib/App/common/kernelModuleEmbedVideo.h index 7b27ee95..7d750b58 100644 --- a/lib/App/common/kernelModuleEmbedVideo.h +++ b/lib/App/common/kernelModuleEmbedVideo.h @@ -205,6 +205,8 @@ typedef map mapSTREAMMAPS; #define EVE_OUTPUT_PICTURES 1 #define EVE_OUTPUT_VIDEO 2 #define EVE_OUTPUT_PIC_AND_VID 3 +//#define ENCODER_DISABLED 0 +//#define ENCODER_ENABLED 1 //#define EVE_ENABLE_EASE_OUTPUT_FPS diff --git a/lib/App/common/kernelModuleFactory.cpp b/lib/App/common/kernelModuleFactory.cpp index 9970b001..4e1c9c05 100644 --- a/lib/App/common/kernelModuleFactory.cpp +++ b/lib/App/common/kernelModuleFactory.cpp @@ -41,7 +41,8 @@ kernelModuleFactory::kernelModuleFactory( uint32_t InstanceID ):basicThread(){ #else m_pDBC = sqliteDBC::getInstance(); #endif - init(); + // Don't INIT Thread -> init in LoadModules + init(); }; kernelModuleFactory::~kernelModuleFactory(){ @@ -102,7 +103,10 @@ bool kernelModuleFactory::loadModules(){ sprintf( tB, "Have %d Modules to create!", tList->size() ); LOG( tB ); #endif - for( DBC_INT_LIST::iterator idx = tList->begin(); idx < tList->end(); idx++ ) createModule( *idx ); + for( DBC_INT_LIST::iterator idx = tList->begin(); idx < tList->end(); idx++ ){ + LOG("**MOMO**"); + createModule( *idx ); + }; tList->clear(); } #ifdef DEBUG @@ -117,7 +121,7 @@ bool kernelModuleFactory::loadModules(){ LOG("No Modules Defined"); } #endif - return true; + return init(); }; kernelModule *kernelModuleFactory::createModule( int id ){ @@ -167,7 +171,9 @@ kernelModule *kernelModuleFactory::createModule( int id ){ break; case KERNEL_MODULE_EMBED_VIDEO: #ifdef DEBUG - LOG("Creating Embed Video Module"); + char tT[129]; + sprintf( tT, "Creating Embed Video Module %d [%d] {%p}", id, tData->module_id, tData ); + LOG( tT ); #endif if ( m_pDBC->isLocal() ){ tVal = new kernelModuleEmbedVideo( tData->module_id );