Nav apraksta

RtcEngine.native.js 37KB

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