Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.

Commit a9ba368

Browse files
Calculate packet loss in time frame instead of accumulated value (#60)
1 parent 48b6bbd commit a9ba368

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

.jellyfish-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.3.0
1+
0.4.2

assets/src/pages/room/RoomPage.tsx

+11-8
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,11 @@ const ConnectComponent: FC<ConnectComponentProps> = (
8585

8686
const bitrate = 8 * (currentBytesReceived - prevBytesReceived) * 1000 / dx; // bits per seconds
8787

88-
const packetLoss = report?.packetsReceived ? report?.packetsLost / report?.packetsReceived * 100 : NaN; // in %
88+
const dxPacketsLost = (report?.packetsLost ?? 0) - (lastReport?.packetsLost ?? 0);
89+
const dxPacketsReceived = (report?.packetsReceived ?? 0) - (lastReport?.packetsReceived ?? 0);
90+
const packetLoss = dxPacketsReceived ? dxPacketsLost / dxPacketsReceived * 100 : NaN; // in %
8991

90-
const selectedCandidatePairId = result[report.transportId]?.selectedCandidatePairId;
92+
const selectedCandidatePairId = result[report?.transportId || ""]?.selectedCandidatePairId;
9193
const roundTripTime = result[selectedCandidatePairId]?.currentRoundTripTime;
9294

9395
const dxJitterBufferEmittedCount = (report?.jitterBufferEmittedCount ?? 0) - (lastReport?.jitterBufferEmittedCount ?? 0);
@@ -96,7 +98,7 @@ const ConnectComponent: FC<ConnectComponentProps> = (
9698

9799
const codecId = report?.codecId || "";
98100

99-
if (report.kind === "video") {
101+
if (report?.kind === "video") {
100102
const codec = result[codecId]?.mimeType?.split("/")?.[1];
101103

102104
const videoStats = VideoStatsSchema.safeParse({
@@ -105,10 +107,10 @@ const ConnectComponent: FC<ConnectComponentProps> = (
105107
codec,
106108
bufferDelay,
107109
roundTripTime,
108-
frameRate: report.framesPerSecond
110+
frameRate: report?.framesPerSecond ?? NaN
109111
});
110112

111-
if (videoStats.success) {
113+
if (videoStats.success && report?.trackIdentifier) {
112114
statistics.setData(report.trackIdentifier, { ...videoStats.data, type: "video" });
113115
}
114116

@@ -126,7 +128,7 @@ const ConnectComponent: FC<ConnectComponentProps> = (
126128
dtx: false
127129
});
128130

129-
if (audioStats.success) {
131+
if (audioStats.success && report?.trackIdentifier) {
130132
statistics.setData(report.trackIdentifier, { ...audioStats.data, type: "audio" });
131133
}
132134
}
@@ -226,13 +228,14 @@ const RoomPage: FC<Props> = ({ roomId, wasCameraDisabled, wasMicrophoneDisabled
226228
className="m-1 w-full rounded bg-brand-grey-80 px-4 py-2 text-white hover:bg-brand-grey-100"
227229
type="submit"
228230
>
229-
Show simulcast controls
231+
{showSimulcastMenu ? "Hide simulcast controls" : "Show simulcast controls"}
230232
</button>
231233
<button
232234
onClick={showStats}
233235
className="m-1 w-full rounded bg-brand-grey-80 px-4 py-2 text-white hover:bg-brand-grey-100"
234236
type="submit"
235-
>Show statistics
237+
>
238+
{statistics.status ? "Hide statistics" : "Show statistics"}
236239
</button>
237240
</div>
238241
</div>

0 commit comments

Comments
 (0)