-
Notifications
You must be signed in to change notification settings - Fork 31
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
feat: collect more granular RTC stats #1735
base: main
Are you sure you want to change the base?
Conversation
string, // method name | ||
string | null, // id | ||
RTCStatsDataType, // payload | ||
number, // timestamp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use TypeScript's labeled tuple elements.
private buffer: [
methodName: string,
id: string | null,
payload: RTCStatsDataType,
timestamp: number,
];
* transforms a maplike to an object. Mostly for getStats + JSON.parse(JSON.stringify()) | ||
* @param {*} m | ||
*/ | ||
export const map2obj = (m: Map<string, any>): Record<string, any> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be replaced with Object.fromEntries
, which is widely available.
const getStats = () => { | ||
pc.getStats(null).then((stats) => { | ||
const now = map2obj(stats as Map<string, any>); | ||
const base = JSON.parse(JSON.stringify(now)); // our new prev |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to clone here? It will be cloned in deltaCompression
anyway.
trace('ontrack', id, `${e.track.kind}:${e.track.id} ${streams}`); | ||
}); | ||
pc.addEventListener('signalingstatechange', () => { | ||
trace('onsignalingstatechange', id, pc.signalingState); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, but I think this is a better place to dispose interval (if (pc. signalingState === 'closed')
). Then pc
instance can be cleaned up as soon as the connection is closed.
Overview
Implements the new RTC stats collection flow. Switches to
max-bundle
RTCPeerConnection bundle policyImplementation notes