ZMVideoSDKShareHelper.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. #import <Foundation/Foundation.h>
  2. #import <CoreGraphics/CoreGraphics.h>
  3. #import "ZMVideoSDKAnnotationHelper.h"
  4. /**
  5. @brief Share sender interface.
  6. */
  7. @interface ZMVideoSDKShareSender : NSObject
  8. /**
  9. @brief Send one frame data.
  10. @param frameBuffer FrameBuffer YUVI420 buffer.
  11. @param width Frame width.
  12. @param height Frame height.
  13. @param frameLength Buffer length.
  14. @return If the function succeeds, the return value is ZMVideoSDKErrors_Success, otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  15. */
  16. - (ZMVideoSDKErrors)sendShareFrame:(char*)frameBuffer width:(int)width height:(int)height frameLength:(int)frameLength DEPRECATED_MSG_ATTRIBUTE("Use -sendShareFrame: width: height: frameLength: format: instead");
  17. /**
  18. @brief Send one frame data.
  19. @param frameBuffer FrameBuffer YUVI420 buffer.
  20. @param width Frame width.
  21. @param height Frame height.
  22. @param frameLength Buffer length.
  23. @param format Raw data format.
  24. @return If the function succeeds, the return value is ZMVideoSDKErrors_Success, otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  25. */
  26. - (ZMVideoSDKErrors)sendShareFrame:(char*)frameBuffer width:(int)width height:(int)height frameLength:(int)frameLength format:(ZMVideoSDKFrameDataFormat)format;
  27. @end
  28. /**
  29. @brief Share source sink interface.
  30. */
  31. @protocol ZMVideoSDKShareSource <NSObject>
  32. /**
  33. @brief Callback for share source can start send raw data.
  34. @param sender See {@link ZMVideoSDKShareSender}.
  35. */
  36. -(void)onShareSendStarted:(ZMVideoSDKShareSender*)sender;
  37. /**
  38. @brief Callback for share source stop send raw data.
  39. */
  40. -(void)onShareSendStopped;
  41. @end
  42. @interface ZMVideoSDKShareAudioSender : NSObject
  43. /**
  44. @brief Sends audio raw data.
  45. @param data The audio data address.
  46. @param length The audio data length. It must be even numbers.
  47. @param rate The audio data sampling rate.
  48. @param channel The channel type. Default type is ZoomVideoSDKAudioChannel_Mono.
  49. @return If the function succeeds, the return value is ZMVideoSDKErrors_Success, otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  50. @note Support sample Rate 44100/48000/50000/50400/.
  51. */
  52. -(ZMVideoSDKErrors)sendShareAudio:(char *)data dataLength:(unsigned int)length sampleRate:(int)rate audioChannel:(ZMVideoSDKAudioChannel)channel;
  53. @end
  54. @protocol ZMVideoSDKShareAudioSource <NSObject>
  55. /**
  56. @brief Callback for audio source to start sending raw data.
  57. @param sender See {@link ZMVideoSDKShareAudioSender}.
  58. */
  59. -(void)onStartSendAudio:(ZMVideoSDKShareAudioSender *)sender;
  60. /**
  61. @brief Callback for audio source to stop sending raw data.
  62. */
  63. -(void)onStopSendAudio;
  64. @end
  65. /**
  66. @brief Share option interface.
  67. */
  68. @interface ZMVideoSDKShareOption : NSObject
  69. /**
  70. @brief Share option, YES means share computer sound when share screen/window, otherwise not.
  71. */
  72. @property (nonatomic, assign, readwrite) BOOL isWithDeviceAudio;
  73. /**
  74. @brief Share option, YES means optimize the frame rate when share screen/window, otherwise not.
  75. */
  76. @property (nonatomic, assign, readwrite) BOOL isOptimizeForSharedVideo;
  77. @end
  78. /**
  79. @brief Share helper interface.
  80. */
  81. @interface ZMVideoSDKShareHelper : NSObject
  82. /**
  83. @brief Start Share a window.
  84. @param windowID The App window id.
  85. @note The CGWindowID contains a unique value within the user session
  86. representing a window.
  87. @param option It is a share option object, contain all option of share.
  88. @return If the function succeeds, the return value is ZMVideoSDKErrors_Success, otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  89. */
  90. - (ZMVideoSDKErrors)startShareView:(CGWindowID)windowID shareOption:(ZMVideoSDKShareOption*)option;
  91. /**
  92. @brief Start share screen.
  93. @param monitorID The ID of the monitor that you want to display the shared content.
  94. @param option It is a share option object, contain all option of share.
  95. @return If the function succeeds, the return value is ZMVideoSDKErrors_Success. Otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  96. */
  97. - (ZMVideoSDKErrors)startShareScreen:(CGDirectDisplayID)monitorID shareOption:(ZMVideoSDKShareOption*)option;
  98. /**
  99. @brief Start sharing the computer audio only.
  100. @return If the function succeeds, the return value is ZMVideoSDKErrors_Success. Otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  101. */
  102. - (ZMVideoSDKErrors)startShareComputerAudio;
  103. /**
  104. @brief Stop view or screen share.
  105. @return If the function succeeds, the return value is ZMVideoSDKErrors_Success. Otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  106. */
  107. - (ZMVideoSDKErrors)stopShare;
  108. /**
  109. @brief Determine whether the current user is sharing.
  110. @return YES indicates the current user is sharing, otherwise NO.
  111. */
  112. - (BOOL)isSharingOut;
  113. /**
  114. @brief Determine whether the current user is sharing the screen.
  115. @return YES indicates the current user is sharing the screen, otherwise NO.
  116. */
  117. - (BOOL)isScreenSharingOut;
  118. /**
  119. @brief Determine whether other user is sharing.
  120. @return YES indicates another user is sharing, otherwise NO.
  121. */
  122. - (BOOL)isOtherSharing;
  123. /**
  124. @brief Lock sharing the view or screen. Only the host can call this method.
  125. @param lock YES to lock sharing.
  126. @return If the function succeeds, the return value is ZMVideoSDKErrors_Success, otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  127. */
  128. - (ZMVideoSDKErrors)lockShare:(BOOL)lock;
  129. /**
  130. @brief Determine whether sharing the view or screen is locked.
  131. @return YES indicates that sharing is locked, otherwise NO.
  132. */
  133. - (BOOL)isShareLocked;
  134. /**
  135. @brief Enable or disable the computer sound when sharing, the SDK does not support sharing raw data audio, for example, when you've enabled virtual speaker.
  136. @param enable YES to enable. NO to disable.
  137. @return If the function succeeds, it will return ZMVideoSDKErrors_Success.
  138. */
  139. - (ZMVideoSDKErrors)enableShareDeviceAudio:(BOOL)enable;
  140. /**
  141. @brief Determine if the SDK has enabled share computer sound. This reflects the execution status of 'enableShareDeviceAudio' instead of 'startShareComputerAudio'.
  142. @return YES if enabled, otherwise not.
  143. */
  144. - (BOOL)isShareDeviceAudioEnabled;
  145. /**
  146. @brief Enable or disable the optimization of frame rate, you can enable it when there is video in shared content.
  147. @param enable YES indicates to enable. NO disable.
  148. @return If the function succeeds, it will return ZMVideoSDKErrors_Success.
  149. */
  150. - (ZMVideoSDKErrors)enableOptimizeForSharedVideo:(BOOL)enable;
  151. /**
  152. @brief Determine if optimization for video is enabled.
  153. @return YES means enabled. Otherwise not.
  154. */
  155. - (BOOL)isOptimizeForSharedVideoEnabled;
  156. /**
  157. @brief Start sharing a camera feed specified by the cameraID as the second camera.
  158. @param cameraID The camera ID.
  159. @return If the function succeeds, it will return ZMVideoSDKErrors_Success.
  160. @note This cameraID must be a different camera than the one sending your primary video.
  161. */
  162. - (ZMVideoSDKErrors)startShare2ndCamera:(NSString*)cameraID;
  163. /**
  164. @brief Subscribe to the raw data stream of the camera that is shared as the second camera.
  165. @param dataHandler The callback sink object.
  166. @return If the function succeeds, it will return ZMVideoSDKErrors_Success.
  167. */
  168. - (ZMVideoSDKErrors)subscribeMyShareCamera:(id<ZMVideoSDKRawDataPipeDelegate>)dataHandler;
  169. /**
  170. @brief Unsubscribe to the raw data stream of the camera that is shared as the second camera.
  171. @return If the function succeeds, it will return ZMVideoSDKErrors_Success.
  172. */
  173. - (ZMVideoSDKErrors)unSubscribeMyShareCamera;
  174. /**
  175. @brief Share an external source.
  176. @param pSource External share source. To get extended error information, see {@link ZMVideoSDKShareSource}.
  177. @return If the function succeeds, it will return ZMVideoSDKErrors_Success. Otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  178. */
  179. - (ZMVideoSDKErrors)startSharingExternalSource:(id<ZMVideoSDKShareSource>)pSource DEPRECATED_MSG_ATTRIBUTE("Use -startSharingExternalSource: audioSource: instead");
  180. /**
  181. @brief Shares an external source.
  182. @param pSource External share source. To get extended error information, see {@link ZMVideoSDKShareSource}.
  183. @param audioSource External audio source. To get extended error information, see {@link ZMVideoSDKShareAudioSource}.
  184. @return If the function succeeds, it will return ZMVideoSDKErrors_Success. Otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  185. @note If audioSource is non-null, it means share user-defined audio at the same time.
  186. */
  187. - (ZMVideoSDKErrors)startSharingExternalSource:(id<ZMVideoSDKShareSource> _Nonnull)shareSource audioSource:(id<ZMVideoSDKShareAudioSource> _Nullable)audioSource;
  188. /**
  189. @brief Starts sharing the pure external audio source.
  190. @param audioSource the pointer of external audio source object. To get extended error information, see {@link ZMVideoSDKShareAudioSource}.
  191. @return If the function succeeds, it will return ZMVideoSDKErrors_Success. Otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  192. */
  193. - (ZMVideoSDKErrors)startSharePureAudioSource:(id<ZMVideoSDKShareAudioSource> _Nonnull)audioSource;
  194. /**
  195. @brief Whether annotation feature is supported or not.
  196. @return YES if support. Otherwise not.
  197. */
  198. - (BOOL)isAnnotationFeatureSupport;
  199. /**
  200. @brief Disable or enable viewer's annotation by the share owner.
  201. @param disable YES mean disable, NO, mean enable.
  202. @return If the function succeeds, it will return ZMVideoSDKErrors_Success. Otherwise failed.
  203. @warning Only the share owner can call this function.
  204. */
  205. - (ZMVideoSDKErrors)disableViewerAnnotation:(BOOL)disable;
  206. /**
  207. @brief Whether annotation on current sharing is disabled or not.
  208. @return YES if disable. Otherwise not.
  209. @warning Only the share owner can call this function.
  210. */
  211. - (BOOL)isViewerAnnotationDisabled;
  212. /**
  213. @brief Creates annotation helper based on shared view.
  214. @param view The shared view. Pass the nil will return the helper for self sharing.
  215. @return If the function succeeds, it will return the object of ZMVideoSDKAnnotationHelper. Otherwise nil.
  216. @warning When the share owner not support the feature of annotate, the others should not do annotate in that case.
  217. */
  218. - (ZMVideoSDKAnnotationHelper* _Nullable)createAnnotationHelper:(NSView* _Nullable)view;
  219. /**
  220. @brief Destroys annotation helper.
  221. @param helper The object of ZMVideoSDKAnnotationHelper.
  222. @return If the function succeeds, it will return ZMVideoSDKErrors_Success. Otherwise failed. To get extended error information, see {@link ZMVideoSDKErrors}.
  223. */
  224. - (ZMVideoSDKErrors)destroyAnnotationHelper:(ZMVideoSDKAnnotationHelper* _Nonnull)helper;
  225. @end