Ingen beskrivning

RtcEngine.native.ts 51KB

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