Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add receiver video mimeType to receiver stats #963

Merged
merged 2 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading