Browse Source

Rock MER

AGP
Evgeny Gagua 3 years ago
parent
commit
e0e6fdd7b1
  1. 2
      Projects/la_mojo/build
  2. 29
      lib/App/common/SQLite_dataBinder.cpp
  3. 39
      lib/App/common/kernelModuleEmbedVideo.cpp
  4. 2
      lib/App/mojo/mojoKernel.cpp
  5. 2
      lib/data/protocol/protocolPTZ_ONVIF.cpp

2
Projects/la_mojo/build

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

29
lib/App/common/SQLite_dataBinder.cpp

@ -296,7 +296,7 @@ bool sqliteDBC::connect( void ){
};
};
};
bool create_tables = false;
m_pDataReports = new SQLite_Connector();
if ( m_pDataReports ) {
LOG("RDB Created!");
@ -324,9 +324,10 @@ bool sqliteDBC::connect( void ){
//strncpy( m_sPRepInfo.DAY, it->second.c_str(), 2 );
};
m_sPRepInfo.ts = getTsFromRDF( m_sPRepInfo );
#ifdef DEBUG_ALL
} else {
create_tables = true;
#ifdef DEBUG_ALL
LOG("No Rows Fetched!");
#endif
};
@ -339,6 +340,7 @@ bool sqliteDBC::connect( void ){
if( checkRDFDir( m_pDbReportBase, m_sPRepInfo, false ) == 0 ) {
LOG_ERROR("Error Connecting to Prev Report!");
m_bLastEventWasClosed = true;
create_tables = true;
} else {
LOG("Create R-Base Connection");
sprintf( m_pDbReport, "%s/%s/%s/%s/report.db", m_pDbReportBase, m_sPRepInfo.YEAR, m_sPRepInfo.MONTH, m_sPRepInfo.DAY );
@ -369,18 +371,24 @@ bool sqliteDBC::connect( void ){
} else {
LOG_ERROR("Error Connecting to Prev Report!");
m_bLastEventWasClosed = true;
create_tables = true;
};
delete( tDBC );
} else {
LOG_ERROR("Error Create DB Connection Object!");
m_bLastEventWasClosed = true;
create_tables = true;
};
} else {
LOG_ERROR("Error No Prev Report Database!");
m_bLastEventWasClosed = true;
create_tables = true;
};
};
} else m_bLastEventWasClosed = true;
} else {
m_bLastEventWasClosed = true;
create_tables = true;
};
if ( m_bLastEventWasClosed ) {
LOG("Event Closed!");
@ -406,14 +414,15 @@ bool sqliteDBC::connect( void ){
#endif
chown( m_pDbReport, web_access_user, web_access_group );
chmod( m_pDbReport, DB_FILE_MODE );
if ( m_sCRepInfo.ts != m_sPRepInfo.ts ) {
//Recreate Table in any case
//if ( m_sCRepInfo.ts != m_sPRepInfo.ts || create_tables ) {
// Created New Report ??
m_pDataReports->SilentQuery("CREATE TABLE IF NOT EXISTS \"events\" ( \"id\" INTEGER NOT NULL, \"node_id\" INTEGER NOT NULL, \"uuid\" TEXT NOT NULL UNIQUE, \"ts\" INTEGER NOT NULL, \"ts_ms\" INTEGER NOT NULL, \"evt_type\" INTEGER NOT NULL, \"lrf_id\" INTEGER, \"range_digital\" INTEGER, \"azimuth\" REAL, \"elevation\" REAL, \"range\" REAL, \"area\" REAL, \"lat\" REAL, \"lon\" REAL, \"alt\" REAL, \"ref_id\" INTEGER, \"ref_uuid\" TEXT, PRIMARY KEY(\"id\" AUTOINCREMENT) )");
m_pDataReports->SilentQuery("CREATE TABLE IF NOT EXISTS \"events_2_pictures\" ( \"evt_id\" INTEGER NOT NULL, \"picture_id\" INTEGER NOT NULL )");
m_pDataReports->SilentQuery("CREATE TABLE IF NOT EXISTS \"events_2_videos\" ( \"evt_id\" INTEGER NOT NULL, \"video_id\" INTEGER NOT NULL, \"frame\" INTEGER DEFAULT 0, \"tss\" INTEGER, \"tms\" INTEGER )");
m_pDataReports->SilentQuery("CREATE TABLE IF NOT EXISTS \"pictures\" ( \"id\" INTEGER NOT NULL, \"media_stream_id\" INTEGER NOT NULL, \"md5\" TEXT NOT NULL UNIQUE, \"uts\" INTEGER NOT NULL, \"uts_ms\" INTEGER NOT NULL, \"ext\" TEXT NOT NULL, \"data\" BLOB COLLATE BINARY, PRIMARY KEY(\"id\" AUTOINCREMENT) )");
m_pDataReports->SilentQuery("CREATE TABLE IF NOT EXISTS \"videos\" ( \"id\" INTEGER NOT NULL, \"media_stream_id\" INTEGER NOT NULL, \"md5\" TEXT NOT NULL UNIQUE, \"uts\" INTEGER NOT NULL, \"uts_ms\" INTEGER NOT NULL, \"ext\" TEXT NOT NULL, \"fps\" INTEGER NOT NULL, \"flength\" INTEGER, PRIMARY KEY(\"id\" AUTOINCREMENT) )");
};
//};
m_bRepIsConnected = true;
} else{
LOG_ERROR("Cannot Connect to DB File");
@ -659,7 +668,7 @@ void sqliteDBC::updateStats( bool evt, bool video, uint8_t ses_status ){
sprintf(tQBuf, "INSERT INTO `days`(`year`,`month`,`day`,`evt_count`) VALUES(%s,%s,%s,1) ON CONFLICT(`year`,`month`,`day`) DO UPDATE SET `evt_count`=`evt_count`+1",
m_sCRepInfo.YEAR, m_sCRepInfo.MONTH, m_sCRepInfo.DAY );
};
#ifdef DEBUG
#ifdef DEBUG_ALL
LOG( tQBuf );
#endif
m_pDataStatistics->SilentQuery( tQBuf );
@ -834,7 +843,7 @@ uint32_t sqliteDBC::addEvent( DBC_EVT_RECORD *ptr ){
};
default: return 0;
};
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG( tQBuf );
#endif
if ( m_bRepIsConnected ) {
@ -1328,7 +1337,7 @@ bool sqliteDBC::addVideoEvent( uint32_t evtID, uint32_t videoID, uint32_t frame,
tss,
tms
);
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
m_pDataReports->SilentQuery( tQBuf );
@ -1349,7 +1358,7 @@ uint32_t sqliteDBC::addVideoRecord( uint32_t streamID, CSTR md5, CSTR ext, uint3
ext,
fps
);
#ifdef DEBUG
#ifdef DEBUG_EXTRA
LOG(tQBuf);
#endif
RetVal = (uint32_t) m_pDataReports->QueryID( tQBuf );

39
lib/App/common/kernelModuleEmbedVideo.cpp

@ -316,7 +316,7 @@ void *kernelModuleEmbedVideo::webClientProc( void *ptr ){
continue;
};
};
#ifdef DEBUG
#ifdef DEBUG_EXTRA
TLOG( "Req URI" );
TLOG( cGetURI );
#endif
@ -380,8 +380,8 @@ void *kernelModuleEmbedVideo::webClientProc( void *ptr ){
#ifdef HAVE_SMAL_PREVIEW_STREAMS
};
#endif
#ifdef DEBUG_EXTRA
TLOG("Sent No Signal Image!");
#ifdef DEBUG
TLOG("VFEED Sent No Signal Image!");
#endif
} else {
// Send 404 Header
@ -460,6 +460,10 @@ void *kernelModuleEmbedVideo::webClientProc( void *ptr ){
continue;
};
} else {
#ifdef DEBUG
TLOG("VFEED Sent No Signal Image!");
#endif
CTX->ModulePtr->m_mEncodedProtector.unlock();
if( CTX->ModulePtr->n_pNoSignalData ){
msgSize = CTX->ModulePtr->m_nNoSignalSize;
@ -607,7 +611,7 @@ void *kernelModuleEmbedVideo::viewClientProc( void *ptr ){
continue;
};
};
#ifdef DEBUG
#ifdef DEBUG_EXTRA
TLOG( "Req URI" );
TLOG( cGetURI );
#endif
@ -624,8 +628,8 @@ void *kernelModuleEmbedVideo::viewClientProc( void *ptr ){
};
if (tB = strcasestr( tP, "ts=" ) ) {
tDTS = atol( tB+3 );
struct tm * ptm = NULL;
ptm = gmtime ( &tDTS );
//struct tm * ptm = gmtime ( &tDTS );
struct tm * ptm = localtime( &tDTS );
if ( ptm ) {
sprintf( tBASE, "%04d/%02d/%02d", (ptm->tm_year+1900), (ptm->tm_mon+1), ptm->tm_mday );
};
@ -635,7 +639,7 @@ void *kernelModuleEmbedVideo::viewClientProc( void *ptr ){
};
sprintf( tFILE, "./data/reports/%s/%s.mjpeg", tBASE, tID );
};
#ifdef DEBUG
#ifdef DEBUG_EXTRA
char tB[64];
sprintf(tB,"Requested Video: %s", tFILE );
TLOG( tB );
@ -658,12 +662,13 @@ void *kernelModuleEmbedVideo::viewClientProc( void *ptr ){
TLOG("Stream id Not Online");
#endif
};
#ifdef DEBUG
} else {
TLOG("No Stream ID");
#endif
TLOG_ERROR("VVIEW File Not Exists!");
};
};
#ifdef DEBUG_EXTRA
TLOG("VVIEW Catched in DeadEnd!");
#endif
if( 1 ) {
//Send Dummy Picture
sprintf( mesg, ht_no_signal, CTX->ModulePtr->m_nNoSignalSize );
@ -671,7 +676,7 @@ void *kernelModuleEmbedVideo::viewClientProc( void *ptr ){
send( CTX->m_iSocketFID, CTX->ModulePtr->n_pNoSignalData, CTX->ModulePtr->m_nNoSignalSize, 0 );
send( CTX->m_iSocketFID, "\r\n\r\n", 4, 0 );
#ifdef DEBUG_EXTRA
TLOG("Sent No Signal Image!");
TLOG("VVIEW Sent No Signal Image!");
#endif
} else {
// Send 404 Header
@ -740,11 +745,11 @@ void *kernelModuleEmbedVideo::viewClientProc( void *ptr ){
memcpy( tBuf, ePtr, cSIZE );
sPtr = ePtr = NULL;
}
#ifdef DEBUG_EXTRA
#ifdef DEBUG
else TLOG("File is Finished!");
#endif
};
#ifdef DEBUG_EXTRA
#ifdef DEBUG
if( feof( tFID ) ) TLOG("LAST FRAME SENT");
#endif
};
@ -766,7 +771,7 @@ void *kernelModuleEmbedVideo::viewClientProc( void *ptr ){
close( CTX->m_iSocketFID );
//pthread_exit( NULL );
CTX->bValid = false;
#ifdef DEBUG
#ifdef DEBUG_EXTRA
TLOG("View Client Handler Ended!");
#endif
return NULL;
@ -2060,7 +2065,8 @@ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){
} else {
if( m_pMaster->m_sEmbedVideoData.show_ts ){
time_t t = time( NULL );
struct tm * tmp = gmtime( &t );
//struct tm * tmp = gmtime( &t );
struct tm * tmp = localtime( &t );
if( tmp ){
if( strftime( tBuffer, sizeof(tBuffer), "%F %T GMT", tmp )!=0 ){
uint8_t shift_x = 0;
@ -2207,6 +2213,7 @@ bool streamHandler::pushFrame( cv::Mat &Frame, void* src ){
m_pMaster->m_mapCAPTURES[tMD->mediaStreamId].clear();
cv::imencode( ".jpg", m_pMaster->m_mapMATS[tMD->mediaStreamId], m_pMaster->m_mapCAPTURES[tMD->mediaStreamId], compression_params );
#ifdef HAVE_SMAL_PREVIEW_STREAMS
// Make Small Preview Thumb
cv::Mat dst;
@ -3991,7 +3998,7 @@ void streamHandler::swapActiveStreams( void ){
bool streamHandler::triggerEvent( uint32_t eid, uint32_t &dbid, uint32_t &frame ){
#ifdef DEBUG_EXTRA
#ifdef DEBUG
LOG("Trig Evt");
#endif

2
lib/App/mojo/mojoKernel.cpp

@ -744,9 +744,11 @@ void mojoKernel::dispatchEvent( EVENT_CONTAINER *Evt ){
case EVT_CLASS_SENSOR_ALS:
case EVT_CLASS_SENSOR_3D:
case EVT_CLASS_SENSOR_ACC:
#ifdef DEBUG_EXTRA
char tB[128];
sprintf( tB,"Evt Class: %d Evt Type: %d ", Evt->m_eClass ,Evt->m_eType );
LOG( tB );
#endif
switch( Evt->m_eType ) {
case EVT_TARGET_1D:{

2
lib/data/protocol/protocolPTZ_ONVIF.cpp

@ -278,6 +278,7 @@ bool protocolPTZ_ONVIF::goAbsolute( float dPan, float dTilt, float dZoom ){
if ( dZoom < 0.0f ) dZoom = 0.0f;
uint8_t TO = 10; // 3.6 second max
if ( m_pOnVif->ptz_AbsoluteMove( m_pProfile->profiletoken, dPan, dTilt, dZoom ) ){
/* No Wait Status!
SLEEP( 333 );
ptzStatus tVal;
while( m_pOnVif->ptz_GetStatus( m_pProfile->profiletoken, &tVal ) && TO ) {
@ -295,6 +296,7 @@ bool protocolPTZ_ONVIF::goAbsolute( float dPan, float dTilt, float dZoom ){
#endif
return true;
} else LOG_ERROR("Error Fetching PTZ Status!");
*/
};
return true;
#else

Loading…
Cancel
Save