Browse Source

Module Sequental Video Recording - before Debug

pull/7/head
Evgeny Gagua 6 months ago
parent
commit
462c1d492a
  1. 6
      Projects/la_mojo/build
  2. 4777
      lib/App/common/kernelModuleEmbedVideo.cpp
  3. 188
      lib/App/common/kernelModuleEmbedVideo.h
  4. 4
      lib/App/common/serverMySQL_dataBinder.cpp
  5. 2
      lib/App/mojo/mojoKernel.cpp
  6. 10
      lib/App/serva/servaKernel.cpp
  7. 2
      lib/App/serva/servaKernel.h
  8. 4
      lib/App/serva/servaVideoComposer.cpp

6
Projects/la_mojo/build

@ -4,11 +4,11 @@
#make clean -e "CFG=Debug"
#make -e "CFG=Debug" -j$(nproc)
make clean -e "CFG=LRF_Proxy_ONLY"
make -e "CFG=LRF_Proxy_ONLY" -j$(nproc)
#make clean -e "CFG=LRF_Proxy_ONLY"
#make -e "CFG=LRF_Proxy_ONLY" -j$(nproc)
#make clean -e "CFG=Debug86"
#make -e "CFG=Debug86" -j$(nproc)
make -e "CFG=Debug86" -j$(nproc)
#cd Debug86
#strip ./mojo_d
#cd ..

4777
lib/App/common/kernelModuleEmbedVideo.cpp
File diff suppressed because it is too large
View File

188
lib/App/common/kernelModuleEmbedVideo.h

