No Description

RtcEngine.native.js 52KB

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