StreamSource.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #ifndef __DAHUA_GENICAM_ISTREAMSOURCE_H__
  2. #define __DAHUA_GENICAM_ISTREAMSOURCE_H__
  3. #include "Defs.h"
  4. #include "Frame.h"
  5. #include "Infra/Signal.h"
  6. GENICAM_NAMESPACE_BEGIN
  7. /// \~chinese
  8. /// \brief 流对象接口类
  9. /// \defgroup stream 流对象操作接口
  10. /// @{
  11. /// \~english
  12. /// \brief stream object interface class
  13. /// \defgroup stream Stream Operation Interface
  14. /// @{
  15. /// \~chinese
  16. /// \brief Class IStreamSource 流对象接口
  17. /// \~english
  18. /// \brief Class IStreamSource stream object interface
  19. class GENICAM_API IStreamSource
  20. {
  21. protected:
  22. /// \~chinese
  23. /// \brief 析构函数
  24. /// \~english
  25. /// \brief destructor
  26. virtual ~IStreamSource(){}
  27. public:
  28. enum EGrabStrategy
  29. {
  30. grabStrartegySequential = 0, ///< \~chinese 按到达顺序处理图片 ///< \~english The images are processed in the order of their arrival
  31. grabStrartegyLatestImage = 1, ///< \~chinese 获取最新的图片 ///< \~english get the latest image
  32. grabStrartegyUndefined ///< \~chinese 未定义 ///< \~english undefined
  33. };
  34. /// \~chinese
  35. /// \brief 设备流回调函数声明:每次回调送出一帧数据
  36. /// CFrame 回调时主动推送的帧对象
  37. /// \~english
  38. /// \brief Callback function declaration of stream: Send out one frame at each time use callback function
  39. /// CFrame The frame which will be active pushed out during the callback
  40. typedef Infra::TSignal1<const CFrame&> Signal;
  41. typedef Signal::Proc Proc;
  42. /// \~chinese
  43. /// \brief 设备流回调函数声明:每次回调送出一帧数据和用户数据
  44. /// CFrame 回调时主动推送的帧对象
  45. /// void* 回调时推送的用户数据
  46. /// \~english
  47. /// \brief Callback function declaration of stream: Send out one frame and user data at each time use callback function
  48. /// CFrame The frame which will be active pushed out during the callback
  49. /// void* The user data which will be active pushed out during the callback
  50. typedef Infra::TSignal2<const CFrame&, const void*> SignalEx;
  51. typedef SignalEx::Proc ProcEx;
  52. /// \~chinese
  53. /// \brief 开始抓图
  54. /// \param [in] maxImagesGrabbed 允许最多的抓图数,达到指定抓图数后停止抓图,如果为0,表示忽略此参数连续抓图
  55. /// \param [in] strategy 抓图策略,默认按缓存队列中的顺序抓图
  56. /// \return 返回抓图是否成功
  57. /// \~english
  58. /// \brief Start grabbing
  59. /// \param [in] maxImagesGrabbed Maximum images allowed to grab, once it reaches the limit then stop grabbing; If it is 0, then ignore this parameter and start grabbing continuously
  60. /// \param [in] strategy Image grabbing strategy; Image grabbing according to the order in buffer queue is default
  61. /// \return success:true, fail:false
  62. virtual bool startGrabbing(uint64_t maxImagesGrabbed = 0,EGrabStrategy strategy = grabStrartegySequential) = 0;
  63. /// \~chinese
  64. /// \brief 停止抓图
  65. /// \return 返回停止抓图是否成功
  66. /// \~english
  67. /// \brief Stop grabbing
  68. /// \return success:true, fail:false
  69. virtual bool stopGrabbing() = 0;
  70. /// \~chinese
  71. /// \brief 是否正在抓图
  72. /// \return 返回是否成功
  73. /// \~english
  74. /// \brief Check whether it is grabbing or not
  75. /// \return grabbing or not grabbing, true means it is grabbing, false means it is not grabbing
  76. virtual bool isGrabbing() = 0;
  77. /// \~chinese
  78. /// \brief 获取一帧图像,该接口不支持多线程调用
  79. /// \param [out] frame 一帧图像
  80. /// \param [in] timeoutMS 获取一帧图像的超时时长,单位MS,当值为INFINITE时表示无限等待
  81. /// \return 返回是否成功
  82. /// \~english
  83. /// \brief get a frame image, and this interface does not support multi-threading
  84. /// \param [out] frame one frame
  85. /// \param [in] timeoutMS The timeout value of getting one image, unit is MS; When the value is INFINITE which means infinite wait
  86. /// \return success:true, fail:false
  87. virtual bool getFrame(CFrame &frame,uint32_t timeoutMS = INFINITE) const = 0;
  88. /// \~chinese
  89. /// \brief 注册数据帧回调函数。该异步获取帧机制和同步获取帧机制互斥,系统中两者只能选其一。
  90. /// \param [in] proc 数据帧回调函数,建议不要在该函数中处理耗时的操作,否则会阻塞后续数据帧的实时性
  91. /// \return 返回注册是否成功
  92. /// \~english
  93. /// \brief Register data frame callback function; This asynchronous frame acquisition mechanism and synchronous frame acquisition mechanism are mutually exclusive, only one method can be choosed between these two in system
  94. /// \brief only callback one function
  95. /// \param [in] proc Data frame callback function; It is advised to not put time-cosuming operation in this function, otherwise it will block follow-up data frames and affect real time performance
  96. /// \return success:true, fail:false
  97. virtual bool attachGrabbing(Proc proc) = 0;
  98. /// \~chinese
  99. /// \brief 去注册数据帧回调函数
  100. /// \param [in] proc 去注册数据帧回调函数
  101. /// \return 返回去注册是否成功
  102. /// \~english
  103. /// \brief Unregister data frame callback function
  104. /// \param [in] proc Unregister data frame callback function
  105. /// \return success:true, fail:false
  106. virtual bool detachGrabbing(Proc proc) = 0;
  107. /// \~chinese
  108. /// \brief 设置缓存个数,不能在拉流过程中设置
  109. /// \param [in] nSize 缓存数量,最大为200
  110. /// \return 返回是否成功
  111. /// \~english
  112. /// \brief Set buffer count, this cannot be set during frame grabbing
  113. /// \param [in] nSize the buffer count, max size is 200.
  114. /// \return success:true, fail:false
  115. virtual bool setBufferCount(uint32_t nSize) = 0;
  116. /// \~chinese
  117. /// \brief 注册数据帧回调函数(包含用户自定义数据)。
  118. /// \param [in] proc 数据帧回调函数,建议不要在该函数中处理耗时的操作,否则会阻塞后续数据帧的实时性
  119. /// \param [in] pUser 用户自定义数据
  120. /// \return 返回注册是否成功
  121. /// \~english
  122. /// \brief Register data frame callback function(include user defined data);
  123. /// \param [in] proc Data frame callback function; It is advised to not put time-cosuming operation in this function, otherwise it will block follow-up data frames and affect real time performance
  124. /// \param [in] pUser user defined data
  125. /// \return success:true, fail:false
  126. virtual bool attachGrabbingEx(ProcEx proc, void* pUser) = 0;
  127. /// \~chinese
  128. /// \brief 去注册数据帧回调函数(包含用户自定义数据)
  129. /// \param [in] proc 去注册数据帧回调函数
  130. /// \param [in] pUser 用户自定义数据(与attachGrabbingEx的pUser相同)
  131. /// \return 返回去注册是否成功
  132. /// \~english
  133. /// \brief Unregister data frame callback function(include user defined data)
  134. /// \param [in] proc Unregister data frame callback function(the same pUser of the attachGrabbingEx)
  135. /// \param [in] pUser user defined data
  136. /// \return success:true, fail:false
  137. virtual bool detachGrabbingEx(ProcEx proc, void* pUser) = 0;
  138. /// \~chinese
  139. /// \brief 设置驱动包间隔时间(ms),仅对Gige设备有效
  140. /// \param [in] nTimeout 包间隔时间,单位ms
  141. /// \return 设置是否成功,true表示成功,false表示失败
  142. /// \~english
  143. /// \brief set packet timeout(ms), just for GigE devices
  144. /// \param [in] the value of timeout
  145. /// \return success:true, fail:false
  146. virtual bool setInterPacketTimeout(uint32_t nTimeout) = 0;
  147. };
  148. typedef Memory::TSharedPtr<IStreamSource> IStreamSourcePtr;
  149. /// @}
  150. GENICAM_NAMESPACE_END
  151. #endif //__DAHUA_GENICAM_ISTREAMSOURCE_H__