@ -5,6 +5,12 @@
#include "../../components/base/basicMutex.h"
#include "kernelModule.h"
#define EVE_SEQUENTAL_OUTPUT
#ifndef EVE_SEQUENTAL_OUTPUT
#define EVE_ENABLE_EASE_OUTPUT_FPS
#endif
#define EVE_OUTPUT_PICTURES 1
#define EVE_OUTPUT_VIDEO 2
#define EVE_OUTPUT_PIC_AND_VID 3
@ -210,8 +216,8 @@ typedef vector<uchar> compressedFRAME;
typedef map<uint32_t, compressedFRAME> mapSTREAMCAPS;
typedef map<uint32_t, cv::Mat> mapSTREAMMAPS;
#define PRE_ALARM_TIME_MILSECONDS 2000 // 2 sec
#define POST_ALARM_TIME_MILSECONDS 2000 // 2 sec
#define PRE_ALARM_TIME_MILSECONDS 5000 // 5 sec
#define POST_ALARM_TIME_MILSECONDS 5000 // 5 sec
#define ENCODING_SEGMENT_MILSECONDS 50000 // 50 sec
#define ENCODING_SEGMENT_LIMIT_MILSECONDS 60000 // 1 minute
// #define ENCODING_SEGMENT_LIMIT_MILSECONDS 900000 // 15 minutes
@ -220,8 +226,6 @@ typedef map<uint32_t, cv::Mat> mapSTREAMMAPS;
// #define ENCODER_DISABLED 0
// #define ENCODER_ENABLED 1
// #define EVE_ENABLE_EASE_OUTPUT_FPS
#ifdef EVE_ENABLE_EASE_OUTPUT_FPS
#define EVE_EASE_FPS_DIVIDER_MINIMUM 1
#define EVE_EASE_FPS_DIVIDER_MAXIMUM 5
@ -286,7 +290,7 @@ class streamHandler :
uint8_t m_bEvtMarkerCounter;
uint8_t m_bCamMoveCounter;
dataBinder * m_pDBC;
dataBinder * m_pDBC;
MS_WORK_MODE m_eWM;
basicMutex m_mEvtIDS_Protector;
@ -297,87 +301,119 @@ class streamHandler :
#ifdef EVE_ENABLE_VIDEO
#ifdef EVE_ENABLE_EASE_OUTPUT_FPS
uint8_t m_bAFrameSkeepDivider;
uint8_t m_bAFrameSkeepDividerCounter;
uint8_t m_bAOutputFPS;
uint8_t m_bBFrameSkeepDivider;
uint8_t m_bBFrameSkeepDividerCounter;
uint8_t m_bBOutputFPS;
uint8_t m_bInitialOutputFPS;
uint8_t m_bCurrentOutputFPS;
uint32_t m_nAPreAlarmFrames;
uint32_t m_nAPostAlarmFrames;
uint32_t m_nASegmentLimitFrames;
uint32_t m_nAHardLimitFrames;
uint32_t m_nBPreAlarmFrames;
uint32_t m_nBPostAlarmFrames;
uint32_t m_nBSegmentLimitFrames;
uint32_t m_nBHardLimitFrames;
#else
uint32_t m_nPreAlarmFrames;
uint32_t m_nPostAlarmFrames;
uint32_t m_nSegmentLimitFrames;
uint32_t m_nHardLimitFrames;
#endif
#ifdef EVE_SEQUENTAL_OUTPUT
basicMutex m_mEventBindingBlocker;
#endif
#ifndef EVE_SEQUENTAL_OUTPUT
#ifdef EVE_ENABLE_EASE_OUTPUT_FPS
uint8_t m_bAFrameSkeepDivider;
uint8_t m_bAFrameSkeepDividerCounter;
uint8_t m_bAOutputFPS;
uint8_t m_bBFrameSkeepDivider;
uint8_t m_bBFrameSkeepDividerCounter;
uint8_t m_bBOutputFPS;
uint8_t m_bInitialOutputFPS;
uint8_t m_bCurrentOutputFPS;
uint32_t m_nAPreAlarmFrames;
uint32_t m_nAPostAlarmFrames;
uint32_t m_nASegmentLimitFrames;
uint32_t m_nAHardLimitFrames;
uint32_t m_nBPreAlarmFrames;
uint32_t m_nBPostAlarmFrames;
uint32_t m_nBSegmentLimitFrames;
uint32_t m_nBHardLimitFrames;
#else
uint32_t m_nPreAlarmFrames;
uint32_t m_nPostAlarmFrames;
uint32_t m_nSegmentLimitFrames;
uint32_t m_nHardLimitFrames;
#endif
#else // EVE_SEQUENTAL_OUTPUT
uint32_t m_nPreAlarmFrames;
uint32_t m_nPostAlarmFrames;
uint32_t m_nSegmentLimitFrames;
uint32_t m_nHardLimitFrames;
#endif // EVE_SEQUENTAL_OUTPUT
basicMutex m_mFrameCounterProtector;
uint64_t m_nGlobalFrameCounter;
uint64_t m_nValidatorFrameCounter;
// uint32_t m_nVideoRegisteredDBID;
uint32_t m_nSegAFrameCounter;
uint32_t m_nSegBFrameCounter;
uint32_t m_nSegAShiftFrames;
uint32_t m_nSegBShiftFrames;
uint32_t m_nSegASkippedFrames;
uint32_t m_nSegBSkippedFrames;
#ifndef EVE_SEQUENTAL_OUTPUT
uint32_t m_nSegAFrameCounter;
uint32_t m_nSegBFrameCounter;
uint32_t m_nSegAShiftFrames;
uint32_t m_nSegBShiftFrames;
uint32_t m_nSegASkippedFrames;
uint32_t m_nSegBSkippedFrames;
uint8_t m_bActiveEncoderStream;
bool m_bSegAActive;
bool m_bSegADelete;
bool m_bSegBActive;
bool m_bSegBDelete;
VIDEO_SEGMENT_INFO m_sStreamSegmentInfo[2];
#else
uint32_t m_nSegFrameCounter;
uint32_t m_nSegShiftFrames;
uint32_t m_nSegSkippedFrames;
bool m_bSegActive;
bool m_bSegDelete;
bool m_bNSegDelete;
VIDEO_SEGMENT_INFO m_sStreamSegmentInfo;
#endif
uint8_t m_bFlipMode;
basicMutex m_mCurrentOperationProtector;
uint8_t m_bCOP;
VIDEO_SEGMENT_INFO m_sStreamSegmentInfo[2];
#ifdef DIRECT_MJPEG_COMPOSING
FILE * m_pOutputFD[2];
#ifndef EVE_SEQUENTAL_OUTPUT
FILE * m_pOutputFD[2];
#else
FILE * m_pOutputFD;
#endif
#else // !DIRECT_MJPEG_COMPOSING
#ifdef OPENCV_VIDEO_OUTPUT
cv::VideoWriter * m_pEncoderA;
cv::VideoWriter * m_pEncoderB;
#ifndef EVE_SEQUENTAL_OUTPUT
cv::VideoWriter * m_pEncoderA;
cv::VideoWriter * m_pEncoderB;
#else
cv::VideoWriter * m_pEncoder;
#endif
#else //! OPENCV_VIDEO_OUTPUT
// char m_pVideoScratchPath[PATH_MAX];
#ifdef SEPARATED_VIDEO_ENCODERS
// encoding video stuff
// Stream A
AVCodec * m_pVideoACodec;
AVCodecContext * m_pCodecACtx;
AVFrame * m_pAVAFrame;
uint8_t * m_pOutABuffer;
// Stream B
AVCodec * m_pVideoBCodec;
AVCodecContext * m_pCodecBCtx;
AVFrame * m_pAVBFrame;
uint8_t * m_pOutBBuffer;
// LibAV encoding video stuff
#ifndef EVE_SEQUENTAL_OUTPUT
// Stream A
AVCodec * m_pVideoACodec;
AVCodecContext * m_pCodecACtx;
AVFrame * m_pAVAFrame;
uint8_t * m_pOutABuffer;
// Stream B
AVCodec * m_pVideoBCodec;
AVCodecContext * m_pCodecBCtx;
AVFrame * m_pAVBFrame;
uint8_t * m_pOutBBuffer;
#else
AVCodec * m_pVideoCodec;
AVCodecContext * m_pCodecCtx;
AVFrame * m_pAVFrame;
uint8_t * m_pOutBuffer;
#endif
#else //! SEPARATED_VIDEO_ENCODERS
// encoding video stuff
AVCodec * m_pVideoCodec;
AVCodecContext * m_pCodecCtx;
#endif //! SEPARATED_VIDEO_ENCODERS
AVFrame * m_pAVFrame;
uint8_t * m_pOutBuffer;
// Common Pix Converter ( for both streams )
SwsContext * m_pConvertCtx;
// LibAV encoding video stuff
AVCodec * m_pVideoCodec;
AVCodecContext * m_pCodecCtx;
AVFrame * m_pAVFrame;
uint8_t * m_pOutBuffer;
#endif //! SEPARATED_VIDEO_ENCODERS
// Common Pix Converter ( for both streams )
SwsContext * m_pConvertCtx;
#endif //! OPENCV_VIDEO_OUTPUT
// char m_cSegNameA[128];
@ -385,22 +421,32 @@ class streamHandler :
// char m_cSegNameB[128];
// char m_cSegMD5B[33];
// File Context 2 units
AVOutputFormat * m_pFormat;
AVFormatContext * m_pFormatCtxA;
AVFormatContext * m_pFormatCtxB;
AVStream * m_pVideoStrA;
AVStream * m_pVideoStrB;
#ifdef SEPARATED_VIDEO_ENCODERS
// File Context 2 units
AVFormatContext * m_pFormatCtxA;
AVFormatContext * m_pFormatCtxB;
AVStream * m_pVideoStrA;
AVStream * m_pVideoStrB;
#else
// File Context 1 units
AVFormatContext * m_pFormatCtx;
AVStream * m_pVideoStr;
#endif
// common output options
AVDictionary * m_pFormatOpts;
#endif //! DIRECT_MJPEG_COMPOSING
basicMutex m_mEncodingQueueProtector;
Q_ENCODING_BUFFER m_qEncodingQueue;
#ifndef EVE_SEQUENTAL_OUTPUT
bool openSegmentA(void);
void closeSegmentA(void);
bool openSegmentB(void);
void closeSegmentB(void);
#else
bool openSegment(void);
void closeSegment(void);
#endif
void swapActiveStreams(void);
void closeAll();
bool initVideoOutput();

