@rtcstats/rtcstats-shared 2.6.0 → 2.6.2

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.
@@ -395,12 +401,17 @@ const methodTable = {
395
401
  'MediaStreamTrack.onunmute': 74,
396
402
  // HTMLMediaElement
397
403
  'HTMLMediaElement.resize': 80,
404
+ // Decompression-only until the next major version bump, see below.
405
+ // 'HTMLMediaElement.setSinkId': 81,
406
+ // 'HTMLMediaElement.setSinkIdOnFailure': 82,
398
407
  };
399
408
  // Properties that are decompressed but for release purpose not yet compressed.
400
409
  // These should be moved to the compression table at major version bumps.
401
410
  const methodTableDecompression = {
402
411
  1: 'getStats',
403
412
  68: 'navigator.mediaDevices.getDisplayMediaOnFailure',
413
+ 81: 'HTMLMediaElement.setSinkId',
414
+ 82: 'HTMLMediaElement.setSinkIdOnFailure',
404
415
  };
405
416
  const reverseMethodTable = Object.keys(methodTable).reduce((table, method) => {
406
417
  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 &&
@@ -201,11 +205,11 @@ export function internalsToRtcstats(data) {
201
205
  const tracks = [];
202
206
  if (gum.audio_track_info) {
203
207
  const t = JSON.parse(gum.audio_track_info);
204
- tracks.push(['audio', t.id, t.label, gum.stream_id]);
208
+ if (t) tracks.push(['audio', t.id, t.label, gum.stream_id]);
205
209
  }
206
210
  if (gum.video_track_info) {
207
211
  const t = JSON.parse(gum.video_track_info);
208
- tracks.push(['video', t.id, t.label, gum.stream_id]);
212
+ if (t) tracks.push(['video', t.id, t.label, gum.stream_id]);
209
213
  }
210
214
  clientTrace.push({type: baseType + 'OnSuccess', value: tracks, timestamp: gum.timestamp, extra: []});
211
215
  } else if (gum.audio !== undefined || gum.video !== undefined) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rtcstats/rtcstats-shared",
3
- "version": "2.6.0",
3
+ "version": "2.6.2",
4
4
  "main": "index.js",
5
5
  "description": "gather WebRTC API traces and statistics",
6
6
  "type": "module",