Nav apraksta

RtcEngine.native.js 52KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const tslib_1 = require("tslib");
  4. const react_native_1 = require("react-native");
  5. const { Agora } = react_native_1.NativeModules;
  6. const AgoraEventEmitter = new react_native_1.NativeEventEmitter(Agora);
  7. /**
  8. * RtcEngine is the javascript object for control agora native sdk through react native bridge.
  9. *
  10. * You can use the RtcEngine methods to create {@link init}
  11. *
  12. * Other methods of the RtcEngine object serve for agora native sdk and set up error logging.
  13. */
  14. class RtcEngine {
  15. /**
  16. * Creates a RtcEngine Object internal.
  17. *
  18. * This method creates and start event observer. You should call this method once.
  19. * @example `RtcEngine.init(option)`
  20. * @param options Defines the property of the client, see {@link Option} for details.
  21. */
  22. static init(options) {
  23. Agora.init(options);
  24. }
  25. /**
  26. * join specified channel
  27. *
  28. * This method joins and begin rendering the video stream. when join succeeds.
  29. * Otherwise, it will invoke error by the event
  30. * @param channelName
  31. * @param uid
  32. * @param token
  33. * @param info
  34. */
  35. static joinChannel(channelName, uid, token, info) {
  36. return Agora.joinChannel({ channelName, uid, token, info });
  37. }
  38. /**
  39. * Registers a user account.
  40. *
  41. * Once registered, the user account can be used to identify the local user when the user joins the channel. After the user successfully registers a user account, the SDK triggers the `on("localUserRegistered", callback)` on the local client, reporting the user ID and user account of the local user.
  42. * To join a channel with a user account, you can choose either of the following:
  43. * Call the {@link registerLocalUserAccount} method to create a user account, and then the {@link joinChannelWithUserAccount} method to join the channel.
  44. * Call the {@link joinChannelWithUserAccount} method to join the channel.
  45. *
  46. * @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.
  47. *
  48. * @param userAccount
  49. * @returns Promise<any>
  50. */
  51. static registerLocalUserAccount(userAccount) {
  52. return Agora.registerLocalUserAccount({ userAccount });
  53. }
  54. /**
  55. * Joins the channel with a user account.
  56. *
  57. * After the user successfully joins the channel, the SDK triggers the following callbacks:
  58. *
  59. * The local client: `on("localUserRegistered", callback)` and `on("joinChannelSuccess", callback)`.
  60. * The remote client: `on("userJoined", callback)` and `on("userInfoUpdated", callback)`, if the user joining the channel is in the Communication profile, or is a BROADCASTER in the Live Broadcast profile.
  61. *
  62. * @note To ensure smooth communication, use the same parameter type to identify the user. For example, if a user joins the channel with a user ID, then ensure all the other users use the user ID too. The same applies to the user account. If a user joins the channel with the Agora Web SDK, ensure that the uid of the user is set to the same parameter type.
  63. *
  64. * @param channelName
  65. * @param userAccount
  66. * @param token
  67. * @returns Promise<any>
  68. */
  69. static joinChannelWithUserAccount(channelName, userAccount, token) {
  70. return Agora.joinChannelWithUserAccount({ channelName, userAccount, token });
  71. }
  72. /**
  73. * Gets the user information by passing in the user account.
  74. *
  75. * After receiving the "userInfoUpdated" callback, you can call this method to get the user ID of the remote user from the {@link AgoraUserInfo} object by passing in the userAccount.
  76. * @param uid
  77. * @returns Promise<{@link AgoraUserInfo}>
  78. */
  79. static getUserInfoByUid(uid) {
  80. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  81. if (react_native_1.Platform.OS === 'android') {
  82. const _uid = this.Uint32ToInt32(uid);
  83. let result = yield Agora.getUserInfoByUid(_uid);
  84. result.uid = this.Uint32ToInt32(result.uid);
  85. return result;
  86. }
  87. return Agora.getUserInfoByUid(uid);
  88. });
  89. }
  90. /**
  91. * Gets the user information by passing in the user account.
  92. *
  93. * After receiving the "userInfoUpdated" callback, you can call this method to get the user ID of the remote user from the {@link AgoraUserInfo} object by passing in the userAccount.
  94. * @param userAccount
  95. * @returns Promise<{@link AgoraUserInfo}>
  96. */
  97. static getUserInfoByUserAccount(userAccount) {
  98. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  99. if (react_native_1.Platform.OS === 'android') {
  100. let result = yield Agora.getUserInfoByUserAccount(userAccount);
  101. result.uid = this.Uint32ToInt32(result.uid);
  102. return result;
  103. }
  104. return Agora.getUserInfoByUserAccount(userAccount);
  105. });
  106. }
  107. /**
  108. * add event listener
  109. *
  110. * This method subscribes specified eventType and run listener. You should call this method at first.
  111. *
  112. * @event listener
  113. *
  114. * ---
  115. * name | description | usage |
  116. * error | occurs when emit error | on("error", evt) |
  117. * warning | occurs when emit warning | on("warning", evt) |
  118. * messageReceived | occurs when message received | on("messageReceived", evt) |
  119. * localInvitationReceivedByPeer | occurs when local inviation received by peer | on("localInvitationReceivedByPeer", evt) |
  120. * localInvitationAccepted | occurs when local invitation accepted | on("localInvitationAccepted", evt) |
  121. * localInvitationRefused | occurs when local invitation refused | on("localInvitationRefused", evt) |
  122. * localInvitationCanceled | occurs when local invitation canceled | on("localInvitationCanceled", evt) |
  123. * localInvitationFailure | occurs when local invitation failure | on("localInvitationFailure", evt) |
  124. * remoteInvitationFailure | occurs when remote invitation failure | on("remoteInvitationFailure", evt) |
  125. * remoteInvitationReceived | occurs when remote invitation received | on("remoteInvitationReceived", evt) |
  126. * remoteInvitationAccepted | occurs when remote invitation accepted | on("remoteInvitationAccepted", evt) |
  127. * remoteInvitationRefused | occurs when remote invitation refused | on("remoteInvitationRefused", evt) |
  128. * remoteInvitationCanceled | occurs when remote invitation canceled | on("remoteInvitationCanceled", evt) |
  129. * channelMessageReceived | occurs when received channel message | on("channelMessageReceived", evt) |
  130. * channelMemberJoined | occurs when some one joined in the subscribed channel | on("channelMemberJoined", evt) |
  131. * channelMemberLeft | occurs when sone one left from u subscribed channel | on("channelMemberLeft", evt) |
  132. * tokenExpired | occurs when token has expired | on("tokenExpired", evt) |
  133. * apiCallExecute | occurs when apiCallExecute emit, this event is api call monitor | on("apiCallExecute", evt) |
  134. * joinChannelSuccess | occurs when joinChannel success | on("joinChannelSuccess", evt) |
  135. * rejoinChannelSuccess | occurs when rejoinChannel success | on("rejoinChannelSuccess", evt) |
  136. * leaveChannel | occurs when leaveChannel success | on("leaveChannel", evt) |
  137. * clientRoleChanged | occurs when setClientRole changed | on("clientRoleChanged", evt) |
  138. * userJoined | occurs when remote user joined | on("userJoined", evt) |
  139. * userOffline | this event occurs when remote user offline in rtc mode, this events only occurs host user offline in live mode | on("userOffline", evt) |
  140. * connectionStateChanged | occurs when sdk connection changed state | on("connectionStateChanged", evt) |
  141. * connectionLost | occurs when sdk connection lost | on("connectionLost", evt) |
  142. * tokenPrivilegeWillExpire | occurs when token will expire | on("tokenPrivilegeWillExpire", evt) |
  143. * requestToken | occurs when token expired | on("requestToken") |
  144. * microphoneEnabled | occurs when microphone enable state changed | on("microphoneEnabled", evt) |
  145. * audioVolumeIndication | occurs when audio volume indication changed | on("audioVolumeIndication", evt) |
  146. * activeSpeaker | occurs when detect active speaker | on("activeSpeaker", evt) |
  147. * firstLocalAudioFrame | occurs when sent first audio frame on local | on("firstLocalAudioFrame", evt) |
  148. * firstRemoteAudioFrame | occurs when received first audio frame from remote side | on("firstRemoteAudioFrame", evt) |
  149. * firstRemoteAudioDecoded | occurs when first remote audio decoded | on("firstRemoteAudioDecoded", evt) |
  150. * firstLocalVideoFrame | occurs when sent first video frame on local | on("firstLocalVideoFrame", evt) |
  151. * firstRemoteVideoDecoded | occurs when received first video frame from remote side decoded | on("firstRemoteVideoDecoded", evt) |
  152. * firstRemoteVideoFrame | occurs when received first video frame from remote side | on("firstRemoteVideoFrame", evt) |
  153. * userMuteAudio | occurs when user mute audio | on("userMuteAudio", evt) |
  154. * userMuteVideo | occurs when user mute video | on("userMuteVideo", evt) |
  155. * userEnableVideo | occurs when remote side's user change video enable state | on("userEnableVideo", evt) |
  156. * userEnableLocalVideo | occurs when user change video enable state on local | on("userEnableLocalVideo", evt) |
  157. * videoSizeChanged | occurs when change local or remote side video size or rotation | on("videoSizeChanged", evt) |
  158. * remoteVideoStateChanged | occurs when remote video state has any changed | on("remoteVideoStateChanged", evt) |
  159. * localPublishFallbackToAudioOnly | occurs when published stream from local side fallback to audio stream | on("localPublishFallbackToAudioOnly", evt) |
  160. * remoteSubscribeFallbackToAudioOnly | occurs when subscribed side's stream fallback to audio stream | on("remoteSubscribeFallbackToAudioOnly", evt) |
  161. * audioRouteChanged | occurs when local audio route changed | on("audioRouteChanged", evt) |
  162. * cameraFocusAreaChanged | occurs when a camera focus area changed | on("cameraFocusAreaChanged", evt) |
  163. * cameraExposureAreaChanged | occurs when a camera exposure area changed | on("cameraExposureAreaChanged", evt) |
  164. * rtcStats | occurs when reports the statistics of the current call session once every two seconds. | on("rtcStats", evt) |
  165. * lastmileQuality | occurs when reports the last mile network quality of the local user once every two seconds before the user joins a channel.| on("lastmileQuality", evt) |
  166. * networkQuality | occurs when reports the last mile network quality of each user in the channel once every two seconds.| on("networkQuality", evt) |
  167. * localVideoStats | occurs when reports local video statistics | on("localVideoStats", evt) |
  168. * remoteVideoStats | occurs when reports remote video statistics| on("remoteVideoStats", evt) |
  169. * remoteAudioStats | occurs when reports remote audio statistics| on("remoteAudioStats", evt) |
  170. * audioTransportStatsOfUid | occurs when reports transport-layer statistics of each remote audio stream. | on("audioTransportStatsOfUid", evt) |
  171. * videoTransportStatsOfUid | occurs when reports transport-layer statistics of each remote video stream.| on("videoTransportStatsOfUid", evt) |
  172. * audioEffectFinish | occurs when the local audio effect playback finishes. | on("audioEffectFinish", evt) |
  173. * streamPublished | occurs when addPublishStreamUrl success| on("streamPublished", evt) |
  174. * streamUnpublish | occurs when removePublishStreamUrl success| on("streamUnpublish", evt) |
  175. * transcodingUpdate | occurs when the cdn live streaming settings are updated | on("transcodingUpdate", evt) |
  176. * streamInjectedStatus | occurs when report the status of online injecting stream to a live broadcast | on("streamInjectedStatus", evt) |
  177. * mediaEngineLoaded | occurs when the media engine loaded | on("mediaEngineLoaded", evt) |
  178. * mediaEngineStartCall | occurs when the media engine call starts | on("mediaEngineStartCall", evt) |
  179. * startEchoTestWithInterval | occurs when startEchoTestWithInterval success | on("startEchoTestWithInterval", evt) |
  180. * audioMixingStateChanged | occurs when reports the local audio mixing state changed | on("audioMixingStateChanged", evt) |
  181. * lastmileProbeTestResult | occurs when reports the last-mile network probe result.| on("lastmileProbeTestResult", evt) |
  182. * rtmpStreamingStateChanged | occurs when reports the rtmp injecting stream state changed | on("rtmpStreamingStateChanged", evt) |
  183. * localVideoChanged | occurs when the local video changed | on("localVideoChanged", evt) |
  184. * networkTypeChanged | occurs when the device network type changed | on("networkTypeChanged", evt) |
  185. * mediaMetaDataReceived | occurs when you received media meta data from the remote side through sendMediaData | on("mediaMetaDataReceived", evt) |
  186. * localUserRegistered | occurs when you register user account success | on("localUserRegistered", evt) |
  187. * userInfoUpdated | occurs when you peer side using user account join channel | on("userInfoUpdated", evt) |
  188. * ---
  189. *
  190. * @param eventType
  191. * @param listener
  192. * @return any
  193. */
  194. static on(eventType, listener) {
  195. // convert int32 to uint32
  196. if ([
  197. 'joinChannelSuccess',
  198. 'rejoinChannelSuccess',
  199. 'userJoined',
  200. 'userOffline',
  201. 'occurStreamMessageError',
  202. 'receiveStreamMessage',
  203. 'activeSpeaker',
  204. 'firstRemoteAudioFrame',
  205. 'firstRemoteVideoDecoded',
  206. 'firstRemoteVideoFrame',
  207. 'userMuteAudio',
  208. 'userMuteVideo',
  209. 'userEnableVideo',
  210. 'userEnableLocalVideo',
  211. 'videoSizeChanged',
  212. 'firstRemoteAudioDecoded',
  213. 'remoteVideoStateChanged',
  214. 'remoteSubscribeFallbackToAudioOnly',
  215. 'networkQuality',
  216. 'streamInjectedStatus',
  217. 'localUserRegistered'
  218. ].indexOf(eventType) != -1) {
  219. AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
  220. const uint32_uid = new Uint32Array(1);
  221. uint32_uid[0] = args.uid;
  222. args.uid = uint32_uid[0];
  223. // convert int32 streamId to uint32
  224. if (args.streamId) {
  225. const uint32_streamId = new Uint32Array(1);
  226. uint32_streamId[0] = args.streamId;
  227. args.streamId = uint32_streamId[0];
  228. }
  229. listener(args);
  230. });
  231. return;
  232. }
  233. if (['userInfoUpdated'].indexOf(eventType) != -1) {
  234. AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
  235. const uint32_uid = new Uint32Array(1);
  236. uint32_uid[0] = args.uid;
  237. args.uid = uint32_uid[0];
  238. const uint32_peer_uid = new Uint32Array(1);
  239. uint32_peer_uid[0] = args.peer.uid;
  240. args.peer.uid = uint32_peer_uid[0];
  241. listener(args);
  242. });
  243. return;
  244. }
  245. if (['audioVolumeIndication'].indexOf(eventType) != -1) {
  246. AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
  247. args.speakers.map((speaker) => {
  248. const uint32_uid = new Uint32Array(1);
  249. uint32_uid[0] = speaker.uid;
  250. return Object.assign({}, speaker, { uid: uint32_uid[0] });
  251. });
  252. listener(args);
  253. });
  254. return;
  255. }
  256. if ([
  257. 'remoteAudioStats',
  258. 'remoteVideoStats',
  259. 'audioTransportStatsOfUid',
  260. 'videoTransportStatsOfUid',
  261. ].indexOf(eventType) != -1) {
  262. AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, (args) => {
  263. const uint32_uid = new Uint32Array(1);
  264. uint32_uid[0] = args.stats.uid;
  265. args.stats.uid = uint32_uid[0];
  266. listener(args);
  267. });
  268. return;
  269. }
  270. AgoraEventEmitter.addListener(`${RtcEngine.AG_PREFIX}${eventType}`, listener);
  271. }
  272. /**
  273. * @deprecated removeAllListeners
  274. */
  275. static removeAllListeners() {
  276. console.warn("removeAllListeners method already deprecated");
  277. }
  278. /**
  279. * @deprecated off
  280. * @param mode
  281. */
  282. static off(evt) {
  283. console.warn("off method already deprecated");
  284. }
  285. /**
  286. * renew token
  287. *
  288. * This method renews a new token.
  289. * @param token
  290. */
  291. static renewToken(token) {
  292. return Agora.renewToken(token);
  293. }
  294. /**
  295. * enable websdk interoperability
  296. *
  297. * This method used to enable websdk interoperability, so that it can connect with agora websdk apps.
  298. *
  299. * @param enabled
  300. * @return Promise<{success, value}>
  301. */
  302. static enableWebSdkInteroperability(enabled) {
  303. return Agora.enableWebSdkInteroperability(enabled);
  304. }
  305. /**
  306. * get agora native sdk connection state
  307. *
  308. * This method gets agora native sdk connection state
  309. * @return Promise<{state: (connection state)}>
  310. */
  311. static getConnectionState() {
  312. return Agora.getConnectionState();
  313. }
  314. /**
  315. * change the client role
  316. *
  317. * This method changes the client of role.
  318. * @param role (audience: 0, host: 1)
  319. */
  320. static setClientRole(role) {
  321. return Agora.setClientRole(role);
  322. }
  323. /**
  324. * leave channel
  325. *
  326. * This method leaves the joined channel, then your video view will not render ever.
  327. * You should call it, when you dont need render video stream.
  328. *
  329. * @return Promise<null>
  330. */
  331. static leaveChannel() {
  332. return Agora.leaveChannel();
  333. }
  334. /**
  335. * destroy
  336. *
  337. * This method stops event subscribe and destroy the RtcEngine instance's.
  338. * You should call it, when you want to destroy the engine.
  339. *
  340. * @return void
  341. */
  342. static destroy() {
  343. return Agora.destroy();
  344. }
  345. /**
  346. * set local video render mode
  347. *
  348. * This method calls native sdk render mode for local video.
  349. * @param mode
  350. * @return Promise<any>
  351. */
  352. static setLocalRenderMode(mode) {
  353. return Agora.setLocalRenderMode(mode);
  354. }
  355. /**
  356. * set the specified remote video render mode
  357. *
  358. * This method calls native sdk render mode for the specified remote video.
  359. *
  360. * @param uid
  361. * @param mode
  362. * @return Promise<any>
  363. */
  364. static setRemoteRenderMode(uid, mode) {
  365. let uint32 = react_native_1.Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
  366. return Agora.setRemoteRenderMode(uint32, mode);
  367. }
  368. /**
  369. * start video preview
  370. *
  371. * This method start video preview for video.
  372. * @return Promise<any>
  373. */
  374. static startPreview() {
  375. return Agora.startPreview();
  376. }
  377. /**
  378. * stop video preview
  379. *
  380. * This method stops video preview for video.
  381. * @return Promise<any>
  382. */
  383. static stopPreview() {
  384. return Agora.stopPreview();
  385. }
  386. /**
  387. * set enable speaker phone
  388. *
  389. * This method set the speaker phone enable or disable by pass boolean parameter.
  390. * @param enabled
  391. * @return Promise<any>
  392. */
  393. static setEnableSpeakerphone(enabled) {
  394. return Agora.setEnableSpeakerphone(enabled);
  395. }
  396. /**
  397. * set default audio speaker
  398. *
  399. * This method set the default audio speaker enable or disable by pass boolean parameter.
  400. * @param enabled
  401. * @return Promise<any>
  402. */
  403. static setDefaultAudioRouteToSpeakerphone(enabled) {
  404. return Agora.setDefaultAudioRouteToSpeakerphone(enabled);
  405. }
  406. /**
  407. * set default mute all remote audio streams
  408. *
  409. * This method set default mute all remote audio streams enable or not by pass boolean parameter.
  410. * @param enabled
  411. * @return Promise<any>
  412. */
  413. static setDefaultMuteAllRemoteAudioStreams(enabled) {
  414. return Agora.setDefaultMuteAllRemoteAudioStreams(enabled);
  415. }
  416. /**
  417. * enable video
  418. *
  419. * This method enables video.
  420. * @return Promise<any>
  421. */
  422. static enableVideo() {
  423. return Agora.enableVideo();
  424. }
  425. /**
  426. * disable video
  427. *
  428. * This method disables video.
  429. * @return Promise<any>
  430. */
  431. static disableVideo() {
  432. return Agora.disableVideo();
  433. }
  434. /**
  435. * enable local video
  436. *
  437. * This method enables the local video by the boolean parameter.
  438. * @param enabled
  439. * @return Promise<any>
  440. */
  441. static enableLocalVideo(enabled) {
  442. return Agora.enableLocalVideo(enabled);
  443. }
  444. /**
  445. * mute local video stream
  446. *
  447. * This method mutes video stream by the boolean parameter.
  448. * @param muted
  449. * @return Promise<any>
  450. */
  451. static muteLocalVideoStream(muted) {
  452. return Agora.muteLocalVideoStream(muted);
  453. }
  454. /**
  455. * mute all remote video streams
  456. *
  457. * This method mutes all remote streams by the boolean parameter.
  458. * @param muted
  459. * @return Promise<any>
  460. */
  461. static muteAllRemoteVideoStreams(muted) {
  462. return Agora.muteAllRemoteVideoStreams(muted);
  463. }
  464. /**
  465. * @ignore Uint32ToInt32
  466. */
  467. static Uint32ToInt32(num) {
  468. const int32 = new Int32Array(1);
  469. int32[0] = num;
  470. return int32[0];
  471. }
  472. /**
  473. * mute specified remote video stream.
  474. *
  475. * This method mutes remote video stream by the number of uid and boolean parameter.
  476. * @param uid
  477. * @param muted
  478. * @return Promise<any>
  479. */
  480. static muteRemoteVideoStream(uid, muted) {
  481. let uint32 = react_native_1.Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
  482. return Agora.muteRemoteVideoStream(uint32, muted);
  483. }
  484. /**
  485. * set default mute all remote video stream
  486. *
  487. * This method mutes all remote video stream default by the boolean parameter.
  488. * @param muted
  489. * @return Promise<any>
  490. */
  491. static setDefaultMuteAllRemoteVideoStreams(muted) {
  492. return Agora.setDefaultMuteAllRemoteVideoStreams(muted);
  493. }
  494. /**
  495. * enable audio
  496. *
  497. * This method enables audio
  498. * @return Promise<any>
  499. */
  500. static enableAudio() {
  501. return Agora.enableAudio();
  502. }
  503. /**
  504. * disable audio
  505. *
  506. * This method disables audio
  507. * @return Promise<any>
  508. */
  509. static disableAudio() {
  510. return Agora.disableAudio();
  511. }
  512. /**
  513. * enable local audio
  514. *
  515. * This method enables local audio by the boolean parameter.
  516. * @param enabled
  517. * @return Promise<any>
  518. */
  519. static enableLocalAudio(enabled) {
  520. return Agora.enableLocalAudio(enabled);
  521. }
  522. /**
  523. * mute local audio stream
  524. *
  525. * This method mutes the local audio stream by muted.
  526. * @param muted
  527. * @return Promise<any>
  528. */
  529. static disableLocalAudio(muted) {
  530. return Agora.disableLocalAudio(muted);
  531. }
  532. /**
  533. * mute all remote audio streams
  534. *
  535. * This method mutes all remote audio streams by muted
  536. * @param muted boolean
  537. * @return Promise<any>
  538. */
  539. static muteAllRemoteAudioStreams(muted) {
  540. return Agora.muteAllRemoteAudioStreams(muted);
  541. }
  542. /**
  543. * mute specified remote audio stream by muted
  544. *
  545. * This method mutes specified remote audio stream by number uid and boolean muted.
  546. * @param uid
  547. * @param muted
  548. * @return Promise<any>
  549. */
  550. static muteRemoteAudioStream(uid, muted) {
  551. let uint32 = react_native_1.Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
  552. return Agora.muteRemoteAudioStream(uint32, muted);
  553. }
  554. /**
  555. * adjust recording signal volume
  556. *
  557. * This method adjusts recording your signal by volume.
  558. * @param volume
  559. * @return Promise<any>
  560. */
  561. static adjustRecordingSignalVolume(volume) {
  562. return Agora.adjustRecordingSignalVolume(volume);
  563. }
  564. /**
  565. * adjust playback signal volume
  566. *
  567. * This method adjusts playback signal by volume.
  568. * @param volume
  569. * @return Promise<any>
  570. */
  571. static adjustPlaybackSignalVolume(volume) {
  572. return Agora.adjustPlaybackSignalVolume(volume);
  573. }
  574. /**
  575. * enable audio volume indication
  576. *
  577. * This method enables audio volume by interval and smooth
  578. * @param interval
  579. * @param smooth
  580. * @return Promise<any>
  581. */
  582. static enableAudioVolumeIndication(interval, smooth) {
  583. return Agora.enableAudioVolumeIndication(interval, smooth);
  584. }
  585. /**
  586. * check for mobile phone speaker enabled
  587. *
  588. * This method checks the phone speaker is enabled
  589. * @param callback
  590. * @return any
  591. */
  592. static methodisSpeakerphoneEnabled(callback) {
  593. return Agora.methodisSpeakerphoneEnabled(callback);
  594. }
  595. /**
  596. * enable in-ear monitor
  597. *
  598. * This method enables in-ear monitoring by boolean parameter enabled
  599. *
  600. * @param enabled
  601. * @return Promise<any>
  602. */
  603. static enableInEarMonitoring(enabled) {
  604. return Agora.enableInEarMonitoring(enabled);
  605. }
  606. /**
  607. * set in-ear monitoring volume
  608. *
  609. * This method sets the in-ear-monitoring volume by number parameter volume
  610. *
  611. * @param volume
  612. * @return Promise<any>
  613. */
  614. static setInEarMonitoringVolume(volume) {
  615. return Agora.setInEarMonitoringVolume(volume);
  616. }
  617. /**
  618. * set local voice pitch
  619. *
  620. * This method sets the local voice pitch by float parameter pitch
  621. *
  622. * @param pitch
  623. * @return Promise<any>
  624. */
  625. static setLocalVoicePitch(pitch) {
  626. return Agora.setLocalVoicePitch(pitch);
  627. }
  628. /**
  629. * set local voice equalization
  630. *
  631. * This method set local video equalization of band frequency by enum band number and number of gain
  632. *
  633. * @param band
  634. * @param gain
  635. * @return Promise<any>
  636. */
  637. static setLocalVoiceEqualization(band, gain) {
  638. Agora.setLocalVoiceEqualization(band, gain);
  639. }
  640. /**
  641. * set local voice reverb
  642. *
  643. * This method sets local voice by reverb and value
  644. * @param reverb
  645. * @param value
  646. */
  647. static setLocalVoiceReverb(reverb, value) {
  648. Agora.setLocalVoiceReverb(reverb, value);
  649. }
  650. /**
  651. * start audio mixing
  652. *
  653. * This method will start audio mixing by option config
  654. *
  655. * @param options {@link AudioMixingOption}
  656. */
  657. static startAudioMixing(options) {
  658. Agora.startAudioMixing(options);
  659. }
  660. /**
  661. * stop audio mixing
  662. *
  663. * This methods stops for audio mixing.
  664. */
  665. static stopAudioMixing() {
  666. Agora.stopAudioMixing();
  667. }
  668. /**
  669. * pause audio mixing
  670. *
  671. * This method pauses for audio mixing.
  672. */
  673. static pauseAudioMixing() {
  674. Agora.pauseAudioMixing();
  675. }
  676. /**
  677. * resume audio mixing
  678. *
  679. * This method resumes for audio mixing.
  680. */
  681. static resumeAudioMixing() {
  682. Agora.resumeAudioMixing();
  683. }
  684. /**
  685. * adjust audio mixing volume
  686. *
  687. * This method adjusts audio mixing volume by the volume number parameter
  688. * @param volume
  689. */
  690. static adjustAudioMixingVolume(volume) {
  691. Agora.adjustAudioMixingVolume(volume);
  692. }
  693. /**
  694. * adjust audio mixing playout volume
  695. *
  696. * This method adjusts audio mixing playout by the volume parameter
  697. * @param volume
  698. */
  699. static adjustAudioMixingPlayoutVolume(volume) {
  700. Agora.adjustAudioMixingPlayoutVolume(volume);
  701. }
  702. /**
  703. * adjust audio mixing publish volume
  704. *
  705. * This method adjusts audio mixing publish by the volume paraemter
  706. * @param volume
  707. */
  708. static adjustAudioMixingPublishVolume(volume) {
  709. Agora.adjustAudioMixingPublishVolume(volume);
  710. }
  711. /**
  712. * get audio mixing duration
  713. *
  714. * This method gets the audio mixing duration
  715. * @return Promise<{success, value}>
  716. */
  717. static getAudioMixingDuration() {
  718. return Agora.getAudioMixingDuration();
  719. }
  720. /**
  721. * get audio mixing current position
  722. *
  723. * This method gets audio mixing current position value.
  724. * @return Promise<{success, value}>
  725. */
  726. static getAudioMixingCurrentPosition() {
  727. return Agora.getAudioMixingCurrentPosition();
  728. }
  729. /**
  730. * set audio mixing position
  731. *
  732. * This method sets audio mixing position by the parameter pos
  733. * @param pos
  734. */
  735. static setAudioMixingPosition(pos) {
  736. return Agora.setAudioMixingPosition(pos);
  737. }
  738. /**
  739. * get effects of volume
  740. *
  741. * This methods get audio mixing effects volume value.
  742. * @return Promise<{success, value}>
  743. */
  744. static getEffectsVolume() {
  745. return Agora.getEffectsVolume();
  746. }
  747. /**
  748. * set effects volume
  749. *
  750. * This methods set audio mixing effects volume by float parameter.
  751. * @param volume
  752. * @return Promise<{success, value}>
  753. */
  754. static setEffectsVolume(volume) {
  755. return Agora.setEffectsVolume(volume);
  756. }
  757. /**
  758. * set volume for playing effects.
  759. *
  760. * This methods set for playing audio mixing effects
  761. * @return Promise<{success, value}>
  762. */
  763. static setVolumeOfEffect(volume) {
  764. return Agora.setVolumeOfEffect(volume);
  765. }
  766. /**
  767. * play specified effect for audio mixing
  768. *
  769. * This methos plays the specified effect of audio mixing file by option config.
  770. * @param options {@link PlayEffectOption}
  771. * @return Promise<{success, value}>
  772. */
  773. static playEffect(options) {
  774. return Agora.playEffect(options);
  775. }
  776. /**
  777. * stop play effect for audio mixing
  778. *
  779. * This methods stops the specified effect for audio mixing file by soundid.
  780. * @param sounid
  781. * @return Promise<{success, value}>
  782. */
  783. static stopEffect(soundId) {
  784. return Agora.stopEffect(soundId);
  785. }
  786. /**
  787. * stop play all for effect audio mixing.
  788. *
  789. * This methods stops all effect audio mixing.
  790. * @return Promise<{success, value}>
  791. */
  792. static stopAllEffects() {
  793. return Agora.stopAllEffects();
  794. }
  795. /**
  796. * preload effect for audio mixing file.
  797. *
  798. * This methods preloads the specified audio mixing file to memory by the soundid
  799. * @param soundid
  800. * @param filepath
  801. * @return Promise<{success, value}>
  802. */
  803. static preloadEffect(soundId, filepath) {
  804. return Agora.preloadEffect(soundId, filepath);
  805. }
  806. /**
  807. * unload effect
  808. *
  809. * This methods unload the already loaded audio mixing file from memory by the soundid.
  810. * @param soundid
  811. * @return Promise<{success, value}>
  812. */
  813. static unloadEffect(soundId) {
  814. return Agora.unloadEffect(soundId);
  815. }
  816. /**
  817. * pause the specified effect for audio mixing by soundid
  818. *
  819. * This method pauses the specified effect for audio mixing by soundid.
  820. * @param soundid
  821. * @return Promise<{success, value}>
  822. */
  823. static pauseEffect(soundId) {
  824. return Agora.pauseEffect(soundId);
  825. }
  826. /**
  827. * pause all effects for audio mixing
  828. *
  829. * This method pause all effects for audio mixing.
  830. * @param soundid
  831. * @return Promise<{success, value}>
  832. */
  833. static pauseAllEffects() {
  834. return Agora.pauseAllEffects();
  835. }
  836. /**
  837. * resume audio mixing effect by the specified soundid
  838. *
  839. * This method resumes audio mixing effect by the specified soundid
  840. * @param soundid
  841. * @return Promise<{success, value}>
  842. */
  843. static resumeEffect(soundId) {
  844. return Agora.resumeEffect(soundId);
  845. }
  846. /**
  847. * resume all audio mixing effects.
  848. *
  849. * This method resumes all audio mixing effects.
  850. * @return Promise<{success, value}>
  851. */
  852. static resumeAllEffects() {
  853. return Agora.resumeAllEffects();
  854. }
  855. /**
  856. * start audio recording by quality
  857. *
  858. * This method start audio recording by quality config
  859. * @param options {@link AudioRecordingOption}
  860. * @return Promise<{success, value}>
  861. */
  862. static startAudioRecording(options) {
  863. return Agora.startAudioRecording(options);
  864. }
  865. /**
  866. * stop audio recording
  867. *
  868. * This method stops audio recording.
  869. * @return Promise<{success, value}>
  870. */
  871. static stopAudioRecording() {
  872. return Agora.stopAudioRecording();
  873. }
  874. /**
  875. * set audio session operation restriction
  876. *
  877. * The SDK and the app can both configure the audio session by default. The app may occasionally use other apps or third-party components to manipulate the audio session and restrict the SDK from doing so. This method allows the app to restrict the SDK’s manipulation of the audio session.
  878. * You can call this method at any time to return the control of the audio sessions to the SDK.
  879. * This method restricts the SDK’s manipulation of the audio session. Any operation to the audio session relies solely on the app, other apps, or third-party components.
  880. * @notice iOS support only
  881. */
  882. static setAudioSessionOperationRestriction() {
  883. if (react_native_1.Platform.OS != 'ios')
  884. throw Error(`setAudioSessionOperationRestriction is not support on your platform. Please check the details in react-native-agora docs`);
  885. Agora.setAudioSessionOperationRestriction();
  886. }
  887. /**
  888. * @deprecated startEchoTest
  889. * startEchoTest
  890. */
  891. /**
  892. * @deprecated isCameraAutoFocusFaceModeSupported
  893. * @deprecated isCameraExposurePositionSupported
  894. * @deprecated isCameraFocusSupported
  895. * @deprecated isCameraTorchSupported
  896. * @deprecated isCameraZoomSupported
  897. * instead use {@method getCameraInfo}
  898. */
  899. /**
  900. * stop echo test
  901. *
  902. * This method stop launched an audio call test.
  903. * @return Promise<{success, value}>
  904. */
  905. static stopEchoTest() {
  906. return Agora.stopEchoTest();
  907. }
  908. /**
  909. * enable lastmile test
  910. *
  911. * This method enables the network connection qualit test.
  912. *
  913. * @return Promise<{success, value}>
  914. */
  915. static enableLastmileTest() {
  916. return Agora.enableLastmileTest();
  917. }
  918. /**
  919. * disable lastmile test
  920. *
  921. * This method disable the network connection qualit test.
  922. *
  923. * @return Promise<{success, value}>
  924. */
  925. static disableLastmileTest() {
  926. return Agora.disableLastmileTest();
  927. }
  928. /**
  929. * set recording audio frame parameters
  930. *
  931. * This method Sets the audio recording format for the audioFrame callback.
  932. *
  933. * @param options {@link RecordingAudioFrameOption}
  934. * @return Promise<{success, value}>
  935. */
  936. static setRecordingAudioFrameParameters(options) {
  937. return Agora.setRecordingAudioFrameParameters(options);
  938. }
  939. /**
  940. * set playback audio frame parameters
  941. *
  942. * This method Sets the audio frame format for the playbackFrame callback.
  943. *
  944. * @param options {@link AudioFrameOption}
  945. * @return Promise<{success, value}>
  946. */
  947. static setPlaybackAudioFrameParameters(options) {
  948. return Agora.setPlaybackAudioFrameParameters(options);
  949. }
  950. /**
  951. * set mixed audio frame parameters
  952. *
  953. * This method Sets the audio frame format for the mixedAudioFrame callback.
  954. *
  955. * @param options {@link MixedAudioFrameOption}
  956. * @return Promise<{success, value}>
  957. */
  958. static setMixedAudioFrameParameters(options) {
  959. return Agora.setMixedAudioFrameParameters(options);
  960. }
  961. /**
  962. * add video watermark
  963. *
  964. * This method adds video watermark to the local video.
  965. *
  966. * @param options {@link ImageOption}
  967. * @return Promise<{success, value}>
  968. */
  969. static addVideoWatermark(options) {
  970. return Agora.addVideoWatermark(options);
  971. }
  972. /**
  973. * clear video watermarks
  974. *
  975. * This method removes the watermark image from the video stream added by addVideoWatermark.
  976. *
  977. * @return Promise<{success, value}>
  978. */
  979. static removclearVideoWatermarkse() {
  980. return Agora.clearVideoWatermarks();
  981. }
  982. /**
  983. * set local publish fallback
  984. *
  985. * This method sets the fallback option for the locally published video stream based on the network conditions.
  986. *
  987. * @param option {0, 1, 2} [more details](https://docs.agora.io/en/Video/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_constants.html#a3e453c93766e783a7e5eca05b1776238)
  988. * @return Promise<{success, value}>
  989. */
  990. static setLocalPublishFallbackOption(option) {
  991. return Agora.setLocalPublishFallbackOption(option);
  992. }
  993. /**
  994. * set remote publish fallback
  995. *
  996. * This method sets the fallback option for the remotely subscribed video stream based on the network conditions.
  997. *
  998. * @param option {0, 1, 2} [more details](https://docs.agora.io/en/Video/API%20Reference/java/classio_1_1agora_1_1rtc_1_1_constants.html#a3e453c93766e783a7e5eca05b1776238)
  999. * @return Promise<{success, value}>
  1000. */
  1001. static setRemoteSubscribeFallbackOption(option) {
  1002. return Agora.setRemoteSubscribeFallbackOption(option);
  1003. }
  1004. /**
  1005. * enable dual stream mode
  1006. *
  1007. * This method enables the dual stream by parameter mode.
  1008. *
  1009. * @param enabled
  1010. * @return Promise<{success, value}>
  1011. */
  1012. static enableDualStreamMode(enabled) {
  1013. return Agora.enableDualStreamMode(enabled);
  1014. }
  1015. /**
  1016. * set remote video stream type
  1017. *
  1018. * This method sets the remote video stream type by uid and streamType.
  1019. *
  1020. * @param options {@link VideoStreamOption}
  1021. * @return Promise<{success, value}>
  1022. */
  1023. static setRemoteVideoStreamType(options) {
  1024. return Agora.setRemoteVideoStreamType(options);
  1025. }
  1026. /**
  1027. * set remote default video stream type
  1028. *
  1029. * This method sets the default video stream type.
  1030. *
  1031. * @param options {@link DefaultVideoStreamOption}
  1032. * @return Promise<{success, value}>
  1033. */
  1034. static setRemoteDefaultVideoStreamType(options) {
  1035. return Agora.setRemoteDefaultVideoStreamType(options);
  1036. }
  1037. /**
  1038. * add inject stream url
  1039. *
  1040. * This method injects an online media stream to a live broadcast.
  1041. *
  1042. * @param options {@link InjectStreamOption}
  1043. * @return Promise<{success, value}>
  1044. */
  1045. static addInjectStreamUrl(options) {
  1046. return Agora.addInjectStreamUrl(options);
  1047. }
  1048. /**
  1049. * remove inject stream url
  1050. *
  1051. * This method removes stream by addInjectsStreamUrl.
  1052. *
  1053. * @param options {@link RemoveInjectStreamOption}
  1054. * @return Promise<{success, value}>
  1055. */
  1056. static removeInjectStreamUrl(options) {
  1057. return Agora.removeInjectStreamUrl(options);
  1058. }
  1059. /**
  1060. * @deprecated sendMessage
  1061. * sendMessage
  1062. */
  1063. static sendMessage() {
  1064. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  1065. return console.warn("sendMessage already deprecated");
  1066. });
  1067. }
  1068. /**
  1069. * @deprecated createDataStream
  1070. * createDataStream
  1071. */
  1072. /**
  1073. * @deprecated setupLocalVideo
  1074. * setupLocalVideo
  1075. */
  1076. /**
  1077. * @deprecated setupRemoteVideo
  1078. * setupRemoteVideo
  1079. */
  1080. /**
  1081. * @deprecated setVideoQualityParameters
  1082. * setVideoQualityParameters
  1083. */
  1084. /**
  1085. * set local video mirror mode
  1086. *
  1087. * This method sets local video mirror mode
  1088. *
  1089. * @param mode
  1090. * @return Promise<{success, value}>
  1091. */
  1092. static setLocalVideoMirrorMode(mode) {
  1093. return Agora.setLocalVideoMirrorMode(mode);
  1094. }
  1095. /**
  1096. * switch camera
  1097. *
  1098. * This method switches camera between front and rear.
  1099. *
  1100. * @return Promise<{success, value}>
  1101. */
  1102. static switchCamera() {
  1103. return Agora.switchCamera();
  1104. }
  1105. /**
  1106. * set camera zoom ratio
  1107. *
  1108. * This method sets the camera zoom ratio.
  1109. *
  1110. * @param zoomFactor
  1111. * @return Promise<{success, value}>
  1112. */
  1113. static setCameraZoomFactor(zoomFactor) {
  1114. return Agora.setCameraZoomFactor(zoomFactor);
  1115. }
  1116. /**
  1117. * get camera max zoom ratio
  1118. *
  1119. * This method gets the camera maximum zoom ratio.
  1120. *
  1121. * @notice Android Only
  1122. * @return Promise<{success, value}>
  1123. */
  1124. static getCameraMaxZoomFactor() {
  1125. return Agora.getCameraMaxZoomFactor();
  1126. }
  1127. /**
  1128. * set camera focus position in preview
  1129. *
  1130. * This method sets the mannual focus position.
  1131. *
  1132. * @param options {@link PositionOption}
  1133. * @return Promise<{success, value}>
  1134. */
  1135. static setCameraFocusPositionInPreview(options) {
  1136. return Agora.setCameraFocusPositionInPreview(options);
  1137. }
  1138. /**
  1139. * set camera exposure position
  1140. *
  1141. * This method sets the mannual exposure position.
  1142. *
  1143. * @param options {@link PositionOption}
  1144. * @return Promise<{success, value}>
  1145. */
  1146. static setCameraExposurePosition(options) {
  1147. return Agora.setCameraExposurePosition(options);
  1148. }
  1149. /**
  1150. * set camera torch on
  1151. *
  1152. * This method enables the camera flash function.
  1153. *
  1154. * @param enabled
  1155. * @return Promise<{success, value}>
  1156. */
  1157. static setCameraTorchOn(enabled) {
  1158. return Agora.setCameraTorchOn(enabled);
  1159. }
  1160. /**
  1161. * set enable auto focus face mode
  1162. *
  1163. * This method enables auto-focus face mode function.
  1164. *
  1165. * @param enabled boolean
  1166. * @return Promise<{success, value}>
  1167. */
  1168. static setCameraAutoFocusFaceModeEnabled(enabled) {
  1169. return Agora.setCameraAutoFocusFaceModeEnabled(enabled);
  1170. }
  1171. /**
  1172. * get call id
  1173. *
  1174. * This method is used to get call id.
  1175. *
  1176. * @return Promise<{success, value}>
  1177. */
  1178. static getCallId() {
  1179. return Agora.getCallId();
  1180. }
  1181. /**
  1182. * set log file and log filter
  1183. *
  1184. * This method sets the log file generated path and specified the log level.
  1185. *
  1186. * @param filepath string
  1187. * @param level enum
  1188. * @param maxfileSize integer (KB)
  1189. * @return Promise<{success, value}>
  1190. */
  1191. static setLog(filepath, level, maxfileSize) {
  1192. return Agora.setLog(filepath, level, maxfileSize);
  1193. }
  1194. /**
  1195. * add publish stream url
  1196. *
  1197. * This method add publish stream by option.
  1198. *
  1199. * @param options {@link PublishStreamOption}
  1200. * @return Promise<{success, value}>
  1201. */
  1202. static addPublishStreamUrl(options) {
  1203. return Agora.addPublishStreamUrl(options);
  1204. }
  1205. /**
  1206. * remove publish stream url
  1207. *
  1208. * This method remove publish stream by options.
  1209. *
  1210. * @param options {@link RemovePublishStreamOption}
  1211. * @return Promise<{success, value}>
  1212. */
  1213. static removePublishStreamUrl(options) {
  1214. return Agora.removePublishStreamUrl(options);
  1215. }
  1216. /**
  1217. * set live transcoding
  1218. *
  1219. * This method sets the video layout and audio settings for CDN live.
  1220. *
  1221. * @param options {@link LiveTranscoding}
  1222. * @return Promise<{success, value}>
  1223. */
  1224. static setLiveTranscoding(options) {
  1225. return Agora.setLiveTranscoding(options);
  1226. }
  1227. /**
  1228. * get sdk version
  1229. *
  1230. * This method gets the sdk version details and passed it into callback function
  1231. *
  1232. * @param callback to handle resolve from getSdkVersion
  1233. * @param errorHandler to handle reject error from getSdkVersion
  1234. * @return any
  1235. */
  1236. static getSdkVersion(callback, errorHandler) {
  1237. return Agora.getSdkVersion().then(callback).catch(errorHandler);
  1238. }
  1239. /**
  1240. * mute local audio stream
  1241. *
  1242. * This method sends/stops sending the local audio.
  1243. *
  1244. * @param enabled
  1245. * @return Promise<any>
  1246. */
  1247. static muteLocalAudioStream(enabled) {
  1248. return Agora.muteLocalAudioStream(enabled);
  1249. }
  1250. /**
  1251. * video pre-process/post-process
  1252. *
  1253. * This method enables/disables image enhancement and sets the options.
  1254. *
  1255. * @param enable boolean
  1256. * @param options {@link BeautyOptions}
  1257. * @return Promise<any>
  1258. */
  1259. static setBeautyEffectOptions(enabled, options) {
  1260. return Agora.setBeautyEffectOptions(enabled, options);
  1261. }
  1262. /**
  1263. * set local voice change
  1264. *
  1265. * This method changes local speaker voice with voiceChanger
  1266. *
  1267. * @param voiceChanger integer
  1268. * @voiceChanger value ranges [
  1269. * 0: "The original voice",
  1270. * 1: "An old man’s voice",
  1271. * 2: "A little boy’s voice.",
  1272. * 3: "A little girl’s voice.",
  1273. * 4: "TBD",
  1274. * 5: "Ethereal vocal effects.",
  1275. * 6: "Hulk’s voice."
  1276. * ]
  1277. * @return Promise<any>
  1278. */
  1279. static setLocalVoiceChanger(voiceChanger) {
  1280. return Agora.setLocalVoiceChanger(voiceChanger);
  1281. }
  1282. /**
  1283. * set the preset local voice reverberation effect.
  1284. *
  1285. * This method sets the preset local voice reverberation effect.
  1286. *
  1287. * @param preset integer
  1288. * @return Promise<any>
  1289. */
  1290. static setLocalVoiceReverbPreset(preset) {
  1291. return Agora.setLocalVoiceReverbPreset(preset);
  1292. }
  1293. /**
  1294. * control stereo panning for remote users
  1295. *
  1296. * This method enables/disables stereo panning for remote users.
  1297. *
  1298. * @param enabled boolean
  1299. * @return Promise<any>
  1300. */
  1301. static enableSoundPositionIndication(enabled) {
  1302. return Agora.enableSoundPositionIndication(enabled);
  1303. }
  1304. /**
  1305. * set the sound position of a remote user
  1306. *
  1307. * This method sets the sound position of a remote user by uid
  1308. *
  1309. * @param uid number | The ID of the remote user
  1310. * @param pan float | The sound position of the remote user. The value ranges from -1.0 to 1.0
  1311. * @pan
  1312. * 0.0: the remote sound comes from the front.
  1313. * -1.0: the remote sound comes from the left.
  1314. * 1.0: the remote sound comes from the right.
  1315. * @param gain float | Gain of the remote user. The value ranges from 0.0 to 100.0. The default value is 100.0 (the original gain of the remote user). The smaller the value, the less the gain.
  1316. * @return Promise<any>
  1317. */
  1318. static setRemoteVoicePosition(uid, pan, gain) {
  1319. let uint32 = react_native_1.Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
  1320. return Agora.setRemoteVoicePosition(uint32, pan, gain);
  1321. }
  1322. /**
  1323. * start the lastmile probe test
  1324. *
  1325. * This method start the last-mile network probe test before joining a channel to get the uplink and downlink last-mile network statistics, including the bandwidth, packet loss, jitter, and round-trip time (RTT).
  1326. *
  1327. * @param config LastmileProbeConfig {@link LastmileProbeConfig}
  1328. *
  1329. * event onLastmileQuality: the SDK triggers this callback within two seconds depending on the network conditions. This callback rates the network conditions with a score and is more closely linked to the user experience.
  1330. * event onLastmileProbeResult: the SDK triggers this callback within 30 seconds depending on the network conditions. This callback returns the real-time statistics of the network conditions and is more objective.
  1331. * @return Promise<any>
  1332. */
  1333. static startLastmileProbeTest(config) {
  1334. return Agora.startLastmileProbeTest(config);
  1335. }
  1336. /**
  1337. * stop the lastmile probe test
  1338. *
  1339. * This method stop the lastmile probe test.
  1340. *
  1341. * @return Promise<any>
  1342. */
  1343. static stopLastmileProbeTest() {
  1344. return Agora.stopLastmileProbeTest();
  1345. }
  1346. /**
  1347. * sets the priority of a remote user's media stream.
  1348. *
  1349. * note: Use this method with the setRemoteSubscribeFallbackOption method. If the fallback function is enabled for a subscribed stream, the SDK ensures the high-priority user gets the best possible stream quality.
  1350. *
  1351. * This method sets the priority of a remote user's media stream.
  1352. * @param uid number
  1353. * @param userPriority number | The value range is [50 is "user's priority is hgih", 100 is "the default user's priority is normal"]
  1354. *
  1355. * @return Promise<any>
  1356. */
  1357. static setRemoteUserPriority(uid, userPrority) {
  1358. let uint32 = react_native_1.Platform.OS === 'android' ? this.Uint32ToInt32(uid) : uid;
  1359. return Agora.setRemoteUserPriority(uint32, userPrority);
  1360. }
  1361. /**
  1362. * start an audio call test.
  1363. *
  1364. * note:
  1365. * Call this method before joining a channel.
  1366. * After calling this method, call the stopEchoTest method to end the test. Otherwise, the app cannot run the next echo test, or call the joinchannel method.
  1367. * In the Live-broadcast profile, only a host can call this method.
  1368. * This method will start an audio call test with interval parameter.
  1369. * In the audio call test, you record your voice. If the recording plays back within the set time interval, the audio devices and the network connection are working properly.
  1370. *
  1371. * @param interval number
  1372. *
  1373. * @return Promise<any>
  1374. */
  1375. static startEchoTestWithInterval(interval) {
  1376. return Agora.startEchoTestWithInterval(interval);
  1377. }
  1378. /**
  1379. * set the camera capture preference.
  1380. *
  1381. * note:
  1382. * For a video call or live broadcast, generally the SDK controls the camera output parameters. When the default camera capture settings do not meet special requirements or cause performance problems, we recommend using this method to set the camera capture preference:
  1383. * If the resolution or frame rate of the captured raw video data are higher than those set by setVideoEncoderConfiguration, processing video frames requires extra CPU and RAM usage and degrades performance. We recommend setting config as CAPTURER_OUTPUT_PREFERENCE_PERFORMANCE(1) to avoid such problems.
  1384. * If you do not need local video preview or are willing to sacrifice preview quality, we recommend setting config as CAPTURER_OUTPUT_PREFERENCE_PERFORMANCE(1) to optimize CPU and RAM usage.
  1385. * If you want better quality for the local video preview, we recommend setting config as CAPTURER_OUTPUT_PREFERENCE_PREVIEW(2).
  1386. *
  1387. * This method will set the camera capture preference.
  1388. *
  1389. * @param config {@link CameraCapturerConfiguration}
  1390. *
  1391. * @return Promise<any>
  1392. */
  1393. static setCameraCapturerConfiguration(config) {
  1394. return Agora.setCameraCapturerConfiguration(config);
  1395. }
  1396. /**
  1397. * Gets the audio mixing volume for local playback.
  1398. *
  1399. * note:
  1400. * This method helps troubleshoot audio volume related issues.
  1401. *
  1402. * @return Promise<any>
  1403. */
  1404. static getAudioMixingPlayoutVolume() {
  1405. return Agora.getAudioMixingPlayoutVolume();
  1406. }
  1407. /**
  1408. * Gets the audio mixing volume for publishing.
  1409. *
  1410. * note:
  1411. * This method helps troubleshoot audio volume related issues.
  1412. *
  1413. * @return Promise<any>
  1414. */
  1415. static getAudioMixingPublishVolume() {
  1416. return Agora.getAudioMixingPublishVolume();
  1417. }
  1418. /**
  1419. * sendMediaData for media observer.
  1420. *
  1421. * note:
  1422. * This method needs you invoke registerMediaMetadataObserver success first and you could send media data through interval media observer feature.
  1423. * The data have limit length is 1024 bytes, if you pass data length bigger than limit it will failed.
  1424. * @param data String: 1024 bytes limit
  1425. * @return Promise<any>
  1426. */
  1427. static sendMediaData(data) {
  1428. return Agora.sendMediaData(data);
  1429. }
  1430. /**
  1431. * Registers the metadata observer.
  1432. *
  1433. * note:
  1434. * This method only work in live mode
  1435. * This method enables you to add synchronized metadata in the video stream for more diversified live broadcast interactions, such as sending shopping links, digital coupons, and online quizzes.
  1436. * This method trigger 'mediaMetaDataReceived' event, here is example:
  1437. * ```javascript
  1438. * RtcEngine.on("mediaMetaDataReceived", (data) => {
  1439. * console.log("mediaMetaDataReceived", data);
  1440. * })
  1441. * ```
  1442. * @return Promise<any>
  1443. */
  1444. static registerMediaMetadataObserver() {
  1445. return Agora.registerMediaMetadataObserver();
  1446. }
  1447. /**
  1448. * Get local device camera support info
  1449. *
  1450. * note:
  1451. * This method returns your current device camera support info.
  1452. * ```javascript
  1453. * RtcEngine.getCameraInfo().then(info => {
  1454. * console.log("your currrent camera", info);
  1455. * })
  1456. * ```
  1457. * @return Promise{cameraSupportInfo}>
  1458. */
  1459. static getCameraInfo() {
  1460. return tslib_1.__awaiter(this, void 0, void 0, function* () {
  1461. return Agora.getCameraInfo();
  1462. });
  1463. }
  1464. }
  1465. /**
  1466. * @ignore AG_PREFIX
  1467. */
  1468. RtcEngine.AG_PREFIX = 'ag_rtc';
  1469. exports.default = RtcEngine;
  1470. //# sourceMappingURL=RtcEngine.native.js.map