@rtcstats/rtcstats-shared 2.6.1 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/compression.js CHANGED
@@ -32,6 +32,11 @@ export function statsCompression(baseStatsInput, newStatsInput, statsIdMap) {
32
32
  return;
33
33
  }
34
34
  Object.keys(report).forEach((name) => {
35
+ if (name === 'timestamp') {
36
+ // Deleting it drops the whole report from the delta and the decoder
37
+ // restores it with the collapsed timestamp. Hits audio remote-*.
38
+ return;
39
+ }
35
40
  if (report[name] === baseStats[id][name]) {
36
41
  delete delta[id][name];
37
42
  } else if (Array.isArray(report[name])) {
@@ -49,7 +54,6 @@ export function statsCompression(baseStatsInput, newStatsInput, statsIdMap) {
49
54
  delete report[name];
50
55
  }
51
56
  }
52
- // TODO: does this ever happen since we have `timestamp`?
53
57
  if (Object.keys(report).length === 0) {
54
58
  delete delta[id];
55
59
  }
@@ -145,6 +149,8 @@ export function statsCompression(baseStatsInput, newStatsInput, statsIdMap) {
145
149
  */
146
150
  export function statsDecompression(baseStatsInput, delta) {
147
151
  const baseStats = map2obj(baseStatsInput);
152
+ // TODO: replace the JSON round-trip and the rename loop below with a hand-rolled
153
+ // deep copy that decompresses property names while copying, roughly 2x faster.
148
154
  const newStats = JSON.parse(JSON.stringify(map2obj(delta)));
149
155
 
150
156
  // Decompress property names using a static table.
@@ -213,6 +219,13 @@ export function statsDecompression(baseStatsInput, delta) {
213
219
  });
214
220
  }
215
221
 
222
+ // The compression removes the id as it is the key.
223
+ Object.keys(newStats).forEach((id) => {
224
+ if (newStats[id] && typeof newStats[id] === 'object') {
225
+ newStats[id].id = id;
226
+ }
227
+ });
228
+
216
229
  return newStats;
217
230
  }
218
231
 
@@ -395,12 +408,17 @@ const methodTable = {
395
408
  'MediaStreamTrack.onunmute': 74,
396
409
  // HTMLMediaElement
397
410
  'HTMLMediaElement.resize': 80,
411
+ // Decompression-only until the next major version bump, see below.
412
+ // 'HTMLMediaElement.setSinkId': 81,
413
+ // 'HTMLMediaElement.setSinkIdOnFailure': 82,
398
414
  };
399
415
  // Properties that are decompressed but for release purpose not yet compressed.
400
416
  // These should be moved to the compression table at major version bumps.
401
417
  const methodTableDecompression = {
402
418
  1: 'getStats',
403
419
  68: 'navigator.mediaDevices.getDisplayMediaOnFailure',
420
+ 81: 'HTMLMediaElement.setSinkId',
421
+ 82: 'HTMLMediaElement.setSinkIdOnFailure',
404
422
  };
405
423
  const reverseMethodTable = Object.keys(methodTable).reduce((table, method) => {
406
424
  table[methodTable[method]] = method;
package/dump.js CHANGED
@@ -110,6 +110,10 @@ export async function readRTCStatsDump(blob) {
110
110
 
111
111
  if (method === 'getStats') { // delta-compressed stats
112
112
  // statsDecompression does not modify its base stats argument.
113
+ if (!baseStats[connection_id]) {
114
+ console.error('stats without baseline');
115
+ return;
116
+ }
113
117
  value = statsDecompression(baseStats[connection_id], value);
114
118
  baseStats[connection_id] = value;
115
119
  } else if (method === 'setLocalDescription' && value &&
package/index.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  // Type definitions for @rtcstats/rtcstats-shared
2
2
 
3
- export async function maybeUncompressDump(blob: Blob): Promise<Blob>;
4
- export async function detectWebRTCInternalsDump(blob: Blob): Promise<boolean>;
5
- export async function readWebRTCInternalsDump(blob: Blob): Promise<object>;
6
- export async function detectRTCStatsDump(blob: Blob): Promise<boolean>;
7
- export async function readRTCStatsDump(blob: Blob): Promise<object>;
8
- export async function extractTracks(peerConnectionTrace: any[]): Promise<any[]>;
3
+ export function maybeUncompressDump(blob: Blob): Promise<Blob>;
4
+ export function detectWebRTCInternalsDump(blob: Blob): Promise<boolean>;
5
+ export function readWebRTCInternalsDump(blob: Blob): Promise<object>;
6
+ export function detectRTCStatsDump(blob: Blob): Promise<boolean>;
7
+ export function readRTCStatsDump(blob: Blob): Promise<object>;
8
+ export function internalsToRtcstats(data: object): object;
9
+ export function readDump(blob: Blob): Promise<object>;
10
+ export function extractTracks(peerConnectionTrace: any[]): Promise<any[]>;
9
11
 
10
12
  export function statsCompression(baseStatsInput: object | RTCStatsReport, newStatsInput: object | RTCStatsReport, statsIdMap: object): object;
11
13
  export function statsDecompression(baseStatsInput: object, delta: object): object;
@@ -17,6 +19,7 @@ export function compressStatsType(type: string): string | number;
17
19
  export function decompressStatsType(typeKey: string | number): string;
18
20
  export function compressStatsProperty(property: string): string | number;
19
21
  export function decompressStatsProperty(property: string | number): string;
22
+ export const computePressureTable: {nominal: number, fair: number, serious: number, critical: number};
20
23
 
21
24
  export function createInternalsTimeSeries(connection: any): object;
22
25
  export function createRtcStatsTimeSeries(trace: any[]): object;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtcstats/rtcstats-shared",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "main": "index.js",
5
5
  "description": "gather WebRTC API traces and statistics",
6
6
  "type": "module",
@@ -17,5 +17,8 @@
17
17
  "license": "MIT",
18
18
  "publishConfig": {
19
19
  "access": "public"
20
+ },
21
+ "devDependencies": {
22
+ "typescript": "^5.9.3"
20
23
  }
21
24
  }