sinch-rtc
Version:
RTC JavaScript/Web SDK
38 lines • 2.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HighRemoteInboundRttDetector = void 0;
const WebRTCStats_types_1 = require("../../reporting/WebRTCStats.types");
const WebRtcStatsUtils_1 = require("../../WebRtcStatsUtils");
const CallQualityWarningEventType_1 = require("../CallQualityWarningEventType");
const CallQualityWarningMediaStreamType_1 = require("../CallQualityWarningMediaStreamType");
const HighRemoteInboundRttWarningEvent_1 = require("../events/HighRemoteInboundRttWarningEvent");
const WebRtcStatsDetector_1 = require("./WebRtcStatsDetector");
class HighRemoteInboundRttDetector extends WebRtcStatsDetector_1.WebRtcStatsDetector {
constructor(mediaStream, fanout) {
super(fanout);
this.mediaStream = mediaStream;
}
onNewWebRtcStats(report) {
const mediaStreamType = this.mediaStream === CallQualityWarningMediaStreamType_1.CallQualityWarningMediaStreamType.Audio
? WebRTCStats_types_1.MediaType.Audio
: WebRTCStats_types_1.MediaType.Video;
const remoteInboundRtpStats = (0, WebRtcStatsUtils_1.getStatsWithType)(report, WebRTCStats_types_1.RtcStatsTypes.RemoteInboundRtp, mediaStreamType);
const currentRtt = remoteInboundRtpStats === null || remoteInboundRtpStats === void 0 ? void 0 : remoteInboundRtpStats[HighRemoteInboundRttDetector.RTT_KEY];
if (!currentRtt) {
return;
}
const currentRttMs = currentRtt * 1000;
if (currentRttMs > HighRemoteInboundRttDetector.RTT_THRESHOLD_MS &&
!this.isInTriggeredState) {
this.emitWarning(new HighRemoteInboundRttWarningEvent_1.HighRemoteInboundRttWarningEvent(CallQualityWarningEventType_1.CallQualityWarningEventType.Trigger, this.mediaStream));
}
else if (currentRttMs <= HighRemoteInboundRttDetector.RTT_THRESHOLD_MS &&
this.isInTriggeredState) {
this.emitWarning(new HighRemoteInboundRttWarningEvent_1.HighRemoteInboundRttWarningEvent(CallQualityWarningEventType_1.CallQualityWarningEventType.Recover, this.mediaStream));
}
}
}
exports.HighRemoteInboundRttDetector = HighRemoteInboundRttDetector;
HighRemoteInboundRttDetector.RTT_THRESHOLD_MS = 300;
HighRemoteInboundRttDetector.RTT_KEY = "roundTripTime";
//# sourceMappingURL=HighRemoteInboundRttDetector.js.map