123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321 |
- "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
- */
- class RtcEngine {
- /**
- * init AgoraRtcEngine
- * @param options: Option
- */
- static init(options) {
- this.removeEmitter();
- Agora.init(options);
- this.listeners = [];
- }
- /**
- * join channel
- * @param channelName String for channel name
- * @param uid Number user id is optional
- * @param token String secure token
- * @param info Object extra info
- * @return Promise
- */
- static joinChannel(channelName, uid, token, info) {
- return Agora.joinChannel({ channelName, uid, token, info });
- }
- /**
- * RtcEngine events register
- * @param eventScheduler EventScheduler
- */
- 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);
- }));
- }
- }
- }
- /**
- * remove emitter
- */
- static removeEmitter() {
- if (this.listeners && this.listeners.length > 0) {
- for (let listener of this.listeners) {
- listener.remove();
- this.listeners = [];
- }
- }
- }
- /**
- * enableLastmileTest
- * @return Promise
- */
- static enableLastmileTest() {
- return Agora.enableLastmileTest();
- }
- /**
- * disableLastmileTest
- * @return Promise
- */
- static disableLastmileTest() {
- return Agora.disableLastmileTest();
- }
- /**
- * leaveChannel
- * @return Promise
- */
- static leaveChannel() {
- return Agora.leaveChannel();
- }
- /**
- * destroy AgoraRtcEngine
- */
- static destroy() {
- Agora.destroy();
- }
- /**
- * setupLocalVideo
- * @param options: VideoOption
- */
- static setupLocalVideo(options) {
- Agora.setupLocalVideo(options);
- }
- /**
- * setupRemoteVideo
- * @param options: VideoOption
- */
- static setupRemoteVideo(options) {
- Agora.setupRemoteVideo(options);
- }
- /**
- * start AgoraRtcEngine preview
- */
- static startPreview() {
- Agora.startPreview();
- }
- /**
- * stop AgoraRtcEngine preview
- */
- static stopPreview() {
- Agora.stopPreview();
- }
- /**
- * start live trancoding
- * @param options LiveTranscoding
- */
- static setLiveTranscoding(options) {
- Agora.setLiveTranscoding(options);
- }
- /**
- * setLocalRenderMode
- * @param mode Number
- */
- static setLocalRenderMode(mode) {
- Agora.setLocalRenderMode(mode);
- }
- /**
- * setRemoteRenderMode
- * @param uid Number
- * @param mode Number
- */
- static setRemoteRenderMode(uid, mode) {
- Agora.setRemoteRenderMode(uid, mode);
- }
- /**
- * enableAudioVolumeIndication
- * @param interval Number
- * @param smooth Number
- */
- static enableAudioVolumeIndication(interval, smooth) {
- Agora.enableAudioVolumeIndication(interval, smooth);
- }
- /**
- * switch camera
- * @return Promise
- */
- static switchCamera() {
- return Agora.switchCamera();
- }
- static enableVideo() {
- Agora.enableVideo();
- }
- static disableVideo() {
- Agora.disableVideo();
- }
- /**
- * setEnableSpeakerphone
- * @param status Boolena
- */
- static setEnableSpeakerphone(status) {
- Agora.setEnableSpeakerphone(status);
- }
- /**
- * muteLocalAudioStream
- * @param status Boolena
- */
- static muteLocalAudioStream(status) {
- Agora.muteLocalAudioStream(status);
- }
- /**
- * muteRemoteAudioStream
- * @param uid Number
- * @param status Boolean
- */
- static muteRemoteAudioStream(uid, status) {
- Agora.muteRemoteAudioStream(uid, status);
- }
- /**
- * muteAllRemoteAudioStreams
- * @param status Boolean
- */
- static muteAllRemoteAudioStreams(status) {
- Agora.muteAllRemoteAudioStreams(status);
- }
- /**
- * setCameraTorchOn
- * @param status Boolean
- * @return Promise
- */
- static setCameraTorchOn(status) {
- return Agora.setCameraTorchOn(status);
- }
- /**
- * setCameraAutoFocusFaceModeEnabled
- * @param status Boolean
- * @return Promise
- */
- static setCameraAutoFocusFaceModeEnabled(status) {
- return Agora.setCameraAutoFocusFaceModeEnabled(status);
- }
- /**
- * setDefaultAudioRouteToSpeakerphone
- * @param status Boolean
- * @return Promise
- */
- static setDefaultAudioRouteToSpeakerphone(status) {
- Agora.setDefaultAudioRouteToSpeakerphone(status);
- }
- /**
- * muteLocalVideoStream
- * @param status Boolean
- */
- static muteLocalVideoStream(status) {
- Agora.muteLocalVideoStream(status);
- }
- /**
- * enableLocalVideo
- * @param status Boolean
- */
- static enableLocalVideo(status) {
- Agora.enableLocalVideo(status);
- }
- /**
- * muteAllRemoteVideoStreams
- * @param status Boolean
- */
- static muteAllRemoteVideoStreams(status) {
- Agora.muteAllRemoteVideoStreams(status);
- }
- /**
- * muteRemoteVideoStream
- * @param status Boolean
- */
- static muteRemoteVideoStream(uid, status) {
- Agora.muteRemoteVideoStream(uid, status);
- }
- /**
- * createDataStream
- * @param reliable Boolean
- * @param ordered Boolean
- * @return Promise
- */
- static createDataStream(reliable, ordered) {
- return Agora.createDataStream({ reliable, ordered });
- }
- /**
- * sendStreamMessage
- * @param reliable Boolean
- * @param ordered Boolean
- * @return Promise
- */
- static sendStreamMessage(streamId, data) {
- return Agora.sendStreamMessage(streamId, data);
- }
- /**
- * getSdkVersion
- * @param callback Function
- */
- static getSdkVersion(callback) {
- Agora.getSdkVersion().then(callback);
- }
- }
- exports.default = RtcEngine;
- ;
- //# sourceMappingURL=RtcEngine.native.js.map
|