@webex/web-client-media-engine 2.1.3 → 2.1.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 CHANGED
@@ -9432,12 +9432,17 @@ class SendOnlyTransceiver extends Transceiver {
9432
9432
  }
9433
9433
  updateSendParameters(requestedIdEncodingParamsMap) {
9434
9434
  return __awaiter(this, void 0, void 0, function* () {
9435
+ if (!this.publishedTrack)
9436
+ return;
9437
+ this.setTrackRequested(requestedIdEncodingParamsMap.size > 0);
9435
9438
  const sendParameters = this.sender.getParameters();
9436
9439
  sendParameters.encodings.forEach((encoding, index) => {
9440
+ var _a, _b;
9437
9441
  const encodingParams = requestedIdEncodingParamsMap.get(index);
9438
9442
  encoding.active = !!encodingParams;
9439
9443
  if (encodingParams) {
9440
- const { maxPayloadBitsPerSecond, scaleDownRatio } = encodingParams;
9444
+ const { maxPayloadBitsPerSecond, maxFs, maxWidth, maxHeight } = encodingParams;
9445
+ const scaleDownRatio = getScaleDownRatio((_a = this.publishedTrack) === null || _a === void 0 ? void 0 : _a.getSettings().width, (_b = this.publishedTrack) === null || _b === void 0 ? void 0 : _b.getSettings().height, maxFs, maxWidth, maxHeight);
9441
9446
  if (maxPayloadBitsPerSecond !== undefined && maxPayloadBitsPerSecond >= 0) {
9442
9447
  encoding.maxBitrate = maxPayloadBitsPerSecond;
9443
9448
  }
@@ -13282,6 +13287,7 @@ class MultistreamConnection extends EventEmitter {
13282
13287
  this.overuseUpdateCallback = () => { };
13283
13288
  this.midPredictor = new MidPredictor();
13284
13289
  this.offerAnswerQueue = new AsyncQueue();
13290
+ this.requestedIdEncodingParamsMap = new Map();
13285
13291
  this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
13286
13292
  logger.info(`Creating multistream connection with options ${JSON.stringify(this.options)}`);
13287
13293
  this.initializePeerConnection();
@@ -13405,7 +13411,7 @@ class MultistreamConnection extends EventEmitter {
13405
13411
  logger.warn('Ignoring non-receiver-selected requests');
13406
13412
  }
13407
13413
  rsRequests.forEach(({ ids, policySpecificInfo, codecInfos, maxPayloadBitsPerSecond }) => {
13408
- var _a, _b, _c, _d;
13414
+ var _a, _b, _c;
13409
13415
  if (ids.length > 1) {
13410
13416
  throw new Error(`More than a single ID being unexpected/invalid ${ids}`);
13411
13417
  }
@@ -13424,10 +13430,9 @@ class MultistreamConnection extends EventEmitter {
13424
13430
  if (encodingIndex !== -1) {
13425
13431
  const encodingParams = { maxPayloadBitsPerSecond };
13426
13432
  if (mediaFamily === MediaFamily.Video) {
13427
- const trackSettings = (_a = sendTransceiver.publishedTrack) === null || _a === void 0 ? void 0 : _a.getSettings();
13428
- if (trackSettings) {
13429
- encodingParams.scaleDownRatio = getScaleDownRatio(trackSettings.width, trackSettings.height, (_b = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _b === void 0 ? void 0 : _b.maxFs, (_c = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _c === void 0 ? void 0 : _c.maxWidth, (_d = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _d === void 0 ? void 0 : _d.maxHeight);
13430
- }
13433
+ encodingParams.maxFs = (_a = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _a === void 0 ? void 0 : _a.maxFs;
13434
+ encodingParams.maxWidth = (_b = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _b === void 0 ? void 0 : _b.maxWidth;
13435
+ encodingParams.maxHeight = (_c = codecInfo === null || codecInfo === void 0 ? void 0 : codecInfo.h264) === null || _c === void 0 ? void 0 : _c.maxHeight;
13431
13436
  }
13432
13437
  requestedIdEncodingParamsMap.set(encodingIndex, encodingParams);
13433
13438
  }
@@ -13439,8 +13444,8 @@ class MultistreamConnection extends EventEmitter {
13439
13444
  logger.warn(`${mediaType}: Unable to find matching stream ID for requested ID: ${JSON.stringify(id)}`);
13440
13445
  }
13441
13446
  });
13442
- sendTransceiver.setTrackRequested(requestedIdEncodingParamsMap.size > 0);
13443
13447
  sendTransceiver.updateSendParameters(requestedIdEncodingParamsMap);
13448
+ this.requestedIdEncodingParamsMap = requestedIdEncodingParamsMap;
13444
13449
  }
13445
13450
  createDataChannel() {
13446
13451
  const dataChannel = this.pc.createDataChannel('datachannel', {});
@@ -13581,8 +13586,9 @@ class MultistreamConnection extends EventEmitter {
13581
13586
  });
13582
13587
  }
13583
13588
  addTrackListeners(mediaType, track) {
13589
+ const sendTransceiver = this.getSendTransceiverOrThrow(mediaType);
13584
13590
  const onTrackResolutionChange = () => {
13585
- this.sendMediaRequestStatus(mediaType);
13591
+ sendTransceiver.updateSendParameters(this.requestedIdEncodingParamsMap);
13586
13592
  };
13587
13593
  track.on(LocalTrack.Events.TrackConstraintsChange, onTrackResolutionChange);
13588
13594
  const onTrackMute = () => {
@@ -13599,16 +13605,18 @@ class MultistreamConnection extends EventEmitter {
13599
13605
  if (!track.muted) {
13600
13606
  this.sendSourceAdvertisement(mediaType);
13601
13607
  this.sendMediaRequestStatus(mediaType);
13608
+ if (mediaType === MediaType.VideoMain) {
13609
+ sendTransceiver.updateSendParameters(this.requestedIdEncodingParamsMap);
13610
+ }
13602
13611
  }
13603
13612
  };
13604
13613
  track.on(LocalTrack.Events.PublishedStateUpdate, onTrackPublish);
13605
13614
  }
13606
13615
  getVideoStreamStates(mediaType) {
13607
- var _a, _b, _c;
13616
+ var _a, _b;
13608
13617
  const sendTransceiver = this.getSendTransceiverOrThrow(mediaType);
13609
- const activeSimulcastLayerNumber = ((_a = sendTransceiver.publishedTrack) === null || _a === void 0 ? void 0 : _a.getNumActiveSimulcastLayers()) || 0;
13610
- const published = (_b = sendTransceiver.publishedTrack) === null || _b === void 0 ? void 0 : _b.published;
13611
- const muted = ((_c = sendTransceiver.publishedTrack) === null || _c === void 0 ? void 0 : _c.muted) === true;
13618
+ const published = (_a = sendTransceiver.publishedTrack) === null || _a === void 0 ? void 0 : _a.published;
13619
+ const muted = ((_b = sendTransceiver.publishedTrack) === null || _b === void 0 ? void 0 : _b.muted) === true;
13612
13620
  return sendTransceiver.senderIds.map((id) => {
13613
13621
  let state;
13614
13622
  if (!published) {
@@ -13617,9 +13625,6 @@ class MultistreamConnection extends EventEmitter {
13617
13625
  else if (muted) {
13618
13626
  state = 'avatar';
13619
13627
  }
13620
- else if (activeSimulcastLayerNumber < sendTransceiver.getEncodingIndexForStreamId(id)) {
13621
- state = 'no source';
13622
- }
13623
13628
  else {
13624
13629
  state = 'live';
13625
13630
  }