Bez popisu

RtcEngine.native.js 55KB

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