diff --git a/.changeset/nervous-rivers-invite.md b/.changeset/nervous-rivers-invite.md new file mode 100644 index 0000000000..52e7b0ce0e --- /dev/null +++ b/.changeset/nervous-rivers-invite.md @@ -0,0 +1,5 @@ +--- +"livekit-client": patch +--- + +Improve VideoSenderStats with FPS and targetBitrate diff --git a/src/room/stats.ts b/src/room/stats.ts index 3ceb658419..794cac142d 100644 --- a/src/room/stats.ts +++ b/src/room/stats.ts @@ -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; + + qualityLimitationResolutionChanges?: number; - qualityLimitationResolutionChanges: number; + retransmittedPacketsSent?: number; - retransmittedPacketsSent: number; + targetBitrate: number; } interface ReceiverStats { diff --git a/src/room/track/LocalVideoTrack.ts b/src/room/track/LocalVideoTrack.ts index 68a06641ed..68b3833184 100644 --- a/src/room/track/LocalVideoTrack.ts +++ b/src/room/track/LocalVideoTrack.ts @@ -180,17 +180,20 @@ export default class LocalVideoTrack extends LocalTrack { 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 @@ -205,6 +208,8 @@ export default class LocalVideoTrack extends LocalTrack { } }); + // make sure highest res layer is always first + items.sort((a, b) => (b.frameWidth ?? 0) - (a.frameWidth ?? 0)); return items; }