infobip-rtc
Version:
Infobip RTC JavaScript SDK - Infobip WebRTC API Implementation
157 lines • 7.51 kB
JavaScript
import { DefaultCall } from "./DefaultCall";
import { CallsApiEvent } from "../event/CallsApiEvents";
import { DefaultLocalWebrtcCapturer } from "./DefaultLocalWebrtcCapturer";
import { DefaultServerWebrtcCapturer } from "./DefaultServerWebrtcCapturer";
export class DefaultWebrtcCall extends DefaultCall {
constructor(webrtcCallOptions, sourceEndpoint, destinationEndpoint) {
super(webrtcCallOptions, sourceEndpoint, destinationEndpoint);
this.isRemoteCameraVideo = false;
this.isRemoteScreenShare = false;
}
pauseIncomingVideo() {
this.applicationCall.pauseIncomingVideo();
}
resumeIncomingVideo() {
this.applicationCall.resumeIncomingVideo();
}
cameraVideo(cameraVideo) {
return this.applicationCall.cameraVideo(cameraVideo);
}
hasCameraVideo() {
return this.applicationCall.hasCameraVideo();
}
hasRemoteCameraVideo() {
return this.isRemoteCameraVideo;
}
screenShare(screenShare) {
return this.applicationCall.screenShare(screenShare);
}
startScreenShare(displayOptions) {
return this.applicationCall.startScreenShare(displayOptions);
}
stopScreenShare() {
return this.applicationCall.stopScreenShare();
}
hasScreenShare() {
return this.applicationCall.hasScreenShare();
}
hasRemoteScreenShare() {
return this.isRemoteScreenShare;
}
setVideoInputDevice(deviceId) {
return this.applicationCall.setVideoInputDevice(deviceId);
}
cameraOrientation() {
return this.applicationCall.cameraOrientation();
}
setCameraOrientation(cameraOrientation) {
return this.applicationCall.setCameraOrientation(cameraOrientation);
}
options() {
return this.basicCallOptions;
}
videoFilter() {
return this.applicationCall.videoFilter();
}
setVideoFilter(videoFilter) {
return this.applicationCall.setVideoFilter(videoFilter);
}
clearVideoFilter() {
return this.applicationCall.clearVideoFilter();
}
localCapturer() {
var _a;
return (_a = this.localWebrtcCapturer) !== null && _a !== void 0 ? _a : (this.localWebrtcCapturer = new DefaultLocalWebrtcCapturer(this.applicationCall.localCapturer(), [this.sourceEndpoint, this.destinationEndpoint].filter(endpoint => endpoint !== this.counterpart())[0].identifier, this.counterpart().identifier));
}
serverCapturer() {
var _a;
return (_a = this.serverWebrtcCapturer) !== null && _a !== void 0 ? _a : (this.serverWebrtcCapturer = new DefaultServerWebrtcCapturer(this.applicationCall.serverCapturer(), [this.sourceEndpoint, this.destinationEndpoint].filter(endpoint => endpoint !== this.counterpart())[0].identifier, this.counterpart().identifier));
}
dataChannel() {
return this.applicationCall.dataChannel();
}
initEventHandlers() {
this.applicationCall.on(CallsApiEvent.RINGING, () => {
this.apiEventEmitter.emit(CallsApiEvent.RINGING, {});
});
this.applicationCall.on(CallsApiEvent.EARLY_MEDIA, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.EARLY_MEDIA, event);
});
this.applicationCall.on(CallsApiEvent.ESTABLISHED, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.ESTABLISHED, event);
});
this.applicationCall.on(CallsApiEvent.HANGUP, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.HANGUP, event);
});
this.applicationCall.on(CallsApiEvent.ERROR, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.ERROR, event);
});
this.applicationCall.on(CallsApiEvent.CAMERA_VIDEO_ADDED, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.CAMERA_VIDEO_ADDED, event);
});
this.applicationCall.on(CallsApiEvent.CAMERA_VIDEO_UPDATED, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.CAMERA_VIDEO_UPDATED, event);
});
this.applicationCall.on(CallsApiEvent.CAMERA_VIDEO_REMOVED, () => {
this.apiEventEmitter.emit(CallsApiEvent.CAMERA_VIDEO_REMOVED, {});
});
this.applicationCall.on(CallsApiEvent.SCREEN_SHARE_ADDED, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.SCREEN_SHARE_ADDED, event);
});
this.applicationCall.on(CallsApiEvent.SCREEN_SHARE_REMOVED, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.SCREEN_SHARE_REMOVED, event);
});
this.applicationCall.on(CallsApiEvent.PARTICIPANT_MUTED, () => {
this.apiEventEmitter.emit(CallsApiEvent.REMOTE_MUTED, {});
});
this.applicationCall.on(CallsApiEvent.PARTICIPANT_UNMUTED, () => {
this.apiEventEmitter.emit(CallsApiEvent.REMOTE_UNMUTED, {});
});
this.applicationCall.on(CallsApiEvent.PARTICIPANT_CAMERA_VIDEO_ADDED, (event) => {
this.isRemoteCameraVideo = true;
this.apiEventEmitter.emit(CallsApiEvent.REMOTE_CAMERA_VIDEO_ADDED, { stream: event.stream });
});
this.applicationCall.on(CallsApiEvent.PARTICIPANT_CAMERA_VIDEO_REMOVED, () => {
this.isRemoteCameraVideo = false;
this.apiEventEmitter.emit(CallsApiEvent.REMOTE_CAMERA_VIDEO_REMOVED, {});
});
this.applicationCall.on(CallsApiEvent.PARTICIPANT_SCREEN_SHARE_ADDED, (event) => {
this.isRemoteScreenShare = true;
this.apiEventEmitter.emit(CallsApiEvent.REMOTE_SCREEN_SHARE_ADDED, { stream: event.stream });
});
this.applicationCall.on(CallsApiEvent.PARTICIPANT_SCREEN_SHARE_REMOVED, () => {
this.isRemoteScreenShare = false;
this.apiEventEmitter.emit(CallsApiEvent.REMOTE_SCREEN_SHARE_REMOVED, {});
});
this.applicationCall.on(CallsApiEvent.NETWORK_QUALITY_CHANGED, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.NETWORK_QUALITY_CHANGED, event);
});
this.applicationCall.on(CallsApiEvent.PARTICIPANT_NETWORK_QUALITY_CHANGED, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.REMOTE_NETWORK_QUALITY_CHANGED, {
networkQuality: event.networkQuality
});
});
this.applicationCall.on(CallsApiEvent.PARTICIPANT_DISCONNECTED, () => {
this.apiEventEmitter.emit(CallsApiEvent.REMOTE_DISCONNECTED, {});
});
this.applicationCall.on(CallsApiEvent.PARTICIPANT_RECONNECTED, () => {
this.apiEventEmitter.emit(CallsApiEvent.REMOTE_RECONNECTED, {});
});
this.applicationCall.on(CallsApiEvent.DIALOG_JOINED, (event) => {
const remote = event.remote;
if (remote.endpoint.identifier === this.counterpart().identifier && remote.media.audio.muted) {
this.apiEventEmitter.emit(CallsApiEvent.REMOTE_MUTED, {});
}
});
this.applicationCall.on(CallsApiEvent.DIALOG_RECORDING_STARTED, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.CALL_RECORDING_STARTED, { recordingType: event.recordingType });
});
this.applicationCall.on(CallsApiEvent.RECONNECTING, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.RECONNECTING, event);
});
this.applicationCall.on(CallsApiEvent.RECONNECTED, (event) => {
this.apiEventEmitter.emit(CallsApiEvent.RECONNECTED, event);
});
}
}
//# sourceMappingURL=DefaultWebrtcCall.js.map