Skip to content

Commit

Permalink
common: add packet loss util to browser signaling session
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Dec 18, 2023
1 parent 2409cc4 commit 0e6b334
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions common/src/rtc-signaling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ export class BrowserSignalingSession implements RTCSignalingSession {
return this.options;
}

async getPacketsLost() {
const stats = await this.pc.getStats();
const packetsLost = ([...stats.values()] as { packetsLost: number }[]).filter(stat => 'packetsLost' in stat).map(stat => stat.packetsLost);
const total = packetsLost.reduce((p, c) => p + c, 0);
return total;
}

async setMicrophone(enabled: boolean) {
if (this.microphone && enabled && !this.micEnabled) {
this.micEnabled = true;
Expand Down

0 comments on commit 0e6b334

Please sign in to comment.