From 85988c579eb8156bb87a1915a27675af77744f7e Mon Sep 17 00:00:00 2001 From: cnderrauber Date: Fri, 15 Dec 2023 10:30:28 +0800 Subject: [PATCH] Add receiver video mimeType to receiver stats (#963) * Add mimeType to receiver stats * changset --- .changeset/flat-bananas-obey.md | 5 +++++ src/room/stats.ts | 2 ++ src/room/track/RemoteVideoTrack.ts | 8 ++++++++ 3 files changed, 15 insertions(+) create mode 100644 .changeset/flat-bananas-obey.md diff --git a/.changeset/flat-bananas-obey.md b/.changeset/flat-bananas-obey.md new file mode 100644 index 0000000000..65623f0f51 --- /dev/null +++ b/.changeset/flat-bananas-obey.md @@ -0,0 +1,5 @@ +--- +'livekit-client': patch +--- + +Add receiver video mime type to stats diff --git a/src/room/stats.ts b/src/room/stats.ts index 49d3c434ea..3ceb658419 100644 --- a/src/room/stats.ts +++ b/src/room/stats.ts @@ -106,6 +106,8 @@ export interface VideoReceiverStats extends ReceiverStats { nackCount?: number; decoderImplementation?: string; + + mimeType?: string; } export function computeBitrate( diff --git a/src/room/track/RemoteVideoTrack.ts b/src/room/track/RemoteVideoTrack.ts index ffb2e355d3..9448fe9c17 100644 --- a/src/room/track/RemoteVideoTrack.ts +++ b/src/room/track/RemoteVideoTrack.ts @@ -169,8 +169,11 @@ export default class RemoteVideoTrack extends RemoteTrack { const stats = await this.receiver.getStats(); let receiverStats: VideoReceiverStats | undefined; + let codecID = ''; + let codecs = new Map(); stats.forEach((v) => { if (v.type === 'inbound-rtp') { + codecID = v.codecId; receiverStats = { type: 'video', framesDecoded: v.framesDecoded, @@ -188,8 +191,13 @@ export default class RemoteVideoTrack extends RemoteTrack { bytesReceived: v.bytesReceived, decoderImplementation: v.decoderImplementation, }; + } else if (v.type === 'codec') { + codecs.set(v.id, v); } }); + if (receiverStats && codecID !== '' && codecs.get(codecID)) { + receiverStats.mimeType = codecs.get(codecID).mimeType; + } return receiverStats; }