@webex/web-client-media-engine 3.15.8 → 3.17.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/cjs/index.js CHANGED
@@ -10464,6 +10464,7 @@ class Transceiver {
10464
10464
  class ReceiveOnlyTransceiver extends Transceiver {
10465
10465
  constructor(rtcRtpTransceiver, mid, munger) {
10466
10466
  super(rtcRtpTransceiver, mid);
10467
+ this.metadata = {};
10467
10468
  this.munger = munger;
10468
10469
  this._receiveSlot = new ReceiveSlot(() => {
10469
10470
  if (!this._rtcRtpTransceiver.mid) {
@@ -10484,7 +10485,22 @@ class ReceiveOnlyTransceiver extends Transceiver {
10484
10485
  return this._receiveSlot;
10485
10486
  }
10486
10487
  getStats() {
10487
- return this.receiver.getStats();
10488
+ return __awaiter$1(this, void 0, void 0, function* () {
10489
+ const statsMap = new Map();
10490
+ const statsReport = yield this.receiver.getStats();
10491
+ statsReport.forEach((stats, key) => {
10492
+ if (stats.type === 'inbound-rtp') {
10493
+ stats.mid = this.mid;
10494
+ stats.csi = this.receiveSlot.currentRxCsi;
10495
+ stats.calliopeMediaType = this.metadata.mediaType;
10496
+ stats.requestedBitrate = this.metadata.requestedBitrate;
10497
+ stats.requestedFrameSize = this.metadata.requestedFrameSize;
10498
+ Object.assign(stats, this.receiverId);
10499
+ }
10500
+ statsMap.set(key, stats);
10501
+ });
10502
+ return statsMap;
10503
+ });
10488
10504
  }
10489
10505
  mungeLocalDescription(mediaDescription) {
10490
10506
  this.munger.mungeLocalDescription(mediaDescription, { twccDisabled: this.twccDisabled });
@@ -10498,6 +10514,16 @@ class ReceiveOnlyTransceiver extends Transceiver {
10498
10514
  resetSdpMunger() {
10499
10515
  this.munger.reset();
10500
10516
  }
10517
+ handleRequested(streamRequest) {
10518
+ var _a, _b;
10519
+ this.metadata.requestedBitrate = streamRequest.maxPayloadBitsPerSecond;
10520
+ this.metadata.requestedFrameSize = (_b = (_a = streamRequest.codecInfos[0]) === null || _a === void 0 ? void 0 : _a.h264) === null || _b === void 0 ? void 0 : _b.maxFs;
10521
+ }
10522
+ handleUnrequested() {
10523
+ this.metadata.requestedBitrate = undefined;
10524
+ this.metadata.requestedFrameSize = undefined;
10525
+ this.receiveSlot._updateSource('no source', undefined);
10526
+ }
10501
10527
  }
10502
10528
  ReceiveOnlyTransceiver.rid = '1';
10503
10529
 
@@ -14317,7 +14343,29 @@ class SendOnlyTransceiver extends Transceiver {
14317
14343
  }
14318
14344
  }
14319
14345
  getStats() {
14320
- return this.sender.getStats();
14346
+ return __awaiter$1(this, void 0, void 0, function* () {
14347
+ const statsMap = new Map();
14348
+ const statsReport = yield this.sender.getStats();
14349
+ statsReport.forEach((stats, key) => {
14350
+ var _a;
14351
+ if (stats.type === 'outbound-rtp') {
14352
+ stats.mid = this.mid;
14353
+ stats.csi = this.csi;
14354
+ stats.calliopeMediaType = this.mediaType;
14355
+ stats.requestedBitrate = this.getRequestedBitrate(stats.ssrc);
14356
+ stats.requestedFrameSize = this.getRequestedFrameSize(stats.ssrc);
14357
+ const trackSettings = (_a = this.publishedStream) === null || _a === void 0 ? void 0 : _a.getSettings();
14358
+ if (trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate) {
14359
+ stats.targetFrameRate = trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate;
14360
+ }
14361
+ }
14362
+ else if (stats.type === 'media-source') {
14363
+ stats.calliopeMediaType = this.mediaType;
14364
+ }
14365
+ statsMap.set(key, stats);
14366
+ });
14367
+ return statsMap;
14368
+ });
14321
14369
  }
14322
14370
  updateSendParameters(requestedIdEncodingParamsMap) {
14323
14371
  return __awaiter$1(this, void 0, void 0, function* () {
@@ -14488,14 +14536,8 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __await
14488
14536
  };
14489
14537
  yield Promise.all([...sendTransceivers.entries()].map(([mediaType, transceiver]) => __awaiter$1(void 0, void 0, void 0, function* () {
14490
14538
  var _a;
14491
- const report = [];
14492
- (yield transceiver.getStats()).forEach((senderStats) => {
14493
- if (senderStats.type === 'outbound-rtp') {
14494
- report.push(Object.assign(Object.assign({}, senderStats), { requestedBitrate: transceiver.getRequestedBitrate(senderStats.ssrc), requestedFrameSize: transceiver.getRequestedFrameSize(senderStats.ssrc) }));
14495
- }
14496
- });
14497
14539
  const item = {
14498
- report,
14540
+ report: yield transceiver.getStats(),
14499
14541
  mid: transceiver.mid,
14500
14542
  csi: transceiver.csi,
14501
14543
  currentDirection: 'sendonly',
@@ -14517,14 +14559,8 @@ const organizeTransceiverStats = (sendTransceivers, recvTransceivers) => __await
14517
14559
  yield Promise.all([...recvTransceivers.entries()].map(([mediaType, transceivers]) => __awaiter$1(void 0, void 0, void 0, function* () {
14518
14560
  return Promise.all(transceivers.map((t) => __awaiter$1(void 0, void 0, void 0, function* () {
14519
14561
  var _b, _c;
14520
- const report = [];
14521
- (yield t.getStats()).forEach((receiverStats) => {
14522
- if (receiverStats.type === 'inbound-rtp') {
14523
- report.push(Object.assign(Object.assign({}, receiverStats), { requestedBitrate: t.requestedBitrate, requestedFrameSize: t.requestedFrameSize }));
14524
- }
14525
- });
14526
14562
  const item = {
14527
- report,
14563
+ report: yield t.getStats(),
14528
14564
  mid: (_b = t.receiveSlot.id) === null || _b === void 0 ? void 0 : _b.mid,
14529
14565
  csi: t.receiveSlot.currentRxCsi,
14530
14566
  currentDirection: 'recvonly',
@@ -14567,6 +14603,7 @@ exports.MultistreamConnectionEventNames = void 0;
14567
14603
  MultistreamConnectionEventNames["AudioSourceCountUpdate"] = "audio-source-count-update";
14568
14604
  MultistreamConnectionEventNames["ActiveSpeakerNotification"] = "active-speaker-notification";
14569
14605
  MultistreamConnectionEventNames["ConnectionStateUpdate"] = "connection-state-update";
14606
+ MultistreamConnectionEventNames["IceGatheringStateUpdate"] = "ice-gathering-state-update";
14570
14607
  MultistreamConnectionEventNames["NegotiationNeeded"] = "negotiation-needed";
14571
14608
  MultistreamConnectionEventNames["CreateOfferOnSuccess"] = "createofferonsuccess";
14572
14609
  MultistreamConnectionEventNames["CreateAnswerOnSuccess"] = "createansweronsuccess";
@@ -14634,10 +14671,16 @@ class MultistreamConnection extends EventEmitter$2 {
14634
14671
  this.pc.on(PeerConnection.Events.SetRemoteDescriptionOnSuccess, (description) => {
14635
14672
  this.emit(exports.MultistreamConnectionEventNames.SetRemoteDescriptionOnSuccess, description);
14636
14673
  });
14674
+ this.pc.on(PeerConnection.Events.IceGatheringStateChange, () => {
14675
+ this.emit(exports.MultistreamConnectionEventNames.IceGatheringStateUpdate, this.getIceGatheringState());
14676
+ });
14637
14677
  }
14638
14678
  getConnectionState() {
14639
14679
  return this.pc.getConnectionState();
14640
14680
  }
14681
+ getIceGatheringState() {
14682
+ return this.pc.iceGatheringState;
14683
+ }
14641
14684
  getVideoEncodingOptions(content) {
14642
14685
  const enabledSimulcast = content === exports.MediaContent.Main
14643
14686
  ? !this.options.disableSimulcast
@@ -14950,6 +14993,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
14950
14993
  const transceiverMid = this.midPredictor.getNextMid(mediaType);
14951
14994
  const munger = new IngressSdpMunger();
14952
14995
  const recvOnlyTransceiver = new ReceiveOnlyTransceiver(rtcRtpTransceiver, transceiverMid, munger);
14996
+ recvOnlyTransceiver.metadata.mediaType = mediaType;
14953
14997
  recvOnlyTransceiver.twccDisabled =
14954
14998
  getMediaFamily(mediaType) === exports.MediaFamily.Audio ? this.options.disableAudioTwcc : false;
14955
14999
  this.recvTransceivers.set(mediaType, [
@@ -15223,35 +15267,24 @@ SCTP Max Message Size: ${maxMessageSize}`);
15223
15267
  return;
15224
15268
  }
15225
15269
  const requestedReceiveSlotIds = [];
15226
- streamRequests.forEach((sr) => {
15227
- sr.receiveSlots.forEach((rs) => {
15228
- if (!rs.id) {
15270
+ streamRequests.forEach((request) => {
15271
+ request.receiveSlots.forEach((slot) => {
15272
+ if (!slot.id) {
15229
15273
  logger.error(`Running stream request task, but ReceiveSlot ID is missing!`);
15230
15274
  return;
15231
15275
  }
15232
- requestedReceiveSlotIds.push(rs.id);
15276
+ requestedReceiveSlotIds.push(slot.id);
15233
15277
  });
15234
15278
  });
15279
+ jmpSession.sendRequests(streamRequests.map((sr) => sr._toJmpStreamRequest()));
15235
15280
  (_a = this.recvTransceivers.get(mediaType)) === null || _a === void 0 ? void 0 : _a.forEach((transceiver) => {
15236
- if (!requestedReceiveSlotIds.some((id) => compareStreamIds(id, transceiver.receiveSlot.id))) {
15237
- transceiver.receiveSlot._updateSource('no source', undefined);
15281
+ if (requestedReceiveSlotIds.some((id) => compareStreamIds(id, transceiver.receiveSlot.id))) {
15282
+ const relevantRequest = streamRequests.find((request) => request.receiveSlots.some((slot) => compareStreamIds(slot.id, transceiver.receiveSlot.id)));
15283
+ transceiver.handleRequested(relevantRequest);
15284
+ }
15285
+ else {
15286
+ transceiver.handleUnrequested();
15238
15287
  }
15239
- });
15240
- jmpSession.sendRequests(streamRequests.map((sr) => sr._toJmpStreamRequest()));
15241
- streamRequests.forEach((sr) => {
15242
- var _a;
15243
- const isAffectedInStreamRequest = (t) => sr.receiveSlots.some((rs) => rs.id && compareStreamIds(rs.id, t.receiverId));
15244
- (_a = this.recvTransceivers.get(mediaType)) === null || _a === void 0 ? void 0 : _a.forEach((t) => {
15245
- var _a, _b;
15246
- if (isAffectedInStreamRequest(t)) {
15247
- t.requestedBitrate = sr.maxPayloadBitsPerSecond;
15248
- t.requestedFrameSize = (_b = (_a = sr.codecInfos[0]) === null || _a === void 0 ? void 0 : _a.h264) === null || _b === void 0 ? void 0 : _b.maxFs;
15249
- }
15250
- else {
15251
- t.requestedBitrate = undefined;
15252
- t.requestedFrameSize = undefined;
15253
- }
15254
- });
15255
15288
  });
15256
15289
  };
15257
15290
  if (((_a = this.dataChannel) === null || _a === void 0 ? void 0 : _a.readyState) === 'open') {
@@ -15317,42 +15350,18 @@ SCTP Max Message Size: ${maxMessageSize}`);
15317
15350
  }
15318
15351
  preProcessStats(stats) {
15319
15352
  return __awaiter$1(this, void 0, void 0, function* () {
15320
- yield Promise.all([...this.sendTransceivers.entries()].map(([mediaType, transceiver]) => __awaiter$1(this, void 0, void 0, function* () {
15353
+ yield Promise.all([...this.sendTransceivers.values()].map((transceiver) => __awaiter$1(this, void 0, void 0, function* () {
15321
15354
  (yield transceiver.getStats()).forEach((senderStats) => {
15322
- var _a;
15323
- if (senderStats.type === 'outbound-rtp') {
15324
- const statsToModify = stats.get(senderStats.id);
15325
- statsToModify.mid = transceiver.mid;
15326
- statsToModify.csi = transceiver.csi;
15327
- statsToModify.calliopeMediaType = mediaType;
15328
- statsToModify.requestedBitrate = transceiver.getRequestedBitrate(senderStats.ssrc);
15329
- statsToModify.requestedFrameSize = transceiver.getRequestedFrameSize(senderStats.ssrc);
15330
- const trackSettings = (_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.getSettings();
15331
- if (trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate) {
15332
- statsToModify.targetFrameRate = trackSettings === null || trackSettings === void 0 ? void 0 : trackSettings.frameRate;
15333
- }
15334
- stats.set(senderStats.id, statsToModify);
15335
- }
15336
- else if (senderStats.type === 'media-source') {
15337
- const statsToModify = stats.get(senderStats.id);
15338
- statsToModify.calliopeMediaType = mediaType;
15339
- stats.set(senderStats.id, statsToModify);
15355
+ if (senderStats.type === 'outbound-rtp' || senderStats.type === 'media-source') {
15356
+ stats.set(senderStats.id, senderStats);
15340
15357
  }
15341
15358
  });
15342
15359
  })));
15343
- yield Promise.all([...this.recvTransceivers.entries()].map(([mediaType, transceivers]) => __awaiter$1(this, void 0, void 0, function* () {
15360
+ yield Promise.all([...this.recvTransceivers.values()].map((transceivers) => __awaiter$1(this, void 0, void 0, function* () {
15344
15361
  yield Promise.all(transceivers.map((transceiver) => __awaiter$1(this, void 0, void 0, function* () {
15345
15362
  (yield transceiver.getStats()).forEach((receiverStats) => {
15346
- var _a;
15347
15363
  if (receiverStats.type === 'inbound-rtp') {
15348
- const statsToModify = stats.get(receiverStats.id);
15349
- statsToModify.mid = (_a = transceiver.receiveSlot.id) === null || _a === void 0 ? void 0 : _a.mid;
15350
- statsToModify.csi = transceiver.receiveSlot.currentRxCsi;
15351
- statsToModify.calliopeMediaType = mediaType;
15352
- statsToModify.requestedBitrate = transceiver.requestedBitrate;
15353
- statsToModify.requestedFrameSize = transceiver.requestedFrameSize;
15354
- Object.assign(statsToModify, transceiver.receiverId);
15355
- stats.set(receiverStats.id, statsToModify);
15364
+ stats.set(receiverStats.id, receiverStats);
15356
15365
  }
15357
15366
  });
15358
15367
  })));