1614 lines
63 KiB
JavaScript
1614 lines
63 KiB
JavaScript
// Metro module 4296 (f4297).
|
|
import { DESKTOP_BITRATE, DESKTOP_BITRATE_ENHANCED, ExperimentFlags, MEDIA_SINK_WANTS_PROPERTIES, MediaTypes, SIMULCAST_HQ_QUALITY, StatsFilter } from "./Module4250";
|
|
import { Codecs, ConnectionStates, DEFAULT_CALL_BITRATE, DEFAULT_CALL_MAX_BITRATE, DEFAULT_CALL_MIN_BITRATE, DEFAULT_PRIORITY_SPEAKER_DUCKING, DEFAULT_SOUNDSHARE_VOICE_BITRATE, DEFAULT_STREAM_VOLUME, DEFAULT_VOLUME, InputModes, MediaEngineContextTypes, NATIVE_MODE_VALUES, NativeFeatures, NoiseCancellerError, PING_INTERVAL, ResolutionTypes, SpeakingFlags } from "./Module4288";
|
|
import Module4297 from "./Module4297";
|
|
import { getVoiceEngine, supportsFeature, getOpenH264LibraryPath } from "./Module4238";
|
|
import { Logger } from "./log";
|
|
import { BaseConnectionEvent } from "./Module4286";
|
|
import { filterVideoCodecs, getExperimentCodecs, parseNativeCodecs, filterParsedVideoCodecs, codecNameToPayloadName } from "./Module4345";
|
|
import { timeout, TimeoutError } from "./Module4346";
|
|
import transformStats from "./transformStats";
|
|
import { STATS_INTERVAL } from "./Module4295";
|
|
import isEqual from "./isEqual_4349";
|
|
import { VideoQuality } from "./WantsVideoQuality";
|
|
import { VADAggressiveness } from "./Module4350";
|
|
import cloneDeep from "./cloneDeep";
|
|
import reduce from "./reduce";
|
|
import clamp from "./clamp_4354";
|
|
let Connection, prototype;
|
|
let c2531_28 = 0;
|
|
const Connection2 = class Connection extends Module4297 {
|
|
constructor(a0, a1, a2) {
|
|
super(a0, a1);
|
|
const r24 = +c2531_28;
|
|
c2531_28 = r24 + 1;
|
|
this.mediaEngineConnectionId = "Native-" + r24;
|
|
this.selfVideo = false;
|
|
this.codecs = [];
|
|
this.initialCodecs = [];
|
|
this.videoEncoderFallbackPending = false;
|
|
this.videoDecoderFallbackSent = new Set();
|
|
this.lastOverrideCodecDenylist = "";
|
|
this.lastOverrideEncoderDenylist = "";
|
|
this.lastCaptureOverrides = "";
|
|
this.overrideCodecResetAt = 0;
|
|
this.desktopDegradationPreference = getVoiceEngine().DegradationPreference.MAINTAIN_FRAMERATE;
|
|
this.sourceDesktopDegradationPreference = getVoiceEngine().DegradationPreference.DISABLED;
|
|
this.videoDegradationPreference = getVoiceEngine().DegradationPreference.BALANCED;
|
|
this.localPans = {};
|
|
this.remoteAudioSSRCs = {};
|
|
this.remoteVideoSSRCs = {};
|
|
this.inputMode = InputModes.VOICE_ACTIVITY;
|
|
this.vadThreshold = -40;
|
|
this.vadAutoThreshold = true;
|
|
this.vadKrispActivationThreshold = 0.5;
|
|
this.vadUseKrisp = true;
|
|
this.vadLeading = 5;
|
|
this.vadTrailing = 25;
|
|
this.vadDuringPreProcess = false;
|
|
this.pttReleaseDelay = 20;
|
|
this.soundshareActive = false;
|
|
this.soundshareId = null;
|
|
this.soundshareSentSpeakingEvent = false;
|
|
this.echoCancellation = true;
|
|
this.noiseSuppression = true;
|
|
this.automaticGainControl = {
|
|
enabled: true
|
|
};
|
|
this.noiseCancellation = false;
|
|
this.noiseCancellationDuringProcessing = false;
|
|
this.echoReferenceMode = "mix";
|
|
this.attenuationFactor = 0.5;
|
|
this.attenuateWhileSpeakingSelf = false;
|
|
this.attenuateWhileSpeakingOthers = true;
|
|
this.qos = true;
|
|
this.minimumJitterBufferLevel = 0;
|
|
this.postponeDecodeLevel = 100;
|
|
this.reconnectInterval = 60000;
|
|
this.keyframeInterval = 0;
|
|
this.clipsKeyFrameInterval = 0;
|
|
this.videoQualityMeasurement = "";
|
|
this.videoEncoderExperiments = "";
|
|
this.numFastUdpReconnects = 0;
|
|
this.lastPreparedTransitionId = -1;
|
|
this.lastExecutedTransitionId = -1;
|
|
this.currentVideoCodec = null;
|
|
this.lastDesktopEncodingOptions = null;
|
|
this.handleSpeakingNative = (a0, a1, a2) => {
|
|
SpeakingFlags.NONE;
|
|
this.handleSpeakingFlags(a0, typeof a1 === "boolean" ? a1 ? SpeakingFlags.VOICE : SpeakingFlags.NONE : a1, a2);
|
|
};
|
|
this.handleNativeMuteChanged = (a0) => {
|
|
this.emit(BaseConnectionEvent.NativeMuteChanged, a0);
|
|
};
|
|
this.handleSpeakingFlags = (a0, a1, a2) => {
|
|
let r19 = this.localSpeakingFlags[a0];
|
|
if (r19 == null) {
|
|
r19 = SpeakingFlags.NONE;
|
|
}
|
|
if (!(this.experimentFlags.has(ExperimentFlags.SWALLOW_VOLUME_ONLY_SPEAKING_EVENTS) && r19 === a1)) {
|
|
this.localSpeakingFlags[a0] = a1;
|
|
this.emit(BaseConnectionEvent.Speaking, a0, a1, a0 === this.userId ? this.audioSSRC : this.remoteAudioSSRCs[a0], a2);
|
|
if (a1 & SpeakingFlags.SOUNDSHARE && this.soundshareSentSpeakingEvent === false) {
|
|
this.emit(BaseConnectionEvent.SoundshareSpeaking);
|
|
this.soundshareSentSpeakingEvent = true;
|
|
}
|
|
}
|
|
};
|
|
this.handleSpeakingWhileMuted = () => {
|
|
this.emit(BaseConnectionEvent.SpeakingWhileMuted);
|
|
};
|
|
this.handlePing = (a0) => {
|
|
this.emit(BaseConnectionEvent.Ping, a0);
|
|
};
|
|
this.handlePingTimeout = (a0, a1, a2, a3) => {
|
|
this.emit(BaseConnectionEvent.PingTimeout, a2, a3 > 0 ? a3 : 4000);
|
|
};
|
|
this.handleVideoEncoderFallback = (a0) => {
|
|
let c25041_0;
|
|
L5: {
|
|
c25041_0 = a0;
|
|
if (!this.videoEncoderFallbackPending) {
|
|
if (this.overrideCodecResetAt > 0 && performance.now() - this.overrideCodecResetAt < 1000) {
|
|
this.logger.info(`Suppressing encoder fallback for ${a0} (override codec reset in progress)`);
|
|
break L5;
|
|
}
|
|
this.logger.info(`Falling back from current video encoder: ${a0}`);
|
|
this.codecs = this.codecs.map((codec) => {
|
|
if (c25041_0 === codec.name || codec.name === "AV1" && c25041_0 === "AV1X") {
|
|
codec.encode = false;
|
|
}
|
|
return codec;
|
|
}).filter((item) => !(item.type === "video" && item.encode === false && item.decode === false));
|
|
this.emit(BaseConnectionEvent.VideoEncoderFallback, this.codecs);
|
|
this.videoEncoderFallbackPending = true;
|
|
}
|
|
}
|
|
};
|
|
this.handleVideoDecoderFallback = (a0) => {
|
|
if (!this.videoDecoderFallbackSent.has(a0)) {
|
|
this.videoDecoderFallbackSent.add(a0);
|
|
this.logger.info(`Falling back from current video decoder: ${a0}`);
|
|
this.codecs = this.codecs.map((codec) => {
|
|
if (a0 === codec.name || codec.name === "AV1" && a0 === "AV1X") {
|
|
codec.decode = false;
|
|
}
|
|
return codec;
|
|
}).filter((item) => !(item.type === "video" && item.encode === false && item.decode === false));
|
|
this.emit(BaseConnectionEvent.VideoDecoderFallback, this.codecs);
|
|
}
|
|
};
|
|
this.handleVideoCodecError = (a0) => {
|
|
this.emit(BaseConnectionEvent.VideoCodecError, a0);
|
|
};
|
|
this.handleVideo = (a0, a1, a2, a3) => {
|
|
let r10, videoStreamParameters;
|
|
let c25043_0;
|
|
L16: {
|
|
r10 = this;
|
|
videoStreamParameters = cloneDeep(r10.videoStreamParameters);
|
|
c25043_0 = videoStreamParameters;
|
|
if (a0 === r10.userId) {
|
|
if (a3 != null && Array.isArray(a3) && a3.length > 0) {
|
|
a3.forEach((c29310_0) => {
|
|
c25043_0.forEach((item, index) => {
|
|
const rid = item.rid;
|
|
if (rid === c29310_0.rid) {
|
|
c25043_0[index] = {
|
|
...item,
|
|
ssrc: c29310_0.ssrc,
|
|
rtxSsrc: c29310_0.rtxSsrc,
|
|
active: c29310_0.active
|
|
};
|
|
}
|
|
});
|
|
});
|
|
break L16;
|
|
}
|
|
if (a1 > 0) {
|
|
videoStreamParameters[0].active = true;
|
|
videoStreamParameters[0].ssrc = a1;
|
|
videoStreamParameters[0].rtxSsrc = a1 != null ? a1 !== 0 ? a1 + 1 : 0 : 0;
|
|
} else {
|
|
videoStreamParameters[0].active = false;
|
|
}
|
|
} else if (a1 > 0) {
|
|
if (r10.remoteVideoSSRCs[a0] !== void 0) {
|
|
if (!r10.remoteVideoSSRCs[a0].includes(a1)) {
|
|
r10.remoteVideoSSRCs[a0] = [...r10.remoteVideoSSRCs[a0], a1];
|
|
}
|
|
} else {
|
|
r10.remoteVideoSSRCs[a0] = [a1];
|
|
}
|
|
}
|
|
}
|
|
r10.videoStreamParameters = videoStreamParameters;
|
|
r10.emit(BaseConnectionEvent.Video, a0, a2 != null ? a2 !== "" ? a2 : null : null, a0 === r10.userId ? r10.audioSSRC : r10.remoteAudioSSRCs[a0], a1, a1 != null ? a1 !== 0 ? a1 + 1 : 0 : 0, r10.videoStreamParameters);
|
|
};
|
|
this.handleFirstFrame = (a0, a1, a2) => {
|
|
this.emit(BaseConnectionEvent.FirstFrame, a0, a1, a2);
|
|
};
|
|
this.handleFirstFrameStats = (a0) => {
|
|
this.emit(BaseConnectionEvent.FirstFrameStats, a0);
|
|
};
|
|
this.handleFirstFrameEncryptedStats = (a0) => {
|
|
this.emit(BaseConnectionEvent.FirstFrameEncryptedStats, a0);
|
|
};
|
|
this.handleNoInput = (a0) => {
|
|
this.emit(BaseConnectionEvent.Silence, !a0);
|
|
};
|
|
this.handleDesktopSourceEnded = (a0, a1) => {
|
|
this.emit(BaseConnectionEvent.DesktopSourceEnd, a0, a1);
|
|
};
|
|
this.handleSoundshare = (a0) => {
|
|
if (a0) {
|
|
this.soundshareActive = true;
|
|
this.conn.setTransportOptions({
|
|
encodingVoiceBitRate: Math.max(DEFAULT_SOUNDSHARE_VOICE_BITRATE, this.voiceBitrate)
|
|
});
|
|
this.emit(BaseConnectionEvent.SoundshareAttached);
|
|
}
|
|
};
|
|
this.handleSoundshareFailed = (a0, a1, a2) => {
|
|
this.emit(BaseConnectionEvent.SoundshareFailed, {
|
|
failureCode: a0,
|
|
failureReason: a1,
|
|
willRetry: a2
|
|
});
|
|
};
|
|
this.handleSoundshareEnded = () => {
|
|
this.soundshareActive = false;
|
|
if (!this.destroyed) {
|
|
this.conn.setTransportOptions({
|
|
encodingVoiceBitRate: this.voiceBitrate
|
|
});
|
|
}
|
|
};
|
|
this.handleNewListenerNative = (a0) => {
|
|
if (a0 === BaseConnectionEvent.ConnectionStateChange) {
|
|
this.emit(a0, this.connectionState);
|
|
}
|
|
};
|
|
this.handleStats = (a0) => {
|
|
if (this.connectionState !== ConnectionStates.DISCONNECTED) {
|
|
if (a0 != null) {
|
|
if (this.stats != null) {
|
|
const r34 = reduce(a0.rtp.outbound, (a0, a1) => {
|
|
const lost = a0.lost;
|
|
let packetsLost = a1.packetsLost;
|
|
if (packetsLost == null) {
|
|
packetsLost = 0;
|
|
}
|
|
a0.lost = lost + packetsLost;
|
|
const sent = a0.sent;
|
|
let packetsSent = a1.packetsSent;
|
|
if (packetsSent == null) {
|
|
packetsSent = 0;
|
|
}
|
|
a0.sent = sent + packetsSent;
|
|
return a0;
|
|
}, {
|
|
lost: 0,
|
|
sent: 0
|
|
});
|
|
const r41 = reduce(this.stats.rtp.outbound, (a0, a1) => {
|
|
const lost = a0.lost;
|
|
let packetsLost = a1.packetsLost;
|
|
if (packetsLost == null) {
|
|
packetsLost = 0;
|
|
}
|
|
a0.lost = lost + packetsLost;
|
|
const sent = a0.sent;
|
|
let packetsSent = a1.packetsSent;
|
|
if (packetsSent == null) {
|
|
packetsSent = 0;
|
|
}
|
|
a0.sent = sent + packetsSent;
|
|
return a0;
|
|
}, {
|
|
lost: 0,
|
|
sent: 0
|
|
});
|
|
const r44 = r34.sent - r41.sent;
|
|
const r47 = r34.lost - r41.lost;
|
|
if (r44 === 0) {
|
|
this.emit(BaseConnectionEvent.OutboundLossRate, 0);
|
|
} else if (r44 > 0 && r47 >= 0) {
|
|
this.emit(BaseConnectionEvent.OutboundLossRate, 100 * clamp(r47 / (r44 + r47), 0, 1));
|
|
}
|
|
const r74 = a0.rtp.outbound.filter((item) => item.type === "audio")[0];
|
|
const r81 = this.stats.rtp.outbound.filter((item) => item.type === "audio")[0];
|
|
if (r74 != null && r81 != null && r74.framesCaptured != null && r81.framesCaptured != null) {
|
|
const r86 = r74.framesCaptured - r81.framesCaptured;
|
|
const r88 = r74.noiseCancellerFrames != null ? r81.noiseCancellerFrames != null ? r74.noiseCancellerFrames - r81.noiseCancellerFrames : 0 : r86;
|
|
if (!supportsFeature(NativeFeatures.KRISP_NATIVE_ERROR)) {
|
|
if (this.noiseCancellation && r88 > 50 && r74.noiseCancellerProcessTime != null && r81.noiseCancellerProcessTime != null) {
|
|
const r104 = r74.noiseCancellerProcessTime - r81.noiseCancellerProcessTime;
|
|
if (r104 / r88 > 8) {
|
|
this.emit(BaseConnectionEvent.NoiseCancellationError, NoiseCancellerError.KRISP_CPU_OVERUSE);
|
|
} else if (r104 === 0) {
|
|
this.emit(BaseConnectionEvent.NoiseCancellationError, NoiseCancellerError.KRISP_FAILED);
|
|
}
|
|
}
|
|
if (this.inputMode === InputModes.VOICE_ACTIVITY && this.vadAutoThreshold && this.vadUseKrisp && r86 > 50 && r74.voiceActivityDetectorProcessTime != null && r81.voiceActivityDetectorProcessTime != null && (r74.voiceActivityDetectorProcessTime - r81.voiceActivityDetectorProcessTime) / r86 > 4) {
|
|
this.emit(BaseConnectionEvent.VoiceActivityDetectorError, NoiseCancellerError.KRISP_VAD_CPU_OVERUSE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.stats = a0;
|
|
}
|
|
} else {
|
|
this.off(BaseConnectionEvent.Stats, this.handleStats);
|
|
}
|
|
};
|
|
this.handleMLSFailure = (a0, a1) => {
|
|
this.emit(BaseConnectionEvent.MLSFailure, a0, a1);
|
|
};
|
|
this.videoSupported = a2;
|
|
this.logger = new Logger(`Connection(${a0})`);
|
|
this.logger.enableNativeLogger(true);
|
|
}
|
|
static create(a0, a1, a2) {
|
|
const connection = new Connection(a0, a1, true);
|
|
connection.initialize(a2);
|
|
return connection;
|
|
}
|
|
static createReplay(a0, a1) {
|
|
let c14117_0 = a0;
|
|
const connection = new Connection(a0, "0", true);
|
|
let c14117_1 = connection;
|
|
const voiceEngine = getVoiceEngine();
|
|
connection.initializeStreamParameters([{
|
|
type: MediaTypes.VIDEO,
|
|
rid: "100",
|
|
ssrc: 0,
|
|
rtxSsrc: 0,
|
|
quality: 100,
|
|
active: false
|
|
}]);
|
|
const replayConnection = voiceEngine.createReplayConnection("default", () => {
|
|
c14117_1.on(BaseConnectionEvent.Stats, c14117_1.handleStats);
|
|
c14117_1.conn.setOnVideoCallback(c14117_1.handleVideo);
|
|
voiceEngine.getCodecCapabilities((a0) => {
|
|
c14117_1.codecs = [{
|
|
type: "audio",
|
|
name: Codecs.OPUS,
|
|
priority: 1,
|
|
payloadType: 120
|
|
}, ...filterVideoCodecs(a0, getExperimentCodecs(c14117_1.experimentFlags)).map((item, index) => {
|
|
const payloadType = 101 + 2 * index;
|
|
return {
|
|
type: "video",
|
|
name: item.name,
|
|
priority: index + 1,
|
|
payloadType,
|
|
rtxPayloadType: payloadType + 1,
|
|
encode: item.encode,
|
|
decode: item.decode
|
|
};
|
|
})];
|
|
c14117_1.setCodecs(Codecs.OPUS, Codecs.H264, c14117_0);
|
|
c14117_1.conn.startReplay();
|
|
});
|
|
}, a1);
|
|
let r29 = null;
|
|
if (replayConnection != null) {
|
|
connection.conn = replayConnection;
|
|
r29 = connection;
|
|
}
|
|
return r29;
|
|
}
|
|
initialize(a0) {
|
|
let r54;
|
|
let createOwnStreamConnection, ownStreamConnectionWithOptions;
|
|
let c14118_1 = a0;
|
|
this.logger.info(`Creating connection to ${a0.address}:${a0.port} with audio ssrc: ${a0.ssrc}`);
|
|
this.beginInitializeAt = performance.now();
|
|
this.audioSSRC = a0.ssrc;
|
|
this.streamUserId = a0.streamUserId;
|
|
this.initializeStreamParameters(a0.streamParameters);
|
|
a0.streamParameters = [{
|
|
type: MediaTypes.AUDIO,
|
|
ssrc: this.audioSSRC,
|
|
rid: "",
|
|
maxBitrate: 64000,
|
|
soundshare: this.context === MediaEngineContextTypes.STREAM
|
|
}, ...this.videoStreamParameters];
|
|
a0.context = this.context;
|
|
const voiceEngine2 = getVoiceEngine();
|
|
if (voiceEngine2.createOwnStreamConnectionWithOptions != null) {
|
|
r54 = this.context === MediaEngineContextTypes.STREAM && this.streamUserId === this.userId ? voiceEngine2.createOwnStreamConnectionWithOptions : voiceEngine2.createVoiceConnectionWithOptions;
|
|
} else if (voiceEngine2.createOwnStreamConnection != null) {
|
|
createOwnStreamConnection = this.context === MediaEngineContextTypes.STREAM && this.streamUserId === this.userId ? voiceEngine2.createOwnStreamConnection : voiceEngine2.createVoiceConnection;
|
|
r54 = (a0, a1, a2) => createOwnStreamConnection(a1.ssrc, this.userId, a1.address, a1.port, a2, a1.experiments, a1.streamParameters);
|
|
} else {
|
|
r54 = (a0, a1, a2) => new voiceEngine2.VoiceConnection(a1.ssrc, a0, a1.address, a1.port, a2, a1.experiments, a1.streamParameters);
|
|
}
|
|
const conn = r54(this.userId, a0, (a0, a1) => {
|
|
if (!this.destroyed) {
|
|
if (a0 != null && a0 !== "") {
|
|
this.setConnectionState(ConnectionStates.NO_ROUTE);
|
|
this.emit(BaseConnectionEvent.Error, a0);
|
|
return void 0;
|
|
}
|
|
if (a1 == null) {
|
|
throw new Error("Invalid transport info");
|
|
}
|
|
this.transportInfo = a1;
|
|
const { protocol, address, port } = a1;
|
|
this.logger.info(`Connected with local address ${address}:${port} and protocol: ${protocol}`);
|
|
this.onConnectCallbackAt = performance.now();
|
|
voiceEngine2.getCodecCapabilities((a0) => {
|
|
let c29311_0;
|
|
this.onVideoCodecsCallbackAt = performance.now();
|
|
this.logger.info(`Available engine codecs: ${JSON.stringify(a0)}`);
|
|
const experimentCodecs = getExperimentCodecs(this.experimentFlags);
|
|
this.logger.info(`Experimental codecs: ${JSON.stringify(experimentCodecs)}`);
|
|
const r46 = parseNativeCodecs(a0);
|
|
this.codecs = [{
|
|
type: "audio",
|
|
name: Codecs.OPUS,
|
|
priority: 1,
|
|
payloadType: 120
|
|
}, ...filterParsedVideoCodecs(r46, experimentCodecs, this.lastOverrideCodecDenylist.length > 0).map((item, index) => {
|
|
const payloadType = 101 + 2 * index;
|
|
return {
|
|
type: "video",
|
|
name: item.name,
|
|
priority: index + 1,
|
|
payloadType,
|
|
rtxPayloadType: payloadType + 1,
|
|
encode: item.encode,
|
|
decode: item.decode
|
|
};
|
|
})];
|
|
c29311_0 = new Map(r46.map((item) => [item.name, item.encode]));
|
|
this.initialCodecs = this.codecs.map((codec) => {
|
|
let encode;
|
|
if (codec.type === "video") {
|
|
let r13 = c29311_0.get(codec.name);
|
|
if (r13 == null) {
|
|
r13 = codec.encode;
|
|
}
|
|
encode = r13;
|
|
} else {
|
|
encode = codec.encode;
|
|
}
|
|
return {
|
|
...codec,
|
|
encode
|
|
};
|
|
});
|
|
this.logger.info(`Audio codecs: ${this.codecs.filter((codec) => codec.type === "audio").map((item) => item.name)}`);
|
|
this.logger.info(`Video codecs: ${this.codecs.filter((codec) => codec.type === "video").map((item) => item.name + "[encode: " + item.encode + ", decode: " + item.decode + "]")}`);
|
|
ownStreamConnectionWithOptions.getEncryptionModes((a0) => {
|
|
this.onEncryptionModesCallbackAt = performance.now();
|
|
this.logger.info(`Encryption modes: ${a0}`);
|
|
ownStreamConnectionWithOptions.setTransportOptions(this.getConnectionTransportOptions());
|
|
ownStreamConnectionWithOptions.setSelfMute(this.selfMute || this.context === MediaEngineContextTypes.STREAM);
|
|
ownStreamConnectionWithOptions.setSelfDeafen(this.selfDeaf);
|
|
ownStreamConnectionWithOptions.setOnSpeakingCallback(this.handleSpeakingNative);
|
|
const setOnNativeMuteChangedCallback = ownStreamConnectionWithOptions.setOnNativeMuteChangedCallback;
|
|
if (setOnNativeMuteChangedCallback != null) {
|
|
setOnNativeMuteChangedCallback.call(ownStreamConnectionWithOptions, this.handleNativeMuteChanged);
|
|
}
|
|
const setOnSpeakingWhileMutedCallback = ownStreamConnectionWithOptions.setOnSpeakingWhileMutedCallback;
|
|
if (setOnSpeakingWhileMutedCallback != null) {
|
|
setOnSpeakingWhileMutedCallback.call(ownStreamConnectionWithOptions, this.handleSpeakingWhileMuted);
|
|
}
|
|
const setPingInterval = ownStreamConnectionWithOptions.setPingInterval;
|
|
if (setPingInterval != null) {
|
|
setPingInterval.call(ownStreamConnectionWithOptions, PING_INTERVAL);
|
|
}
|
|
ownStreamConnectionWithOptions.setPingCallback(this.handlePing);
|
|
const setPingTimeoutCallback = ownStreamConnectionWithOptions.setPingTimeoutCallback;
|
|
if (setPingTimeoutCallback != null) {
|
|
setPingTimeoutCallback.call(ownStreamConnectionWithOptions, this.handlePingTimeout);
|
|
}
|
|
const setOnVideoEncoderFallbackCallback = ownStreamConnectionWithOptions.setOnVideoEncoderFallbackCallback;
|
|
if (setOnVideoEncoderFallbackCallback != null) {
|
|
setOnVideoEncoderFallbackCallback.call(ownStreamConnectionWithOptions, this.handleVideoEncoderFallback);
|
|
}
|
|
const setOnVideoDecoderFallbackCallback = ownStreamConnectionWithOptions.setOnVideoDecoderFallbackCallback;
|
|
if (setOnVideoDecoderFallbackCallback != null) {
|
|
setOnVideoDecoderFallbackCallback.call(ownStreamConnectionWithOptions, this.handleVideoDecoderFallback);
|
|
}
|
|
const setVideoCodecErrorCallback = ownStreamConnectionWithOptions.setVideoCodecErrorCallback;
|
|
if (setVideoCodecErrorCallback != null) {
|
|
setVideoCodecErrorCallback.call(ownStreamConnectionWithOptions, this.handleVideoCodecError);
|
|
}
|
|
voiceEngine2.setTransportOptions({
|
|
builtInEchoCancellation: true,
|
|
echoCancellation: this.echoCancellation,
|
|
noiseSuppression: this.noiseSuppression,
|
|
automaticGainControl: this.automaticGainControl.enabled,
|
|
automaticGainControlConfig: this.automaticGainControl,
|
|
noiseCancellation: this.noiseCancellation,
|
|
noiseCancellationDuringProcessing: this.noiseCancellationDuringProcessing
|
|
});
|
|
voiceEngine2.setNoInputThreshold(-100);
|
|
voiceEngine2.setNoInputCallback(this.handleNoInput);
|
|
if (this.videoSupported) {
|
|
ownStreamConnectionWithOptions.setOnVideoCallback(this.handleVideo);
|
|
const setOnFirstFrameCallback = ownStreamConnectionWithOptions.setOnFirstFrameCallback;
|
|
if (setOnFirstFrameCallback != null) {
|
|
setOnFirstFrameCallback.call(ownStreamConnectionWithOptions, this.handleFirstFrame);
|
|
}
|
|
const setOnFirstFrameDeliveredStatsCallback = ownStreamConnectionWithOptions.setOnFirstFrameDeliveredStatsCallback;
|
|
if (setOnFirstFrameDeliveredStatsCallback != null) {
|
|
setOnFirstFrameDeliveredStatsCallback.call(ownStreamConnectionWithOptions, this.handleFirstFrameStats);
|
|
}
|
|
const setOnFirstFrameEncryptedStatsCallback = ownStreamConnectionWithOptions.setOnFirstFrameEncryptedStatsCallback;
|
|
if (setOnFirstFrameEncryptedStatsCallback != null) {
|
|
setOnFirstFrameEncryptedStatsCallback.call(ownStreamConnectionWithOptions, this.handleFirstFrameEncryptedStats);
|
|
}
|
|
const setOnDesktopSourceEnded = ownStreamConnectionWithOptions.setOnDesktopSourceEnded;
|
|
if (setOnDesktopSourceEnded != null) {
|
|
setOnDesktopSourceEnded.call(ownStreamConnectionWithOptions, this.handleDesktopSourceEnded);
|
|
}
|
|
const setOnSoundshare = ownStreamConnectionWithOptions.setOnSoundshare;
|
|
if (setOnSoundshare != null) {
|
|
setOnSoundshare.call(ownStreamConnectionWithOptions, this.handleSoundshare);
|
|
}
|
|
const setOnSoundshareEnded = ownStreamConnectionWithOptions.setOnSoundshareEnded;
|
|
if (setOnSoundshareEnded != null) {
|
|
setOnSoundshareEnded.call(ownStreamConnectionWithOptions, this.handleSoundshareEnded);
|
|
}
|
|
const setOnSoundshareFailed = ownStreamConnectionWithOptions.setOnSoundshareFailed;
|
|
if (setOnSoundshareFailed != null) {
|
|
setOnSoundshareFailed.call(ownStreamConnectionWithOptions, this.handleSoundshareFailed);
|
|
}
|
|
}
|
|
const setOnMLSFailureCallback = ownStreamConnectionWithOptions.setOnMLSFailureCallback;
|
|
if (setOnMLSFailureCallback != null) {
|
|
setOnMLSFailureCallback.call(ownStreamConnectionWithOptions, this.handleMLSFailure);
|
|
}
|
|
this.setConnectionState(ConnectionStates.CONNECTED);
|
|
this.emit(BaseConnectionEvent.Connected, protocol, {
|
|
address,
|
|
port,
|
|
mode: this.chooseEncryptionMode(c14118_1.modes, a0),
|
|
codecs: this.codecs
|
|
});
|
|
this.on(BaseConnectionEvent.Stats, this.handleStats);
|
|
const userOptions = this.getUserOptions();
|
|
userOptions.forEach((userOption) => {
|
|
const logger = this.logger;
|
|
const { id, ssrc, videoSsrcs } = userOption;
|
|
let r9 = videoSsrcs == null ? void 0 : videoSsrcs.join(",");
|
|
if (r9 == null) {
|
|
r9 = 0;
|
|
}
|
|
return logger.info(`Creating user: ${id} with audio SSRC: ${ssrc} and video SSRCs: ${r9}`);
|
|
});
|
|
this.mergeUsers(userOptions);
|
|
this.emit(BaseConnectionEvent.RemoteStreamsReady, userOptions.length);
|
|
for (const item of Object.keys(this.localSpeakingFlags)) {
|
|
if (item !== this.userId) {
|
|
this.setSpeakingFlags(item, this.localSpeakingFlags[item]);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
});
|
|
this.conn = conn;
|
|
ownStreamConnectionWithOptions = conn;
|
|
const setSecureFramesStateUpdateCallback = ownStreamConnectionWithOptions.setSecureFramesStateUpdateCallback;
|
|
if (setSecureFramesStateUpdateCallback != null) {
|
|
setSecureFramesStateUpdateCallback.call(ownStreamConnectionWithOptions, (a0) => {
|
|
this.logger.info(`DAVE protocol state update: ${JSON.stringify(a0)}`);
|
|
this.emit(BaseConnectionEvent.SecureFramesUpdate, a0);
|
|
});
|
|
}
|
|
const setDesktopSourceStatusCallback2 = ownStreamConnectionWithOptions.setDesktopSourceStatusCallback;
|
|
if (setDesktopSourceStatusCallback2 != null) {
|
|
setDesktopSourceStatusCallback2.call(ownStreamConnectionWithOptions, (a0) => {
|
|
if (a0.type === "videohook_start") {
|
|
this.emit(BaseConnectionEvent.VideoHookStart);
|
|
} else if (a0.type === "videohook_stop") {
|
|
this.emit(BaseConnectionEvent.VideoHookStop);
|
|
} else if (a0.type === "videohook_initialize") {
|
|
this.emit(BaseConnectionEvent.VideoHookInitialize, a0.backend, a0.format, a0.framebufferFormat, a0.sampleCount, a0.success, a0.reinitialization);
|
|
} else if (a0.type === "screenshare_finish") {
|
|
const ScreenshareFinish = BaseConnectionEvent.ScreenshareFinish;
|
|
const { screenshareFrames, videohookFrames, hybridDxgiFrames, hybridGdiFrames, hybridVideohookFrames, hybridGraphicsCaptureFrames, hybridCaptureMethodSwitches, hybridGdiBitBltFrames, hybridGdiPrintWindowFrames, hybridGraphicsCaptureFramesUnique, hybridDxgiFramesUnique, hybridVideohookFramesUnique, hybridGdiBitBltFramesUnique, hybridGdiPrintWindowFramesUnique, skipHistoryJson, quartzFrames } = a0;
|
|
let desktopCapturerType = a0.desktopCapturerType;
|
|
if (desktopCapturerType == null) {
|
|
desktopCapturerType = a0.desktop_capturer_type;
|
|
}
|
|
this.emit(ScreenshareFinish, screenshareFrames, videohookFrames, hybridDxgiFrames, hybridGdiFrames, hybridVideohookFrames, hybridGraphicsCaptureFrames, hybridCaptureMethodSwitches, hybridGdiBitBltFrames, hybridGdiPrintWindowFrames, hybridGraphicsCaptureFramesUnique, hybridDxgiFramesUnique, hybridVideohookFramesUnique, hybridGdiBitBltFramesUnique, hybridGdiPrintWindowFramesUnique, skipHistoryJson, quartzFrames, desktopCapturerType, a0.activity, a0.goLiveCameraFrames, a0.screenCaptureKitFrames, a0.hdrFramesCapable, a0.hdrFrames, a0.targetWindowElevated, a0.pipewireFrames, a0.x11Frames, a0.videohookBackend);
|
|
} else if (a0.type === "video_state") {
|
|
this.emit(BaseConnectionEvent.VideoState, a0.state);
|
|
} else if (a0.type.startsWith("soundshare_")) {
|
|
this.emit(BaseConnectionEvent.SoundshareTrace, a0);
|
|
}
|
|
});
|
|
}
|
|
this.on("newListener", this.handleNewListenerNative);
|
|
}
|
|
destroy(r7 = false) {
|
|
this.conn.destroy(r7);
|
|
Object.keys(this.localSpeakingFlags).filter((item) => item !== this.userId).forEach((item) => this.emit(BaseConnectionEvent.Speaking, item, SpeakingFlags.NONE, this.remoteAudioSSRCs[item]));
|
|
this.setConnectionState(ConnectionStates.DISCONNECTED);
|
|
Reflect.get(Object.getPrototypeOf(prototype), "destroy", this).call(this);
|
|
}
|
|
setCodecs(a0, a1, a2) {
|
|
const currentVideoCodec = this.currentVideoCodec;
|
|
this.currentVideoCodec = a1;
|
|
if (currentVideoCodec !== a1 && this.lastDesktopEncodingOptions != null) {
|
|
const lastDesktopEncodingOptions = this.lastDesktopEncodingOptions;
|
|
this.setDesktopEncodingOptions(lastDesktopEncodingOptions.width, lastDesktopEncodingOptions.height, lastDesktopEncodingOptions.framerate);
|
|
}
|
|
this.conn.setTransportOptions(this.getCodecOptions(a0, a1, a2));
|
|
if (this.videoEncoderFallbackPending) {
|
|
this.videoEncoderFallbackPending = false;
|
|
}
|
|
}
|
|
getStats() {
|
|
return this.connectionState === ConnectionStates.DISCONNECTED ? Promise.resolve(null) : timeout(new Promise((c25045_0) => {
|
|
if (this.conn.getFilteredStats != null) {
|
|
this.conn.getFilteredStats(StatsFilter.ALL, (a0) => c25045_0(transformStats(this.mediaEngineConnectionId, a0, this.remoteVideoSinkWants, this.localVideoSinkWants)));
|
|
} else if (this.conn.getStats != null) {
|
|
this.conn.getStats((a0) => c25045_0(transformStats(this.mediaEngineConnectionId, a0, this.remoteVideoSinkWants, this.localVideoSinkWants)));
|
|
} else {
|
|
getVoiceEngine().getStats((a0) => c25045_0(transformStats(this.mediaEngineConnectionId, a0, this.remoteVideoSinkWants, this.localVideoSinkWants)));
|
|
}
|
|
}), STATS_INTERVAL).catch((error) => {
|
|
if (error instanceof TimeoutError) {
|
|
return void 0;
|
|
}
|
|
throw error;
|
|
});
|
|
}
|
|
createUser(a0, a1, a2) {
|
|
let r40;
|
|
L34: {
|
|
const r9 = this.remoteAudioSSRCs[a0];
|
|
const r24 = this.remoteVideoSSRCs[a0];
|
|
if (r9 != null && a1 === 0) {
|
|
this.logger.info(`Ignoring attempt to recreate user ${a0} with 0 audio SSRC`);
|
|
} else {
|
|
const r29 = r24 !== void 0 ? [...r24].sort() : [];
|
|
if (a2 === void 0) {
|
|
let r41 = r29;
|
|
if (r41 == null) {
|
|
r41 = [];
|
|
}
|
|
r40 = r41;
|
|
} else {
|
|
r40 = [...a2].sort();
|
|
}
|
|
const isEqual2 = isEqual(r29, r40);
|
|
this.remoteAudioSSRCs[a0] = a1;
|
|
const remoteVideoSSRCs = this.remoteVideoSSRCs;
|
|
const videoSsrcs = r40;
|
|
let r51 = videoSsrcs;
|
|
if (r51 == null) {
|
|
r51 = [];
|
|
}
|
|
remoteVideoSSRCs[a0] = r51;
|
|
if (this.userId !== a0) {
|
|
if (r9 === a1 && isEqual2) {
|
|
break L34;
|
|
}
|
|
const videoSsrc = videoSsrcs !== void 0 ? videoSsrcs.length > 0 ? videoSsrcs[0] : 0 : 0;
|
|
const r57 = {
|
|
id: a0,
|
|
ssrc: a1,
|
|
videoSsrc,
|
|
videoSsrcs,
|
|
rtxSsrc: videoSsrc != null ? videoSsrc !== 0 ? videoSsrc + 1 : 0 : 0,
|
|
mute: this.getLocalMute(a0),
|
|
volume: this.getLocalVolume(a0)
|
|
};
|
|
if (this.connectionState === ConnectionStates.CONNECTED) {
|
|
const logger = this.logger;
|
|
let r15 = videoSsrcs == null ? void 0 : videoSsrcs.join(",");
|
|
if (r15 == null) {
|
|
r15 = 0;
|
|
}
|
|
logger.info(`Creating user: ${a0} with audio SSRC: ${a1} and video SSRCs: ${r15}`);
|
|
this.mergeUsers([r57]);
|
|
}
|
|
const r83 = this.localPans[a0];
|
|
if (r83 != null) {
|
|
this.setLocalPan(a0, r83.left, r83.right);
|
|
}
|
|
const r89 = this.localSpeakingFlags[a0];
|
|
if (r89 != null && r89 !== SpeakingFlags.NONE) {
|
|
this.setSpeakingFlags(a0, r89);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
destroyUser(a0) {
|
|
if (this.remoteAudioSSRCs[a0] != null) {
|
|
this.conn.destroyUser(a0);
|
|
delete this.remoteAudioSSRCs[a0];
|
|
delete this.remoteVideoSSRCs[a0];
|
|
}
|
|
}
|
|
setSelfMute(a0) {
|
|
this.selfMute = a0;
|
|
this.conn.setSelfMute(a0);
|
|
this.emit(BaseConnectionEvent.Mute, a0);
|
|
}
|
|
getSelfMute() {
|
|
return this.selfMute;
|
|
}
|
|
getSelfDeaf() {
|
|
return this.selfDeaf;
|
|
}
|
|
setSelfDeaf(a0) {
|
|
this.selfDeaf = a0;
|
|
this.conn.setSelfDeafen(a0);
|
|
this.emit(BaseConnectionEvent.Deafen, a0);
|
|
}
|
|
setSoundshareSource(a0, a1) {
|
|
let soundsharePid = a0;
|
|
if (!(this.soundshareId === a0 && this.soundshareSentSpeakingEvent) && this.context === MediaEngineContextTypes.STREAM) {
|
|
this.soundshareId = a0;
|
|
this.soundshareSentSpeakingEvent = false;
|
|
if (a0 === null) {
|
|
soundsharePid = 0;
|
|
}
|
|
this.conn.setTransportOptions({
|
|
soundsharePid,
|
|
soundshareEventDriven: true,
|
|
soundshareLoopback: a1
|
|
});
|
|
}
|
|
}
|
|
setLocalMute(a0, a1) {
|
|
this.localMutes[a0] = a1;
|
|
this.conn.setLocalMute(a0, a1);
|
|
this.emit(BaseConnectionEvent.LocalMute, a0, a1);
|
|
}
|
|
setUserPosition(a0, a1) {
|
|
const conn = this.conn;
|
|
const setUserPosition2 = conn.setUserPosition;
|
|
if (setUserPosition2 != null) {
|
|
setUserPosition2.call(conn, a0, a1);
|
|
}
|
|
}
|
|
fastUdpReconnect() {
|
|
if (this.conn.fastUdpReconnect != null) {
|
|
this.numFastUdpReconnects = this.numFastUdpReconnects + 1;
|
|
this.conn.fastUdpReconnect();
|
|
}
|
|
}
|
|
getNumFastUdpReconnects() {
|
|
return this.conn.fastUdpReconnect != null ? this.numFastUdpReconnects : null;
|
|
}
|
|
wasRemoteDisconnected() {
|
|
const conn = this.conn;
|
|
const wasRemoteDisconnected2 = conn.wasRemoteDisconnected;
|
|
if (wasRemoteDisconnected2 != null) {
|
|
wasRemoteDisconnected2.call(conn);
|
|
}
|
|
}
|
|
setLocalVideoDisabled(a0, a1) {
|
|
this.disabledLocalVideos[a0] = a1;
|
|
this.emit(BaseConnectionEvent.LocalVideoDisabled, a0, a1);
|
|
}
|
|
setMinimumJitterBufferLevel(a0) {
|
|
this.minimumJitterBufferLevel = a0;
|
|
}
|
|
setPostponeDecodeLevel(a0) {
|
|
this.postponeDecodeLevel = a0;
|
|
}
|
|
setClipRecordUser(a0, a1, a2) {
|
|
if (!this.destroyed) {
|
|
let r5 = "soundboardAudio";
|
|
if (a1 !== "soundboard") {
|
|
const r4 = this.context === MediaEngineContextTypes.STREAM ? "application" : "user";
|
|
r5 = r4.concat.call(r4, a1 === "audio" ? "Audio" : "Video");
|
|
}
|
|
const conn = this.conn;
|
|
const setClipRecordUser2 = conn.setClipRecordUser;
|
|
if (setClipRecordUser2 != null) {
|
|
setClipRecordUser2.call(conn, a0, r5, a2);
|
|
}
|
|
}
|
|
}
|
|
setClipsKeyFrameInterval(a0) {
|
|
if (this.context === MediaEngineContextTypes.STREAM) {
|
|
this.clipsKeyFrameInterval = a0;
|
|
this.conn.setTransportOptions({
|
|
keyframeInterval: this.getKeyFrameInterval(),
|
|
alwaysSendVideo: this.keyframeInterval > 0
|
|
});
|
|
}
|
|
}
|
|
setViewerSideClip(a0) {
|
|
if (this.context === MediaEngineContextTypes.STREAM) {
|
|
this.conn.setTransportOptions({
|
|
enableViewerSideClip: a0
|
|
});
|
|
}
|
|
}
|
|
setRemoteAudioHistory(a0) {
|
|
this.conn.setTransportOptions({
|
|
remoteAudioHistoryMs: a0
|
|
});
|
|
}
|
|
setQualityDecoupling(a0) {
|
|
if (this.context === MediaEngineContextTypes.STREAM) {
|
|
this.conn.setTransportOptions({
|
|
enableQualityDecoupling: a0
|
|
});
|
|
}
|
|
}
|
|
getLocalVolume(a0) {
|
|
let r5 = this.localVolumes[a0];
|
|
if (r5 == null) {
|
|
r5 = this.context === MediaEngineContextTypes.DEFAULT ? DEFAULT_VOLUME : DEFAULT_STREAM_VOLUME;
|
|
}
|
|
if (r5 == null) {
|
|
r5 = DEFAULT_VOLUME;
|
|
}
|
|
return r5 / DEFAULT_VOLUME;
|
|
}
|
|
setLocalVolume(a0, a1) {
|
|
this.localVolumes[a0] = a1;
|
|
try {
|
|
this.conn.setLocalVolume(a0, this.getLocalVolume(a0));
|
|
} catch ($e) {
|
|
this.logger.warn(`Failed to set volume for user: ${a0}: ${a1}`);
|
|
}
|
|
}
|
|
setLocalPan(a0, a1, a2) {
|
|
this.localPans[a0] = {
|
|
left: a1,
|
|
right: a2
|
|
};
|
|
this.conn.setLocalPan(a0, a1, a2);
|
|
}
|
|
isAttenuating() {
|
|
return this.attenuationFactor < 1;
|
|
}
|
|
setAttenuation(a0, a1, a2) {
|
|
this.attenuationFactor = (100 - a0) / 100;
|
|
this.attenuateWhileSpeakingSelf = a1;
|
|
this.attenuateWhileSpeakingOthers = a2;
|
|
this.conn.setTransportOptions(this.getAttenuationOptions());
|
|
}
|
|
setCanHavePriority(a0, a1) {
|
|
const conn = this.conn;
|
|
const setRemoteUserCanHavePriority = conn.setRemoteUserCanHavePriority;
|
|
if (setRemoteUserCanHavePriority != null) {
|
|
setRemoteUserCanHavePriority.call(conn, a0, a1);
|
|
}
|
|
}
|
|
setBitRate(a0) {
|
|
this.setVoiceBitRate(a0);
|
|
}
|
|
setVoiceBitRate(a0) {
|
|
if (this.voiceBitrate !== a0) {
|
|
this.voiceBitrate = a0;
|
|
const voiceBitrate = this.voiceBitrate;
|
|
this.conn.setTransportOptions({
|
|
encodingVoiceBitRate: this.soundshareActive ? Math.max(DEFAULT_SOUNDSHARE_VOICE_BITRATE, voiceBitrate) : voiceBitrate
|
|
});
|
|
}
|
|
}
|
|
setCameraBitRate(a0, a1, a2) {
|
|
if (a2 == null && a1 == null) {
|
|
this.videoQualityManager.setQualityOverwrite({});
|
|
} else {
|
|
this.videoQualityManager.setQualityOverwrite({
|
|
bitrateMin: a2 != null ? a2 > 0 ? a2 : a1 : a1,
|
|
bitrateMax: a1
|
|
});
|
|
}
|
|
if (!this.hasDesktopSource()) {
|
|
this.conn.setTransportOptions({
|
|
encodingVideoBitRate: a0,
|
|
encodingVideoMinBitRate: a2,
|
|
encodingVideoMaxBitRate: a1
|
|
});
|
|
}
|
|
}
|
|
setEchoCancellation(a0) {
|
|
this.echoCancellation = a0;
|
|
getVoiceEngine().setTransportOptions({
|
|
echoCancellation: this.echoCancellation
|
|
});
|
|
}
|
|
setNoiseSuppression(a0) {
|
|
this.noiseSuppression = a0;
|
|
getVoiceEngine().setTransportOptions({
|
|
noiseSuppression: this.noiseSuppression
|
|
});
|
|
}
|
|
setAutomaticGainControl(a0) {
|
|
this.automaticGainControl = a0;
|
|
getVoiceEngine().setTransportOptions({
|
|
automaticGainControl: this.automaticGainControl.enabled,
|
|
automaticGainControlConfig: this.automaticGainControl
|
|
});
|
|
}
|
|
setNoiseCancellation(a0) {
|
|
this.noiseCancellation = a0;
|
|
getVoiceEngine().setTransportOptions({
|
|
noiseCancellation: this.noiseCancellation
|
|
});
|
|
}
|
|
setNoiseCancellationDuringProcessing(a0) {
|
|
this.noiseCancellationDuringProcessing = a0;
|
|
getVoiceEngine().setTransportOptions({
|
|
noiseCancellationDuringProcessing: this.noiseCancellationDuringProcessing
|
|
});
|
|
}
|
|
setEchoReferenceMode(a0) {
|
|
this.echoReferenceMode = a0;
|
|
getVoiceEngine().setTransportOptions({
|
|
echoReferenceMode: this.echoReferenceMode
|
|
});
|
|
}
|
|
getNoiseCancellation() {
|
|
return this.noiseCancellation;
|
|
}
|
|
setQoS(a0) {
|
|
this.qos = a0;
|
|
this.conn.setTransportOptions({
|
|
qos: this.qos
|
|
});
|
|
}
|
|
setSoundshareDiscardRearChannels(a0) {
|
|
this.conn.setTransportOptions({
|
|
soundshareDiscardRearChannels: a0
|
|
});
|
|
}
|
|
setInputMode(a0, a1) {
|
|
this.inputMode = a0;
|
|
if (InputModes.PUSH_TO_TALK === a0) {
|
|
this.pttReleaseDelay = a1.pttReleaseDelay;
|
|
} else {
|
|
if (InputModes.VOICE_ACTIVITY !== a0) {
|
|
throw new Error(`Unknown Input Mode: ${a0}`);
|
|
}
|
|
this.vadThreshold = a1.vadThreshold;
|
|
this.vadAutoThreshold = a1.vadAutoThreshold;
|
|
this.vadUseKrisp = a1.vadUseKrisp;
|
|
this.vadLeading = a1.vadLeading;
|
|
this.vadTrailing = a1.vadTrailing;
|
|
this.vadKrispActivationThreshold = a1.vadKrispActivationThreshold;
|
|
this.vadDuringPreProcess = a1.vadDuringPreProcess;
|
|
}
|
|
this.conn.setTransportOptions({
|
|
inputMode: NATIVE_MODE_VALUES[this.inputMode],
|
|
inputModeOptions: this.createInputModeOptions()
|
|
});
|
|
}
|
|
setSilenceThreshold(a0) {
|
|
getVoiceEngine().setNoInputThreshold(a0);
|
|
}
|
|
setForceAudioInput(a0, r6 = false, r5 = false) {
|
|
this.conn.setPTTActive(a0, r6, r5);
|
|
}
|
|
setSpeakingFlags(a0, a1) {
|
|
if (this.conn.setRemoteUserSpeakingStatus != null) {
|
|
this.conn.setRemoteUserSpeakingStatus(a0, a1);
|
|
} else if (this.conn.setRemoteUserSpeaking != null) {
|
|
this.conn.setRemoteUserSpeaking(a0, (a1 & SpeakingFlags.VOICE) === SpeakingFlags.VOICE);
|
|
}
|
|
this.handleSpeakingFlags(a0, a1);
|
|
}
|
|
clearAllSpeaking() {}
|
|
setEncryption(a0, a1) {
|
|
this.logger.info(`Selected encryption mode: ${a0}`);
|
|
this.conn.setTransportOptions({
|
|
encryptionSettings: {
|
|
mode: a0,
|
|
secretKey: a1
|
|
}
|
|
});
|
|
}
|
|
setReconnectInterval(a0) {
|
|
this.reconnectInterval = a0;
|
|
this.conn.setTransportOptions({
|
|
reconnectInterval: this.reconnectInterval
|
|
});
|
|
}
|
|
setKeyframeInterval(a0) {
|
|
this.keyframeInterval = a0;
|
|
this.conn.setTransportOptions({
|
|
keyframeInterval: this.getKeyFrameInterval(),
|
|
alwaysSendVideo: this.keyframeInterval > 0
|
|
});
|
|
}
|
|
setVideoQualityMeasurement(a0) {
|
|
this.videoQualityMeasurement = a0;
|
|
this.conn.setTransportOptions({
|
|
videoQualityMeasurement: this.videoQualityMeasurement
|
|
});
|
|
}
|
|
setVideoEncoderExperiments(a0) {
|
|
this.videoEncoderExperiments = a0;
|
|
this.conn.setTransportOptions({
|
|
videoEncoderExperiments: this.videoEncoderExperiments
|
|
});
|
|
}
|
|
setAudioVideoOverridesTransport(a0) {
|
|
let r19 = a0.overrideDeniedVideoCodecs != null && a0.overrideDeniedVideoCodecs !== this.lastOverrideCodecDenylist;
|
|
const r1 = a0.overrideDeniedVideoEncoders != null && a0.overrideDeniedVideoEncoders !== this.lastOverrideEncoderDenylist;
|
|
const r2 = a0.captureOverrides != null && a0.captureOverrides !== this.lastCaptureOverrides;
|
|
const r10 = {};
|
|
if (r19) {
|
|
r10.overrideDeniedVideoCodecs = a0.overrideDeniedVideoCodecs;
|
|
}
|
|
if (r1) {
|
|
r10.overrideDeniedVideoEncoders = a0.overrideDeniedVideoEncoders;
|
|
}
|
|
if (r2) {
|
|
r10.captureOverrides = a0.captureOverrides;
|
|
}
|
|
if ((r19 ? r19 : r1) || r2) {
|
|
this.conn.setTransportOptions(r10);
|
|
}
|
|
if (r19) {
|
|
this.lastOverrideCodecDenylist = a0.overrideDeniedVideoCodecs;
|
|
}
|
|
if (r1) {
|
|
this.lastOverrideEncoderDenylist = a0.overrideDeniedVideoEncoders;
|
|
}
|
|
if (r2) {
|
|
this.lastCaptureOverrides = a0.captureOverrides;
|
|
}
|
|
if (r19 ? r19 : r1) {
|
|
this.videoEncoderFallbackPending = false;
|
|
this.videoDecoderFallbackSent.clear();
|
|
}
|
|
if (!(!r19 && !r1) && this.initialCodecs.length > 0) {
|
|
const r45 = this.lastOverrideCodecDenylist.length > 0 ? new Set(this.lastOverrideCodecDenylist.split(",").map((item) => item.trim().toUpperCase())) : null;
|
|
let c14121_1;
|
|
let c14121_0 = r45;
|
|
const codecs = this.initialCodecs.map((initialCodec) => ({
|
|
...initialCodec
|
|
})).filter((item) => item.type !== "video" || c14121_0 == null || item.name === "VP8" || item.name === "VP9" || !c14121_0.has(item.name));
|
|
const set = new Set(this.codecs.filter((codec) => codec.type === "video" && codec.encode).map((item) => item.name));
|
|
c14121_1 = new Set(codecs.filter((codec) => codec.type === "video" && codec.encode).map((item) => item.name));
|
|
const r90 = [...set].some((item) => !c14121_1.has(item));
|
|
this.codecs = codecs;
|
|
if (r19) {
|
|
r19 = r90;
|
|
}
|
|
if (r19) {
|
|
this.overrideCodecResetAt = performance.now();
|
|
}
|
|
this.emit(BaseConnectionEvent.VideoEncoderFallback, this.codecs);
|
|
}
|
|
}
|
|
setVideoBroadcast(a0) {
|
|
if (this.selfVideo !== a0) {
|
|
this.selfVideo = a0;
|
|
this.applyVideoTransportOptions();
|
|
}
|
|
}
|
|
setGoLiveSource(a0) {
|
|
const quality = a0.quality;
|
|
const { resolution, frameRate } = quality;
|
|
const r56 = resolution <= 480 ? resolution / 3 * 4 : resolution / 9 * 16;
|
|
const goLiveSourceIdentifier = a0.desktopDescription != null ? a0.desktopDescription.id : a0.cameraDescription != null ? `${a0.cameraDescription.videoDeviceGuid}:${a0.cameraDescription.audioDeviceGuid}` : null;
|
|
if (this.goLiveSourceIdentifier !== goLiveSourceIdentifier) {
|
|
this.goLiveSourceIdentifier = goLiveSourceIdentifier;
|
|
if (this.conn.setDesktopSource != null) {
|
|
if (a0.desktopDescription != null) {
|
|
const desktopDescription2 = a0.desktopDescription;
|
|
const { id, soundshareId, useLoopback: useLoopback2, useVideoHook, useHookFramePacer, useGraphicsCaptureApiLevel, useCaptureDeviceForEncode, useGraphicsCapture, useQuartzCapturer, allowScreenCaptureKit, videoHookStaleFrameTimeoutMs, graphicsCaptureStaleFrameTimeoutMs, hdrCaptureMode, enableGlobalFramePoolLock, useGraphicsCaptureDirtyRegions, videoHookAllowDx12, minCaptureWidth, minCaptureHeight } = desktopDescription2;
|
|
this.setSoundshareSource(soundshareId, useLoopback2);
|
|
const [type, sourceId] = id != null ? id.split(":") : ["", ""];
|
|
if (id != null) {
|
|
this.logger.info(`capturing desktop (type: ${type}, handle: ${sourceId}, use-video-hook: ${useVideoHook.toString()}, use-graphics-capture: ${useGraphicsCapture == null ? void 0 : useGraphicsCapture.toString()}, use-graphics-capture-api-level: ${useGraphicsCaptureApiLevel == null ? void 0 : useGraphicsCaptureApiLevel.toString()}, use-capture-device-for-encode: ${useCaptureDeviceForEncode == null ? void 0 : useCaptureDeviceForEncode.toString()}).`);
|
|
} else {
|
|
this.logger.info("capturing desktop (type: <stop>).");
|
|
}
|
|
if (this.conn.setDesktopSourceWithOptions != null) {
|
|
if (id != null) {
|
|
this.setDesktopEncodingOptions(r56, resolution, frameRate);
|
|
this.conn.setDesktopSourceWithOptions({
|
|
type,
|
|
sourceId,
|
|
useVideoHook,
|
|
useHookFramePacer,
|
|
useGraphicsCapture,
|
|
useGraphicsCaptureApiLevel,
|
|
useCaptureDeviceForEncode,
|
|
useQuartzCapturer,
|
|
allowScreenCaptureKit,
|
|
videoHookStaleFrameTimeoutMs,
|
|
graphicsCaptureStaleFrameTimeoutMs,
|
|
hdrCaptureMode,
|
|
enableGlobalFramePoolLock,
|
|
useGraphicsCaptureDirtyRegions,
|
|
videoHookAllowDx12,
|
|
minCaptureWidth,
|
|
minCaptureHeight
|
|
});
|
|
} else {
|
|
this.conn.clearDesktopSource();
|
|
}
|
|
} else {
|
|
this.conn.setDesktopSource(`wumpus-${sourceId}`, useVideoHook, type);
|
|
}
|
|
} else if (a0.cameraDescription != null) {
|
|
const cameraDescription = a0.cameraDescription;
|
|
this.conn.setGoLiveDevices({
|
|
videoInputDeviceId: cameraDescription.videoDeviceGuid,
|
|
audioInputDeviceId: cameraDescription.audioDeviceGuid
|
|
});
|
|
}
|
|
this.setDesktopEncodingOptions(r56, resolution, frameRate);
|
|
}
|
|
} else {
|
|
this.setDesktopEncodingOptions(r56, resolution, frameRate);
|
|
if (a0.desktopDescription != null) {
|
|
const desktopDescription = a0.desktopDescription;
|
|
const { soundshareId: soundshareId2, useLoopback } = desktopDescription;
|
|
if (this.soundshareId !== soundshareId2) {
|
|
this.setSoundshareSource(soundshareId2, useLoopback);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
clearGoLiveDevices() {
|
|
if (this.conn.clearGoLiveDevices != null) {
|
|
this.conn.clearGoLiveDevices();
|
|
}
|
|
}
|
|
clearDesktopSource() {
|
|
this.goLiveSourceIdentifier = null;
|
|
if (this.conn.clearDesktopSource != null) {
|
|
this.conn.clearDesktopSource();
|
|
} else {
|
|
this.conn.setDesktopSource("", false, "");
|
|
}
|
|
}
|
|
setDesktopSourceStatusCallback(a0) {
|
|
const conn = this.conn;
|
|
const setDesktopSourceStatusCallback2 = conn.setDesktopSourceStatusCallback;
|
|
if (setDesktopSourceStatusCallback2 != null) {
|
|
setDesktopSourceStatusCallback2.call(conn, a0);
|
|
}
|
|
}
|
|
hasDesktopSource() {
|
|
return this.goLiveSourceIdentifier != null;
|
|
}
|
|
setDesktopEncodingOptions(a0, a1, a2) {
|
|
if (!this.destroyed) {
|
|
this.lastDesktopEncodingOptions = {
|
|
width: a0,
|
|
height: a1,
|
|
framerate: a2
|
|
};
|
|
let bitrateMax = this.calcMaxBitrateFunc({
|
|
width: a0,
|
|
height: a1,
|
|
framerate: a2,
|
|
videoCodec: this.currentVideoCodec
|
|
});
|
|
if (bitrateMax == null) {
|
|
bitrateMax = !(a1 === 0 && a2 >= 10) && (!(a1 > 720) && !(a2 > 30)) ? DESKTOP_BITRATE : DESKTOP_BITRATE_ENHANCED;
|
|
}
|
|
const capture = {
|
|
width: a0,
|
|
height: a1,
|
|
framerate: a2
|
|
};
|
|
const quality = this.videoQualityManager.getQuality();
|
|
const r39 = VideoQuality.equals(capture, quality.capture);
|
|
const r1 = r39 ? quality.bitrateMax !== bitrateMax : !r39;
|
|
let r44 = this.videoStreamParameters.findIndex((videoStreamParameter) => videoStreamParameter.quality === SIMULCAST_HQ_QUALITY);
|
|
if (r44 === -1) {
|
|
r44 = 0;
|
|
}
|
|
if (r1) {
|
|
this.videoQualityManager.setGoliveQuality({
|
|
capture,
|
|
encode: capture,
|
|
bitrateMax
|
|
});
|
|
if (this.videoStreamParameters.length > r44) {
|
|
this.videoStreamParameters[r44].maxResolution = {
|
|
type: a0 === 0 && a1 === 0 ? ResolutionTypes.SOURCE : ResolutionTypes.FIXED,
|
|
width: a0,
|
|
height: a1
|
|
};
|
|
this.videoStreamParameters[r44].maxFrameRate = a2;
|
|
this.videoStreamParameters[r44].maxBitrate = bitrateMax;
|
|
}
|
|
const emit = this.emit;
|
|
const Video = BaseConnectionEvent.Video;
|
|
const userId = this.userId;
|
|
const audioSSRC = this.audioSSRC;
|
|
const ssrc = this.videoStreamParameters[r44].ssrc;
|
|
const ssrc2 = this.videoStreamParameters[r44].ssrc;
|
|
emit.call(this, Video, userId, null, audioSSRC, ssrc, ssrc2 != null ? ssrc2 !== 0 ? ssrc2 + 1 : 0 : 0, this.videoStreamParameters);
|
|
this.conn.setTransportOptions(this.applyQualityConstraints().constraints);
|
|
}
|
|
}
|
|
}
|
|
setSDP() {}
|
|
setRemoteVideoSinkWants(a0) {
|
|
this.remoteVideoSinkWants = a0;
|
|
this.updateVideoQuality(MEDIA_SINK_WANTS_PROPERTIES);
|
|
}
|
|
setLocalVideoSinkWants(a0) {
|
|
const localVideoSinkWants = this.localVideoSinkWants;
|
|
for (const item of Object.entries(this.remoteVideoSSRCs)) {
|
|
const [r43, r18] = item;
|
|
let r44 = 0;
|
|
let r45 = 0;
|
|
for (const item2 of r18) {
|
|
r44 = r44 + (localVideoSinkWants == null ? void 0 : localVideoSinkWants[item2]);
|
|
r45 = r45 + (a0 == null ? void 0 : a0[item2]);
|
|
}
|
|
if (r44 === 0 && r45 !== 0) {
|
|
const conn = this.conn;
|
|
const setDisableLocalVideo = conn.setDisableLocalVideo;
|
|
if (setDisableLocalVideo != null) {
|
|
setDisableLocalVideo.call(conn, r43, false);
|
|
}
|
|
}
|
|
if (!(r44 !== 0 && r45 === 0)) {
|
|
continue;
|
|
}
|
|
const conn2 = this.conn;
|
|
const setDisableLocalVideo2 = conn2.setDisableLocalVideo;
|
|
if (setDisableLocalVideo2 == null) {
|
|
continue;
|
|
}
|
|
setDisableLocalVideo2.call(conn2, r43, true);
|
|
}
|
|
this.localVideoSinkWants = a0;
|
|
}
|
|
startSamplesLocalPlayback(a0, a1, a2, a3) {
|
|
if (a1.numberOfChannels > 2) {
|
|
a3(2, "Too many channels");
|
|
} else if (this.conn.startSamplesLocalPlayback != null) {
|
|
const r10 = [];
|
|
const numberOfChannels = a1.numberOfChannels;
|
|
let r0 = 0;
|
|
if (0 < numberOfChannels) {
|
|
do {
|
|
r10.push(a1.getChannelData(r0));
|
|
r0 = r0 + 1;
|
|
} while (r0 < a1.numberOfChannels);
|
|
}
|
|
this.conn.startSamplesLocalPlayback(a0, {
|
|
sampleRate: a1.sampleRate,
|
|
volume: a2
|
|
}, r10, a3);
|
|
} else {
|
|
a3(3, "Not supported");
|
|
}
|
|
}
|
|
stopAllSamplesLocalPlayback() {
|
|
this.conn.stopAllSamplesLocalPlayback();
|
|
}
|
|
stopSamplesLocalPlayback(a0) {
|
|
const conn = this.conn;
|
|
const stopSamplesLocalPlayback2 = conn.stopSamplesLocalPlayback;
|
|
if (stopSamplesLocalPlayback2 != null) {
|
|
stopSamplesLocalPlayback2.call(conn, a0);
|
|
}
|
|
}
|
|
setBandwidthEstimationExperiments(a0) {
|
|
this.conn.setTransportOptions({
|
|
bandwidthEstimationExperiments: a0
|
|
});
|
|
}
|
|
updateVideoQualityCore(a0) {
|
|
if (this.videoSupported && !this.destroyed) {
|
|
this.conn.setTransportOptions(a0);
|
|
}
|
|
}
|
|
setStreamParameters(c14122_1) {
|
|
const _this2 = this;
|
|
const _this = this;
|
|
return new Promise((resolve, c25046_0) => {
|
|
const _loop = function _loop(c29312_0) {
|
|
const r6 = c14122_1.findIndex((item) => item.rid === c29312_0.rid);
|
|
if (r6 === -1) {
|
|
c25046_0(new Error("Invalid rid"));
|
|
return {
|
|
v: void 0
|
|
};
|
|
}
|
|
const streamParameters = [];
|
|
if (!isEqual(_this.videoStreamParameters[r6], c14122_1[r6])) {
|
|
_this.videoStreamParameters[r6] = {
|
|
...c14122_1[r6]
|
|
};
|
|
streamParameters.push({
|
|
...c14122_1[r6]
|
|
});
|
|
}
|
|
_this.conn.setTransportOptions({
|
|
streamParameters
|
|
});
|
|
};
|
|
for (const videoStreamParameter of _this2.videoStreamParameters) {
|
|
const r26 = _loop(videoStreamParameter);
|
|
if (!r26) {
|
|
continue;
|
|
}
|
|
return r26.v;
|
|
}
|
|
resolve();
|
|
});
|
|
}
|
|
applyVideoTransportOptions() {
|
|
if (this.videoSupported) {
|
|
const r1 = this.hasDesktopSource() && this.videoStreamParameters.length > 0 ? this.videoStreamParameters[0].maxResolution?.type === ResolutionTypes.SOURCE : false;
|
|
this.conn.setTransportOptions(this.applyQualityConstraints({
|
|
encodingVideoDegradationPreference: this.hasDesktopSource() ? r1 ? this.sourceDesktopDegradationPreference : this.desktopDegradationPreference : this.videoDegradationPreference
|
|
}).constraints);
|
|
this.conn.setVideoBroadcast(this.selfVideo);
|
|
}
|
|
}
|
|
chooseEncryptionMode(a0, a1) {
|
|
let r20;
|
|
for (const item2 of a1) {
|
|
done8: {
|
|
for (const item of a0) {
|
|
if (item2 !== item) {
|
|
continue;
|
|
}
|
|
r20 = item2;
|
|
break done8;
|
|
}
|
|
continue;
|
|
}
|
|
return r20;
|
|
}
|
|
return "xsalsa20_poly1305";
|
|
}
|
|
getUserOptions() {
|
|
return Object.keys(this.remoteAudioSSRCs).map((item) => {
|
|
const videoSsrc = this.remoteVideoSSRCs[item] !== void 0 ? this.remoteVideoSSRCs[item].length > 0 ? this.remoteVideoSSRCs[item][0] : 0 : 0;
|
|
return {
|
|
id: item,
|
|
ssrc: this.remoteAudioSSRCs[item],
|
|
videoSsrc,
|
|
videoSsrcs: this.remoteVideoSSRCs[item],
|
|
rtxSsrc: videoSsrc != null ? videoSsrc !== 0 ? videoSsrc + 1 : 0 : 0,
|
|
mute: this.getLocalMute(item),
|
|
volume: this.getLocalVolume(item)
|
|
};
|
|
});
|
|
}
|
|
createInputModeOptions() {
|
|
const inputMode = this.inputMode;
|
|
if (InputModes.VOICE_ACTIVITY === inputMode) {
|
|
return {
|
|
vadThreshold: this.vadThreshold,
|
|
vadAutoThreshold: this.vadAutoThreshold ? VADAggressiveness.VERY_AGGRESSIVE : VADAggressiveness.DISABLED,
|
|
vadUseKrisp: this.vadUseKrisp,
|
|
vadLeading: this.vadLeading,
|
|
vadTrailing: this.vadTrailing,
|
|
vadKrispActivationThreshold: this.vadKrispActivationThreshold,
|
|
vadDuringPreProcess: this.vadDuringPreProcess
|
|
};
|
|
}
|
|
if (InputModes.PUSH_TO_TALK === inputMode) {
|
|
return {
|
|
pttReleaseDelay: this.pttReleaseDelay
|
|
};
|
|
}
|
|
throw new Error(`Unknown Input Mode: ${this.inputMode}`);
|
|
}
|
|
getAttenuationOptions() {
|
|
return {
|
|
attenuation: this.isAttenuating(),
|
|
attenuationFactor: this.attenuationFactor,
|
|
attenuateWhileSpeakingSelf: this.attenuateWhileSpeakingSelf,
|
|
attenuateWhileSpeakingOthers: this.attenuateWhileSpeakingOthers
|
|
};
|
|
}
|
|
getCodecParams(a0, a1) {
|
|
return a0 !== Codecs.H264 ? {} : a1 ? {
|
|
"level-asymmetry-allowed": "1",
|
|
"packetization-mode": "1",
|
|
"profile-level-id": "42e034"
|
|
} : {
|
|
"level-asymmetry-allowed": "1",
|
|
"packetization-mode": "1",
|
|
"profile-level-id": getVoiceEngine().platform === "android" ? "42e01f" : "4d0033"
|
|
};
|
|
}
|
|
getCodecOptions(a0, a1, a2) {
|
|
let type = this.codecs.find((codec) => codec.name === a0)?.payloadType;
|
|
if (type == null) {
|
|
type = 0;
|
|
}
|
|
const audioEncoder = {
|
|
type,
|
|
name: a0,
|
|
freq: 48000,
|
|
pacsize: 960,
|
|
channels: 1,
|
|
rate: 64000
|
|
};
|
|
const audioDecoders = this.codecs.filter((codec) => codec.type === "audio").map((item) => {
|
|
let type = item?.payloadType;
|
|
if (type == null) {
|
|
type = 0;
|
|
}
|
|
return {
|
|
type,
|
|
name: item.name,
|
|
freq: 48000,
|
|
channels: 2,
|
|
params: {
|
|
stereo: "1"
|
|
}
|
|
};
|
|
});
|
|
if (a2 === MediaEngineContextTypes.STREAM) {
|
|
audioEncoder.channels = 2;
|
|
}
|
|
const videoDecoders = [];
|
|
let videoEncoder = {
|
|
name: "",
|
|
type: 0,
|
|
rtxType: 0,
|
|
params: {}
|
|
};
|
|
for (const codec of this.codecs) {
|
|
const r63 = codec;
|
|
if (codec.name !== a0) {
|
|
const r68 = {
|
|
name: codecNameToPayloadName(r63.name),
|
|
type: null,
|
|
rtxType: null,
|
|
params: null
|
|
};
|
|
let type2 = r63?.payloadType;
|
|
if (type2 == null) {
|
|
type2 = 0;
|
|
}
|
|
r68.type = type2;
|
|
let rtxType = r63?.rtxPayloadType;
|
|
if (rtxType == null) {
|
|
rtxType = 0;
|
|
}
|
|
r68.rtxType = rtxType;
|
|
r68.params = this.getCodecParams(r63.name, true);
|
|
if (this.experimentFlags.has(ExperimentFlags.RESET_DECODER_ON_ERRORS)) {
|
|
r68.params["reset-on-errors"] = "1";
|
|
}
|
|
if (this.experimentFlags.has(ExperimentFlags.SOFTWARE_FALLBACK_ON_ERRORS)) {
|
|
r68.params["fallback-after-errors"] = "3";
|
|
}
|
|
if (this.experimentFlags.has(ExperimentFlags.SOFTWARE_FALLBACK_ON_CONSECUTIVE_ERRORS)) {
|
|
r68.params["fallback-on-consecutive-errors"] = "1";
|
|
}
|
|
if (this.experimentFlags.has(ExperimentFlags.SIGNAL_AV1_HARDWARE_DECODE)) {
|
|
r68.params["hardware-av1-decode"] = "1";
|
|
}
|
|
r68.name;
|
|
r68.params["hardware-h264"] = "1";
|
|
if (this.experimentFlags.has(ExperimentFlags.USE_LIBOPENH264_DECODER)) {
|
|
const openH264LibraryPath = getOpenH264LibraryPath();
|
|
if (openH264LibraryPath != null) {
|
|
r68.params.libopenh264 = "1";
|
|
r68.params["libopenh264-path"] = openH264LibraryPath;
|
|
}
|
|
}
|
|
videoDecoders.push(r68);
|
|
if (r63.name === a1) {
|
|
videoEncoder = {
|
|
...r68,
|
|
params: this.getCodecParams(r63.name, false)
|
|
};
|
|
if (this.experimentFlags.has(ExperimentFlags.VIDEOTOOLBOX_RATE_CONTROL)) {
|
|
videoEncoder.params["fixed-rate-presentation-timestamps"] = "1";
|
|
}
|
|
if (this.experimentFlags.has(ExperimentFlags.LOW_LATENCY_RATE_CONTROL)) {
|
|
videoEncoder.params["low-latency-rate-control"] = "1";
|
|
}
|
|
if (this.experimentFlags.has(ExperimentFlags.WMF_GPU_ENCODE)) {
|
|
videoEncoder.params["wmf-gpu"] = "1";
|
|
}
|
|
if (this.experimentFlags.has(ExperimentFlags.INTEL_GPU_DISABLE)) {
|
|
videoEncoder.params["intel-gpu"] = "0";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return {
|
|
videoEncoder,
|
|
videoDecoders,
|
|
audioEncoder,
|
|
audioDecoders
|
|
};
|
|
}
|
|
getKeyFrameInterval() {
|
|
return this.keyframeInterval > 0 && this.clipsKeyFrameInterval > 0 ? Math.min(this.keyframeInterval, this.clipsKeyFrameInterval) : Math.max(this.keyframeInterval, this.clipsKeyFrameInterval);
|
|
}
|
|
getConnectionTransportOptions() {
|
|
const r3 = {
|
|
selfMute: this.selfMute,
|
|
inputMode: NATIVE_MODE_VALUES[this.inputMode],
|
|
inputModeOptions: this.createInputModeOptions(),
|
|
minimumJitterBufferLevel: this.minimumJitterBufferLevel,
|
|
postponeDecodeLevel: this.postponeDecodeLevel,
|
|
...this.getAttenuationOptions(),
|
|
fec: true,
|
|
packetLossRate: 0.3,
|
|
qos: this.qos,
|
|
prioritySpeakerDucking: DEFAULT_PRIORITY_SPEAKER_DUCKING,
|
|
encodingVoiceBitRate: this.voiceBitrate,
|
|
callBitRate: DEFAULT_CALL_BITRATE,
|
|
callMinBitRate: DEFAULT_CALL_MIN_BITRATE,
|
|
callMaxBitRate: DEFAULT_CALL_MAX_BITRATE,
|
|
encodingVideoDegradationPreference: this.videoDegradationPreference,
|
|
reconnectInterval: this.reconnectInterval
|
|
};
|
|
if (supportsFeature(NativeFeatures.VIDEO_EFFECTS) && this.context === MediaEngineContextTypes.STREAM) {
|
|
r3.enableVideoEffects = true;
|
|
}
|
|
return r3;
|
|
}
|
|
setStream() {
|
|
throw new Error("Method not implemented.");
|
|
}
|
|
getUserIdBySsrc() {}
|
|
prepareSecureFramesTransition(a0, a1, a2) {
|
|
if (a0 === 0) {
|
|
this.lastExecutedTransitionId = -1;
|
|
this.lastPreparedTransitionId = -1;
|
|
}
|
|
this.lastPreparedTransitionId = a0;
|
|
const conn = this.conn;
|
|
const prepareSecureFramesTransition2 = conn.prepareSecureFramesTransition;
|
|
if (prepareSecureFramesTransition2 != null) {
|
|
prepareSecureFramesTransition2.call(conn, a0, a1, a2);
|
|
}
|
|
}
|
|
prepareSecureFramesEpoch(a0, a1, a2) {
|
|
const conn = this.conn;
|
|
const prepareSecureFramesEpoch2 = conn.prepareSecureFramesEpoch;
|
|
if (prepareSecureFramesEpoch2 != null) {
|
|
prepareSecureFramesEpoch2.call(conn, a0, a1, a2);
|
|
}
|
|
}
|
|
executeSecureFramesTransition(a0) {
|
|
if (this.lastExecutedTransitionId !== -1 && this.lastPreparedTransitionId !== -1 && !(this.lastPreparedTransitionId >= this.lastExecutedTransitionId ? a0 > this.lastExecutedTransitionId && a0 <= this.lastPreparedTransitionId : a0 > this.lastExecutedTransitionId || a0 <= this.lastPreparedTransitionId)) {
|
|
const r8 = `Skipping invalid transition ${a0} outside of range (${this.lastExecutedTransitionId}-${this.lastPreparedTransitionId}]`;
|
|
this.logger.warn(r8);
|
|
throw new Error(r8);
|
|
}
|
|
this.lastExecutedTransitionId = a0;
|
|
const conn = this.conn;
|
|
const executeSecureFramesTransition2 = conn.executeSecureFramesTransition;
|
|
if (executeSecureFramesTransition2 != null) {
|
|
executeSecureFramesTransition2.call(conn, a0);
|
|
}
|
|
}
|
|
getMLSKeyPackage(a0) {
|
|
const conn = this.conn;
|
|
const getMLSKeyPackage2 = conn.getMLSKeyPackage;
|
|
if (getMLSKeyPackage2 != null) {
|
|
getMLSKeyPackage2.call(conn, a0);
|
|
}
|
|
}
|
|
updateMLSExternalSender(a0) {
|
|
const conn = this.conn;
|
|
const updateMLSExternalSender2 = conn.updateMLSExternalSender;
|
|
if (updateMLSExternalSender2 != null) {
|
|
updateMLSExternalSender2.call(conn, a0);
|
|
}
|
|
}
|
|
processMLSProposals(a0, a1) {
|
|
const conn = this.conn;
|
|
const processMLSProposals2 = conn.processMLSProposals;
|
|
if (processMLSProposals2 != null) {
|
|
processMLSProposals2.call(conn, a0, a1);
|
|
}
|
|
}
|
|
prepareMLSCommitTransition(a0, a1, a2) {
|
|
this.lastPreparedTransitionId = a0;
|
|
const conn = this.conn;
|
|
const prepareMLSCommitTransition2 = conn.prepareMLSCommitTransition;
|
|
if (prepareMLSCommitTransition2 != null) {
|
|
prepareMLSCommitTransition2.call(conn, a0, a1, a2);
|
|
}
|
|
}
|
|
processMLSWelcome(a0, a1, a2) {
|
|
this.lastPreparedTransitionId = a0;
|
|
const conn = this.conn;
|
|
const processMLSWelcome2 = conn.processMLSWelcome;
|
|
if (processMLSWelcome2 != null) {
|
|
processMLSWelcome2.call(conn, a0, a1, a2);
|
|
}
|
|
}
|
|
getMLSPairwiseFingerprint(a0, a1, a2) {
|
|
const conn = this.conn;
|
|
const getMLSPairwiseFingerprint2 = conn.getMLSPairwiseFingerprint;
|
|
if (getMLSPairwiseFingerprint2 != null) {
|
|
getMLSPairwiseFingerprint2.call(conn, a0, a1, a2);
|
|
}
|
|
}
|
|
presentDesktopSourcePicker(a0) {
|
|
const conn = this.conn;
|
|
const presentDesktopSourcePicker2 = conn.presentDesktopSourcePicker;
|
|
if (presentDesktopSourcePicker2 != null) {
|
|
presentDesktopSourcePicker2.call(conn, a0);
|
|
}
|
|
}
|
|
mergeUsers(a0) {
|
|
this.conn.mergeUsers(a0);
|
|
this.emit(BaseConnectionEvent.UsersMerged, a0);
|
|
}
|
|
};
|
|
const prototype2 = Connection2.prototype;
|
|
Connection = Connection2;
|
|
prototype = prototype2;
|
|
export default Connection;
|