From ee10ca8ad85b8cf651036d66a2115328c99cf525 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pontus=20Fagerstr=C3=B6m?= <144339208+pnts-se-whereby@users.noreply.github.com> Date: Mon, 12 Feb 2024 10:54:53 +0100 Subject: [PATCH] Split distortion into concealment and acceleration/deceleration (#68) * split audio distoration into concealment,acceleration and deceleration * handle audio nack being null * add glitchfree metric --- package.json | 2 +- src/utils/ReconnectManager.js | 2 ++ src/webrtc/stats/IssueMonitor/index.js | 45 ++++++++++++++++++++---- src/webrtc/stats/StatsMonitor/metrics.js | 2 +- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index d742a73..b83cacc 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@whereby/jslib-media", "description": "Media library for Whereby", - "version": "1.7.5", + "version": "1.7.6", "private": false, "license": "MIT", "homepage": "https://github.com/whereby/jslib-media", diff --git a/src/utils/ReconnectManager.js b/src/utils/ReconnectManager.js index cb9bcc3..3460d0c 100644 --- a/src/utils/ReconnectManager.js +++ b/src/utils/ReconnectManager.js @@ -16,6 +16,7 @@ export class ReconnectManager extends EventEmitter { roomJoinedLate: 0, pendingClientCanceled: 0, evaluationFailed: 0, + roomJoined: 0, }; socket.on("disconnect", () => { @@ -129,6 +130,7 @@ export class ReconnectManager extends EventEmitter { } }); + this.metrics.roomJoined++; this.emit(PROTOCOL_RESPONSES.ROOM_JOINED, payload); } diff --git a/src/webrtc/stats/IssueMonitor/index.js b/src/webrtc/stats/IssueMonitor/index.js index fe0f8c5..19b8759 100644 --- a/src/webrtc/stats/IssueMonitor/index.js +++ b/src/webrtc/stats/IssueMonitor/index.js @@ -112,13 +112,22 @@ const issueDetectors = [ check: ({ stats }) => stats.pressure.state === "critical", }, { - id: "distorted", + id: "concealed", enabled: ({ hasLiveTrack, ssrc0, kind }) => hasLiveTrack && ssrc0 && kind === "audio", check: ({ ssrc0 }) => - ssrc0.bitrate && - ssrc0.direction === "in" && - ssrc0.audioLevel >= 0.001 && - Math.max(ssrc0.audioConcealment, ssrc0.audioAcceleration, ssrc0.audioDeceleration) >= 0.1, + ssrc0.bitrate && ssrc0.direction === "in" && ssrc0.audioLevel >= 0.001 && ssrc0.audioConcealment >= 0.1, + }, + { + id: "decelerated", + enabled: ({ hasLiveTrack, ssrc0, kind }) => hasLiveTrack && ssrc0 && kind === "audio", + check: ({ ssrc0 }) => + ssrc0.bitrate && ssrc0.direction === "in" && ssrc0.audioLevel >= 0.001 && ssrc0.audioDeceleration >= 0.1, + }, + { + id: "accelerated", + enabled: ({ hasLiveTrack, ssrc0, kind }) => hasLiveTrack && ssrc0 && kind === "audio", + check: ({ ssrc0 }) => + ssrc0.bitrate && ssrc0.direction === "in" && ssrc0.audioLevel >= 0.001 && ssrc0.audioAcceleration >= 0.1, }, // todo: // jitter/congestion - increasing jitter for several "ticks" @@ -205,7 +214,29 @@ const metrics = [ value: ({ stats }) => ({ nominal: 0.25, fair: 0.5, serious: 0.75, critical: 1 })[stats.pressure.state] || 0, }, { - id: "distortion", + id: "concealment", + enabled: ({ hasLiveTrack, ssrc0, kind }) => + hasLiveTrack && + ssrc0 && + ssrc0.bitrate && + ssrc0.direction === "in" && + kind === "audio" && + ssrc0.audioLevel >= 0.001, + value: ({ ssrc0 }) => ssrc0.audioConcealment, + }, + { + id: "deceleration", + enabled: ({ hasLiveTrack, ssrc0, kind }) => + hasLiveTrack && + ssrc0 && + ssrc0.bitrate && + ssrc0.direction === "in" && + kind === "audio" && + ssrc0.audioLevel >= 0.001, + value: ({ ssrc0 }) => ssrc0.audioDeceleration, + }, + { + id: "acceleration", enabled: ({ hasLiveTrack, ssrc0, kind }) => hasLiveTrack && ssrc0 && @@ -213,7 +244,7 @@ const metrics = [ ssrc0.direction === "in" && kind === "audio" && ssrc0.audioLevel >= 0.001, - value: ({ ssrc0 }) => Math.max(ssrc0.audioConcealment, ssrc0.audioAcceleration, ssrc0.audioDeceleration), + value: ({ ssrc0 }) => ssrc0.audioAcceleration, }, { id: "qpf", diff --git a/src/webrtc/stats/StatsMonitor/metrics.js b/src/webrtc/stats/StatsMonitor/metrics.js index 0a9cd3c..9eaa912 100644 --- a/src/webrtc/stats/StatsMonitor/metrics.js +++ b/src/webrtc/stats/StatsMonitor/metrics.js @@ -53,7 +53,7 @@ export function captureSsrcInfo(ssrcMetrics, currentSsrcStats, prevSsrcStats, ti } export function captureCommonSsrcMetrics(ssrcMetrics, currentSsrcStats, prevSsrcStats, timeDiff, report) { - const nackCountDiff = currentSsrcStats.nackCount - (prevSsrcStats?.nackCount || 0); + const nackCountDiff = (currentSsrcStats.nackCount || 0) - (prevSsrcStats?.nackCount || 0); ssrcMetrics.nackCount = (ssrcMetrics.nackCount || 0) + nackCountDiff; ssrcMetrics.nackRate = (1000 * nackCountDiff) / timeDiff;