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; }