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.

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