Skip to content

Commit

Permalink
Improve VideoSenderStats with FPS and targetBitrate (#1090)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidzhao authored Mar 23, 2024
1 parent d89c58e commit 4679eba
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-rivers-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"livekit-client": patch
---

Improve VideoSenderStats with FPS and targetBitrate
12 changes: 9 additions & 3 deletions src/room/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,20 @@ export interface VideoSenderStats extends SenderStats {

frameHeight: number;

framesPerSecond: number;

framesSent: number;

// bandwidth, cpu, other, none
qualityLimitationReason: string;
qualityLimitationReason?: string;

qualityLimitationDurations?: Record<string, number>;

qualityLimitationResolutionChanges?: number;

qualityLimitationResolutionChanges: number;
retransmittedPacketsSent?: number;

retransmittedPacketsSent: number;
targetBitrate: number;
}

interface ReceiverStats {
Expand Down
13 changes: 9 additions & 4 deletions src/room/track/LocalVideoTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,20 @@ export default class LocalVideoTrack extends LocalTrack<Track.Kind.Video> {
streamId: v.id,
frameHeight: v.frameHeight,
frameWidth: v.frameWidth,
framesPerSecond: v.framesPerSecond,
framesSent: v.framesSent,
firCount: v.firCount,
pliCount: v.pliCount,
nackCount: v.nackCount,
packetsSent: v.packetsSent,
bytesSent: v.bytesSent,
framesSent: v.framesSent,
timestamp: v.timestamp,
rid: v.rid ?? v.id,
retransmittedPacketsSent: v.retransmittedPacketsSent,
qualityLimitationReason: v.qualityLimitationReason,
qualityLimitationDurations: v.qualityLimitationDurations,
qualityLimitationResolutionChanges: v.qualityLimitationResolutionChanges,
rid: v.rid ?? v.id,
retransmittedPacketsSent: v.retransmittedPacketsSent,
targetBitrate: v.targetBitrate,
timestamp: v.timestamp,
};

// locate the appropriate remote-inbound-rtp item
Expand All @@ -205,6 +208,8 @@ export default class LocalVideoTrack extends LocalTrack<Track.Kind.Video> {
}
});

// make sure highest res layer is always first
items.sort((a, b) => (b.frameWidth ?? 0) - (a.frameWidth ?? 0));
return items;
}

Expand Down

0 comments on commit 4679eba

Please sign in to comment.