You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

157 lines
4.7 KiB

​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
2 months ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. #ifndef __KERNEL_MODULE_EMBED_VIDEO_HEADER__
  2. #define __KERNEL_MODULE_EMBED_VIDEO_HEADER__
  3. #include "../../components/base/basicDualThread.h"
  4. #include "../../components/base/basicEventHeap.h"
  5. #include "../../components/base/basicMutex.h"
  6. #include "kernelModule.h"
  7. //#include "streamHandler.h"
  8. extern const char * m_pVideoScratchPath;
  9. #define EVE_WORK_WITH_MEDIAMTX
  10. #define EVE_OUTPUT_PICTURES 1
  11. #define EVE_OUTPUT_VIDEO 2
  12. #define EVE_OUTPUT_PIC_AND_VID 3
  13. #ifndef LRF_PROXY_ONLY
  14. // #include "../../data/media/video/videoAVLIBDestination.h"
  15. #include "../../components/base/basicMediaDestination.h"
  16. #include "../../components/base/basicMediaSource.h"
  17. class streamHandler;
  18. typedef map<uint32_t, streamHandler *> mapSTREAMHANDLERS;
  19. #ifndef EVE_WORK_WITH_MEDIAMTX
  20. class kernelModuleEmbedVideo;
  21. typedef struct S_WEB_CLIENT_CTX
  22. {
  23. int m_iSocketFID;
  24. int m_iEncoderPipe[2];
  25. bool bValid;
  26. bool initDone;
  27. bool headerIsSent;
  28. uint32_t mediaStreamId;
  29. #ifdef HAVE_SMAL_PREVIEW_STREAMS
  30. bool bPreviewMode;
  31. #endif
  32. streamHandler * m_pHandler;
  33. kernelModuleEmbedVideo * ModulePtr;
  34. } WEB_CLIENT_CTX;
  35. typedef struct S_WEB_HANDLER
  36. {
  37. DWORD m_dwThreadID;
  38. #ifdef __linux__
  39. pthread_t m_hThreadHandle;
  40. #else
  41. HANDLE m_hThreadHandle;
  42. #endif
  43. WEB_CLIENT_CTX * CTX;
  44. } WEB_HANDLER;
  45. typedef vector<WEB_HANDLER *> vectorHANDLERS;
  46. #endif // !EVE_WORK_WITH_MEDIAMTX
  47. // typedef vector<STREAM_CTX*> vectorSTREAMS;
  48. typedef struct S_STREAM_CAP
  49. {
  50. uint32_t stream_id;
  51. uint32_t buffer_size;
  52. uint8_t picture_buffer;
  53. } STREAM_CAP;
  54. typedef struct S_VIDEO_EVT
  55. {
  56. uint32_t dbid;
  57. uint32_t frame;
  58. } VIDEO_EVT;
  59. #ifndef EVE_WORK_WITH_MEDIAMTX
  60. typedef vector<uchar> compressedFRAME;
  61. typedef map<uint32_t, compressedFRAME> mapSTREAMCAPS;
  62. #endif // !EVE_WORK_WITH_MEDIAMTX
  63. typedef map<uint32_t, cv::Mat> mapSTREAMMAPS;
  64. class kernelModuleEmbedVideo : public kernelModule
  65. #ifndef EVE_WORK_WITH_MEDIAMTX
  66. , public basicDualThread
  67. #endif
  68. {
  69. private:
  70. basicEventHeap * m_pEventHeap;
  71. #ifndef EVE_WORK_WITH_MEDIAMTX
  72. static void * webClientProc(void * ptr);
  73. static void * viewClientProc(void * ptr);
  74. vectorHANDLERS m_vHandlersPool;
  75. mapSTREAMCAPS m_mapCAPTURES;
  76. vectorHANDLERS m_vViewHandlersPool;
  77. basicMutex m_mViewHandlersProtector;
  78. int m_nViewSocketDescriptor;
  79. basicMutex m_mWebHandlersProtector;
  80. bool registerForMediaStream(uint32_t id, WEB_CLIENT_CTX *& CTX);
  81. #endif // !EVE_WORK_WITH_MEDIAMTX
  82. int m_nSocketDescriptor;
  83. basicMutex m_mStreamHandlersProtector;
  84. basicMutex m_mPictureProtector;
  85. basicMutex m_mEncodedProtector;
  86. DBC_MODULE_EMBED_VIDEO_DATA m_sEmbedVideoData;
  87. mapSTREAMMAPS m_mapMATS;
  88. mapSTREAMHANDLERS m_mapHANDLERS;
  89. uint8_t * n_pNoSignalData;
  90. uint32_t m_nNoSignalSize;
  91. #ifdef HAVE_SMAL_PREVIEW_STREAMS
  92. mapSTREAMCAPS m_mapPREVIEWS;
  93. uint8_t * n_pNoSignalSmallData;
  94. uint32_t m_nNoSignalSmallSize;
  95. #endif
  96. cv::Mat m_mLogoPic;
  97. cv::Mat m_mLogoMask;
  98. char m_pBaseSavePath[PATH_MAX];
  99. bool saveStreamPicture(uint32_t id);
  100. bool saveStreamPicture(DBC_SNAPSHOT_DATA * ptr);
  101. bool generateSavePicPath(CSTR MD5, CSTR Output);
  102. #ifndef EVE_WORK_WITH_MEDIAMTX
  103. protected:
  104. /* From Basic Dual Thread */
  105. virtual void m_fThreadAProc(void);
  106. virtual void m_fThreadBProc(void);
  107. #endif // !EVE_WORK_WITH_MEDIAMTX
  108. public:
  109. explicit kernelModuleEmbedVideo(uint32_t moduleID);
  110. virtual ~kernelModuleEmbedVideo();
  111. /* From Kernel Module */
  112. virtual bool reloadSettings();
  113. virtual bool startService();
  114. virtual bool stopService(bool force = false);
  115. virtual bool dispatchEvent(EVENT_CONTAINER * Evt);
  116. virtual bool validate();
  117. /*
  118. //from Media Destination
  119. virtual bool pushFrame( AVFrame *Frame, void* src = NULL);
  120. //virtual void pushFrame( cv::Mat* Frame, void* src = NULL);
  121. virtual bool pushFrame( cv::Mat &Frame, void* src = NULL);
  122. // Module Specific Functionality
  123. */
  124. int getWidh(void);
  125. int getHeight(void);
  126. bool registerStream(uint32_t streamID, uint8_t flip_mode = 0);
  127. bool unregisterStream(uint32_t streamID);
  128. uint8_t getMediaMode(void);
  129. bool isProcessingVideoStream();
  130. friend class streamHandler;
  131. };
  132. #else //LRF_PROXY_ONLY
  133. class kernelModuleEmbedVideo : public kernelModule{
  134. public:
  135. explicit kernelModuleEmbedVideo(uint32_t moduleID);
  136. virtual ~kernelModuleEmbedVideo();
  137. };
  138. #endif //LRF_PROXY_ONLY
  139. #endif