123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184 |
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- const react_native_1 = require("react-native");
- const { Agora } = react_native_1.NativeModules;
- const AgoraEventEmitter = new react_native_1.NativeEventEmitter(Agora);
- class RtcEngine {
- static init(options) {
- this.removeEmitter();
- Agora.init(options);
- this.listeners = [];
- }
- static joinChannel(channelName, uid, token, info) {
- return Agora.joinChannel({ channelName, uid, token, info });
- }
- static eventEmitter(eventScheduler) {
- this.removeEmitter();
- // const events = EventSchedulerKeys;
- const events = [
- "onWarning",
- "onError",
- "onJoinChannelSuccess",
- "onRejoinChannelSuccess",
- "onLeaveChannel",
- "onClientRoleChanged",
- "onUserJoined",
- "onUserOffline",
- "onConnectionStateChanged",
- "onConnectionInterrupted",
- "onConnectionLost",
- "onConnectionBanned",
- "onApiCallExecuted",
- "onTokenPrivilegeWillExpire",
- "onRequestToken",
- "onMicrophoneEnabled",
- "onAudioVolumeIndication",
- "onActiveSpeaker",
- "onFirstLocalAudioFrame",
- "onFirstRemoteAudioFrame",
- "onVideoStopped",
- "onFirstLocalVideoFrame",
- "onFirstRemoteVideoDecoded",
- "onFirstRemoteVideoFrame",
- "onUserMuteAudio",
- "onUserMuteVideo",
- "onUserEnableVideo",
- "onUserEnableLocalVideo",
- "onVideoSizeChanged",
- "onRemoteVideoStateChanged",
- "onLocalPublishFallbackToAudioOnly",
- "onRemoteSubscribeFallbackToAudioOnly",
- "onAudioRouteChanged",
- "onCameraReady",
- "onCameraFocusAreaChanged",
- "onCameraExposureAreaChanged",
- "onAudioQuality",
- "onRtcStats",
- "onLastmileQuality",
- "onNetworkQuality",
- "onLocalVideoStats",
- "onRemoteVideoStats",
- "onRemoteAudioStats",
- "onLocalVideoStat",
- "onRemoteVideoStat",
- "onRemoteAudioTransportStats",
- "onRemoteVideoTransportStats",
- "onAudioMixingFinished",
- "onAudioEffectFinished",
- "onStreamPublished",
- "onStreamUnpublished",
- "onTranscodingUpdated",
- "onStreamInjectedStatus",
- "onStreamMessage",
- "onStreamMessageError",
- "onMediaEngineLoadSuccess",
- "onMediaEngineStartCallSuccess",
- ];
- for (let event of events) {
- const functor = eventScheduler[event];
- if (functor) {
- this.listeners.push(AgoraEventEmitter.addListener(event, msg => {
- functor(msg);
- }));
- }
- }
- }
- static removeEmitter() {
- if (this.listeners && this.listeners.length > 0) {
- for (let listener of this.listeners) {
- listener.remove();
- this.listeners = [];
- }
- }
- }
- static enableLastmileTest() {
- return Agora.enableLastmileTest();
- }
- static disableLastmileTest() {
- return Agora.disableLastmileTest();
- }
- static leaveChannel() {
- return Agora.leaveChannel();
- }
- static destroy() {
- Agora.destroy();
- }
- static setupLocalVideo(options) {
- Agora.setupLocalVideo(options);
- }
- static setupRemoteVideo(options) {
- Agora.setupRemoteVideo(options);
- }
- static startPreview() {
- Agora.startPreview();
- }
- static stopPreview() {
- Agora.stopPreview();
- }
- static setLiveTranscoding(options) {
- Agora.setLiveTranscoding(options);
- }
- static setLocalRenderMode(mode) {
- Agora.setLocalRenderMode(mode);
- }
- static setRemoteRenderMode(uid, mode) {
- Agora.setRemoteRenderMode(uid, mode);
- }
- static enableAudioVolumeIndication(interval, smooth) {
- Agora.enableAudioVolumeIndication(interval, smooth);
- }
- static switchCamera() {
- return Agora.switchCamera();
- }
- static enableVideo() {
- Agora.enableVideo();
- }
- static disableVideo() {
- Agora.disableVideo();
- }
- static setEnableSpeakerphone(status) {
- Agora.setEnableSpeakerphone(status);
- }
- static muteLocalAudioStream(status) {
- Agora.muteLocalAudioStream(status);
- }
- static muteRemoteAudioStream(uid, status) {
- Agora.muteRemoteAudioStream(uid, status);
- }
- static muteAllRemoteAudioStreams(status) {
- Agora.muteAllRemoteAudioStreams(status);
- }
- static setCameraTorchOn(status) {
- return Agora.setCameraTorchOn(status);
- }
- static setCameraAutoFocusFaceModeEnabled(status) {
- return Agora.setCameraAutoFocusFaceModeEnabled(status);
- }
- static setDefaultAudioRouteToSpeakerphone(status) {
- Agora.setDefaultAudioRouteToSpeakerphone(status);
- }
- static muteLocalVideoStream(status) {
- Agora.muteLocalVideoStream(status);
- }
- static enableLocalVideo(status) {
- Agora.enableLocalVideo(status);
- }
- static muteAllRemoteVideoStreams(status) {
- Agora.muteAllRemoteVideoStreams(status);
- }
- static muteRemoteVideoStream(uid, status) {
- Agora.muteRemoteVideoStream(uid, status);
- }
- static createDataStream(reliable, ordered) {
- return Agora.createDataStream(reliable, ordered);
- }
- static sendStreamMessage(streamId, data) {
- return Agora.sendStreamMessage(streamId, data);
- }
- static getSdkVersion(callback) {
- Agora.getSdkVersion().then(callback);
- }
- }
- exports.default = RtcEngine;
- ;
- //# sourceMappingURL=RtcEngine.native.js.map
|