Skip to content

Commit

Permalink
Split distortion into concealment and acceleration/deceleration (#68)
Browse files Browse the repository at this point in the history
* split audio distoration into concealment,acceleration and deceleration
* handle audio nack being null
* add glitchfree metric
  • Loading branch information
pnts-se-whereby authored Feb 12, 2024
1 parent 02de6a9 commit ee10ca8
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/utils/ReconnectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export class ReconnectManager extends EventEmitter {
roomJoinedLate: 0,
pendingClientCanceled: 0,
evaluationFailed: 0,
roomJoined: 0,
};

socket.on("disconnect", () => {
Expand Down Expand Up @@ -129,6 +130,7 @@ export class ReconnectManager extends EventEmitter {
}
});

this.metrics.roomJoined++;
this.emit(PROTOCOL_RESPONSES.ROOM_JOINED, payload);
}

Expand Down
45 changes: 38 additions & 7 deletions src/webrtc/stats/IssueMonitor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -205,15 +214,37 @@ 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 &&
ssrc0.bitrate &&
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",
Expand Down
2 changes: 1 addition & 1 deletion src/webrtc/stats/StatsMonitor/metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit ee10ca8

Please sign in to comment.