Skip to content

Commit

Permalink
Add receiver video mimeType to receiver stats (#963)
Browse files Browse the repository at this point in the history
* Add mimeType to receiver stats

* changset
  • Loading branch information
cnderrauber authored Dec 15, 2023
1 parent e9050b9 commit 85988c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/flat-bananas-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-client': patch
---

Add receiver video mime type to stats
2 changes: 2 additions & 0 deletions src/room/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ export interface VideoReceiverStats extends ReceiverStats {
nackCount?: number;

decoderImplementation?: string;

mimeType?: string;
}

export function computeBitrate<T extends ReceiverStats | SenderStats>(
Expand Down
8 changes: 8 additions & 0 deletions src/room/track/RemoteVideoTrack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>();
stats.forEach((v) => {
if (v.type === 'inbound-rtp') {
codecID = v.codecId;
receiverStats = {
type: 'video',
framesDecoded: v.framesDecoded,
Expand All @@ -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;
}

Expand Down

0 comments on commit 85988c5

Please sign in to comment.