|
|
|
@ -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(); |
|
|
|
|