@webex/web-client-media-engine 1.34.2 → 1.34.4
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/dist/cjs/index.js +94 -20
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +94 -20
- package/dist/esm/index.js.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/package.json +3 -3
package/dist/esm/index.js
CHANGED
|
@@ -5609,7 +5609,11 @@ class JmpSession extends EventEmitter$3 {
|
|
|
5609
5609
|
}
|
|
5610
5610
|
updateSourceIndication(numTotalSources, numLiveSources, sources) {
|
|
5611
5611
|
var _a;
|
|
5612
|
-
const
|
|
5612
|
+
const filteredSources = sources.filter((source) => {
|
|
5613
|
+
var _a;
|
|
5614
|
+
return (_a = this.lastReceivedScr) === null || _a === void 0 ? void 0 : _a.requests.some((req) => req.ids.find((streamId) => compareStreamIds(streamId, source.id)));
|
|
5615
|
+
});
|
|
5616
|
+
const sourceIndicationMsg = new SourceIndicationMsg(this.currSourceIndicationSeqNum++, numTotalSources, numLiveSources, filteredSources);
|
|
5613
5617
|
const jmpMsg = new JmpMsg(this.mediaFamily, this.mediaContent, {
|
|
5614
5618
|
msgType: JmpMsgType.SourceIndication,
|
|
5615
5619
|
payload: sourceIndicationMsg,
|
|
@@ -6436,6 +6440,43 @@ var uuid_1 = require$$0;
|
|
|
6436
6440
|
* @returns - Copied value.
|
|
6437
6441
|
*/
|
|
6438
6442
|
var deepCopy$1 = function (value) { return JSON.parse(JSON.stringify(value)); };
|
|
6443
|
+
/**
|
|
6444
|
+
* Check deep equality between two values.
|
|
6445
|
+
*
|
|
6446
|
+
* @param value1 - First value to check.
|
|
6447
|
+
* @param value2 - Second value to check.
|
|
6448
|
+
* @returns True if values are deeply equal, false otherwise.
|
|
6449
|
+
*/
|
|
6450
|
+
var deepEqual = function (value1, value2) {
|
|
6451
|
+
// If both immutable values are equal, return true.
|
|
6452
|
+
if (value1 === value2) {
|
|
6453
|
+
return true;
|
|
6454
|
+
}
|
|
6455
|
+
// If both are objects, we check the length and properties of each.
|
|
6456
|
+
if (value1 && value2 && typeof value1 === 'object' && typeof value2 === 'object') {
|
|
6457
|
+
if (value1.constructor !== value2.constructor)
|
|
6458
|
+
return false;
|
|
6459
|
+
// Return false if the objects are of different sizes.
|
|
6460
|
+
if (Object.keys(value1).length !== Object.keys(value2).length) {
|
|
6461
|
+
return false;
|
|
6462
|
+
}
|
|
6463
|
+
// Deep equal check each property in the opject.
|
|
6464
|
+
for (var prop in value1) {
|
|
6465
|
+
if (value2.hasOwnProperty(prop)) {
|
|
6466
|
+
if (!deepEqual(value1[prop], value2[prop])) {
|
|
6467
|
+
return false;
|
|
6468
|
+
}
|
|
6469
|
+
}
|
|
6470
|
+
else {
|
|
6471
|
+
return false;
|
|
6472
|
+
}
|
|
6473
|
+
}
|
|
6474
|
+
// Return true if we found no differing properties.
|
|
6475
|
+
return true;
|
|
6476
|
+
}
|
|
6477
|
+
// Return false if no other conditions are met.
|
|
6478
|
+
return false;
|
|
6479
|
+
};
|
|
6439
6480
|
/**
|
|
6440
6481
|
* Translates a RTCStatsReport into an object.
|
|
6441
6482
|
*
|
|
@@ -6452,6 +6493,16 @@ var map2obj = function (report) {
|
|
|
6452
6493
|
});
|
|
6453
6494
|
return o;
|
|
6454
6495
|
};
|
|
6496
|
+
var persistedKeys = ['type', 'id', 'timestamp'];
|
|
6497
|
+
/**
|
|
6498
|
+
* Check to see if the report consists of more than just the persisted metadata.
|
|
6499
|
+
*
|
|
6500
|
+
* @param report - The report line being checked.
|
|
6501
|
+
* @returns True if the report item contains non-persisted keys, false otherwise.
|
|
6502
|
+
*/
|
|
6503
|
+
var hasNonMetadata = function (report) {
|
|
6504
|
+
return !!Object.keys(report).filter(function (key) { return !persistedKeys.includes(key); }).length;
|
|
6505
|
+
};
|
|
6455
6506
|
/**
|
|
6456
6507
|
* Apply a delta compression to the stats report. Reduces size by ~90%.
|
|
6457
6508
|
* To reduce further, report keys could be compressed.
|
|
@@ -6464,20 +6515,21 @@ var deltaCompression = function (oldStats, newStats) {
|
|
|
6464
6515
|
var updatedStats = deepCopy$1(newStats);
|
|
6465
6516
|
Object.keys(updatedStats).forEach(function (id) {
|
|
6466
6517
|
var report = updatedStats[id];
|
|
6467
|
-
delete report.id;
|
|
6468
6518
|
if (!oldStats[id]) {
|
|
6469
6519
|
return;
|
|
6470
6520
|
}
|
|
6521
|
+
// Persist specific values beyond delta compression, as long as they
|
|
6522
|
+
// aren't the only non-deduped keys.
|
|
6471
6523
|
Object.keys(report).forEach(function (name) {
|
|
6472
|
-
if (report[name]
|
|
6524
|
+
if (deepEqual(report[name], oldStats[id][name]) && !persistedKeys.includes(name)) {
|
|
6473
6525
|
delete updatedStats[id][name];
|
|
6474
6526
|
}
|
|
6475
|
-
if (
|
|
6476
|
-
(Object.keys(report).length === 1 && report.timestamp)) {
|
|
6527
|
+
if (!hasNonMetadata(report)) {
|
|
6477
6528
|
delete updatedStats[id];
|
|
6478
6529
|
}
|
|
6479
6530
|
});
|
|
6480
6531
|
});
|
|
6532
|
+
// Use the most recent timestamp.
|
|
6481
6533
|
var timestamp = -Infinity;
|
|
6482
6534
|
Object.keys(updatedStats).forEach(function (id) {
|
|
6483
6535
|
var report = updatedStats[id];
|
|
@@ -6485,15 +6537,34 @@ var deltaCompression = function (oldStats, newStats) {
|
|
|
6485
6537
|
timestamp = report.timestamp;
|
|
6486
6538
|
}
|
|
6487
6539
|
});
|
|
6540
|
+
// Delete the timestamps on each item.
|
|
6488
6541
|
Object.keys(updatedStats).forEach(function (id) {
|
|
6489
6542
|
var report = updatedStats[id];
|
|
6490
6543
|
if (report.timestamp === timestamp) {
|
|
6491
|
-
report.timestamp
|
|
6544
|
+
delete report.timestamp;
|
|
6492
6545
|
}
|
|
6493
6546
|
});
|
|
6494
6547
|
updatedStats.timestamp = timestamp;
|
|
6495
6548
|
return updatedStats;
|
|
6496
6549
|
};
|
|
6550
|
+
/**
|
|
6551
|
+
* Format the stats report into an array.
|
|
6552
|
+
*
|
|
6553
|
+
* @param report - A WebRTC stats report.
|
|
6554
|
+
* @returns - An array of Stats Report items.
|
|
6555
|
+
*/
|
|
6556
|
+
var formatStatsReport = function (report) {
|
|
6557
|
+
return Object.keys(report)
|
|
6558
|
+
.filter(function (name) { return name !== 'timestamp'; })
|
|
6559
|
+
.map(function (name) { return report[name]; });
|
|
6560
|
+
};
|
|
6561
|
+
/**
|
|
6562
|
+
* Parametrize a single string event to contain type and an (empty) id.
|
|
6563
|
+
*
|
|
6564
|
+
* @param value - The value to parametrize.
|
|
6565
|
+
* @returns An event object.
|
|
6566
|
+
*/
|
|
6567
|
+
var makeEvent = function (value) { return ([{ value: value, type: 'string', id: '' }]); };
|
|
6497
6568
|
/**
|
|
6498
6569
|
* Attach a Peer Connection to periodically get updated on events and stats.
|
|
6499
6570
|
*
|
|
@@ -6510,39 +6581,41 @@ var rtcStats = function (pc, logger, intervalTime, id, statsPreProcessor) {
|
|
|
6510
6581
|
/**
|
|
6511
6582
|
* Log stats or event data with additional tracking information.
|
|
6512
6583
|
*
|
|
6513
|
-
* @param
|
|
6584
|
+
* @param name - Name of the event to log.
|
|
6585
|
+
* @param payload - Log data pertaining to the event.
|
|
6514
6586
|
*/
|
|
6515
|
-
var trace = function (
|
|
6516
|
-
logger({
|
|
6587
|
+
var trace = function (name, payload, timestamp) {
|
|
6588
|
+
logger({ id: id, timestamp: timestamp ? Math.round(timestamp) : Date.now(), name: name, payload: payload });
|
|
6517
6589
|
};
|
|
6518
|
-
trace('creating stats report');
|
|
6519
6590
|
pc.addEventListener('icecandidate', function (e) {
|
|
6520
|
-
|
|
6591
|
+
if (e.candidate) {
|
|
6592
|
+
trace('onicecandidate', makeEvent(JSON.stringify(e.candidate)));
|
|
6593
|
+
}
|
|
6521
6594
|
});
|
|
6522
6595
|
pc.addEventListener('icecandidateerror', function (event) {
|
|
6523
6596
|
var _a = event, errorCode = _a.errorCode, errorText = _a.errorText;
|
|
6524
|
-
trace('onicecandidateerror',
|
|
6597
|
+
trace('onicecandidateerror', makeEvent("".concat(errorCode, ": ").concat(errorText)));
|
|
6525
6598
|
});
|
|
6526
6599
|
pc.addEventListener('track', function (e) {
|
|
6527
|
-
trace('ontrack', "".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams.map(function (stream) { return "stream:".concat(stream.id); })));
|
|
6600
|
+
trace('ontrack', makeEvent("".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams.map(function (stream) { return "stream:".concat(stream.id); }).join(' '))));
|
|
6528
6601
|
});
|
|
6529
6602
|
pc.addEventListener('signalingstatechange', function () {
|
|
6530
|
-
trace('onsignalingstatechange', pc.signalingState);
|
|
6603
|
+
trace('onsignalingstatechange', makeEvent(pc.signalingState));
|
|
6531
6604
|
});
|
|
6532
6605
|
pc.addEventListener('iceconnectionstatechange', function () {
|
|
6533
|
-
trace('oniceconnectionstatechange', pc.iceConnectionState);
|
|
6606
|
+
trace('oniceconnectionstatechange', makeEvent(pc.iceConnectionState));
|
|
6534
6607
|
});
|
|
6535
6608
|
pc.addEventListener('icegatheringstatechange', function () {
|
|
6536
|
-
trace('onicegatheringstatechange', pc.iceGatheringState);
|
|
6609
|
+
trace('onicegatheringstatechange', makeEvent(pc.iceGatheringState));
|
|
6537
6610
|
});
|
|
6538
6611
|
pc.addEventListener('connectionstatechange', function () {
|
|
6539
|
-
trace('onconnectionstatechange', pc.connectionState);
|
|
6612
|
+
trace('onconnectionstatechange', makeEvent(pc.connectionState));
|
|
6540
6613
|
});
|
|
6541
6614
|
pc.addEventListener('negotiationneeded', function () {
|
|
6542
|
-
trace('onnegotiationneeded');
|
|
6615
|
+
trace('onnegotiationneeded', makeEvent('negotiationneeded'));
|
|
6543
6616
|
});
|
|
6544
6617
|
pc.addEventListener('datachannel', function (event) {
|
|
6545
|
-
trace('ondatachannel',
|
|
6618
|
+
trace('ondatachannel', makeEvent("".concat(event.channel.id, ": ").concat(event.channel.label)));
|
|
6546
6619
|
});
|
|
6547
6620
|
var interval = window.setInterval(function () {
|
|
6548
6621
|
if (pc.signalingState === 'closed') {
|
|
@@ -6553,7 +6626,8 @@ var rtcStats = function (pc, logger, intervalTime, id, statsPreProcessor) {
|
|
|
6553
6626
|
var now = map2obj(res);
|
|
6554
6627
|
statsPreProcessor(now).then(function () {
|
|
6555
6628
|
var base = deepCopy$1(now); // our new prev
|
|
6556
|
-
|
|
6629
|
+
var compressed = deltaCompression(prev, now);
|
|
6630
|
+
trace('stats-report', formatStatsReport(compressed), compressed.timestamp !== -Infinity ? compressed.timestamp : undefined);
|
|
6557
6631
|
prev = base;
|
|
6558
6632
|
});
|
|
6559
6633
|
});
|