infobip-rtc
Version:
Infobip RTC JavaScript SDK - Infobip WebRTC API Implementation
44 lines • 2.37 kB
JavaScript
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";
import { DefaultOutgoingApplicationCall } from "./DefaultOutgoingApplicationCall";
export class DefaultOutgoingWebrtcCall extends DefaultWebrtcCall {
constructor(infobipRtc, webrtcCallOptions, currentUserIdentity, counterpartIdentity, logger) {
super(webrtcCallOptions, new WebrtcEndpoint(currentUserIdentity), new WebrtcEndpoint(counterpartIdentity), logger);
let applicationCallOptions = this.mapOptions(counterpartIdentity, webrtcCallOptions);
this.applicationCall = infobipRtc.callApplication(counterpartIdentity, applicationCallOptions);
this.initEventHandlers();
}
counterpart() {
return this.destinationEndpoint;
}
mapOptions(counterpartIdentity, webrtcCallOptions) {
if (webrtcCallOptions?.customData) {
ValidationUtil.validateCustomData(webrtcCallOptions?.customData);
}
let internalCustomData = {
to: counterpartIdentity,
type: FlowType.WEBRTC.toString(),
...getRecordingOptions(webrtcCallOptions),
withDialog: "true",
...webrtcCallOptions?.video && { isVideo: "true" }
};
let applicationCallOptions = ApplicationCallOptions.builder()
.setAudio(webrtcCallOptions?.audio)
.setAudioOptions(webrtcCallOptions?.audioOptions)
.setVideo(webrtcCallOptions?.video)
.setVideoOptions(webrtcCallOptions?.videoOptions)
.setDataChannel(webrtcCallOptions?.dataChannel)
.setAutoReconnect(webrtcCallOptions?.autoReconnect)
.build();
if (webrtcCallOptions?.customData) {
applicationCallOptions.customData = webrtcCallOptions?.customData;
}
return new InternalApplicationCallOptions(applicationCallOptions, internalCustomData, DefaultOutgoingApplicationCall.WEBRTC_CALLS_CONFIGURATION_ID);
}
}
//# sourceMappingURL=DefaultOutgoingWebrtcCall.js.map