@webex/web-client-media-engine 3.17.2 → 3.18.0

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/esm/index.js CHANGED
@@ -10437,6 +10437,25 @@ class ReceiveSlot extends EventEmitter$2 {
10437
10437
  }
10438
10438
  ReceiveSlot.Events = ReceiveSlotEvents;
10439
10439
 
10440
+ function getCurrentTimestamp() {
10441
+ return performance.timeOrigin + performance.now();
10442
+ }
10443
+ class StatsManager {
10444
+ constructor(statsGetter, statsPreprocessor = () => __awaiter$1(this, void 0, void 0, function* () { })) {
10445
+ this.statsGetter = statsGetter;
10446
+ this.statsPreProcessor = statsPreprocessor;
10447
+ }
10448
+ getStats() {
10449
+ return __awaiter$1(this, void 0, void 0, function* () {
10450
+ const statsReport = yield this.statsGetter();
10451
+ const statsMap = new Map();
10452
+ statsReport.forEach((stats, key) => statsMap.set(key, stats));
10453
+ yield this.statsPreProcessor(statsMap);
10454
+ return statsMap;
10455
+ });
10456
+ }
10457
+ }
10458
+
10440
10459
  class Transceiver {
10441
10460
  constructor(rtcRtpTransceiver, mid) {
10442
10461
  this.twccDisabled = false;
@@ -10460,7 +10479,7 @@ class Transceiver {
10460
10479
  class ReceiveOnlyTransceiver extends Transceiver {
10461
10480
  constructor(rtcRtpTransceiver, mid, munger) {
10462
10481
  super(rtcRtpTransceiver, mid);
10463
- this.metadata = { isActiveSpeaker: false };
10482
+ this.metadata = { isRequested: false, isActiveSpeaker: false };
10464
10483
  this.munger = munger;
10465
10484
  this._receiveSlot = new ReceiveSlot(() => {
10466
10485
  if (!this._rtcRtpTransceiver.mid) {
@@ -10491,6 +10510,8 @@ class ReceiveOnlyTransceiver extends Transceiver {
10491
10510
  stats.calliopeMediaType = this.metadata.mediaType;
10492
10511
  stats.requestedBitrate = this.metadata.requestedBitrate;
10493
10512
  stats.requestedFrameSize = this.metadata.requestedFrameSize;
10513
+ stats.isRequested = this.metadata.isRequested;
10514
+ stats.lastRequestedUpdateTimestamp = this.metadata.lastRequestedUpdateTimestamp;
10494
10515
  stats.isActiveSpeaker = this.metadata.isActiveSpeaker;
10495
10516
  stats.lastActiveSpeakerUpdateTimestamp = this.metadata.lastActiveSpeakerUpdateTimestamp;
10496
10517
  Object.assign(stats, this.receiverId);
@@ -10514,10 +10535,18 @@ class ReceiveOnlyTransceiver extends Transceiver {
10514
10535
  }
10515
10536
  handleRequested(streamRequest) {
10516
10537
  var _a, _b;
10538
+ if (!this.metadata.isRequested) {
10539
+ this.metadata.isRequested = true;
10540
+ this.metadata.lastRequestedUpdateTimestamp = getCurrentTimestamp();
10541
+ }
10517
10542
  this.metadata.requestedBitrate = streamRequest.maxPayloadBitsPerSecond;
10518
10543
  this.metadata.requestedFrameSize = (_b = (_a = streamRequest.codecInfos[0]) === null || _a === void 0 ? void 0 : _a.h264) === null || _b === void 0 ? void 0 : _b.maxFs;
10519
10544
  }
10520
10545
  handleUnrequested() {
10546
+ if (this.metadata.isRequested) {
10547
+ this.metadata.isRequested = false;
10548
+ this.metadata.lastRequestedUpdateTimestamp = getCurrentTimestamp();
10549
+ }
10521
10550
  this.metadata.requestedBitrate = undefined;
10522
10551
  this.metadata.requestedFrameSize = undefined;
10523
10552
  this.receiveSlot._updateSource('no source', undefined);
@@ -10525,7 +10554,7 @@ class ReceiveOnlyTransceiver extends Transceiver {
10525
10554
  handleActiveSpeakerUpdate(value) {
10526
10555
  if (this.metadata.isActiveSpeaker !== value) {
10527
10556
  this.metadata.isActiveSpeaker = value;
10528
- this.metadata.lastActiveSpeakerUpdateTimestamp = performance.timeOrigin + performance.now();
10557
+ this.metadata.lastActiveSpeakerUpdateTimestamp = getCurrentTimestamp();
10529
10558
  }
10530
10559
  }
10531
10560
  }
@@ -14246,6 +14275,7 @@ class SendOnlyTransceiver extends Transceiver {
14246
14275
  this.namedMediaGroupsChange = new TypedEvent();
14247
14276
  this.requestedIdEncodingParamsMap = new Map();
14248
14277
  this.updateSendParametersQueue = new AsyncQueue();
14278
+ this.metadata = { lastRequestedUpdateTimestampsMap: new Map() };
14249
14279
  this.csi = csi;
14250
14280
  this.direction = 'sendrecv';
14251
14281
  this.handleTrackChange = this.handleTrackChange.bind(this);
@@ -14356,8 +14386,16 @@ class SendOnlyTransceiver extends Transceiver {
14356
14386
  stats.mid = this.mid;
14357
14387
  stats.csi = this.csi;
14358
14388
  stats.calliopeMediaType = this.mediaType;
14359
- stats.requestedBitrate = this.getRequestedBitrate(stats.ssrc);
14360
- stats.requestedFrameSize = this.getRequestedFrameSize(stats.ssrc);
14389
+ const senderId = this.munger.getSenderIds().find((id) => id.ssrc === stats.ssrc);
14390
+ if (senderId) {
14391
+ const encodingIndex = this.getEncodingIndexForStreamId(senderId);
14392
+ const encodingParams = this.requestedIdEncodingParamsMap.get(encodingIndex);
14393
+ stats.requestedBitrate = encodingParams === null || encodingParams === void 0 ? void 0 : encodingParams.maxPayloadBitsPerSecond;
14394
+ stats.requestedFrameSize = encodingParams === null || encodingParams === void 0 ? void 0 : encodingParams.maxFs;
14395
+ stats.isRequested = !!encodingParams;
14396
+ stats.lastRequestedUpdateTimestamp =
14397
+ this.metadata.lastRequestedUpdateTimestampsMap.get(encodingIndex);
14398
+ }
14361
14399
  const trackSettings = (_a = this.publishedStream) === null || _a === void 0 ? void 0 : _a.getSettings();
14362
14400
  if (trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate) {
14363
14401
  stats.targetFrameRate = trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate;
@@ -14391,6 +14429,17 @@ class SendOnlyTransceiver extends Transceiver {
14391
14429
  }
14392
14430
  });
14393
14431
  yield this.sender.setParameters(sendParameters);
14432
+ const timestamp = getCurrentTimestamp();
14433
+ requestedIdEncodingParamsMap.forEach((_, index) => {
14434
+ if (!this.requestedIdEncodingParamsMap.has(index)) {
14435
+ this.metadata.lastRequestedUpdateTimestampsMap.set(index, timestamp);
14436
+ }
14437
+ });
14438
+ this.requestedIdEncodingParamsMap.forEach((_, index) => {
14439
+ if (!requestedIdEncodingParamsMap.has(index)) {
14440
+ this.metadata.lastRequestedUpdateTimestampsMap.set(index, timestamp);
14441
+ }
14442
+ });
14394
14443
  const oldRequested = this.requested;
14395
14444
  const newRequested = requestedIdEncodingParamsMap.size > 0;
14396
14445
  this.requestedIdEncodingParamsMap = requestedIdEncodingParamsMap;
@@ -14400,22 +14449,6 @@ class SendOnlyTransceiver extends Transceiver {
14400
14449
  }));
14401
14450
  });
14402
14451
  }
14403
- getRequestedBitrate(ssrc) {
14404
- const index = this.senderIds.findIndex((streamId) => streamId.ssrc === ssrc);
14405
- if (this.requestedIdEncodingParamsMap.has(index)) {
14406
- const encodingParams = this.requestedIdEncodingParamsMap.get(index);
14407
- return encodingParams === null || encodingParams === void 0 ? void 0 : encodingParams.maxPayloadBitsPerSecond;
14408
- }
14409
- return undefined;
14410
- }
14411
- getRequestedFrameSize(ssrc) {
14412
- const index = this.senderIds.findIndex((streamId) => streamId.ssrc === ssrc);
14413
- if (this.requestedIdEncodingParamsMap.has(index)) {
14414
- const encodingParams = this.requestedIdEncodingParamsMap.get(index);
14415
- return encodingParams === null || encodingParams === void 0 ? void 0 : encodingParams.maxFs;
14416
- }
14417
- return undefined;
14418
- }
14419
14452
  isSimulcastEnabled() {
14420
14453
  const params = this.sender.getParameters();
14421
14454
  return params.encodings.length > 1;
@@ -14503,22 +14536,6 @@ class SendSlot {
14503
14536
  }
14504
14537
  }
14505
14538
 
14506
- class StatsManager {
14507
- constructor(statsGetter, statsPreprocessor = () => __awaiter$1(this, void 0, void 0, function* () { })) {
14508
- this.statsGetter = statsGetter;
14509
- this.statsPreProcessor = statsPreprocessor;
14510
- }
14511
- getStats() {
14512
- return __awaiter$1(this, void 0, void 0, function* () {
14513
- const statsReport = yield this.statsGetter();
14514
- const statsMap = new Map();
14515
- statsReport.forEach((stats, key) => statsMap.set(key, stats));
14516
- yield this.statsPreProcessor(statsMap);
14517
- return statsMap;
14518
- });
14519
- }
14520
- }
14521
-
14522
14539
  const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __awaiter$1(void 0, void 0, void 0, function* () {
14523
14540
  const result = {
14524
14541
  audio: {