Browse Source

Added Picture support for SQLite

AGP
Evgeny Gagua 3 years ago
parent
commit
c5208f435c
  1. 4
      Projects/la_mojo/build
  2. 32
      lib/App/common/SQLite_dataBinder.cpp
  3. 2
      lib/App/common/SQLite_dataBinder.h
  4. 2
      lib/App/common/dataBinder_structures.h
  5. 3101
      lib/App/common/deviceNodeCamera.cpp
  6. 1
      lib/App/common/deviceNodeCamera.h
  7. 40
      lib/App/common/kernelModuleEmbedVideo.cpp
  8. 2
      lib/App/common/kernelModuleEmbedVideo.h
  9. 18
      lib/data/protocol/protocol.cpp
  10. 1
      lib/data/protocol/protocolPTZ.h
  11. 51
      lib/data/protocol/protocolPTZ_ONVIF.cpp
  12. 1
      lib/data/protocol/protocolPTZ_ONVIF.h
  13. 1
      lib/rgoose/rgooseCamera.h

4
Projects/la_mojo/build

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

32
lib/App/common/SQLite_dataBinder.cpp

@ -1299,6 +1299,38 @@ bool sqliteDBC::addLRFWidthTable( uint32_t sensorID, PWIDTH_TABLE ptr ){
return false;
};
bool sqliteDBC::addPicture( DBC_SNAPSHOT_DATA *ptr, CSTR ext ){
bool rVal = false;
if( ptr != NULL ){
if( m_bRepIsConnected ){
char tQBuf[MAX_PATH_LEN];
uint32_t pic_id;
sprintf( tQBuf, "%s/%s/%s/%s/%s.%s",
m_pDbReportBase, m_sPRepInfo.YEAR, m_sPRepInfo.MONTH, m_sPRepInfo.DAY, ptr->md5, ext );
FILE *fd = fopen( tQBuf, "wb+" );
if( fd ){
fwrite( ptr->data, 1, ptr->data_size, fd );
fclose(fd);
chown( tQBuf, web_access_user, web_access_group );
} else {
LOG_ERROR("Error Saving Captured picture!");
return rVal;
};
sprintf( tQBuf, "INSERT INTO pictures(`media_stream_id`,`uts`,`uts_ms`,`md5`,`ext`) VALUES(%d,%d,0,'%s','%s')",
ptr->stream_id, ptr->ts, ptr->md5, ext );
pic_id = (uint32_t) m_pDataReports->QueryID( tQBuf );
if ( pic_id ) {
for( DBC_INT_LIST::iterator idx = ptr->assoc_event_ids.begin(); idx < ptr->assoc_event_ids.end(); idx++ ) {
sprintf( tQBuf, "INSERT INTO `events_2_pictures`(`evt_id`,`picture_id`) VALUES(%d,%d)", (*idx), pic_id );
m_pDataReports->SilentQuery( tQBuf );
};
rVal = true;
};
};
};
return rVal;
};
uint32_t sqliteDBC::addResource( uint8_t type, CSTR devName, uint32_t auxID ){
uint32_t RetVal = 0;
if( m_bStoIsConnected ){

2
lib/App/common/SQLite_dataBinder.h

@ -79,7 +79,7 @@ class sqliteDBC: public dataBinder {
virtual bool addLRFMaskPolygonePoint( uint32_t polyID, int16_t x, int16_t y );
virtual bool addLRFWidthTable(uint32_t sensorID, PWIDTH_TABLE ptr );
virtual bool addPicture( DBC_SNAPSHOT_DATA *ptr, CSTR ext );
virtual uint32_t addResource( uint8_t type, CSTR devName, uint32_t auxID = 0 );
virtual bool addVideoEvent( uint32_t evtID, uint32_t videoID, uint32_t frame, uint32_t tss, uint32_t tms );
virtual uint32_t addVideoRecord( uint32_t streamID, CSTR md5, CSTR ext, uint32_t ts, uint32_t tsms, uint32_t fps );

2
lib/App/common/dataBinder_structures.h

@ -293,7 +293,7 @@ typedef struct S_DBC_MODULE_DATA{
}DBC_MODULE_DATA;
typedef struct S_DBC_MODULE_EMBED_VIDEO_DATA{
uint8_t output_mode;
uint8_t output_mode;// Video-Picture
uint16_t port;
bool show_ts;
bool show_label;

3101
lib/App/common/deviceNodeCamera.cpp
File diff suppressed because it is too large
View File

1
lib/App/common/deviceNodeCamera.h

@ -75,6 +75,7 @@ typedef enum E_CAM_WORKING_STATE{
CAM_WS_GO_ABS_ROI = 15,
CAM_WS_READY = 64,
CAM_WS_BUSY = 128,
CAM_WS_WAIT_ONPOS = 129,
CAM_WS_END = 255
}CAM_WORK_STATE;

40
lib/App/common/kernelModuleEmbedVideo.cpp

@ -97,8 +97,10 @@ kernelModuleEmbedVideo::kernelModuleEmbedVideo( uint32_t moduleID ): kernelModul
sprintf( tB, "Web Streams Port: %d", m_sEmbedVideoData.port );
LOG( tB );
sprintf( tB, "Frame: [%dx%d]", m_sEmbedVideoData.width, m_sEmbedVideoData.height );
LOG( tB );
if( m_sEmbedVideoData.show_ts ) LOG("Show TimeStamp");
LOG( tB );
if( m_sEmbedVideoData.output_mode & EVE_OUTPUT_PICTURES ) LOG("Output Pictures");
if( m_sEmbedVideoData.output_mode & EVE_OUTPUT_VIDEO ) LOG("Output Video");
if (m_sEmbedVideoData.show_ts) LOG("Show TimeStamp");
if( m_sEmbedVideoData.show_label ) LOG("Show Label");
if( m_sEmbedVideoData.show_logo ) LOG("Show Logo");
#endif
@ -380,7 +382,7 @@ void *kernelModuleEmbedVideo::webClientProc( void *ptr ){
#ifdef HAVE_SMAL_PREVIEW_STREAMS
};
#endif
#ifdef DEBUG
#ifdef DEBUG_EXTRA
TLOG("VFEED Sent No Signal Image!");
#endif
} else {
@ -461,7 +463,7 @@ void *kernelModuleEmbedVideo::webClientProc( void *ptr ){
};
} else {
#ifdef DEBUG
#ifdef DEBUG_EXTRA
TLOG("VFEED Sent No Signal Image!");
#endif
CTX->ModulePtr->m_mEncodedProtector.unlock();
@ -1434,15 +1436,13 @@ void kernelModuleEmbedVideo::dispatchEvent( EVENT_CONTAINER *Evt ){
//https://www.mikekohn.net/software/playstation2.php
bool kernelModuleEmbedVideo::saveStreamPicture( DBC_SNAPSHOT_DATA *ptr ){
if( ptr == NULL ) return false;
if( m_sEmbedVideoData.output_mode & EVE_OUTPUT_PICTURES ){
if( ( m_sEmbedVideoData.output_mode & EVE_OUTPUT_PICTURES ) == EVE_OUTPUT_PICTURES ){
LOG("Saving Picture!");
saveStreamPicture( ptr->stream_id );
//saveStreamPicture( ptr->stream_id );
/*
//*
if( ptr->assoc_event_ids.size() ){
if( m_mapCAPTURES.find( ptr->stream_id ) != m_mapCAPTURES.end() ){
m_mPictureProtector.lock();
@ -1468,9 +1468,9 @@ bool kernelModuleEmbedVideo::saveStreamPicture( DBC_SNAPSHOT_DATA *ptr ){
#endif
};
};
*/
//*/
};
if( 1 || m_sEmbedVideoData.output_mode & EVE_OUTPUT_VIDEO ){
if( ( m_sEmbedVideoData.output_mode & EVE_OUTPUT_VIDEO ) == EVE_OUTPUT_VIDEO ){
LOG("Saving Video!");
if( ptr->assoc_event_ids.size() ){
m_mStreamHandlersProtector.lock();
@ -1480,10 +1480,22 @@ bool kernelModuleEmbedVideo::saveStreamPicture( DBC_SNAPSHOT_DATA *ptr ){
uint32_t cfrm;
for( DBC_INT_LIST::iterator idx = ptr->assoc_event_ids.begin(); idx < ptr->assoc_event_ids.end(); idx++ )
(*hnd).second->triggerEvent( (*idx), db_id, cfrm );
} else LOG("No Stream Found!");
#ifdef DEBUG_EXTRA
} else {
LOG("No Stream Found!");
#endif
};
m_mStreamHandlersProtector.unlock();
} else LOG("No Assoc EVTIDS!");
} else LOG("No Video Mode!");
#ifdef DEBUG_EXTRA
} else {
LOG("No Assoc EVTIDS!");
#endif
};
#ifdef DEBUG_EXTRA
} else {
LOG("No Video Mode!");
#endif
};
return true;
};

2
lib/App/common/kernelModuleEmbedVideo.h

@ -23,7 +23,7 @@ class kernelModuleEmbedVideo;
#define FILESTREAMBUFFERSZ 1048576
#ifndef MEKOROT_PROJECT
#ifndef MEKOROT_PROJECT__
#define EVE_ENABLE_VIDEO
#endif
//#define USE_SCALING_IN

18
lib/data/protocol/protocol.cpp

@ -122,9 +122,11 @@ basicTransport *protocolParser::getCurrentTransport( void ){
bool protocolParser::parse( U8 *Buffer, size_t BufferSize ){
bool rv = false;
if( m_pParserBuffer != NULL ) {
#ifdef DUBUG_COMMUNICATION
char ttZZ[256];
#ifdef DEBUG
char ttZZ[513];
sprintf( ttZZ, "New %d bytes to Parse (allredy have in buffer: %d)", BufferSize, m_nParserDataCount );
LOG(ttZZ);
for ( uint8_t i = 0; i < BufferSize; i++ ) sprintf( ttZZ+(i*2), "%02X", Buffer[i] );
LOG(ttZZ);
#endif
m_mBufferProtectorMutex.lock();
@ -150,8 +152,8 @@ bool protocolParser::parse( U8 *Buffer, size_t BufferSize ){
protocolPackage* tVal = NULL;
tVal = packetExtractor( m_pParserBuffer, m_nParserDataCount );
if (tVal != NULL) {
#ifdef DUBUG_COMMUNICATION
LOG("Package Handling");
#ifdef DUBUG
LOG("Package Accepted");
char tBuf[256];
sprintf(tBuf, "Pack Size: %d from %d bytes", tVal->m_nSize, m_nParserDataCount);
LOG(tBuf);
@ -159,14 +161,14 @@ bool protocolParser::parse( U8 *Buffer, size_t BufferSize ){
//Move unused data toward buffer's begin to parse at next parse attempt
m_nParserDataCount -= tVal->m_nSize;
if( m_nParserDataCount > 0 ) {
memcpy(m_pParserBuffer, m_pParserBuffer + tVal->m_nSize, m_nParserDataCount);
memcpy( m_pParserBuffer, m_pParserBuffer + tVal->m_nSize, m_nParserDataCount );
} else {
// Clean Buff;
memset( m_pParserBuffer, 0, PROTOCOL_PARSER_BUFFER_SIZE);
m_nParserDataCount = 0;
};
// In Case implementation of packetHandler - handler must return !true!
if (!packetHandler(tVal)) {
if( !packetHandler(tVal) ){
LOG("Handler Not Consumed Data!");
m_vPackagePool.push_back(tVal);
if (m_vPackagePool.size() > PROTO_QUEUE_MAX_PACKAGES) {
@ -177,10 +179,12 @@ bool protocolParser::parse( U8 *Buffer, size_t BufferSize ){
free(tVal);
};
} else {
LOG("Handler Consumed Data!");
dataEraser(tVal->m_pData);
free(tVal);
};
} else {
} else {
LOG_ERROR("Packet Not Extracted!");
// All data consumed in MAVLINK proto but not parsed into message
m_nParserDataCount = 0;
};

1
lib/data/protocol/protocolPTZ.h

@ -194,6 +194,7 @@ class protocolPTZ: public protocolParser {
virtual bool goAbsolute( float dPan, float dTilt, float dZoom ){ return true; };
virtual bool goPreset( char *PresetToken ){ return true; };
virtual bool setOSD( bool nMode ){ return true; };
virtual bool waitMoveIsDone( void ){ return false; };
};
#endif // NO_PTZ_CAMERAS

51
lib/data/protocol/protocolPTZ_ONVIF.cpp

@ -265,38 +265,43 @@ bool protocolPTZ_ONVIF::move( uint32_t MoveMatrix ){
#include <math.h>
bool protocolPTZ_ONVIF::waitMoveIsDone( void ){
ptzStatus tVal;
uint8_t TO = 10; // 3.6 second max
SLEEP( 333 );
while( m_pOnVif->ptz_GetStatus( m_pProfile->profiletoken, &tVal ) && TO ) {
if( tVal.hasMoveStatus ) {
if( tVal.PanTiltIdle && tVal.ZoomIdle ) break;
} else {
//if( ( fabs(tVal.pan - dPan) < 0.0005 ) && ( fabs( tVal.tilt - dTilt) < 0.0005 ) ) break;//&& ( fabs( tVal.zoom - dZoom ) < 0.05 ) ) break;
};
SLEEP( 333 );
TO--;
};
if( TO ) {
#ifdef DEBUG_EXTRA
LOG("Finished Move!");
#endif
return true;
} else LOG_ERROR("Error Fetching PTZ Status!");
return false;
};
bool protocolPTZ_ONVIF::goAbsolute( float dPan, float dTilt, float dZoom ){
#ifdef USE_PONVIF
//if (m_bStatus == 0) return false;
#ifdef DEBUG_EXTRA
LOG("ABS Move");
#endif
#ifdef DEBUG_EXTRA
LOG("ABS Move");
#endif
if( m_pProfile == NULL ){
LOG_ERROR("No PTZ Profile!!");
return false;
};
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 ) {
if( tVal.hasMoveStatus ) {
if( tVal.PanTiltIdle && tVal.ZoomIdle ) break;
} else {
if( ( fabs(tVal.pan - dPan) < 0.0005 ) && ( fabs( tVal.tilt - dTilt) < 0.0005 ) ) break;//&& ( fabs( tVal.zoom - dZoom ) < 0.05 ) ) break;
};
SLEEP( 333 );
TO--;
};
if( TO ) {
#ifdef DEBUG_EXTRA
LOG("Finished Move!");
#endif
return true;
} else LOG_ERROR("Error Fetching PTZ Status!");
*/
};
return true;
#else

1
lib/data/protocol/protocolPTZ_ONVIF.h

@ -45,6 +45,7 @@ class protocolPTZ_ONVIF: public protocolPTZ{
bool setUsername( CSTR username );
bool setPassword( CSTR password );
bool setAuthMode( uint8_t Mode );
virtual bool waitMoveIsDone( void );
};

1
lib/rgoose/rgooseCamera.h

@ -72,6 +72,7 @@ typedef enum E_CAM_WORKING_STATE{
CAM_WS_GO_ABS_POSITION = 12,
CAM_WS_READY = 64,
CAM_WS_BUSY = 128,
CAM_WS_WAIT_ONPOS = 129,
CAM_WS_END = 255
}CAM_WORK_STATE;

Loading…
Cancel
Save