Browse Source

Merge branch 'master' of 172.105.5.225:/srv/git/argus

pull/7/head
Stéphane Charette 10 months ago
parent
commit
eccfc0cd27
  1. 20
      lib/App/common/kernelEventFilterBubble.cpp
  2. 1
      lib/App/common/kernelEventFilterBubble.h
  3. 65
      lib/App/common/kernelModuleEmbedVideo.cpp
  4. 12
      lib/App/common/kernelModuleEmbedVideo.h
  5. 25
      lib/data/mysql/mysql_class.cpp
  6. 48
      lib/data/sqlite/sqlite_class.cpp

20
lib/App/common/kernelEventFilterBubble.cpp

@ -334,6 +334,9 @@ bool kernelEventFilterBubble::validateTarget( uint32_t DevID, TARGET_DATA *ptr )
bool kernelEventFilterBubble::popSessionBubbles(){
m_mDataProtector.lock();
if ( m_vTargetBubbles.size() ) {
//Erase Only Blocked During Session Bubbles
//All Regular Bubbles must die in natural way
//At the Session End all Regular Bubbles Should be Naturally Dead
for( V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); ){
if( (*idx)->mode == TS_MODE_BLOCKED ) {
free(*idx);
@ -343,7 +346,15 @@ bool kernelEventFilterBubble::popSessionBubbles(){
};
};
};
//ToDo: It may be right way here to purge all bubbles and automatically reload all Permanent Bubbles Only
/*
m_mDataProtector.lock();
if ( m_vTargetBubbles.size() ) {
//Erase All
for (V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); ) free(*idx);
m_vTargetBubbles.clear();
};
DBC_INT_LIST *tList = m_pDBC->listFrozenBubbles( m_sBubbleFilterData.min_block_counts );
if ( tList ) {
if ( tList->size() ) {
@ -356,6 +367,8 @@ bool kernelEventFilterBubble::popSessionBubbles(){
};
delete( tList );
};
m_mDataProtector.unlock();
*/
m_mDataProtector.unlock();
return true;
@ -369,10 +382,11 @@ bool kernelEventFilterBubble::dispatchEvent( EVENT_CONTAINER *Evt ){
switch (Evt->m_eType) {
case EVT_LRF_END_SESSION_TO:
case EVT_LRF_END_SESSION_MA: popSessionBubbles(); break;
case EVT_FLT_BUBBLES_BLOCK: blockCurrentActiveBubbles(); break;
case EVT_FLT_BUBBLES_BLOCK: blockCurrentActiveBubbles(); break;
case EVT_FLT_BUBBLES_RELOAD:{
m_mDataProtector.lock();
if ( m_vTargetBubbles.size() ) {
//Erase Currently loadded Permanent Bubbles
for (V_TARGET_SEGMENTS::iterator idx = m_vTargetBubbles.begin(); idx != m_vTargetBubbles.end(); )
if( (*idx)->mode > TS_MODE_BLOCKED ){
free(*idx);
@ -403,7 +417,3 @@ bool kernelEventFilterBubble::dispatchEvent( EVENT_CONTAINER *Evt ){
#undef LOG
#undef LOG_ERROR
//westlaike 203
//Nov 8
//10.134.2.203

1
lib/App/common/kernelEventFilterBubble.h

@ -40,7 +40,6 @@ class kernelEventFilterBubble: public kernelEventFilter, public basicEventHandle
virtual bool dispatchEvent( EVENT_CONTAINER *Evt );
bool blockCurrentActiveBubbles();
bool resetAllBubbles();
//virtual bool dispatchEvent( EVENT_CONTAINER *Evt );
};
#endif

65
lib/App/common/kernelModuleEmbedVideo.cpp

@ -1236,7 +1236,7 @@ bool kernelModuleEmbedVideo::stopService( bool force ){
LOG( tB );
#endif
for( vectorHANDLERS::iterator index = m_vHandlersPool.begin(); index < m_vHandlersPool.end(); index++ ) {
for( vectorHANDLERS::iterator index = m_vHandlersPool.begin(); index != m_vHandlersPool.end(); index++ ) {
if( force ) {
#ifdef DEBUG_EXTRA
LOG("Force Client Handler to Stop!");
@ -1258,9 +1258,8 @@ bool kernelModuleEmbedVideo::stopService( bool force ){
#ifdef DEBUG_EXTRA
LOG("Some Caps!");
#endif
for( mapSTREAMCAPS::iterator idx = m_mapCAPTURES.begin(); idx != m_mapCAPTURES.end(); idx++ ) idx->second.clear();
m_mapCAPTURES.clear();
//for( mapSTREAMCAPS::iterator idx = m_mapCAPTURES.begin(); idx < m_mapCAPTURES.end(); idx++ ) {
//};
#ifdef DEBUG_EXTRA
LOG("No More Caps!");
#endif
@ -3809,7 +3808,7 @@ void streamHandler::m_fThreadProc( void ){
};
if ( nQueueSize ) {
#else
#else //!EVE_ENABLE_EASE_OUTPUT_FPS
if ( nQueueSize ) {
#endif
m_mEncodingQueueProtector.lock();
@ -3851,31 +3850,23 @@ void streamHandler::m_fThreadProc( void ){
free( tData->data );
free( tData );
#ifdef EVE_ENABLE_EASE_OUTPUT_FPS
if( !bSkeepA ){
if( !bSkeepA )
#endif
if (m_bSegAActive) {
if ( m_pEncoderA->isOpened() ) {
m_pEncoderA->write( image );
m_mFrameCounterProtector.lock();
m_nSegAFrameCounter++;
m_mFrameCounterProtector.unlock();
};
};
#ifdef EVE_ENABLE_EASE_OUTPUT_FPS
if (m_bSegAActive) if ( m_pEncoderA->isOpened() ) {
m_pEncoderA->write( image );
m_mFrameCounterProtector.lock();
m_nSegAFrameCounter++;
m_mFrameCounterProtector.unlock();
};
if( !bSkeepB ){
#endif
if ( m_bSegBActive ) {
if ( m_pEncoderB->isOpened() ) {
m_pEncoderB->write( image );
m_mFrameCounterProtector.lock();
m_nSegBFrameCounter++;
m_mFrameCounterProtector.unlock();
};
};
#ifdef EVE_ENABLE_EASE_OUTPUT_FPS
};
if( !bSkeepB )
#endif
if ( m_bSegBActive ) if ( m_pEncoderB->isOpened() ) {
m_pEncoderB->write( image );
m_mFrameCounterProtector.lock();
m_nSegBFrameCounter++;
m_mFrameCounterProtector.unlock();
};
#else // !OPENCV_VIDEO_OUTPUT
//av_frame_make_writable( m_pAVFrame );
//m_qEncodingQueue.pop();
@ -3906,17 +3897,13 @@ void streamHandler::m_fThreadProc( void ){
};
m_pAVFrame->pts = m_nGlobalFrameCounter + 1;
#ifdef SEPARATED_VIDEO_ENCODERS
//if( m_bSegAActive ) {
rVal = avcodec_send_frame(m_pCodecACtx, m_pAVFrame );
//};
//if( m_bSegBActive ) {
// rVal = avcodec_send_frame(m_pCodecBCtx, m_pAVFrame );
//};
#else // SEPARATED_VIDEO_ENCODERS
if( m_bSegAActive ) rVal = avcodec_send_frame( m_pCodecACtx, m_pAVFrame );
if( m_bSegBActive ) rVal = avcodec_send_frame( m_pCodecBCtx, m_pAVFrame );
#else //!SEPARATED_VIDEO_ENCODERS
rVal = avcodec_send_frame( m_pCodecCtx, m_pAVFrame );
#endif // SEPARATED_VIDEO_ENCODERS
#endif // !OPENCV_VIDEO_OUTPUT
#endif // !DIRECT_MJPEG_COMPOSING
#endif //!SEPARATED_VIDEO_ENCODERS
#endif //!OPENCV_VIDEO_OUTPUT
#endif //!DIRECT_MJPEG_COMPOSING
m_mFrameCounterProtector.lock();
m_nGlobalFrameCounter++;
m_mFrameCounterProtector.unlock();
@ -3937,7 +3924,7 @@ void streamHandler::m_fThreadProc( void ){
fclose( m_pOutputFD[0] );
m_pOutputFD[0] = NULL;
};
#else // !DIRECT_MJPEG_COMPOSING
#else //!DIRECT_MJPEG_COMPOSING
#ifdef OPENCV_VIDEO_OUTPUT
if ( m_pEncoderA->isOpened() ) {
m_pEncoderA->release();
@ -3946,11 +3933,11 @@ void streamHandler::m_fThreadProc( void ){
LOG(" Encoder A is NOT Opened!");
#endif
};
#else
#else //!OPENCV_VIDEO_OUTPUT
av_write_trailer( m_pFormatCtxA );
avio_close( m_pFormatCtxA->pb );
#endif //OPENCV_VIDEO_OUTPUT
#endif // !DIRECT_MJPEG_COMPOSING
#endif //!OPENCV_VIDEO_OUTPUT
#endif //!DIRECT_MJPEG_COMPOSING
EVENT_CONTAINER *bEVT = createBasicEvent( m_sStreamData.source_id, EVT_CLASS_VIDEO, EVT_CAPTURE_DONE, NULL, NULL, &m_sStreamSegmentInfo[0] );
if ( bEVT ) {
basicEventHeap::getInstance()->broadcast( bEVT );

12
lib/App/common/kernelModuleEmbedVideo.h

@ -247,14 +247,14 @@ typedef map<uint32_t, cv::Mat> mapSTREAMMAPS;
uint8_t * data;
size_t size;
}ENCODING_BUFFER;
#else
#else //!OPENCV_VIDEO_OUTPUT
typedef struct S_ENCODING_BUFFER{
int linesize[2];
int rows;
uint8_t * data[2];
size_t size;
}ENCODING_BUFFER;
#endif //OPENCV_VIDEO_OUTPUT
#endif //!OPENCV_VIDEO_OUTPUT
#endif //!DIRECT_MJPEG_COMPOSING
typedef std::queue<ENCODING_BUFFER *> Q_ENCODING_BUFFER;
#endif
@ -356,17 +356,17 @@ class streamHandler:
AVCodecContext * m_pCodecBCtx;
AVFrame * m_pAVBFrame;
uint8_t * m_pOutBBuffer;
#else //SEPARATED_VIDEO_ENCODERS
#else //!SEPARATED_VIDEO_ENCODERS
// encoding video stuff
AVCodec * m_pVideoCodec;
AVCodecContext * m_pCodecCtx;
#endif //SEPARATED_VIDEO_ENCODERS
#endif //!SEPARATED_VIDEO_ENCODERS
AVFrame * m_pAVFrame;
uint8_t * m_pOutBuffer;
// Common Pix Converter ( for both streams )
SwsContext * m_pConvertCtx;
#endif //OPENCV_VIDEO_OUTPUT
#endif //!OPENCV_VIDEO_OUTPUT
//char m_cSegNameA[128];
//char m_cSegMD5A[33];
@ -381,7 +381,7 @@ class streamHandler:
AVStream * m_pVideoStrB;
//common output options
AVDictionary * m_pFormatOpts;
#endif // !DIRECT_MJPEG_COMPOSING
#endif //!DIRECT_MJPEG_COMPOSING
basicMutex m_mEncodingQueueProtector;
Q_ENCODING_BUFFER m_qEncodingQueue;

25
lib/data/mysql/mysql_class.cpp

@ -225,27 +225,16 @@ AAssoc *MySQL_Connector::Query( CSTR QS, bool useCache ){
Fields = mysql_fetch_fields( Result );
while ( ( Row = mysql_fetch_row( Result ) ) != NULL ){
tElement = new Assoc();
string *Key;
string *Val;
string Key;
string Val;
for( int i = 0; i < num_Fields; i++ ){
Key = NULL;
Val = NULL;
Key = new string( Fields[ i ].name );
if( Key!= NULL ) {
if( Row[ i ] != NULL ){
Val = new string( Row[ i ] );
} else {
Val = new string( "0" );
};
if( Val != NULL ){
//(*tElement).insert( pair< string, string > ( *Key, *Val ) );
(*tElement)[*Key]=*Val;
} else {
LOG_ERROR( "Val Alloc Error" );
};
Key = string( Fields[ i ].name );
if( Row[ i ] != NULL ){
Val = string( Row[ i ] );
} else {
LOG_ERROR( "Key Alloc Error" );
Val = string( "0" );
};
(*tElement)[Key]=Val;
};
/*for (map<string, string>::iterator p = (*tElement).begin( ); p != (*tElement).end( ); ++p ) {
cout << "Field: " << p->first<< ", #: " << p->second << endl;

48
lib/data/sqlite/sqlite_class.cpp

@ -244,44 +244,26 @@ AAssoc *SQLite_Connector::Query( CSTR QS, bool useCache ){
#endif
RetVal = new AAssoc();
while( sqlite3_step( query ) != SQLITE_DONE ){
string *Key;
string *Val;
string Key;
string Val;
uint32_t num_cols = sqlite3_column_count( query );
if( num_cols ){
tElement = new Assoc();
if( tElement ){
for( uint32_t i = 0; i < num_cols; i++ ){
Key = NULL;
Val = NULL;
Key = new string( sqlite3_column_name( query, i ) );
if( Key!= NULL ) {
switch( sqlite3_column_type( query, i ) ){
case SQLITE_INTEGER:
Val = new std::string( (char*) sqlite3_column_text( query, i ) );
break;
case SQLITE_FLOAT:
Val = new std::string( (char*) sqlite3_column_text( query, i ) );
break;
case SQLITE3_TEXT:
Val = new std::string( (char*) sqlite3_column_text( query, i ) );
break;
case SQLITE_BLOB:
case SQLITE_NULL:
Val = new std::string( "" );
break;
default:
Val = new std::string( "" );
break;
};
if( Val != NULL ){
//(*tElement).insert( pair< string, string > ( *Key, *Val ) );
(*tElement)[*Key]=*Val;
} else {
LOG_ERROR( "Val Alloc Error" );
};
} else {
LOG_ERROR( "Key Alloc Error" );
};
Key = string( sqlite3_column_name( query, i ) );
switch( sqlite3_column_type( query, i ) ){
case SQLITE_INTEGER:
Val = std::string( (char*) sqlite3_column_text( query, i ) );
break;
case SQLITE_FLOAT:
Val = std::string( (char*) sqlite3_column_text( query, i ) );
break;
case SQLITE3_TEXT:
Val = std::string( (char*) sqlite3_column_text( query, i ) );
break;
};
(*tElement)[Key]=Val;
};
RetVal->push_back( tElement );
};

Loading…
Cancel
Save