説明なし

RtcEngine.native.js 5.9KB

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