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