Ingen beskrivning

RtcEngine.native.js 39KB

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