No Description

RtcEngine.native.js 54KB

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