No Description

RtcEngine.native.js 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const react_native_1 = require("react-native");
  4. const { Agora } = react_native_1.NativeModules;
  5. const AgoraEventEmitter = new react_native_1.NativeEventEmitter(Agora);
  6. class RtcEngine {
  7. static init(options) {
  8. this.removeEmitter();
  9. Agora.init(options);
  10. this.listeners = [];
  11. }
  12. static joinChannel(channelName, uid, token, info) {
  13. return Agora.joinChannel({ channelName, uid, token, info });
  14. }
  15. static eventEmitter(eventScheduler) {
  16. this.removeEmitter();
  17. // const events = EventSchedulerKeys;
  18. const events = [
  19. "onWarning",
  20. "onError",
  21. "onJoinChannelSuccess",
  22. "onRejoinChannelSuccess",
  23. "onLeaveChannel",
  24. "onClientRoleChanged",
  25. "onUserJoined",
  26. "onUserOffline",
  27. "onConnectionStateChanged",
  28. "onConnectionInterrupted",
  29. "onConnectionLost",
  30. "onConnectionBanned",
  31. "onApiCallExecuted",
  32. "onTokenPrivilegeWillExpire",
  33. "onRequestToken",
  34. "onMicrophoneEnabled",
  35. "onAudioVolumeIndication",
  36. "onActiveSpeaker",
  37. "onFirstLocalAudioFrame",
  38. "onFirstRemoteAudioFrame",
  39. "onVideoStopped",
  40. "onFirstLocalVideoFrame",
  41. "onFirstRemoteVideoDecoded",
  42. "onFirstRemoteVideoFrame",
  43. "onUserMuteAudio",
  44. "onUserMuteVideo",
  45. "onUserEnableVideo",
  46. "onUserEnableLocalVideo",
  47. "onVideoSizeChanged",
  48. "onRemoteVideoStateChanged",
  49. "onLocalPublishFallbackToAudioOnly",
  50. "onRemoteSubscribeFallbackToAudioOnly",
  51. "onAudioRouteChanged",
  52. "onCameraReady",
  53. "onCameraFocusAreaChanged",
  54. "onCameraExposureAreaChanged",
  55. "onAudioQuality",
  56. "onRtcStats",
  57. "onLastmileQuality",
  58. "onNetworkQuality",
  59. "onLocalVideoStats",
  60. "onRemoteVideoStats",
  61. "onRemoteAudioStats",
  62. "onLocalVideoStat",
  63. "onRemoteVideoStat",
  64. "onRemoteAudioTransportStats",
  65. "onRemoteVideoTransportStats",
  66. "onAudioMixingFinished",
  67. "onAudioEffectFinished",
  68. "onStreamPublished",
  69. "onStreamUnpublished",
  70. "onTranscodingUpdated",
  71. "onStreamInjectedStatus",
  72. "onStreamMessage",
  73. "onStreamMessageError",
  74. "onMediaEngineLoadSuccess",
  75. "onMediaEngineStartCallSuccess",
  76. ];
  77. for (let event of events) {
  78. const functor = eventScheduler[event];
  79. if (functor) {
  80. this.listeners.push(AgoraEventEmitter.addListener(event, msg => {
  81. functor(msg);
  82. }));
  83. }
  84. }
  85. }
  86. static removeEmitter() {
  87. if (this.listeners && this.listeners.length > 0) {
  88. for (let listener of this.listeners) {
  89. listener.remove();
  90. this.listeners = [];
  91. }
  92. }
  93. }
  94. static enableLastmileTest() {
  95. return Agora.enableLastmileTest();
  96. }
  97. static disableLastmileTest() {
  98. return Agora.disableLastmileTest();
  99. }
  100. static leaveChannel() {
  101. return Agora.leaveChannel();
  102. }
  103. static destroy() {
  104. Agora.destroy();
  105. }
  106. static setupLocalVideo(options) {
  107. Agora.setupLocalVideo(options);
  108. }
  109. static setupRemoteVideo(options) {
  110. Agora.setupRemoteVideo(options);
  111. }
  112. static startPreview() {
  113. Agora.startPreview();
  114. }
  115. static stopPreview() {
  116. Agora.stopPreview();
  117. }
  118. static setLiveTranscoding(options) {
  119. Agora.setLiveTranscoding(options);
  120. }
  121. static setLocalRenderMode(mode) {
  122. Agora.setLocalRenderMode(mode);
  123. }
  124. static setRemoteRenderMode(uid, mode) {
  125. Agora.setRemoteRenderMode(uid, mode);
  126. }
  127. static enableAudioVolumeIndication(interval, smooth) {
  128. Agora.enableAudioVolumeIndication(interval, smooth);
  129. }
  130. static switchCamera() {
  131. return Agora.switchCamera();
  132. }
  133. static enableVideo() {
  134. Agora.enableVideo();
  135. }
  136. static disableVideo() {
  137. Agora.disableVideo();
  138. }
  139. static setEnableSpeakerphone(status) {
  140. Agora.setEnableSpeakerphone(status);
  141. }
  142. static muteLocalAudioStream(status) {
  143. Agora.muteLocalAudioStream(status);
  144. }
  145. static muteRemoteAudioStream(uid, status) {
  146. Agora.muteRemoteAudioStream(uid, status);
  147. }
  148. static muteAllRemoteAudioStreams(status) {
  149. Agora.muteAllRemoteAudioStreams(status);
  150. }
  151. static setCameraTorchOn(status) {
  152. return Agora.setCameraTorchOn(status);
  153. }
  154. static setCameraAutoFocusFaceModeEnabled(status) {
  155. return Agora.setCameraAutoFocusFaceModeEnabled(status);
  156. }
  157. static setDefaultAudioRouteToSpeakerphone(status) {
  158. Agora.setDefaultAudioRouteToSpeakerphone(status);
  159. }
  160. static muteLocalVideoStream(status) {
  161. Agora.muteLocalVideoStream(status);
  162. }
  163. static enableLocalVideo(status) {
  164. Agora.enableLocalVideo(status);
  165. }
  166. static muteAllRemoteVideoStreams(status) {
  167. Agora.muteAllRemoteVideoStreams(status);
  168. }
  169. static muteRemoteVideoStream(uid, status) {
  170. Agora.muteRemoteVideoStream(uid, status);
  171. }
  172. static createDataStream(reliable, ordered) {
  173. return Agora.createDataStream(reliable, ordered);
  174. }
  175. static sendStreamMessage(streamId, data) {
  176. return Agora.sendStreamMessage(streamId, data);
  177. }
  178. static getSdkVersion(callback) {
  179. Agora.getSdkVersion().then(callback);
  180. }
  181. }
  182. exports.default = RtcEngine;
  183. ;
  184. //# sourceMappingURL=RtcEngine.native.js.map