TUICallEngine.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. //
  2. // TUICallEngine.h
  3. // TUICalling
  4. //
  5. // Created by noah on 2022/4/26.
  6. // Copyright © 2022 Tencent. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <TUICallEngine/TUICallObserver.h>
  10. #import <TUICallEngine/TUICallDefine.h>
  11. #import <TUICallEngine/TUICommonDefine.h>
  12. @class TRTCCloud;
  13. NS_ASSUME_NONNULL_BEGIN
  14. @interface TUICallEngine : NSObject
  15. /**
  16. * This API is used to create a TUICallEngine singleton.
  17. */
  18. + (TUICallEngine *)createInstance
  19. NS_SWIFT_NAME(createInstance());
  20. /**
  21. * This API is used to destroy a TUICallEngine singleton.
  22. */
  23. + (void)destroyInstance
  24. NS_SWIFT_NAME(destroyInstance());
  25. /**
  26. * This API is used to initialize TUICallEngine. Call it to authenticate the call service and perform other required actions before you call other APIs.
  27. *
  28. * @param sdkAppID You can view SDKAppID in Application Management > Application Info of the Console.
  29. * @param userId The ID of the current user, which is a string that can contain only letters (a-z and A-Z), digits (0-9), hyphens (-), and underscores (_).
  30. * @param userSig Tencent Cloud's proprietary security signature. For how to calculate and use it, see UserSig.
  31. */
  32. - (void)init:(int)sdkAppID userId:(NSString *)userId userSig:(NSString *)userSig succ:(TUICallSucc)succ fail:(TUICallFail)fail;
  33. /**
  34. * This API is used to register an event listener to listen for TUICallObserver events.
  35. */
  36. - (void)addObserver:(id<TUICallObserver>)observer
  37. NS_SWIFT_NAME(addObserver(_:));
  38. /**
  39. * This API is used to unregister an event listener.
  40. */
  41. - (void)removeObserver:(id<TUICallObserver>)observer
  42. NS_SWIFT_NAME(removeObserver(_:));
  43. /**
  44. * This API is used to make a (one-to-one) call.
  45. *
  46. * @param roomId The room ID
  47. * @param userId The target user ID.
  48. * @param callMediaType The call type, which can be video or audio.
  49. * @param params An additional parameter. For example, you can use it to customize an offline notification.
  50. */
  51. - (void)call:(TUIRoomId *)roomId
  52. userId:(NSString *)userId
  53. callMediaType:(TUICallMediaType)callMediaType
  54. params:(TUICallParams *)params
  55. succ:(TUICallSucc)succ
  56. fail:(TUICallFail)fail
  57. NS_SWIFT_NAME(call(roomId:userId:callMediaType:params:succ:fail:))
  58. __attribute__((deprecated("use call:callMediaType:params:succ:fail:")));
  59. /**
  60. * This API is used to make a (one-to-one) call.
  61. *
  62. * @param userId The target user ID.
  63. * @param callMediaType The call type, which can be video or audio.
  64. * @param params An additional parameter. For example, you can use it to customize an offline notification.
  65. */
  66. - (void)call:(NSString *)userId
  67. callMediaType:(TUICallMediaType)callMediaType
  68. params:(TUICallParams *)params
  69. succ:(TUICallSucc)succ
  70. fail:(TUICallFail)fail
  71. NS_SWIFT_NAME(call(userId:callMediaType:params:succ:fail:));
  72. /**
  73. * This API is used to make a group call. Note that you need to create an IM group before making a group call.
  74. *
  75. * @param roomId The room ID.
  76. * @param groupId The group ID.
  77. * @param userIdList The target user IDs.
  78. * @param callMediaType The call type, which can be video or audio.
  79. * @param params An additional parameter. For example, you can use it to customize an offline notification.
  80. */
  81. - (void)groupCall:(TUIRoomId *)roomId
  82. groupId:(NSString *)groupId
  83. userIdList:(NSArray<NSString *> *)userIdList
  84. callMediaType:(TUICallMediaType)callMediaType
  85. params:(TUICallParams *)params
  86. succ:(TUICallSucc)succ
  87. fail:(TUICallFail)fail
  88. NS_SWIFT_NAME(groupCall(roomId:groupId:userIdList:callMediaType:params:succ:fail:))
  89. __attribute__((deprecated("use groupCall:userIdList:callMediaType:params:succ:fail:")));
  90. /**
  91. * This API is used to make a group call. Note that you need to create an IM group before making a group call.
  92. *
  93. * @param groupId The group ID.
  94. * @param userIdList The target user IDs.
  95. * @param callMediaType The call type, which can be video or audio.
  96. * @param params An additional parameter. For example, you can use it to customize an offline notification.
  97. */
  98. - (void)groupCall:(NSString *)groupId
  99. userIdList:(NSArray<NSString *> *)userIdList
  100. callMediaType:(TUICallMediaType)callMediaType
  101. params:(TUICallParams *)params
  102. succ:(TUICallSucc)succ
  103. fail:(TUICallFail)fail
  104. NS_SWIFT_NAME(groupCall(groupId:userIdList:callMediaType:params:succ:fail:));
  105. /**
  106. * This API is used to accept a call. After receiving the onCallReceived() callback, you can call this API to accept the call.
  107. */
  108. - (void)accept:(TUICallSucc)succ fail:(TUICallFail)fail
  109. NS_SWIFT_NAME(accept(succ:fail:));
  110. /**
  111. * This API is used to reject a call. After receiving the onCallReceived() callback, you can call this API to reject the call.
  112. */
  113. - (void)reject:(TUICallSucc)succ fail:(TUICallFail)fail
  114. NS_SWIFT_NAME(reject(succ:fail:));
  115. /**
  116. * This API is used to end a call.
  117. */
  118. - (void)hangup:(TUICallSucc)succ fail:(TUICallFail)fail
  119. NS_SWIFT_NAME(hangup(succ:fail:));
  120. /**
  121. * This API is used to ignore a call. After receiving the onCallReceived(), you can call this API to ignore the call. The caller will receive the onUserLineBusy callback.
  122. * Note: If your project involves live streaming or conferencing, you can also use this API to implement the “in a meeting” or “on air” feature.
  123. */
  124. - (void)ignore:(TUICallSucc)succ fail:(TUICallFail)fail
  125. NS_SWIFT_NAME(ignore(succ:fail:));
  126. /**
  127. * This API is used to invite users to the current group call.
  128. * This API is called by a participant of a group call to invite new users.
  129. *
  130. * @param userIdList The target user IDs.
  131. * @param params An additional parameter. For example, you can use it to customize an offline notification.
  132. */
  133. - (void)inviteUser:(NSArray<NSString *> *)userIdList params:(TUICallParams *)params succ:(void(^)(NSArray <NSString *> *userIdList))succ fail:(TUICallFail)fail
  134. NS_SWIFT_NAME(inviteUser(userIdList:params:succ:fail:));
  135. /**
  136. * This API is used to join a group call.
  137. * This API is called by a group member to join the group’s call.
  138. *
  139. * @param roomId The room ID.
  140. * @param groupId The group ID.
  141. * @param callMediaType The call type, which can be video or audio.
  142. */
  143. - (void)joinInGroupCall:(TUIRoomId *)roomId groupId:(NSString *)groupId callMediaType:(TUICallMediaType)callMediaType succ:(TUICallSucc)succ fail:(TUICallFail)fail
  144. NS_SWIFT_NAME(joinInGroupCall(roomId:groupId:callMediaType:succ:fail:));
  145. /**
  146. * This API is used to change the call type.
  147. *
  148. * @param newType The call type, which can be video or audio.
  149. */
  150. - (void)switchCallMediaType:(TUICallMediaType)newType
  151. NS_SWIFT_NAME(switchCallMediaType(_:));
  152. /**
  153. * This API is used to subscribe to the video stream of a remote user.
  154. *
  155. * @param userId The target user ID.
  156. * @param videoView The view to be rendered.
  157. */
  158. - (void)startRemoteView:(NSString *)userId
  159. videoView:(TUIVideoView *)videoView
  160. onPlaying:(void (^)(NSString *userId))onPlaying
  161. onLoading:(void (^)(NSString *userId))onLoading
  162. onError:(void (^)(NSString *userId, int code, NSString *errMsg))onError
  163. NS_SWIFT_NAME(startRemoteView(userId:videoView:onPlaying:onLoading:onError:));
  164. /**
  165. * This API is used to unsubscribe from the video stream of a remote user.
  166. *
  167. * @param userId The target user ID.
  168. */
  169. - (void)stopRemoteView:(NSString *)userId
  170. NS_SWIFT_NAME(stopRemoteView(userId:));
  171. /**
  172. * This API is used to turn the camera on.
  173. *
  174. * @param camera The front or rear camera.
  175. * @param videoView The view to be rendered.
  176. */
  177. - (void)openCamera:(TUICamera)camera videoView:(TUIVideoView *)videoView succ:(TUICallSucc)succ fail:(TUICallFail)fail
  178. NS_SWIFT_NAME(openCamera(_:videoView:succ:fail:));
  179. /**
  180. * This API is used to turn the camera off.
  181. */
  182. - (void)closeCamera
  183. NS_SWIFT_NAME(closeCamera());
  184. /**
  185. * This API is used to switch between the front and back cameras.
  186. *
  187. * @param camera The front or rear camera.
  188. */
  189. - (void)switchCamera:(TUICamera)camera
  190. NS_SWIFT_NAME(switchCamera(_:));
  191. /**
  192. * This API is used to turn the mic on.
  193. */
  194. - (void)openMicrophone:(TUICallSucc)succ fail:(TUICallFail)fail
  195. NS_SWIFT_NAME(openMicrophone(succ:fail:));
  196. /**
  197. * This API is used to turn the mic off.
  198. */
  199. - (void)closeMicrophone
  200. NS_SWIFT_NAME(closeMicrophone());
  201. /**
  202. * This API is used to select the audio playback device (earpiece or speakerphone). In call scenarios, you can use this API to turn on/off hands-free mode.
  203. *
  204. * @param device The speakerphone or earpiece.
  205. */
  206. - (void)selectAudioPlaybackDevice:(TUIAudioPlaybackDevice)device
  207. NS_SWIFT_NAME(selectAudioPlaybackDevice(_:));
  208. /**
  209. * This API is used to set the alias and profile photo. The alias cannot exceed 500 bytes, and the profile photo is specified by a URL.
  210. *
  211. * @param nickname The alias.
  212. * @param avatar The URL of the profile photo.
  213. */
  214. - (void)setSelfInfo:(NSString *_Nullable)nickname avatar:(NSString *_Nullable)avatar succ:(TUICallSucc)succ fail:(TUICallFail)fail
  215. NS_SWIFT_NAME(setSelfInfo(nickname:avatar:succ:fail:));
  216. /**
  217. * This API is used to set whether to enable multi-device login for TUICallEngine (supported by the premium package).
  218. *
  219. * @param enable true/false.
  220. */
  221. - (void)enableMultiDeviceAbility:(BOOL)enable succ:(TUICallSucc)succ fail:(TUICallFail)fail
  222. NS_SWIFT_NAME(enableMultiDeviceAbility(enable:succ:fail:));
  223. /**
  224. * Set the rendering mode of video image
  225. * The parameters that can be set include video image rotation and fill mode
  226. *
  227. * @param userId ID of the specified user
  228. * @param params Video rendering parameters,more details: {@link TUICommonDefine.VideoRenderParams}.
  229. */
  230. - (void)setVideoRenderParams:(NSString *)userId params:(TUIVideoRenderParams *)params succ:(TUICallSucc)succ fail:(TUICallFail)fail
  231. NS_SWIFT_NAME(setVideoRenderParams(userId:params:succ:fail:));
  232. /**
  233. * Set the encoding parameters of video encoder
  234. * This setting can determine the quality of image viewed by remote users,
  235. * which is also the image quality of on-cloud recording files.
  236. *
  237. * @param params It is used to set relevant parameters for the video encoder,more details: {@link TUICommonDefine.VideoEncoderParams}.
  238. */
  239. - (void)setVideoEncoderParams:(TUIVideoEncoderParams *)params succ:(TUICallSucc)succ fail:(TUICallFail)fail
  240. NS_SWIFT_NAME(setVideoEncoderParams(_:succ:fail:));
  241. /**
  242. * Query recent calls
  243. *
  244. * @param filter Query filter conditions
  245. * @param succ Query successful result list
  246. * @param fail Query failure callback
  247. */
  248. - (void)queryRecentCalls:(TUICallRecentCallsFilter *)filter succ:(void (^)(NSArray<TUICallRecords *> *callRecords))succ fail:(void (^)(void))fail
  249. NS_SWIFT_NAME(queryRecentCalls(filter:succ:fail:));
  250. /**
  251. * Delete record calls
  252. *
  253. * @param callIdList List of callIds to be deleted
  254. * @param succ List of successfully deleted callIds
  255. * @param fail Delete failure callback
  256. */
  257. - (void)deleteRecordCalls:(NSArray<NSString *> *)callIdList succ:(void (^)(NSArray<NSString *> *succList))succ fail:(void (^)(void))fail
  258. NS_SWIFT_NAME(deleteRecordCalls(_:succ:fail:));
  259. /**
  260. * Advanced features,get the TRTCCloud instance in calling.
  261. *
  262. * @return TRTCCloud instance
  263. */
  264. - (TRTCCloud *)getTRTCCloudInstance
  265. NS_SWIFT_NAME(getTRTCCloudInstance());
  266. /**
  267. * Set Beauty
  268. */
  269. - (void)setBeautyLevel:(CGFloat)level succ:(TUICallSucc)succ fail:(TUICallFail)fail
  270. NS_SWIFT_NAME(setBeautyLevel(_:succ:fail:));
  271. /**
  272. * Experimental interface
  273. */
  274. - (void )callExperimentalAPI:(NSString *)jsonObject
  275. NS_SWIFT_NAME(callExperimentalAPI(jsonObject:));
  276. /**
  277. * Set the video call blurring effect
  278. *
  279. * @param level Blurring level: 0 - turn off the blurring effect; 1 - low; 2 - middle; 3 - high
  280. * @param fail Error callback
  281. */
  282. - (void)setBlurBackground:(NSInteger)level fail:(TUICallFail)fail
  283. NS_SWIFT_NAME(setBlurBackground(_:fail:));
  284. /**
  285. * Set the video call image background
  286. *
  287. * @param imagePath local path of the image, if empty, the background image effect will be turned off; if not empty, the background image effect will be turned on
  288. * @param fail Error callback
  289. */
  290. - (void)setVirtualBackground:(NSString *)imagePath fail:(TUICallFail)fail
  291. NS_SWIFT_NAME(setVirtualBackground(_:fail:));
  292. @end
  293. NS_ASSUME_NONNULL_END