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.

155 lines
4.6 KiB

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