|
|
|
@ -900,20 +900,11 @@ void argusModuleEmbedVideo::dispatchEvent( EVENT_CONTAINER *Evt ){ |
|
|
|
#endif
|
|
|
|
DBC_SNAPSHOT_DATA *tData = (DBC_SNAPSHOT_DATA *) Evt->m_pEvtData; |
|
|
|
if( tData ){ |
|
|
|
if( saveStreamPicture(tData) ){ |
|
|
|
//Create Event Finish Capture
|
|
|
|
} else { |
|
|
|
#ifdef DEBUG
|
|
|
|
LOG_ERROR("Save Error!"); |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
LOG("Free Data!"); |
|
|
|
if( !saveStreamPicture( tData ) ) LOG_ERROR("Save Error!"); |
|
|
|
tData->assoc_event_ids.clear(); |
|
|
|
delete( tData ); |
|
|
|
Evt->m_pEvtData = NULL; |
|
|
|
} else { |
|
|
|
LOG("No Data!"); |
|
|
|
}; |
|
|
|
} else LOG_ERROR("No Evt Data!"); |
|
|
|
break; |
|
|
|
}; |
|
|
|
}; |
|
|
|
@ -928,54 +919,31 @@ void argusModuleEmbedVideo::dispatchEvent( EVENT_CONTAINER *Evt ){ |
|
|
|
bool argusModuleEmbedVideo::saveStreamPicture( DBC_SNAPSHOT_DATA *ptr ){ |
|
|
|
if( ptr == NULL ) return false; |
|
|
|
if( ptr->assoc_event_ids.size() ){ |
|
|
|
LOG("Have EVTS!"); |
|
|
|
if( m_mapCAPTURES.find( ptr->stream_id ) != m_mapCAPTURES.end()) { |
|
|
|
LOG("CAP FOUND!"); |
|
|
|
FILE *tFD; |
|
|
|
if( m_mapCAPTURES.find( ptr->stream_id ) != m_mapCAPTURES.end() ){ |
|
|
|
m_mPictureProtector.lock(); |
|
|
|
size_t tBufferSize = m_mapCAPTURES[ptr->stream_id].size(); |
|
|
|
uint8_t * tBuffer = (uint8_t *) malloc( tBufferSize ); |
|
|
|
if( tBuffer ){ |
|
|
|
LOG("Buff OK!"); |
|
|
|
memcpy( tBuffer, m_mapCAPTURES[ptr->stream_id].data(), tBufferSize ); |
|
|
|
ptr->data = (uint8_t *) malloc( m_mapCAPTURES[ptr->stream_id].size() ); |
|
|
|
if( ptr->data ){ |
|
|
|
ptr->data_size = m_mapCAPTURES[ptr->stream_id].size(); |
|
|
|
memcpy( ptr->data, m_mapCAPTURES[ptr->stream_id].data(), ptr->data_size ); |
|
|
|
m_mPictureProtector.unlock(); |
|
|
|
|
|
|
|
CSTR MD5 = MD5Binary( tBuffer, tBufferSize ); |
|
|
|
CSTR MD5 = MD5Binary( ptr->data, ptr->data_size ); |
|
|
|
if( MD5 ){ |
|
|
|
LOG("MD5 OK!"); |
|
|
|
char tFileName[MAX_PATH]; |
|
|
|
strncpy( ptr->md5, MD5, 32 ); |
|
|
|
LOG( ptr->md5 ); |
|
|
|
free(MD5); |
|
|
|
if( generateSavePicPath( ptr->md5, tFileName ) ){ |
|
|
|
LOG( tFileName ); |
|
|
|
FILE *fd = fopen( tFileName, "wb+" ); |
|
|
|
if( fd ){ |
|
|
|
fwrite( tBuffer, 1, tBufferSize, fd ); |
|
|
|
fclose(fd); |
|
|
|
chown( tFileName, "nobody", "nogroup" ); |
|
|
|
return m_pDBC->addPicture( ptr, "jpg" ); |
|
|
|
//retVal = m_pDBC->addPicture( id, MD5, "jpg" );
|
|
|
|
} else { |
|
|
|
LOG_ERROR("Can not open picture file!"); |
|
|
|
}; |
|
|
|
} else { |
|
|
|
LOG_ERROR("Can not generate file name!"); |
|
|
|
}; |
|
|
|
|
|
|
|
} else { |
|
|
|
LOG_ERROR("no MD5 Hash!"); |
|
|
|
}; |
|
|
|
free(tBuffer); |
|
|
|
free( MD5 ); |
|
|
|
if( !m_pDBC->addPicture( ptr, "jpg" ) ) LOG_ERROR("Database Error to consume capture!"); |
|
|
|
} else LOG_ERROR("no MD5 Hash!"); |
|
|
|
free( ptr->data ); |
|
|
|
} else { |
|
|
|
m_mPictureProtector.unlock(); |
|
|
|
LOG_ERROR("no memory to allocate!"); |
|
|
|
LOG_ERROR("No memory to allocate!"); |
|
|
|
}; |
|
|
|
} else { |
|
|
|
} |
|
|
|
#ifdef DEBUG
|
|
|
|
else { |
|
|
|
LOG("No apropriate Stream Found!"); |
|
|
|
} |
|
|
|
#endif
|
|
|
|
}; |
|
|
|
; |
|
|
|
}; |
|
|
|
return true; |
|
|
|
}; |
|
|
|
@ -1000,16 +968,10 @@ bool argusModuleEmbedVideo::saveStreamPicture( uint32_t id ){ |
|
|
|
fclose(fd); |
|
|
|
chown( tFileName, "nobody", "nogroup" ); |
|
|
|
//retVal = m_pDBC->addPicture( id, MD5, "jpg" );
|
|
|
|
} else { |
|
|
|
LOG_ERROR("Can not open picture file!"); |
|
|
|
}; |
|
|
|
} else { |
|
|
|
LOG_ERROR("Can not generate file name!"); |
|
|
|
}; |
|
|
|
} else LOG_ERROR("Can not open picture file!"); |
|
|
|
} else LOG_ERROR("Can not generate file name!"); |
|
|
|
free(MD5); |
|
|
|
} else { |
|
|
|
LOG_ERROR("no MD5 Hash!"); |
|
|
|
}; |
|
|
|
} else LOG_ERROR("no MD5 Hash!"); |
|
|
|
free(tBuffer); |
|
|
|
} else { |
|
|
|
m_mPictureProtector.unlock(); |
|
|
|
@ -1020,16 +982,12 @@ bool argusModuleEmbedVideo::saveStreamPicture( uint32_t id ){ |
|
|
|
}; |
|
|
|
|
|
|
|
int argusModuleEmbedVideo::getWidh( void ){ |
|
|
|
if( m_sEmbedVideoData.width ){ |
|
|
|
return m_sEmbedVideoData.width; |
|
|
|
}; |
|
|
|
if( m_sEmbedVideoData.width ) return m_sEmbedVideoData.width; |
|
|
|
return -1; |
|
|
|
}; |
|
|
|
|
|
|
|
int argusModuleEmbedVideo::getHeight( void ){ |
|
|
|
if( m_sEmbedVideoData.height ) { |
|
|
|
return m_sEmbedVideoData.height; |
|
|
|
}; |
|
|
|
if( m_sEmbedVideoData.height ) return m_sEmbedVideoData.height; |
|
|
|
return -1; |
|
|
|
}; |
|
|
|
|
|
|
|
|