|
|
|
@ -448,12 +448,12 @@ void *kernelModuleEmbedVideo::webClientProc( void *ptr ){ |
|
|
|
|
|
|
|
void kernelModuleEmbedVideo::m_fThreadProc( void ){ |
|
|
|
if( !m_bEnabled ) { |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Module is Disabled!"); |
|
|
|
#endif
|
|
|
|
return; |
|
|
|
}; |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Module Started!"); |
|
|
|
#endif
|
|
|
|
struct pollfd pfd[1]; |
|
|
|
@ -475,7 +475,7 @@ void kernelModuleEmbedVideo::m_fThreadProc( void ){ |
|
|
|
// Handle Connections
|
|
|
|
if( RetVal != 0 ){ |
|
|
|
if ( pfd[0].revents & POLLIN ) { |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Handle New Client"); |
|
|
|
#endif
|
|
|
|
int tSID = accept( pfd[0].fd, NULL, NULL); |
|
|
|
@ -484,17 +484,17 @@ void kernelModuleEmbedVideo::m_fThreadProc( void ){ |
|
|
|
sprintf(tBuf, "Accept() error: %s", strerror(errno)); |
|
|
|
LOG_ERROR(tBuf); |
|
|
|
} else { |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Accept OK"); |
|
|
|
#endif
|
|
|
|
WEB_CLIENT_CTX *tCTX = (WEB_CLIENT_CTX *) malloc(sizeof(WEB_CLIENT_CTX)); |
|
|
|
if( tCTX ) { |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("CTX OK"); |
|
|
|
#endif
|
|
|
|
WEB_HANDLER *tHANDLER = (WEB_HANDLER *) malloc(sizeof(WEB_HANDLER)); |
|
|
|
if( tHANDLER ) { |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("HANDLER OK"); |
|
|
|
#endif
|
|
|
|
memset( tCTX, 0, sizeof(WEB_CLIENT_CTX) ); |
|
|
|
@ -520,7 +520,7 @@ void kernelModuleEmbedVideo::m_fThreadProc( void ){ |
|
|
|
m_mWebHandlersProtector.lock(); |
|
|
|
m_vHandlersPool.push_back( tHANDLER ); |
|
|
|
m_mWebHandlersProtector.unlock(); |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Handler Pushed to a Pool"); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
@ -542,7 +542,7 @@ void kernelModuleEmbedVideo::m_fThreadProc( void ){ |
|
|
|
if( m_vHandlersPool.size() ) { |
|
|
|
for( vectorHANDLERS::iterator idx = m_vHandlersPool.begin(); idx < m_vHandlersPool.end(); idx++ ) { |
|
|
|
if( !( (*idx)->CTX->bValid ) ) { |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Have Dead Client!"); |
|
|
|
#endif
|
|
|
|
pthread_join( (*idx)->m_hThreadHandle, NULL ); |
|
|
|
@ -553,7 +553,7 @@ void kernelModuleEmbedVideo::m_fThreadProc( void ){ |
|
|
|
m_mWebHandlersProtector.lock(); |
|
|
|
m_vHandlersPool.erase(idx); |
|
|
|
m_mWebHandlersProtector.unlock(); |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Web Handler Ripped!"); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
@ -601,7 +601,7 @@ bool kernelModuleEmbedVideo::startService(){ |
|
|
|
if( T.cols > 0 ) { |
|
|
|
cv::Mat mask; |
|
|
|
vector<cv::Mat> layers; |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Logo Loaded OK"); |
|
|
|
#endif
|
|
|
|
cv::split( T, layers); // seperate channels
|
|
|
|
@ -617,14 +617,20 @@ bool kernelModuleEmbedVideo::startService(){ |
|
|
|
m_mLogoPic.copyTo( destinationROI, m_mLogoMask ); |
|
|
|
//m_sEmbedVideoData.show_logo = false;
|
|
|
|
} else { |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Logo Disabled - No Picture is Loaded"); |
|
|
|
#endif
|
|
|
|
m_sEmbedVideoData.show_logo = false; |
|
|
|
}; |
|
|
|
} else { |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Logo Disabled - Wrong Coords"); |
|
|
|
#endif
|
|
|
|
m_sEmbedVideoData.show_logo = false; |
|
|
|
}; |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Logo Draw OK"); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
|
|
|
|
try{ |
|
|
|
@ -667,17 +673,23 @@ bool kernelModuleEmbedVideo::startService(){ |
|
|
|
LOG_ERROR("Failed binding Socket"); |
|
|
|
close( m_nSocketDescriptor ); |
|
|
|
return false; |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
} else { |
|
|
|
LOG("Bind Socessfull"); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
if( listen( m_nSocketDescriptor, 10) != 0 ){ |
|
|
|
LOG_ERROR("Failed setting web listen backlog"); |
|
|
|
close( m_nSocketDescriptor ); |
|
|
|
return false; |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
} else { |
|
|
|
LOG("Listen OK"); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Start Thread"); |
|
|
|
#endif
|
|
|
|
m_bEnabled = init(); |
|
|
|
return m_bEnabled; |
|
|
|
}; |
|
|
|
@ -1733,7 +1745,7 @@ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){ |
|
|
|
//do {
|
|
|
|
//In Any Case Close Stream if it Long enough
|
|
|
|
if( m_nSegAFrameCounter > m_nAHardLimitFrames ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("HardLimit Reached!(A)"); |
|
|
|
#endif
|
|
|
|
closeSegmentA(); |
|
|
|
@ -1741,14 +1753,14 @@ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){ |
|
|
|
}; |
|
|
|
if( m_nSegAFrameCounter > ( m_nASegmentLimitFrames - ( m_nAPostAlarmFrames + m_nBPreAlarmFrames ))){ |
|
|
|
if ( !m_bSegBActive ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Start Alt!(A)"); |
|
|
|
#endif
|
|
|
|
openSegmentB(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
if( m_nSegAFrameCounter > ( m_nASegmentLimitFrames - m_nAPostAlarmFrames ) && !m_bActiveEncoderStream ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Swap Active!(A)"); |
|
|
|
#endif
|
|
|
|
swapActiveStreams(); |
|
|
|
@ -1759,7 +1771,7 @@ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){ |
|
|
|
//do {
|
|
|
|
//In Any Case Close Stream if it Long enough
|
|
|
|
if( m_nSegAFrameCounter > m_nHardLimitFrames ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("HardLimit Reached!(A)"); |
|
|
|
#endif
|
|
|
|
closeSegmentA(); |
|
|
|
@ -1767,14 +1779,14 @@ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){ |
|
|
|
}; |
|
|
|
if( m_nSegAFrameCounter > ( m_nSegmentLimitFrames - ( m_nPostAlarmFrames + m_nPreAlarmFrames ))){ |
|
|
|
if ( !m_bSegBActive ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Start Alt!(A)"); |
|
|
|
#endif
|
|
|
|
openSegmentB(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
if( m_nSegAFrameCounter > ( m_nSegmentLimitFrames - m_nPostAlarmFrames ) && !m_bActiveEncoderStream ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Swap Active!(A)"); |
|
|
|
#endif
|
|
|
|
swapActiveStreams(); |
|
|
|
@ -1789,7 +1801,7 @@ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){ |
|
|
|
// do {
|
|
|
|
//In Any Case Close Stream if it Long enough
|
|
|
|
if( m_nSegBFrameCounter > m_nBHardLimitFrames ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("HardLimit Reached!(B)"); |
|
|
|
#endif
|
|
|
|
closeSegmentB(); |
|
|
|
@ -1797,14 +1809,14 @@ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){ |
|
|
|
}; |
|
|
|
if( m_nSegBFrameCounter > ( m_nBSegmentLimitFrames - ( m_nBPostAlarmFrames + m_nAPreAlarmFrames ))){ |
|
|
|
if ( !m_bSegAActive ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Start Alt!(B)"); |
|
|
|
#endif
|
|
|
|
openSegmentA(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
if( m_nSegBFrameCounter > ( m_nBSegmentLimitFrames - m_nBPostAlarmFrames ) && m_bActiveEncoderStream ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Swap Active!(B)"); |
|
|
|
#endif
|
|
|
|
swapActiveStreams(); |
|
|
|
@ -1815,7 +1827,7 @@ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){ |
|
|
|
// do {
|
|
|
|
//In Any Case Close Stream if it Long enough
|
|
|
|
if( m_nSegBFrameCounter > m_nHardLimitFrames ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("HardLimit Reached!(B)"); |
|
|
|
#endif
|
|
|
|
closeSegmentB(); |
|
|
|
@ -1823,14 +1835,14 @@ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){ |
|
|
|
}; |
|
|
|
if( m_nSegBFrameCounter > ( m_nSegmentLimitFrames - ( m_nPostAlarmFrames + m_nPreAlarmFrames ))){ |
|
|
|
if ( !m_bSegAActive ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Start Alt!(B)"); |
|
|
|
#endif
|
|
|
|
openSegmentA(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
if( m_nSegBFrameCounter > ( m_nSegmentLimitFrames - m_nPostAlarmFrames ) && m_bActiveEncoderStream ){ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Swap Active!(B)"); |
|
|
|
#endif
|
|
|
|
swapActiveStreams(); |
|
|
|
@ -1896,7 +1908,7 @@ void streamHandler::closeSegmentA( void ){ |
|
|
|
m_mCurrentOperationProtector.lock(); |
|
|
|
if ( m_bCOP == 0 ) m_bCOP = 0x01; |
|
|
|
m_mCurrentOperationProtector.unlock(); |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Closing Stream A"); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
@ -1905,7 +1917,7 @@ void streamHandler::closeSegmentB( void ){ |
|
|
|
m_mCurrentOperationProtector.lock(); |
|
|
|
if ( m_bCOP == 0 ) m_bCOP = 0x02; |
|
|
|
m_mCurrentOperationProtector.unlock(); |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Closing Stream B"); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
@ -2059,7 +2071,7 @@ bool streamHandler::openSegmentA( void ){ |
|
|
|
if( !m_pEncoderA->open( mn, fourcc, fps, fz ) ){ |
|
|
|
LOG_ERROR("Cannot Open Output Segment A!"); |
|
|
|
return false; |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
} else { |
|
|
|
char tB[256]; |
|
|
|
sprintf( tB,"VideoStream A is Created [%s] %.2f fps", m_sStreamSegmentInfo[0].scratchPath, fps ); |
|
|
|
@ -2213,7 +2225,7 @@ bool streamHandler::openSegmentB( void ){ |
|
|
|
if( !m_pEncoderB->open( mn, fourcc, fps, fz ) ){ |
|
|
|
LOG_ERROR("Cannot Open Output Segment B!"); |
|
|
|
return false; |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
} else { |
|
|
|
char tB[256]; |
|
|
|
sprintf( tB,"VideoStream B is Created [%s] %.2f fps", m_sStreamSegmentInfo[1].scratchPath, fps ); |
|
|
|
@ -2712,7 +2724,7 @@ bool streamHandler::initVideoOutput(){ |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
} else { |
|
|
|
LOG("output codec context is already opened"); |
|
|
|
#endif
|
|
|
|
@ -3054,7 +3066,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
if ( m_bWebFrameSkeepDivider > EVE_EASE_FPS_DIVIDER_MAXIMUM ) { |
|
|
|
m_bWebFrameSkeepDivider = EVE_EASE_FPS_DIVIDER_MAXIMUM; |
|
|
|
} else { |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Video Quality Degraded!"); |
|
|
|
#endif
|
|
|
|
EVENT_CONTAINER *bEVT = createBasicEvent( m_sStreamData.source_id, EVT_CLASS_VIDEO, EVT_VIDEO_FPS_DEGRADED, NULL, NULL, NULL ); |
|
|
|
@ -3070,7 +3082,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
if ( m_bWebFrameSkeepDivider < EVE_EASE_FPS_DIVIDER_MINIMUM ) { |
|
|
|
m_bWebFrameSkeepDivider = EVE_EASE_FPS_DIVIDER_MINIMUM; |
|
|
|
} else { |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Video Quality Upgraded!"); |
|
|
|
#endif
|
|
|
|
EVENT_CONTAINER *bEVT = createBasicEvent( m_sStreamData.source_id, EVT_CLASS_VIDEO, EVT_VIDEO_FPS_RAISED, NULL, NULL, NULL ); |
|
|
|
@ -3199,7 +3211,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
m_mCurrentOperationProtector.lock(); |
|
|
|
switch ( m_bCOP ) { |
|
|
|
case 0x01:{ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Actual Closing Video Stream A!"); |
|
|
|
LOG( m_sStreamSegmentInfo[0].scratchPath ); |
|
|
|
#endif
|
|
|
|
@ -3214,7 +3226,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
#ifdef OPENCV_VIDEO_OUTPUT
|
|
|
|
if ( m_pEncoderA->isOpened() ) { |
|
|
|
m_pEncoderA->release(); |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
} else { |
|
|
|
LOG(" Encoder A is NOT Opened!"); |
|
|
|
#endif
|
|
|
|
@ -3228,7 +3240,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
if ( bEVT ) { |
|
|
|
basicEventHeap::getInstance()->broadcast( bEVT ); |
|
|
|
} else LOG_ERROR( "Event Creation failure!"); |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Stream A is Saved"); |
|
|
|
#endif
|
|
|
|
} else { |
|
|
|
@ -3241,7 +3253,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
#ifdef OPENCV_VIDEO_OUTPUT
|
|
|
|
if ( m_pEncoderA->isOpened() ) { |
|
|
|
m_pEncoderA->release(); |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
} else { |
|
|
|
LOG(" Encoder A is NOT Opened!"); |
|
|
|
#endif
|
|
|
|
@ -3256,7 +3268,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
#ifndef EVE_DONT_DELETE_SEGMENTS
|
|
|
|
unlink( m_sStreamSegmentInfo[0].scratchPath ); |
|
|
|
#endif
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Stream A is Closed!"); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
@ -3277,7 +3289,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
break; |
|
|
|
}; |
|
|
|
case 0x02:{ |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Actual Closing Video Stream B!"); |
|
|
|
LOG( m_sStreamSegmentInfo[1].scratchPath ); |
|
|
|
#endif
|
|
|
|
@ -3292,7 +3304,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
#ifdef OPENCV_VIDEO_OUTPUT
|
|
|
|
if ( m_pEncoderB->isOpened() ) { |
|
|
|
m_pEncoderB->release(); |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
} else { |
|
|
|
LOG(" Encoder B is NOT Opened!"); |
|
|
|
#endif
|
|
|
|
@ -3306,7 +3318,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
if ( bEVT ) { |
|
|
|
basicEventHeap::getInstance()->broadcast( bEVT ); |
|
|
|
} else LOG_ERROR( "Event Creation failure!"); |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Stream B is Saved"); |
|
|
|
|
|
|
|
#endif
|
|
|
|
@ -3320,7 +3332,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
#ifdef OPENCV_VIDEO_OUTPUT
|
|
|
|
if ( m_pEncoderB->isOpened() ) { |
|
|
|
m_pEncoderB->release(); |
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
} else { |
|
|
|
LOG(" Encoder B is NOT Opened!"); |
|
|
|
#endif
|
|
|
|
@ -3335,7 +3347,7 @@ void streamHandler::m_fThreadProc( void ){ |
|
|
|
#ifndef EVE_DONT_DELETE_SEGMENTS
|
|
|
|
unlink( m_sStreamSegmentInfo[1].scratchPath ); |
|
|
|
#endif
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Stream B is Closed!"); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
@ -3486,7 +3498,7 @@ void streamHandler::swapActiveStreams( void ){ |
|
|
|
|
|
|
|
bool streamHandler::triggerEvent( uint32_t eid, uint32_t &dbid, uint32_t &frame ){ |
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Trig Evt"); |
|
|
|
#endif
|
|
|
|
|
|
|
|
@ -3540,13 +3552,17 @@ bool streamHandler::triggerEvent( uint32_t eid, uint32_t &dbid, uint32_t &frame |
|
|
|
m_mFrameCounterProtector.unlock(); |
|
|
|
//if ( dbid == 0 ) return false;
|
|
|
|
//dbid = m_nVideoRegisteredDBID;
|
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Event Registered!"); |
|
|
|
#endif
|
|
|
|
#endif // EVE_ENABLE_VIDEO
|
|
|
|
return true; |
|
|
|
}; |
|
|
|
|
|
|
|
bool streamHandler::triggerCamMove( void ){ |
|
|
|
#ifdef DEBUG_EXTRA
|
|
|
|
LOG("Trig Cammove"); |
|
|
|
#endif
|
|
|
|
m_bCamMoveCounter = 255; |
|
|
|
return true; |
|
|
|
}; |
|
|
|
|