抓娃娃版1127

AgoraRtcEngineKit.h 55KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459
  1. //
  2. // AgoraRtcEngineKit.h
  3. // AgoraRtcEngineKit
  4. //
  5. // Created by Sting Feng on 2015-8-11.
  6. // Copyright (c) 2015 Agora. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <CoreMedia/CoreMedia.h>
  10. #if TARGET_OS_IPHONE
  11. #import <UIKit/UIKit.h>
  12. typedef UIView VIEW_CLASS;
  13. #elif TARGET_OS_MAC
  14. #import <AppKit/AppKit.h>
  15. typedef NSView VIEW_CLASS;
  16. #endif
  17. typedef NS_ENUM(NSInteger, AgoraRtcWarningCode) {
  18. AgoraRtc_Warn_InvalidView = 8,
  19. AgoraRtc_Warn_InitVideo = 16,
  20. AgoraRtc_Warn_Pending = 20,
  21. AgoraRtc_Warn_NoAvailableChannel = 103,
  22. AgoraRtc_Warn_LookupChannelTimeout = 104,
  23. AgoraRtc_Warn_LookupChannelRejected = 105,
  24. AgoraRtc_Warn_OpenChannelTimeout = 106,
  25. AgoraRtc_Warn_OpenChannelRejected = 107,
  26. AgoraRtc_Warn_SwitchLiveVideoTimeout = 111,
  27. // sdk:vos, callmanager, peermanager: 100~1000
  28. AgoraRtc_Warn_SetClientRoleTimeout = 118,
  29. AgoraRtc_Warn_SetClientRoleNotAuthorized = 119,
  30. AgoraRtc_Warn_AudioMixingOpenError = 701,
  31. AgoraRtc_Warn_Adm_RuntimePlayoutWarning = 1014,
  32. AgoraRtc_Warn_Adm_RuntimeRecordingWarning = 1016,
  33. AgoraRtc_Warn_Adm_RecordAudioSilence = 1019,
  34. AgoraRtc_Warn_Adm_PlaybackMalfunction = 1020,
  35. AgoraRtc_Warn_Adm_RecordMalfunction = 1021,
  36. AgoraRtc_Warn_Adm_Interruption = 1025,
  37. AgoraRtc_Warn_Apm_Howling = 1051,
  38. };
  39. typedef NS_ENUM(NSInteger, AgoraRtcErrorCode) {
  40. AgoraRtc_Error_NoError = 0,
  41. AgoraRtc_Error_Failed = 1,
  42. AgoraRtc_Error_InvalidArgument = 2,
  43. AgoraRtc_Error_NotReady = 3,
  44. AgoraRtc_Error_NotSupported = 4,
  45. AgoraRtc_Error_Refused = 5,
  46. AgoraRtc_Error_BufferTooSmall = 6,
  47. AgoraRtc_Error_NotInitialized = 7,
  48. AgoraRtc_Error_NoPermission = 9,
  49. AgoraRtc_Error_TimedOut = 10,
  50. AgoraRtc_Error_Canceled = 11,
  51. AgoraRtc_Error_TooOften = 12,
  52. AgoraRtc_Error_BindSocket = 13,
  53. AgoraRtc_Error_NetDown = 14,
  54. AgoraRtc_Error_NoBufs = 15,
  55. AgoraRtc_Error_JoinChannelRejected = 17,
  56. AgoraRtc_Error_LeaveChannelRejected = 18,
  57. AgoraRtc_Error_AlreadyInUse = 19,
  58. AgoraRtc_Error_InvalidAppId = 101,
  59. AgoraRtc_Error_InvalidChannelName = 102,
  60. AgoraRtc_Error_ChannelKeyExpired = 109,
  61. AgoraRtc_Error_InvalidChannelKey = 110,
  62. AgoraRtc_Error_ConnectionInterrupted = 111, // only used in web sdk
  63. AgoraRtc_Error_ConnectionLost = 112, // only used in web sdk
  64. AgoraRtc_Error_NotInChannel = 113,
  65. AgoraRtc_Error_SizeTooLarge = 114,
  66. AgoraRtc_Error_BitrateLimit = 115,
  67. AgoraRtc_Error_TooManyDataStreams = 116,
  68. AgoraRtc_Error_DecryptionFailed = 120,
  69. AgoraRtc_Error_LoadMediaEngine = 1001,
  70. AgoraRtc_Error_StartCall = 1002,
  71. AgoraRtc_Error_StartCamera = 1003,
  72. AgoraRtc_Error_StartVideoRender = 1004,
  73. AgoraRtc_Error_Adm_GeneralError = 1005,
  74. AgoraRtc_Error_Adm_JavaResource = 1006,
  75. AgoraRtc_Error_Adm_SampleRate = 1007,
  76. AgoraRtc_Error_Adm_InitPlayout = 1008,
  77. AgoraRtc_Error_Adm_StartPlayout = 1009,
  78. AgoraRtc_Error_Adm_StopPlayout = 1010,
  79. AgoraRtc_Error_Adm_InitRecording = 1011,
  80. AgoraRtc_Error_Adm_StartRecording = 1012,
  81. AgoraRtc_Error_Adm_StopRecording = 1013,
  82. AgoraRtc_Error_Adm_RuntimePlayoutError = 1015,
  83. AgoraRtc_Error_Adm_RuntimeRecordingError = 1017,
  84. AgoraRtc_Error_Adm_RecordAudioFailed = 1018,
  85. AgoraRtc_Error_Adm_Play_Abnormal_Frequency = 1020,
  86. AgoraRtc_Error_Adm_Record_Abnormal_Frequency = 1021,
  87. AgoraRtc_Error_Adm_Init_Loopback = 1022,
  88. AgoraRtc_Error_Adm_Start_Loopback = 1023,
  89. // 1025, as warning for interruption of adm on ios
  90. // 1026, as warning for route change of adm on ios
  91. // VDM error code starts from 1500
  92. AgoraRtc_Error_Vdm_Camera_Not_Authorized = 1501,
  93. // VCM error code starts from 1600
  94. AgoraRtc_Error_Vcm_Unknown_Error = 1600,
  95. AgoraRtc_Error_Vcm_Encoder_Init_Error = 1601,
  96. AgoraRtc_Error_Vcm_Encoder_Encode_Error = 1602,
  97. AgoraRtc_Error_Vcm_Encoder_Set_Error = 1603,
  98. };
  99. typedef NS_ENUM(NSInteger, AgoraRtcChannelProfile) {
  100. AgoraRtc_ChannelProfile_Communication = 0,
  101. AgoraRtc_ChannelProfile_LiveBroadcasting = 1,
  102. AgoraRtc_ChannelProfile_Game = 2,
  103. };
  104. typedef NS_ENUM(NSInteger, AgoraRtcClientRole) {
  105. AgoraRtc_ClientRole_Broadcaster = 1,
  106. AgoraRtc_ClientRole_Audience = 2,
  107. };
  108. typedef NS_ENUM(NSInteger, AgoraRtcVideoProfile) {
  109. // res fps kbps
  110. AgoraRtc_VideoProfile_Invalid = -1,
  111. AgoraRtc_VideoProfile_120P = 0, // 160x120 15 65
  112. #if TARGET_OS_IPHONE
  113. AgoraRtc_VideoProfile_120P_3 = 2, // 120x120 15 50
  114. AgoraRtc_VideoProfile_180P = 10, // 320x180 15 140
  115. AgoraRtc_VideoProfile_180P_3 = 12, // 180x180 15 100
  116. AgoraRtc_VideoProfile_180P_4 = 13, // 240x180 15 120
  117. #endif
  118. AgoraRtc_VideoProfile_240P = 20, // 320x240 15 200
  119. #if TARGET_OS_IPHONE
  120. AgoraRtc_VideoProfile_240P_3 = 22, // 240x240 15 140
  121. AgoraRtc_VideoProfile_240P_4 = 23, // 424x240 15 220
  122. #endif
  123. AgoraRtc_VideoProfile_360P = 30, // 640x360 15 400
  124. #if TARGET_OS_IPHONE
  125. AgoraRtc_VideoProfile_360P_3 = 32, // 360x360 15 260
  126. #endif
  127. AgoraRtc_VideoProfile_360P_4 = 33, // 640x360 30 600
  128. AgoraRtc_VideoProfile_360P_6 = 35, // 360x360 30 400
  129. AgoraRtc_VideoProfile_360P_7 = 36, // 480x360 15 320
  130. AgoraRtc_VideoProfile_360P_8 = 37, // 480x360 30 490
  131. AgoraRtc_VideoProfile_360P_9 = 38, // 640x360 15 800
  132. AgoraRtc_VideoProfile_360P_10 = 39, // 640x360 24 800
  133. AgoraRtc_VideoProfile_360P_11 = 100, // 640x360 24 1000
  134. AgoraRtc_VideoProfile_480P = 40, // 640x480 15 500
  135. #if TARGET_OS_IPHONE
  136. AgoraRtc_VideoProfile_480P_3 = 42, // 480x480 15 400
  137. #endif
  138. AgoraRtc_VideoProfile_480P_4 = 43, // 640x480 30 750
  139. AgoraRtc_VideoProfile_480P_6 = 45, // 480x480 30 600
  140. AgoraRtc_VideoProfile_480P_8 = 47, // 848x480 15 610
  141. AgoraRtc_VideoProfile_480P_9 = 48, // 848x480 30 930
  142. AgoraRtc_VideoProfile_480P_10 = 49, // 640x480 10 400
  143. AgoraRtc_VideoProfile_720P = 50, // 1280x720 15 1130
  144. AgoraRtc_VideoProfile_720P_3 = 52, // 1280x720 30 1710
  145. AgoraRtc_VideoProfile_720P_5 = 54, // 960x720 15 910
  146. AgoraRtc_VideoProfile_720P_6 = 55, // 960x720 30 1380
  147. AgoraRtc_VideoProfile_1080P = 60, // 1920x1080 15 2080
  148. AgoraRtc_VideoProfile_1080P_3 = 62, // 1920x1080 30 3150
  149. AgoraRtc_VideoProfile_1080P_5 = 64, // 1920x1080 60 4780
  150. AgoraRtc_VideoProfile_1440P = 66, // 2560x1440 30 4850
  151. AgoraRtc_VideoProfile_1440P_2 = 67, // 2560x1440 60 7350
  152. AgoraRtc_VideoProfile_4K = 70, // 3840x2160 30 8190
  153. AgoraRtc_VideoProfile_4K_3 = 72, // 3840x2160 60 13500
  154. AgoraRtc_VideoProfile_DEFAULT = AgoraRtc_VideoProfile_360P,
  155. };
  156. typedef NS_ENUM(NSUInteger, AgoraRtcQuality) {
  157. AgoraRtc_Quality_Unknown = 0,
  158. AgoraRtc_Quality_Excellent = 1,
  159. AgoraRtc_Quality_Good = 2,
  160. AgoraRtc_Quality_Poor = 3,
  161. AgoraRtc_Quality_Bad = 4,
  162. AgoraRtc_Quality_VBad = 5,
  163. AgoraRtc_Quality_Down = 6,
  164. };
  165. typedef NS_ENUM(NSUInteger, AgoraRtcUserOfflineReason) {
  166. AgoraRtc_UserOffline_Quit = 0,
  167. AgoraRtc_UserOffline_Dropped = 1,
  168. AgoraRtc_UserOffline_BecomeAudience = 2,
  169. };
  170. typedef NS_ENUM(NSInteger, AgoraRtcVideoStreamType) {
  171. AgoraRtc_VideoStream_High = 0,
  172. AgoraRtc_VideoStream_Low = 1,
  173. };
  174. typedef NS_ENUM(NSInteger, AgoraRtcAudioOutputRouting)
  175. {
  176. AgoraRtc_AudioOutputRouting_Default = -1,
  177. AgoraRtc_AudioOutputRouting_Headset = 0,
  178. AgoraRtc_AudioOutputRouting_Earpiece = 1,
  179. AgoraRtc_AudioOutputRouting_HeadsetNoMic = 2,
  180. AgoraRtc_AudioOutputRouting_Speakerphone = 3,
  181. AgoraRtc_AudioOutputRouting_Loudspeaker = 4,
  182. AgoraRtc_AudioOutputRouting_HeadsetBluetooth = 5
  183. };
  184. typedef NS_ENUM(NSInteger, AgoraRtcAudioRecordingQuality) {
  185. AgoraRtc_AudioRecordingQuality_Low = 0,
  186. AgoraRtc_AudioRecordingQuality_Medium = 1,
  187. AgoraRtc_AudioRecordingQuality_High = 2
  188. };
  189. typedef NS_ENUM(NSUInteger, AgoraRtcLogFilter) {
  190. AgoraRtc_LogFilter_Off = 0,
  191. AgoraRtc_LogFilter_Debug = 0x080f,
  192. AgoraRtc_LogFilter_Info = 0x000f,
  193. AgoraRtc_LogFilter_Warn = 0x000e,
  194. AgoraRtc_LogFilter_Error = 0x000c,
  195. AgoraRtc_LogFilter_Critical = 0x0008,
  196. };
  197. typedef NS_ENUM(NSInteger, AgoraRtmpStreamLifeCycle) {
  198. RtmpStream_LifeCycle_Bind2Channel = 1,
  199. RtmpStream_LifeCycle_Bind2Ownner = 2,
  200. };
  201. typedef NS_ENUM(NSUInteger, AgoraRtcRenderMode) {
  202. /**
  203. Hidden(1): If the video size is different than that of the display window, crops the borders of the video (if the video is bigger) or stretch the video (if the video is smaller) to fit it in the window.
  204. */
  205. AgoraRtc_Render_Hidden = 1,
  206. /**
  207. AgoraRtc_Render_Fit(2): If the video size is different than that of the display window, resizes the video proportionally to fit the window.
  208. */
  209. AgoraRtc_Render_Fit = 2,
  210. /**
  211. AgoraRtc_Render_Adaptive(3):If both callers use the same screen orientation, i.e., both use vertical screens or both use horizontal screens, the AgoraRtc_Render_Hidden mode applies; if they use different screen orientations, i.e., one vertical and one horizontal, the AgoraRtc_Render_Fit mode applies.
  212. */
  213. AgoraRtc_Render_Adaptive = 3,
  214. };
  215. typedef NS_ENUM(NSUInteger, AgoraRtcQualityReportFormat) {
  216. AgoraRtc_QualityReportFormat_Json = 0,
  217. AgoraRtc_QualityReportFormat_Html = 1,
  218. };
  219. typedef NS_ENUM(NSInteger, AgoraRtcRawAudioFrameOpMode) {
  220. AgoraRtc_RawAudioFrame_OpMode_ReadOnly = 0,
  221. AgoraRtc_RawAudioFrame_OpMode_WriteOnly = 1,
  222. AgoraRtc_RawAudioFrame_OpMode_ReadWrite = 2,
  223. };
  224. #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
  225. typedef NS_ENUM(NSInteger, AgoraRtcDeviceType) {
  226. AgoraRtc_DeviceType_Audio_Unknown = -1,
  227. AgoraRtc_DeviceType_Audio_Recording = 0,
  228. AgoraRtc_DeviceType_Audio_Playout = 1,
  229. AgoraRtc_DeviceType_Video_Render = 2,
  230. AgoraRtc_DeviceType_Video_Capture = 3,
  231. };
  232. __attribute__((visibility("default"))) @interface AgoraRtcDeviceInfo : NSObject
  233. @property (assign, nonatomic) int index;
  234. @property (assign, nonatomic) AgoraRtcDeviceType type; // 0: recording, 1: playback, 2: capture
  235. @property (copy, nonatomic) NSString* deviceId; //
  236. @property (copy, nonatomic) NSString* deviceName; //
  237. @end
  238. #endif
  239. __attribute__((visibility("default"))) @interface AgoraRtcVideoCanvas : NSObject
  240. /**
  241. * The video display view. The SDK does not maintain the lifecycle of the view.
  242. The view can be safely released after calling leaveChannel with a returned value.
  243. The SDK keeps a cache of the view value, so 'setupLocalVideo' to set the view value to NULL could be able to clear cache before switching or releasing view.
  244. */
  245. @property (strong, nonatomic) VIEW_CLASS* view;
  246. @property (assign, nonatomic) AgoraRtcRenderMode renderMode; // the render mode of view: hidden, fit and adaptive
  247. @property (assign, nonatomic) NSUInteger uid; // the user id of view
  248. @end
  249. /**
  250. * For AgoraVideoFrame: color format field
  251. */
  252. typedef NS_ENUM(NSUInteger, AgoraVideoFormat) {
  253. AgoraRtc_FrameFormat_texture = 12,
  254. AgoraRtc_FrameFormat_I420 = 1,
  255. AgoraRtc_FrameFormat_RGBA = 4,
  256. AgoraRtc_FrameFormat_IMC2 = 5,
  257. };
  258. __attribute__((visibility("default"))) @interface AgoraVideoFrame : NSObject
  259. @property (assign, nonatomic) NSInteger format; /* 10: android texture (GL_TEXTURE_2D)
  260. 11: android texture (OES, typically from camera)
  261. 12: ios texture (CVPixelBufferRef)
  262. 1: I420
  263. 2: BGRA
  264. 3: NV21
  265. 4: RGBA
  266. 5: IMC2
  267. 6: BGRA (same as 2)
  268. 7: ARGB
  269. 8: NV12
  270. */
  271. @property (assign, nonatomic) CMTime time; // time for this frame.
  272. @property (assign, nonatomic) int stride DEPRECATED_MSG_ATTRIBUTE("use strideInPixels instead");
  273. @property (assign, nonatomic) int strideInPixels; // how many pixels between 2 consecutive rows. Note: in pixel, not byte.
  274. // in case of ios texture, it is not used
  275. @property (assign, nonatomic) int height; // how many rows of pixels, in case of ios texture, it is not used
  276. @property (assign, nonatomic) CVPixelBufferRef textureBuf;
  277. @property (strong, nonatomic) NSData *dataBuf; // raw data buffer. in case of ios texture, it is not used
  278. @property (assign, nonatomic) int cropLeft; // how many pixels to crop on the left boundary
  279. @property (assign, nonatomic) int cropTop; // how many pixels to crop on the top boundary
  280. @property (assign, nonatomic) int cropRight; // how many pixels to crop on the right boundary
  281. @property (assign, nonatomic) int cropBottom; // how many pixels to crop on the bottom boundary
  282. @property (assign, nonatomic) int rotation; // 0, 90, 180, 270. See document for rotation calculation
  283. /* Note
  284. * 1. strideInPixels
  285. * Stride is in unit of pixel, not byte
  286. * 2. About frame width and height
  287. * No field defined for width. However, it can be deduced by:
  288. * croppedWidth = (strideInPixels - cropLeft - cropRight)
  289. * And
  290. * croppedHeight = (height - cropTop - cropBottom)
  291. * 3. About crop
  292. * _________________________________________________________________.....
  293. * | ^ | ^
  294. * | | | |
  295. * | cropTop | |
  296. * | | | |
  297. * | v | |
  298. * | ________________________________ | |
  299. * | | | | |
  300. * | | | | |
  301. * |<-- cropLeft -->| valid region |<- cropRight ->|
  302. * | | | | height
  303. * | | | |
  304. * | |_____________________________ | | |
  305. * | ^ | |
  306. * | | | |
  307. * | cropBottom | |
  308. * | | | |
  309. * | v | v
  310. * _________________________________________________________________......
  311. * | |
  312. * |<---------------- strideInPixels ----------------------------->|
  313. *
  314. * If your buffer contains garbage data, you can crop them. E.g. frame size is
  315. * 360 x 640, often the buffer stride is 368, i.e. there extra 8 pixels on the
  316. * right are for padding, and should be removed. In this case, you can set:
  317. * strideInPixels = 368;
  318. * height = 640;
  319. * cropRight = 8;
  320. * // cropLeft, cropTop, cropBottom are default to 0
  321. */
  322. @end
  323. __attribute__((visibility("default"))) @interface AgoraRtcStats : NSObject
  324. @property (assign, nonatomic) NSUInteger duration;
  325. @property (assign, nonatomic) NSUInteger txBytes;
  326. @property (assign, nonatomic) NSUInteger rxBytes;
  327. @property (assign, nonatomic) NSUInteger txAudioKBitrate;
  328. @property (assign, nonatomic) NSUInteger rxAudioKBitrate;
  329. @property (assign, nonatomic) NSUInteger txVideoKBitrate;
  330. @property (assign, nonatomic) NSUInteger rxVideoKBitrate;
  331. @property (assign, nonatomic) NSUInteger users;
  332. @property (assign, nonatomic) double cpuAppUsage;
  333. @property (assign, nonatomic) double cpuTotalUsage;
  334. @end
  335. __attribute__((visibility("default"))) @interface AgoraRtcLocalVideoStats : NSObject
  336. @property (assign, nonatomic) NSUInteger sentBitrate;
  337. @property (assign, nonatomic) NSUInteger sentFrameRate;
  338. @end
  339. __attribute__((visibility("default"))) @interface AgoraRtcRemoteVideoStats : NSObject
  340. @property (assign, nonatomic) NSUInteger uid;
  341. @property (assign, nonatomic) NSUInteger delay;
  342. @property (assign, nonatomic) NSUInteger width;
  343. @property (assign, nonatomic) NSUInteger height;
  344. @property (assign, nonatomic) NSUInteger receivedBitrate;
  345. @property (assign, nonatomic) NSUInteger receivedFrameRate;
  346. @property (assign, nonatomic) AgoraRtcVideoStreamType rxStreamType;
  347. @end
  348. __attribute__((visibility("default"))) @interface AgoraRtcAudioVolumeInfo : NSObject
  349. @property (assign, nonatomic) NSUInteger uid;
  350. @property (assign, nonatomic) NSUInteger volume;
  351. @end
  352. __attribute__((visibility("default"))) @interface AgoraRtcVideoCompositingRegion : NSObject
  353. @property (assign, nonatomic) NSUInteger uid;
  354. @property (assign, nonatomic) double x;
  355. @property (assign, nonatomic) double y;
  356. @property (assign, nonatomic) double width;
  357. @property (assign, nonatomic) double height;
  358. @property (assign, nonatomic) NSInteger zOrder; //optional, [0, 100] //0 (default): bottom most, 100: top most
  359. @property (assign, nonatomic) double alpha; //optional, [0, 1.0] where 0 denotes throughly transparent, 1.0 opaque
  360. @property (assign, nonatomic) AgoraRtcRenderMode renderMode;
  361. @end
  362. __attribute__((visibility("default"))) @interface AgoraRtcVideoCompositingLayout : NSObject
  363. @property (assign, nonatomic) NSInteger canvasWidth;
  364. @property (assign, nonatomic) NSInteger canvasHeight;
  365. @property (copy, nonatomic) NSString* backgroundColor;//e.g. "#c0c0c0"
  366. @property (retain, nonatomic) NSArray* regions; //array of AgoraRtcVideoCompositingRegion
  367. @property (copy, nonatomic) NSString* appData;//app defined data
  368. @end
  369. __attribute__((visibility("default"))) @interface AgoraPublisherConfiguration : NSObject
  370. @property (assign, nonatomic) BOOL owner;
  371. @property (assign, nonatomic) NSInteger width;
  372. @property (assign, nonatomic) NSInteger height;
  373. @property (assign, nonatomic) NSInteger framerate;
  374. @property (assign, nonatomic) NSInteger bitrate;
  375. @property (assign, nonatomic) NSInteger defaultLayout;
  376. @property (assign, nonatomic) AgoraRtmpStreamLifeCycle lifeCycle;
  377. @property (assign, nonatomic) NSInteger injectStreamWidth;
  378. @property (assign, nonatomic) NSInteger injectStreamHeight;
  379. @property (copy, nonatomic) NSString* injectStreamUrl;
  380. @property (copy, nonatomic) NSString* publishUrl;
  381. @property (copy, nonatomic) NSString* rawStreamUrl;
  382. @property (copy, nonatomic) NSString* extraInfo;
  383. -(BOOL) validate;
  384. -(NSString *) toJsonString;
  385. @end
  386. __attribute__((visibility("default"))) @interface AgoraPublisherConfigurationBuilder : NSObject
  387. - (AgoraPublisherConfigurationBuilder *) setOwner:(BOOL)isOwner;
  388. - (AgoraPublisherConfigurationBuilder *) setWidth:(NSInteger)width height:(NSInteger)height framerate:(NSInteger)framerate bitrate:(NSInteger)bitrate;
  389. - (AgoraPublisherConfigurationBuilder *) setDefaultLayout:(NSInteger)layoutStyle;
  390. - (AgoraPublisherConfigurationBuilder *) setLifeCycle:(AgoraRtmpStreamLifeCycle)lifecycle;
  391. - (AgoraPublisherConfigurationBuilder *) setPublisherUrl:(NSString*)url;
  392. - (AgoraPublisherConfigurationBuilder *) setRawStreamUrl:(NSString*)url;
  393. - (AgoraPublisherConfigurationBuilder *) setExtraInfo:(NSString *)info;
  394. - (AgoraPublisherConfigurationBuilder *) injectStream:(NSString *)url width:(NSInteger)width height:(NSInteger)height;
  395. - (AgoraPublisherConfiguration *) build;
  396. @end
  397. @class AgoraRtcEngineKit;
  398. @protocol AgoraRtcEngineDelegate <NSObject>
  399. @optional
  400. /**
  401. * The warning occurred in SDK. The APP could igonre the warning, and the SDK could try to resume automically.
  402. *
  403. * @param engine The engine kit
  404. * @param warningCode The warning code
  405. */
  406. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didOccurWarning:(AgoraRtcWarningCode)warningCode;
  407. /**
  408. * The error occurred in SDK. The SDK couldn't resume to normal state, and the app need to handle it.
  409. *
  410. * @param engine The engine kit
  411. * @param errorCode The error code
  412. */
  413. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didOccurError:(AgoraRtcErrorCode)errorCode;
  414. /**
  415. * The sdk reports the volume of a speaker. The interface is disable by default, and it could be enable by API "enableAudioVolumeIndication"
  416. *
  417. * @param engine The engine kit
  418. * @param speakers AgoraRtcAudioVolumeInfos array
  419. * @param totalVolume The total volume of speakers
  420. */
  421. - (void)rtcEngine:(AgoraRtcEngineKit *)engine reportAudioVolumeIndicationOfSpeakers:(NSArray*)speakers totalVolume:(NSInteger)totalVolume;
  422. /**
  423. * Event of the first local frame starts rendering on the screen.
  424. *
  425. * @param engine The engine kit
  426. * @param size The size of local video stream
  427. * @param elapsed The elapsed time(ms) from the beginning of the session.
  428. */
  429. - (void)rtcEngine:(AgoraRtcEngineKit *)engine firstLocalVideoFrameWithSize:(CGSize)size elapsed:(NSInteger)elapsed;
  430. /**
  431. * Event of the first frame of remote user is decoded successfully.
  432. *
  433. * @param engine The engine kit
  434. * @param uid The remote user id
  435. * @param size The size of video stream
  436. * @param elapsed The elapsed time(ms) from the beginning of the session.
  437. */
  438. - (void)rtcEngine:(AgoraRtcEngineKit *)engine firstRemoteVideoDecodedOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed;
  439. /**
  440. * Event of video size changed for local or remote user
  441. *
  442. * @param engine The engine kit
  443. * @param uid The user id
  444. * @param size The new size of video
  445. * @param rotation The new rotate of video
  446. */
  447. - (void)rtcEngine:(AgoraRtcEngineKit *)engine videoSizeChangedOfUid:(NSUInteger)uid size:(CGSize)size rotation:(NSInteger)rotation;
  448. /**
  449. * Event of the first frame of remote user is rendering on the screen.
  450. *
  451. * @param engine The engine kit
  452. * @param uid The remote user id
  453. * @param size The size of video stream
  454. * @param elapsed The elapsed time(ms) from the beginning of the session.
  455. */
  456. - (void)rtcEngine:(AgoraRtcEngineKit *)engine firstRemoteVideoFrameOfUid:(NSUInteger)uid size:(CGSize)size elapsed:(NSInteger)elapsed;
  457. /**
  458. * Event of remote user joined
  459. *
  460. * @param engine The engine kit
  461. * @param uid The remote user id
  462. * @param elapsed The elapsed time(ms) from the beginning of the session.
  463. */
  464. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didJoinedOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed;
  465. /**
  466. * Event of remote user offlined
  467. *
  468. * @param engine The engine kit
  469. * @param uid The remote user id
  470. * @param reason Reason of user offline, quit, drop or became audience
  471. */
  472. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didOfflineOfUid:(NSUInteger)uid reason:(AgoraRtcUserOfflineReason)reason;
  473. /**
  474. * Event of remote user audio muted or unmuted
  475. *
  476. * @param engine The engine kit
  477. * @param muted Muted or unmuted
  478. * @param uid The remote user id
  479. */
  480. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didAudioMuted:(BOOL)muted byUid:(NSUInteger)uid;
  481. /**
  482. * Event of remote user video muted or unmuted
  483. *
  484. * @param engine The engine kit
  485. * @param muted Muted or unmuted
  486. * @param uid The remote user id
  487. */
  488. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didVideoMuted:(BOOL)muted byUid:(NSUInteger)uid;
  489. /**
  490. * Event of remote user video muted or unmuted
  491. *
  492. * @param engine The engine kit
  493. * @param routing the current audio output routing
  494. */
  495. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didAudioRouteChanged:(AgoraRtcAudioOutputRouting)routing;
  496. /**
  497. * Event of remote user video enabled or disabled
  498. *
  499. * @param engine The engine kit
  500. * @param enabled Enabled or disabled
  501. * @param uid The remote user id
  502. */
  503. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didVideoEnabled:(BOOL)enabled byUid:(NSUInteger)uid;
  504. /**
  505. * The statistics of local video stream. Update every two seconds.
  506. *
  507. * @param engine The engine kit
  508. * @param stats The statistics of local video, including sent bitrate, sent framerate
  509. */
  510. - (void)rtcEngine:(AgoraRtcEngineKit *)engine localVideoStats:(AgoraRtcLocalVideoStats*)stats;
  511. /**
  512. * The statistics of remote video stream. Update every two seconds.
  513. *
  514. * @param engine The engine kit
  515. * @param stats The statistics of remote video, including user id, delay, resolution, received bitrate, received framerate, video stream type
  516. */
  517. - (void)rtcEngine:(AgoraRtcEngineKit *)engine remoteVideoStats:(AgoraRtcRemoteVideoStats*)stats;
  518. /**
  519. * Event of load media engine success
  520. *
  521. * @param engine The engine kit
  522. */
  523. - (void)rtcEngineMediaEngineDidLoaded:(AgoraRtcEngineKit *)engine;
  524. /**
  525. * Event of media engine start call success
  526. *
  527. * @param engine The engine kit
  528. */
  529. - (void)rtcEngineMediaEngineDidStartCall:(AgoraRtcEngineKit *)engine;
  530. /**
  531. * Event of meida engine finish audio mixing.
  532. *
  533. * @param engine The engine kit
  534. */
  535. - (void)rtcEngineMediaEngineDidAudioMixingFinish:(AgoraRtcEngineKit *)engine;
  536. /**
  537. * Event of meida engine finish audio mixing.
  538. *
  539. * @param engine The engine kit
  540. */
  541. - (void)rtcEngineMediaEngineDidAudioEffectFinish:(AgoraRtcEngineKit *)engine soundId:(NSInteger)soundId;
  542. /**
  543. * Event of camera opened
  544. *
  545. * @param engine The engine kit
  546. */
  547. - (void)rtcEngineCameraDidReady:(AgoraRtcEngineKit *)engine;
  548. /**
  549. * Event of camera stopped
  550. *
  551. * @param engine The engine kit
  552. */
  553. - (void)rtcEngineVideoDidStop:(AgoraRtcEngineKit *)engine;
  554. /**
  555. * Event of disconnected with server. This event is reported at the moment SDK loses connection with server.
  556. * In the mean time SDK automatically tries to reconnect with the server until APP calls leaveChannel.
  557. *
  558. * @param engine The engine kit
  559. */
  560. - (void)rtcEngineConnectionDidInterrupted:(AgoraRtcEngineKit *)engine;
  561. /**
  562. * Event of loss connection with server. This event is reported after the connection is interrupted and exceed the retry period (10 seconds by default).
  563. * In the mean time SDK automatically tries to reconnect with the server until APP calls leaveChannel.
  564. *
  565. * @param engine The engine kit
  566. */
  567. - (void)rtcEngineConnectionDidLost:(AgoraRtcEngineKit *)engine;
  568. /**
  569. * Event of the user joined the channel.
  570. *
  571. * @param engine The engine kit
  572. * @param channel The channel name
  573. * @param uid The remote user id
  574. * @param elapsed The elapsed time (ms) from session beginning
  575. */
  576. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didJoinChannel:(NSString*)channel withUid:(NSUInteger)uid elapsed:(NSInteger) elapsed;
  577. /**
  578. * Event of the user rejoined the channel
  579. *
  580. * @param engine The engine kit
  581. * @param channel The channel name
  582. * @param uid The user id
  583. * @param elapsed The elapsed time (ms) from session beginning
  584. */
  585. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didRejoinChannel:(NSString*)channel withUid:(NSUInteger)uid elapsed:(NSInteger) elapsed;
  586. /**
  587. * Statistics of rtc engine status. Updated every two seconds.
  588. *
  589. * @param engine The engine kit
  590. * @param stats The statistics of rtc status, including duration, sent bytes and received bytes
  591. */
  592. - (void)rtcEngine:(AgoraRtcEngineKit *)engine reportRtcStats:(AgoraRtcStats*)stats;
  593. /**
  594. * The statistics of the call when leave channel
  595. *
  596. * @param engine The engine kit
  597. * @param stats The statistics of the call, including duration, sent bytes and received bytes
  598. */
  599. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didLeaveChannelWithStats:(AgoraRtcStats*)stats;
  600. /**
  601. * The audio quality of the user. updated every two seconds.
  602. *
  603. * @param engine The engine kit
  604. * @param uid The id of user
  605. * @param quality The audio quality
  606. * @param delay The delay from the remote user
  607. * @param lost The percentage of lost packets
  608. */
  609. - (void)rtcEngine:(AgoraRtcEngineKit *)engine audioQualityOfUid:(NSUInteger)uid quality:(AgoraRtcQuality)quality delay:(NSUInteger)delay lost:(NSUInteger)lost;
  610. /**
  611. * The network quality of local user.
  612. *
  613. * @param engine The engine kit
  614. * @param uid The id of user
  615. * @param txQuality The sending network quality
  616. * @param rxQuality The receiving network quality
  617. */
  618. - (void)rtcEngine:(AgoraRtcEngineKit *)engine networkQuality:(NSUInteger)uid txQuality:(AgoraRtcQuality)txQuality rxQuality:(AgoraRtcQuality)rxQuality;
  619. /**
  620. * The network quality of lastmile test.
  621. *
  622. * @param engine The engine kit
  623. * @param quality The network quality
  624. */
  625. - (void)rtcEngine:(AgoraRtcEngineKit *)engine lastmileQuality:(AgoraRtcQuality)quality;
  626. #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
  627. /**
  628. * the notificaitoin of device added removed
  629. *
  630. * @param engine The engine kit
  631. * @param deviceId the identification of device
  632. * @param deviceType type of device: -1: audio unknown; 0: audio recording ; 1: audio playout ; 2: render; 4: capture
  633. * @param state state of device: 0: added; 1: removed
  634. */
  635. - (void)rtcEngine:(AgoraRtcEngineKit *)engine device:(NSString*) deviceId type:(AgoraRtcDeviceType) deviceType stateChanged:(NSInteger) state;
  636. #endif
  637. /**
  638. * Event of API call executed
  639. *
  640. * @param engine The engine kit
  641. * @param api The API description
  642. * @param error The error code
  643. */
  644. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didApiCallExecute:(NSString*)api error:(NSInteger)error;
  645. /**
  646. * This callback returns the status code after executing the refreshRecordingServiceStatus method successfully.
  647. *
  648. * @param engine The engine kit
  649. * @param status 0:Recording is stopped. 1:Recording is ongoing.
  650. */
  651. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didRefreshRecordingServiceStatus:(NSInteger)status;
  652. /**
  653. * receive custom data from remote user
  654. *
  655. * @param engine The engine kit
  656. * @param uid The remote user id
  657. * @param streamId The stream id
  658. * @param data The user defined data
  659. */
  660. - (void)rtcEngine:(AgoraRtcEngineKit *)engine receiveStreamMessageFromUid:(NSUInteger)uid streamId:(NSInteger)streamId data:(NSData*)data;
  661. /**
  662. * the local user has not received the data stream from the other user within 5 seconds.
  663. *
  664. * @param engine The engine kit
  665. * @param uid The remote user id
  666. * @param streamId The stream id
  667. * @param error The error code
  668. * @param missed The number of lost messages
  669. * @param cached The number of incoming cached messages when the data stream is interrupted
  670. */
  671. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didOccurStreamMessageErrorFromUid:(NSUInteger)uid streamId:(NSInteger)streamId error:(NSInteger)error missed:(NSInteger)missed cached:(NSInteger)cached;
  672. /**
  673. * when channel key is enabled, and specified channel key is invalid or expired, this function will be called.
  674. * APP should generate a new channel key and call renewChannelKey() to refresh the key.
  675. * NOTE: to be compatible with previous version, ERR_CHANNEL_KEY_EXPIRED and ERR_INVALID_CHANNEL_KEY are also reported via onError() callback.
  676. * You should move renew of channel key logic into this callback.
  677. * @param engine The engine kit
  678. */
  679. - (void)rtcEngineRequestChannelKey:(AgoraRtcEngineKit *)engine;
  680. /**
  681. * Event of the first audio frame is sent.
  682. *
  683. * @param engine The engine kit
  684. * @param elapsed The elapsed time(ms) from the beginning of the session.
  685. */
  686. - (void)rtcEngine:(AgoraRtcEngineKit *)engine firstLocalAudioFrame:(NSInteger)elapsed;
  687. /**
  688. * Event of the first audio frame from remote user is received.
  689. *
  690. * @param engine The engine kit
  691. * @param uid The remote user id
  692. * @param elapsed The elapsed time(ms) from the beginning of the session.
  693. */
  694. - (void)rtcEngine:(AgoraRtcEngineKit *)engine firstRemoteAudioFrameOfUid:(NSUInteger)uid elapsed:(NSInteger)elapsed;
  695. /**
  696. * The sdk reports who is active speaker in the channel
  697. *
  698. * @param engine The engine kit
  699. * @param speakerUid The speaker who is talking
  700. */
  701. - (void)rtcEngine:(AgoraRtcEngineKit *)engine activeSpeaker:(NSUInteger)speakerUid;
  702. /**
  703. * Event of cient role change. only take effect under broadcasting mode
  704. *
  705. * @param engine The engine kit
  706. * @param oldRole the previous role
  707. * @param newRole the new role
  708. */
  709. - (void)rtcEngine:(AgoraRtcEngineKit *)engine didClientRoleChanged:(AgoraRtcClientRole)oldRole newRole:(AgoraRtcClientRole)newRole;
  710. @end
  711. __attribute__((visibility("default"))) @interface AgoraRtcEngineKit : NSObject
  712. /**
  713. * Get the version of Agora SDK.
  714. *
  715. * @return string, sdk version
  716. */
  717. + (NSString *)getSdkVersion;
  718. /**
  719. * Get the version of Media Engine
  720. *
  721. * @return string, engine version
  722. */
  723. + (NSString *)getMediaEngineVersion;
  724. /**
  725. * Get the native handler of sdk Engine
  726. */
  727. - (void*)getNativeHandle;
  728. /**
  729. * Initializes the AgoraRtcEngineKit object.
  730. *
  731. * @param appId The appId is issued to the application developers by Agora.
  732. * @param delegate The AgoraRtcEngineDelegate
  733. *
  734. * @return an object of AgoraRtcEngineKit class
  735. */
  736. + (instancetype)sharedEngineWithAppId:(NSString*)appId
  737. delegate:(id<AgoraRtcEngineDelegate>)delegate;
  738. /**
  739. * deprecated
  740. */
  741. + (instancetype)sharedEngineWithAppId:(NSString*)AppId
  742. error:(void(^)(AgoraRtcErrorCode errorCode))errorBlock __deprecated;
  743. + (void)destroy;
  744. /**
  745. * deprecated blocks
  746. */
  747. - (void)audioVolumeIndicationBlock:(void(^)(NSArray *speakers, NSInteger totalVolume))audioVolumeIndicationBlock __deprecated;
  748. - (void)firstLocalVideoFrameBlock:(void(^)(NSInteger width, NSInteger height, NSInteger elapsed))firstLocalVideoFrameBlock __deprecated;
  749. - (void)firstRemoteVideoDecodedBlock:(void(^)(NSUInteger uid, NSInteger width, NSInteger height, NSInteger elapsed))firstRemoteVideoDecodedBlock __deprecated;
  750. - (void)firstRemoteVideoFrameBlock:(void(^)(NSUInteger uid, NSInteger width, NSInteger height, NSInteger elapsed))firstRemoteVideoFrameBlock __deprecated;
  751. - (void)userJoinedBlock:(void(^)(NSUInteger uid, NSInteger elapsed))userJoinedBlock __deprecated;
  752. - (void)userOfflineBlock:(void(^)(NSUInteger uid))userOfflineBlock __deprecated;
  753. - (void)userMuteAudioBlock:(void(^)(NSUInteger uid, BOOL muted))userMuteAudioBlock __deprecated;
  754. - (void)userMuteVideoBlock:(void(^)(NSUInteger uid, BOOL muted))userMuteVideoBlock __deprecated;
  755. - (void)localVideoStatBlock:(void(^)(NSInteger sentBitrate, NSInteger sentFrameRate))localVideoStatBlock __deprecated;
  756. - (void)remoteVideoStatBlock:(void(^)(NSUInteger uid, NSInteger delay, NSInteger receivedBitrate, NSInteger receivedFrameRate))remoteVideoStatBlock __deprecated;
  757. - (void)cameraReadyBlock:(void(^)())cameraReadyBlock __deprecated;
  758. - (void)connectionLostBlock:(void(^)())connectionLostBlock __deprecated;
  759. - (void)rejoinChannelSuccessBlock:(void(^)(NSString* channel, NSUInteger uid, NSInteger elapsed))rejoinChannelSuccessBlock __deprecated;
  760. - (void)rtcStatsBlock:(void(^)(AgoraRtcStats* stat))rtcStatsBlock __deprecated;
  761. - (void)leaveChannelBlock:(void(^)(AgoraRtcStats* stat))leaveChannelBlock __deprecated;
  762. - (void)audioQualityBlock:(void(^)(NSUInteger uid, AgoraRtcQuality quality, NSUInteger delay, NSUInteger lost))audioQualityBlock __deprecated;
  763. - (void)networkQualityBlock:(void(^)(NSUInteger uid, AgoraRtcQuality txQuality, AgoraRtcQuality rxQuality))networkQualityBlock __deprecated;
  764. - (void)lastmileQualityBlock:(void(^)(AgoraRtcQuality quality))lastmileQualityBlock __deprecated;
  765. - (void)mediaEngineEventBlock:(void(^)(NSInteger code))mediaEngineEventBlock __deprecated;
  766. /**
  767. * Enable / Disable dispatching delegate to main queue. if disable, the app should dispatch UI operating to main queue by himself.
  768. *
  769. * @param enabled YES: dispatch delegate method to main queue. NO: not dispatch delegate methods to main queue
  770. *
  771. * @return 0 when executed successfully. return negative value if failed.
  772. */
  773. - (int) enableMainQueueDispatch: (BOOL) enabled;
  774. /** BEGIN OF COMMON METHODS */
  775. /**
  776. * Create an open UDP socket to the AgoraRtcEngineKit cloud service to join a channel.
  777. Users in the same channel can talk to each other with same vendor key.
  778. Users using different vendor keys cannot call each other.
  779. The method is asynchronous.
  780. *
  781. * @param channelKey Channel key generated by APP using sign certificate.
  782. * @param channelName Joining in the same channel indicates those clients have entered in one room.
  783. * @param info Optional, this argument can be whatever the programmer likes personally.
  784. * @param uid Optional, this argument is the unique ID for each member in one channel.
  785. If not specified, or set to 0, the SDK automatically allocates an ID, and the id could be gotten in onJoinChannelSuccess.
  786. * @param joinSuccessBlock This callback indicates that the user has successfully joined the specified channel. Same as rtcEngine:didJoinChannel:withUid:elapsed:. If nil, the callback rtcEngine:didJoinChannel:withUid:elapsed: will works.
  787. *
  788. * @return 0 when executed successfully, and return negative value when failed.
  789. */
  790. - (int)joinChannelByKey:(NSString *)channelKey
  791. channelName:(NSString *)channelName
  792. info:(NSString *)info
  793. uid:(NSUInteger)uid
  794. joinSuccess:(void(^)(NSString* channel, NSUInteger uid, NSInteger elapsed))joinSuccessBlock;
  795. /**
  796. * lets the user leave a channel, i.e., hanging up or exiting a call.
  797. After joining a channel, the user must call the leaveChannel method to end the call before joining another one.
  798. It is synchronous, i.e., it only returns until the call ends and all resources are released.
  799. * @param leaveChannelBlock indicate the statistics of this call, from joinChannel to leaveChannel, including duration, tx bytes and rx bytes in the call.
  800. *
  801. * @return 0 if executed successfully, or return negative value if failed.
  802. */
  803. - (int)leaveChannel:(void(^)(AgoraRtcStats* stat))leaveChannelBlock;
  804. /**
  805. * Enables the network quality test. When enabled, the callback 'networkQualityBlock' notifies the application about the user's network connection quality.
  806. Note: Once the network test is enabled, it uses the network bandwidth even when the application is not in a call.
  807. Recommandation: When the application is foreground, enable the network connection test; and when the application is switched to background, disable network test in order to reduce network traffic.
  808. By default, the network test is disabled
  809. *
  810. * @return 0 when executed successfully, and return negative value when failed.
  811. */
  812. - (int)enableLastmileTest;
  813. /**
  814. * Disables the network quality test.
  815. *
  816. * @return 0 when executed successfully, and return negative value when failed.
  817. */
  818. - (int)disableLastmileTest;
  819. /**
  820. * Enables video mode. Switches from audio to video mode.
  821. It could be called during a call and before entering a channel.
  822. *
  823. * @return 0 when this method is called successfully, or negative value when this method failed.
  824. */
  825. - (int)enableVideo;
  826. /**
  827. * Disable video mode. Switch from video to audio mode.
  828. It could be called during a call and before entering a channel.
  829. *
  830. * @return 0 when this method is called successfully, or negative value when this method failed.
  831. */
  832. - (int)disableVideo;
  833. /**
  834. * Enables local video.
  835. *
  836. * @param enabled YES to enabled local video capture and render (by default), NO to disable using local camera device.
  837. * @return 0 when this method is called successfully, or negative value when this method failed.
  838. */
  839. - (int)enableLocalVideo:(BOOL)enabled;
  840. /**
  841. * start local video preview, while not sending data to server
  842. *
  843. * @return 0 when this method is called successfully, or negative value when this method failed.
  844. */
  845. - (int)startPreview;
  846. /**
  847. * stop local video preview
  848. *
  849. * @return 0 when this method is called successfully, or negative value when this method failed.
  850. */
  851. - (int)stopPreview;
  852. /**
  853. * Enables audio function, which is enabled by default.
  854. *
  855. * @return 0 when this method is called successfully, or negative value when this method failed.
  856. */
  857. - (int)enableAudio;
  858. /**
  859. * Disable audio function.
  860. *
  861. * @return 0 when this method is called successfully, or negative value when this method failed.
  862. */
  863. - (int)disableAudio;
  864. /**
  865. * Specify sdk parameters
  866. *
  867. * @param options sdk options in json format.
  868. */
  869. - (int)setParameters:(NSString *)options;
  870. - (NSString*)getParameter:(NSString*)parameter
  871. args:(NSString*)args;
  872. /**
  873. * The call id of current client. The call id could be used in 'rate' and 'complain' method.
  874. *
  875. * @return The current call id.
  876. */
  877. - (NSString*) getCallId;
  878. /**
  879. * Let user rate the call. Often called after the call ends.
  880. *
  881. * @param callId The call ID retrieved from the 'getCallId' method.
  882. * @param rating The rating for the call between 1 (lowest score) to 10 (highest score).
  883. * @param description Optional, decribed by user for the call with a length less than 800 bytes.
  884. *
  885. * @return 0 when executed successfully. return ERR_INVALID_ARGUMENT (-2):The passed argument is invalid, e.g., callId invalid. return ERR_NOT_READY (-3):The SDK status is incorrect, e.g., initialization failed.
  886. */
  887. - (int) rate:(NSString*) callId
  888. rating:(NSInteger) rating
  889. description:(NSString*) description;
  890. /**
  891. * Let user complain the quality of the call. Often called after the call ends.
  892. *
  893. * @param callId The call ID retrieved from the 'getCallId' method.
  894. * @param description Optional, decribed by user for the call with a length less than 800 bytes.
  895. *
  896. * @return 0 when executed successfully. return ERR_INVALID_ARGUMENT (-2):The passed argument is invalid, e.g., callId invalid. return ERR_NOT_READY (-3):The SDK status is incorrect, e.g., initialization failed.
  897. */
  898. - (int) complain:(NSString*) callId
  899. description:(NSString*) description;
  900. /** END OF COMMON METHODS */
  901. /** BEGIN OF AUDIO METHODS */
  902. /**
  903. * Enable / Disable speaker of device
  904. *
  905. * @param enableSpeaker YES: Switches to speakerphone. NO: Switches to headset.
  906. *
  907. * @return 0 when executed successfully. return negative value if failed.
  908. */
  909. - (int)setEnableSpeakerphone:(BOOL)enableSpeaker;
  910. /**
  911. * test if the speakerphone is enabled or not.
  912. *
  913. * @return YES when speakerphone is enabled. NO when speakerphone is not enabled.
  914. */
  915. - (BOOL)isSpeakerphoneEnabled;
  916. /**
  917. * Set default audio route to Speakerphone
  918. *
  919. * @param defaultToSpeaker YES: default to speakerphone. NO: default to earpiece for voice chat, speaker for video chat.
  920. *
  921. * @return 0 when executed successfully. return negative value if failed.
  922. */
  923. - (int)setDefaultAudioRouteToSpeakerphone:(BOOL)defaultToSpeaker;
  924. /**
  925. * Sets the speakerphone volume. The speaker volume could be adjust by MPMusicPlayerController and other iOS API easily.
  926. *
  927. * @param volume between 0 (lowest volume) to 255 (highest volume).
  928. *
  929. * @return 0 when executed successfully. return negative value if failed.
  930. */
  931. - (int)setSpeakerphoneVolume:(NSUInteger)volume __deprecated;
  932. /**
  933. * Enables to report to the application about the volume of the speakers.
  934. *
  935. * @param interval Specifies the time interval between two consecutive volume indications.
  936. <=0: Disables volume indication.
  937. >0 : The volume indication interval in milliseconds. Recommandation: >=200ms.
  938. * @param smooth The smoothing factor. Recommended: 3.
  939. *
  940. * @return 0 when executed successfully. return negative value if failed.
  941. */
  942. - (int)enableAudioVolumeIndication:(NSInteger)interval
  943. smooth:(NSInteger)smooth;
  944. /**
  945. * Start recording conversation to file specified by the file path.
  946. *
  947. * @param filePath file path to save recorded conversation.
  948. * @param quality encode quality for the record file
  949. *
  950. * @return 0 when executed successfully. return negative value if failed.
  951. */
  952. - (int)startAudioRecording:(NSString*)filePath
  953. quality:(AgoraRtcAudioRecordingQuality)quality;
  954. /**
  955. * Stop conversation recording
  956. *
  957. * @return 0 when executed successfully. return negative value if failed.
  958. */
  959. - (int)stopAudioRecording;
  960. - (int)startAudioMixing:(NSString*) filePath
  961. loopback:(BOOL) loopback
  962. replace:(BOOL) replace
  963. cycle:(NSInteger) cycle;
  964. - (int)stopAudioMixing;
  965. - (int)pauseAudioMixing;
  966. - (int)resumeAudioMixing;
  967. - (int)adjustAudioMixingVolume:(NSInteger) volume;
  968. - (int)getAudioMixingDuration;
  969. - (int)getAudioMixingCurrentPosition;
  970. - (int)setAudioMixingPosition:(NSInteger) pos;
  971. //- (int)setScreenCaptureId:(NSUInteger)windowId;
  972. /**
  973. * Launches an echo test to test if the audio devices (e.g., headset and speaker) and the network connection work properly. In the test, the user speaks first, and the recording will be played back in 10 seconds. If the user can hear what he said in 10 seconds, it indicates that the audio devices and network connection work properly.
  974. Notes: Must call stopEchoTest to end the test, or won't start new test or join channel.
  975. *
  976. * @param successBlock The callback indicates that the user has successfully joined the specified channel.
  977. *
  978. * @return 0 when executed successfully. return negative value if failed. e.g. ERR_REFUSED (-5):Failed to launch the echo test, e.g., initialization failed.
  979. */
  980. - (int)startEchoTest:(void(^)(NSString* channel, NSUInteger uid, NSInteger elapsed))successBlock;
  981. /**
  982. * Stop echo test.
  983. *
  984. * @return 0 when executed successfully. return negative value if failed. e.g. ERR_REFUSED(-5):Failed to stop the echo test. It could be that the echo test is not running.
  985. */
  986. - (int)stopEchoTest;
  987. /**
  988. * Mutes / Unmutes local audio.
  989. *
  990. * @param mute true: Mutes the local audio. false: Unmutes the local audio.
  991. *
  992. * @return 0 when executed successfully. return negative value if failed.
  993. */
  994. - (int)muteLocalAudioStream:(BOOL)mute;
  995. /**
  996. * Mutes / Unmutes all remote audio.
  997. *
  998. * @param mute true: Mutes all remote received audio. false: Unmutes all remote received audio.
  999. *
  1000. * @return 0 when executed successfully. return negative value if failed.
  1001. */
  1002. - (int)muteAllRemoteAudioStreams:(BOOL)mute;
  1003. - (int)muteRemoteAudioStream:(NSUInteger)uid
  1004. mute:(BOOL)mute;
  1005. /** END OF AUDIO METHODS */
  1006. /** BEGIN OF VIDIO METHODS */
  1007. /**
  1008. * Set up the local video view. The video canvus is initialized with video display setting. And it could be called before entering a channel.
  1009. *
  1010. * @param local the canvas is composed of view, renderMode and uid. How to initialize 'local'? please take a look at 'AgoraRtcVideoCanvas'
  1011. *
  1012. * @return 0 when executed successfully. return negative value if failed.
  1013. */
  1014. - (int)setupLocalVideo:(AgoraRtcVideoCanvas*)local;
  1015. /**
  1016. * Set up the remote video view. The video canvus is initialized with video display setting. It could be called after receiving the remote video streams to configure the video settings.
  1017. *
  1018. * @param remote the canvas is composed of view, renderMode and uid. How to initialize 'remote'? please take a look at 'AgoraRtcVideoCanvas'
  1019. *
  1020. * @return 0 when executed successfully. return negative value if failed.
  1021. */
  1022. - (int)setupRemoteVideo:(AgoraRtcVideoCanvas*)remote;
  1023. /**
  1024. * Configure display setting of local view. And it could be called mutiple times during a call.
  1025. *
  1026. * @param mode There are Hidden(1), Fit(2) and Adaptive(3) mode. Please take a look at definition of enum AgoraRtcRenderMode
  1027. *
  1028. * @return 0 when executed successfully. return negative value if failed.
  1029. */
  1030. - (int)setLocalRenderMode:(AgoraRtcRenderMode) mode;
  1031. /**
  1032. * Configure display setting of remote view. And it could be called mutiple times during a call.
  1033. *
  1034. * @param uid The user id of remote view.
  1035. * @param mode There are Hidden(1), Fit(2) and Adaptive(3) mode. Please take a look at definition of enum AgoraRtcRenderMode
  1036. *
  1037. * @return 0 when executed successfully. return negative value if failed.
  1038. */
  1039. - (int)setRemoteRenderMode: (NSUInteger)uid
  1040. mode:(AgoraRtcRenderMode) mode;
  1041. /**
  1042. * API deprecated. Please refer to open source https://github.com/AgoraLab/AgoraDemo, the function "onSwitchRemoteUsers" in demo agora-easycall-ios-oc
  1043. * Switches between video display views of two different users.
  1044. *
  1045. * @param uid1 The user ID of the user whose video is to be switched.
  1046. * @param uid2 The user ID of another user whose video is to be switched.
  1047. *
  1048. * @return 0 when executed successfully. return negative value if failed.
  1049. */
  1050. - (int)switchView:(NSUInteger)uid1
  1051. andAnother:(NSUInteger)uid2 __deprecated;
  1052. /**
  1053. * Switches between front and back cameras.
  1054. *
  1055. * @return 0 when executed successfully. return negative value if failed.
  1056. */
  1057. - (int)switchCamera;
  1058. /**
  1059. * set video profile, including resolution, fps, kbps
  1060. *
  1061. * @param profile enumeration definition about the video resolution, fps and max kbps
  1062. *
  1063. * @return 0 when executed successfully. return negative value if failed.
  1064. */
  1065. - (int)setVideoProfile:(AgoraRtcVideoProfile)profile
  1066. swapWidthAndHeight:(BOOL)swapWidthAndHeight;
  1067. /**
  1068. * Enable / disable sending local video streams to the network.
  1069. *
  1070. * @param mute YES: stop sending local video stream to the network, NO: start sending local video stream.
  1071. *
  1072. * @return 0 when executed successfully. return negative value if failed.
  1073. */
  1074. - (int)muteLocalVideoStream:(BOOL)mute;
  1075. /**
  1076. * Enables / disables playing all remote callers’ video streams.
  1077. *
  1078. * @param mute YES: stop playing, NO: start playing.
  1079. *
  1080. * @return 0 when executed successfully. return negative value if failed.
  1081. */
  1082. - (int)muteAllRemoteVideoStreams:(BOOL)mute;
  1083. /**
  1084. * Enable / disable a remote user's video stream
  1085. *
  1086. * @param uid The remote user id
  1087. * @param mute YES: discard the video stream from remote user, NO: start receiving remote video stream.
  1088. *
  1089. * @return 0 when executed successfully. return negative value if failed.
  1090. */
  1091. - (int)muteRemoteVideoStream:(NSUInteger)uid
  1092. mute:(BOOL)mute;
  1093. /** END OF VIDIO METHODS */
  1094. /**
  1095. * Specifies the SDK output log file.
  1096. *
  1097. * @param filePath The full file path of the log file.
  1098. *
  1099. * @return 0 when executed successfully. return negative value if failed.
  1100. */
  1101. - (int)setLogFile:(NSString*)filePath;
  1102. /**
  1103. * Specifiy the log level of output
  1104. *
  1105. * @param filter The log level
  1106. *
  1107. * @return 0 when executed successfully. return negative value if failed.
  1108. */
  1109. - (int)setLogFilter:(NSUInteger)filter;
  1110. /**
  1111. * Renew channel key, refresh the new key into agora engine. APP should call this API when SDK reports error ERR_CHANNEL_KEY_EXPIRED.
  1112. *
  1113. * @param channelKey new channel key
  1114. *
  1115. * @return 0 when executed successfully. return negative value if failed.
  1116. */
  1117. - (int)renewChannelKey:(NSString*)channelKey;
  1118. /**
  1119. * Set the channel profile: such as communication, live broadcasting
  1120. *
  1121. * @param profile the channel profile
  1122. *
  1123. * @return 0 when executed successfully. return negative value if failed.
  1124. */
  1125. - (int)setChannelProfile:(AgoraRtcChannelProfile)profile;
  1126. /**
  1127. * Set the role of user: such as broadcaster, audience
  1128. *
  1129. * @param role the role of client
  1130. * @param permissionKey the permission key of role change
  1131. *
  1132. * @return 0 when executed successfully. return negative value if failed.
  1133. */
  1134. - (int)setClientRole:(AgoraRtcClientRole)role withKey: (NSString *)permissionKey;
  1135. - (int)enableDualStreamMode:(BOOL)enabled;
  1136. /**
  1137. * Specify encryption mode of AES encryption algorithm.
  1138. * @param [in] encryptionMode
  1139. * encryption mode of AES algorithm, could be one of the following:
  1140. * "aes-128-xts", "aes-256-xts".
  1141. * The default value is "aes-128-xts". specify NULL value will use default encryption mode.
  1142. * @return return 0 if success or an error code
  1143. */
  1144. - (int)setEncryptionMode:(NSString*)encryptionMode;
  1145. /**
  1146. * Specifying encryption secret enables built-in AES-128 encryption. Leaving channel will clear the secret specified in last channel
  1147. * @param [in] secret
  1148. * secret to enable encryption
  1149. * @return return 0 if success or an error code
  1150. */
  1151. - (int)setEncryptionSecret:(NSString*)secret;
  1152. - (int) setRemoteVideoStream: (NSUInteger) uid
  1153. type: (AgoraRtcVideoStreamType) streamType;
  1154. - (int) startRecordingService:(NSString*)recordingKey;
  1155. - (int) stopRecordingService:(NSString*)recordingKey;
  1156. - (int) refreshRecordingServiceStatus;
  1157. - (int)createDataStream:(NSInteger*)streamId
  1158. reliable:(BOOL)reliable
  1159. ordered:(BOOL)ordered;
  1160. - (int)sendStreamMessage:(NSInteger)streamId
  1161. data:(NSData*)data;
  1162. - (int)setRecordingAudioFrameParametersWithSampleRate:(NSInteger)sampleRate
  1163. channel:(NSInteger)channel
  1164. mode:(AgoraRtcRawAudioFrameOpMode)mode
  1165. samplesPerCall:(NSInteger)samplesPerCall;
  1166. - (int)setPlaybackAudioFrameParametersWithSampleRate:(NSInteger)sampleRate
  1167. channel:(NSInteger)channel
  1168. mode:(AgoraRtcRawAudioFrameOpMode)mode
  1169. samplesPerCall:(NSInteger)samplesPerCall;
  1170. - (int)setMixedAudioFrameParametersWithSampleRate:(NSInteger)sampleRate
  1171. samplesPerCall:(NSInteger)samplesPerCall;
  1172. /**
  1173. * adjust recording signal volume
  1174. *
  1175. * @param [in] volume range from 0 to 400
  1176. *
  1177. * @return return 0 if success or an error code
  1178. */
  1179. - (int)adjustRecordingSignalVolume:(NSInteger)volume;
  1180. /**
  1181. * adjust playback signal volume
  1182. *
  1183. * @param [in] volume range from 0 to 400
  1184. *
  1185. * @return return 0 if success or an error code
  1186. */
  1187. - (int)adjustPlaybackSignalVolume:(NSInteger)volume;
  1188. - (int)setHighQualityAudioParametersWithFullband:(BOOL)fullband
  1189. stereo:(BOOL)stereo
  1190. fullBitrate:(BOOL)fullBitrate;
  1191. - (int)enableInEarMonitoring:(BOOL)enabled;
  1192. - (int)enableWebSdkInteroperability:(BOOL)enabled;
  1193. - (int)setVideoQualityParameters:(BOOL)preferFrameRateOverImageQuality;
  1194. - (int)configPublisher:(AgoraPublisherConfiguration *)config;
  1195. - (int)setVideoCompositingLayout:(AgoraRtcVideoCompositingLayout*)layout;
  1196. - (int)clearVideoCompositingLayout;
  1197. #if (!(TARGET_OS_IPHONE) && (TARGET_OS_MAC))
  1198. /**
  1199. * Start screen capture
  1200. *
  1201. * @return 0 when executed successfully. return negative value if failed.
  1202. */
  1203. - (int)startScreenCapture:(NSUInteger)windowId withCaptureFreq: (int) captureFreq AndRect :(CGRect)rect;
  1204. /**
  1205. * Stop screen capture
  1206. *
  1207. * @return 0 when executed successfully. return negative value if failed.
  1208. */
  1209. - (int)stopScreenCapture;
  1210. /**
  1211. * Update screen capture Region
  1212. *
  1213. * @return 0 when executed successfully. return negative value if failed.
  1214. */
  1215. - (int)updateScreenCaptureRegion:(CGRect)rect;
  1216. - (void) monitorDeviceChange: (BOOL)enabled;
  1217. - (NSArray*) enumerateDevices:(AgoraRtcDeviceType)type; // return array of AgoraRtcDeviceInfo
  1218. - (NSString*) getDeviceId:(AgoraRtcDeviceType)type;
  1219. - (int) setDevice:(AgoraRtcDeviceType)type deviceId:(NSString *) deviceId;
  1220. - (int) getDeviceVolume:(AgoraRtcDeviceType)type;
  1221. - (int) setDeviceVolume:(AgoraRtcDeviceType)type volume:(int)volume;
  1222. - (int) startRecordingDeviceTest:(int) indicationInterval;
  1223. - (int) stopRecordingDeviceTest;
  1224. - (int) startPlaybackDeviceTest:(NSString *) audioFileName;
  1225. - (int) stopPlaybackDeviceTest;
  1226. - (int) startCaptureDeviceTest:(NSView *) view;
  1227. - (int) stopCaptureDeviceTest;
  1228. #endif
  1229. //Audio Effects
  1230. - (double) getEffectsVolume;
  1231. - (int) setEffectsVolume:(double) volume;
  1232. - (int) setVolumeOfEffect:(int) soundId
  1233. withVolume:(double) volume;
  1234. - (int) playEffect:(int) soundId
  1235. filePath:(NSString*)filePath
  1236. loop:(BOOL)loop
  1237. pitch:(double) pitch
  1238. pan:(double) pan
  1239. gain:(double) gain;
  1240. - (int) stopEffect:(int) soundId;
  1241. - (int) stopAllEffects;
  1242. - (int) preloadEffect:(int) soundId
  1243. filePath:(NSString*) filePath;
  1244. - (int) unloadEffect:(int) soundId;
  1245. - (int) pauseEffect:(int) soundId;
  1246. - (int) pauseAllEffects;
  1247. - (int) resumeEffect:(int) soundId;
  1248. - (int) resumeAllEffects;
  1249. /**
  1250. * External video source support
  1251. * For new application, uses this interface instead of the one in libvideoprp
  1252. */
  1253. // query whether texture can be supported (always returns YES)
  1254. //+ (BOOL) isTextureEncodeSupported;
  1255. // If external video source is to use, call this API before enableVideo/startPreview
  1256. - (void) setExternalVideoSource:(BOOL) enable useTexture:(BOOL)useTexture pushMode:(BOOL)pushMode;
  1257. // Push a video frame to SDK
  1258. - (BOOL) pushExternalVideoFrame:(AgoraVideoFrame *)frame;
  1259. @end