sinch-rtc
Version:
RTC JavaScript/Web SDK
33 lines • 2.24 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HighInboundJitterDetector = void 0;
const CallQualityWarningMediaStreamType_1 = require("../CallQualityWarningMediaStreamType");
const BufferedWarningDetector_1 = require("./BufferedWarningDetector");
const HighInboundJitterWarningEvent_1 = require("../events/HighInboundJitterWarningEvent");
const WebRTCStats_types_1 = require("../../reporting/WebRTCStats.types");
const WebRtcStatsUtils_1 = require("../../WebRtcStatsUtils");
const WebRtcStatsDetector_1 = require("./WebRtcStatsDetector");
class HighInboundJitterDetector extends BufferedWarningDetector_1.BufferedWarningDetector {
constructor(mediaStream, fanout) {
super(fanout, BufferedWarningDetector_1.BufferedWarningDetector.DEFAULT_BUFFER_SIZE, BufferedWarningDetector_1.BufferedWarningDetector.DEFAULT_SAMPLES_COUNT_FOR_WARNING, HighInboundJitterDetector.JITTER_THRESHOLD_MS);
this.mediaStream = mediaStream;
}
onNewWebRtcStats(report) {
const mediaStreamType = this.mediaStream === CallQualityWarningMediaStreamType_1.CallQualityWarningMediaStreamType.Audio
? WebRTCStats_types_1.MediaType.Audio
: WebRTCStats_types_1.MediaType.Video;
const inboundRtpStats = (0, WebRtcStatsUtils_1.getStatsWithType)(report, WebRTCStats_types_1.RtcStatsTypes.InboundRtp, mediaStreamType);
const currentJitterSeconds = inboundRtpStats === null || inboundRtpStats === void 0 ? void 0 : inboundRtpStats[HighInboundJitterDetector.JITTER_KEY];
const currentJitterMs = currentJitterSeconds !== undefined
? currentJitterSeconds * 1000
: undefined;
this.onNewMonitoredValue(currentJitterMs, inboundRtpStats === null || inboundRtpStats === void 0 ? void 0 : inboundRtpStats[WebRtcStatsDetector_1.WebRtcStatsDetector.TIMESTAMP_KEY]);
}
warningEventWithType(type) {
return new HighInboundJitterWarningEvent_1.HighInboundJitterWarningEvent(type, this.mediaStream);
}
}
exports.HighInboundJitterDetector = HighInboundJitterDetector;
HighInboundJitterDetector.JITTER_KEY = "jitter";
HighInboundJitterDetector.JITTER_THRESHOLD_MS = 30;
//# sourceMappingURL=HighInboundJitterDetector.js.map