4
lib/App/common/serverMySQL_dataBinder.cpp

@ -1176,12 +1176,12 @@ uint64_t servaMySQLDBC::getSessionWithUnmergedVideo( uint32_t delay_secs ){
char tQBuf[MAX_PATH_LEN];
AAssoc * result;
if ( delay_secs ) {
uint32_t stc = (uint32_t) time( NULL );
uint32_t sts = (uint32_t) time( NULL );
sts -= delay_secs-1;
sprintf(tQBuf, "SELECT `id` FROM `sessions` WHERE `final`='Y' AND `ts` < %d ORDER BY `ts` LIMIT 1", sts );
} else {
sprintf(tQBuf, "SELECT `id` FROM `sessions` WHERE `final`='Y' ORDER BY `ts` LIMIT 1");
}æ
}
#ifdef DEBUG_ALL
LOG(tQBuf);
#endif

2
lib/App/mojo/mojoKernel.cpp

@ -336,7 +336,7 @@ bool mojoKernel::create()
#else
LOG_ERROR("DATA PROXY Processing Module!");
m_bMediaMode = 0;
#endif;
#endif
m_pNodeFactory = deviceNodeFactory::getInstance();
if (! m_pNodeFactory)

10
lib/App/serva/servaKernel.cpp

@ -28,7 +28,7 @@
#include "../common/serverMySQL_dataBinder.h"
#include "servaModBusManager.h"
#include "servaVideoComposer.h"
#define LOG( X ) kernelPrototype::m_pLog->Log( "KRNL", this, X )
#ifdef DEBUG
@ -154,10 +154,10 @@ bool servaKernel::create(){
/* Test Composer */
//servaVideoComposer *tVC = new servaVideoComposer( 49 );
//if ( tVC ) {
// tVC->compose();
//};
servaVideoComposer *tVC = new servaVideoComposer( 49 );
if ( tVC ) {
tVC->compose();
};
m_pRPC = servaRemoteClient::getInstance(this);
if ( m_pRPC ) {

2
lib/App/serva/servaKernel.h

@ -36,6 +36,7 @@
#include "servaRemoteClient.h"
#include "servaMediaEncoder.h"
#include "servaSessionManager.h"
#include "servaVideoComposer.h"
#define MAX_CYCLE_COUNTER_VALUE 0xFFFFFFFF;
#define SLEEP_KERNEL_INTERVAL 10 // 10 millisecond
@ -51,6 +52,7 @@ class servaKernel: public kernelPrototype{
servaSessionManager * m_pSM;
void * m_pModBus;
DBC_SERVA_CONFIG m_sServaConfig;
servaVideoComposer * m_pVideoComposer;
protected:
virtual void m_fThreadProc( void );
// Constructor

4
lib/App/serva/servaVideoComposer.cpp

@ -1699,7 +1699,7 @@ void servaVideoComposer::m_fThreadProc(void){
if ( m_sComposerSettings.debugMode ) {
char tsb[64];
sprintf( tsb,"#%d", L_idx+1 );
cv::putText( mat, tsb, cv::Point(100, 100), cv::FONT_HERSHEY_DUPLEX, 3.0, cv::Scalar(0, 255, 255), 1, cv::LINE_8 );
cv::putText( mat, tsb, cv::Point(100, 100), cv::FONT_HERSHEY_DUPLEX, 3.0, cv::Scalar(0, 255, 255), 5, cv::LINE_8 );
uint32_t tTS = (CurrentTS / 1000);
time_t t = (time_t) tTS;
@ -1743,7 +1743,7 @@ void servaVideoComposer::m_fThreadProc(void){
if ( m_sComposerSettings.debugMode ) {
char tsb[64];
sprintf( tsb,"#%d", L_idx+1 );
cv::putText( mat, tsb, cv::Point(100, 100), cv::FONT_HERSHEY_DUPLEX, 3.0, cv::Scalar(0, 255, 255), 1, cv::LINE_8 );
cv::putText( mat, tsb, cv::Point(100, 100), cv::FONT_HERSHEY_DUPLEX, 3.0, cv::Scalar(0, 255, 255), 5, cv::LINE_8 );
uint32_t tTS = (CurrentTS / 1000);
time_t t = (time_t) tTS;

Loading…
Cancel
Save