UNPKG

infobip-rtc

Version:

Infobip RTC JavaScript SDK - Infobip WebRTC API Implementation

37 lines 2.94 kB
import { FlowType } from "../FlowType"; import { WebrtcEndpoint } from "../../util/Endpoint"; import { DefaultWebrtcCall } from "./DefaultWebrtcCall"; import { ApplicationCallOptions } from "../options/ApplicationCallOptions"; import ValidationUtil from "./util/ValidationUtil"; import { InternalApplicationCallOptions } from "../options/InternalApplicationCallOptions"; import { getRecordingOptions } from "./util/CallOptionsUtil"; export class DefaultOutgoingWebrtcCall extends DefaultWebrtcCall { constructor(infobipRtc, webrtcCallOptions, currentUserIdentity, counterpartIdentity) { super(webrtcCallOptions, new WebrtcEndpoint(currentUserIdentity), new WebrtcEndpoint(counterpartIdentity)); let applicationCallOptions = this.mapOptions(counterpartIdentity, webrtcCallOptions); this.applicationCall = infobipRtc.callApplication(counterpartIdentity, applicationCallOptions); this.initEventHandlers(); } counterpart() { return this.destinationEndpoint; } mapOptions(counterpartIdentity, webrtcCallOptions) { if (webrtcCallOptions === null || webrtcCallOptions === void 0 ? void 0 : webrtcCallOptions.customData) { ValidationUtil.validateCustomData(webrtcCallOptions === null || webrtcCallOptions === void 0 ? void 0 : webrtcCallOptions.customData); } let internalCustomData = Object.assign(Object.assign(Object.assign({ to: counterpartIdentity, type: FlowType.WEBRTC.toString() }, getRecordingOptions(webrtcCallOptions)), { withDialog: "true" }), (webrtcCallOptions === null || webrtcCallOptions === void 0 ? void 0 : webrtcCallOptions.video) && { isVideo: "true" }); let applicationCallOptions = ApplicationCallOptions.builder() .setAudio(webrtcCallOptions === null || webrtcCallOptions === void 0 ? void 0 : webrtcCallOptions.audio) .setAudioOptions(webrtcCallOptions === null || webrtcCallOptions === void 0 ? void 0 : webrtcCallOptions.audioOptions) .setVideo(webrtcCallOptions === null || webrtcCallOptions === void 0 ? void 0 : webrtcCallOptions.video) .setVideoOptions(webrtcCallOptions === null || webrtcCallOptions === void 0 ? void 0 : webrtcCallOptions.videoOptions) .setDataChannel(webrtcCallOptions === null || webrtcCallOptions === void 0 ? void 0 : webrtcCallOptions.dataChannel) .setAutoReconnect(webrtcCallOptions === null || webrtcCallOptions === void 0 ? void 0 : webrtcCallOptions.autoReconnect) .build(); if (webrtcCallOptions === null || webrtcCallOptions === void 0 ? void 0 : webrtcCallOptions.customData) { applicationCallOptions.customData = webrtcCallOptions === null || webrtcCallOptions === void 0 ? void 0 : webrtcCallOptions.customData; } return new InternalApplicationCallOptions(applicationCallOptions, internalCustomData); } } //# sourceMappingURL=DefaultOutgoingWebrtcCall.js.map