@webex/web-client-media-engine 3.8.3 → 3.8.5

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
@@ -13840,11 +13840,25 @@ class SendOnlyTransceiver extends Transceiver {
13840
13840
  this.munger = munger;
13841
13841
  this.mediaType = mediaType;
13842
13842
  }
13843
+ replaceSenderSource(stream) {
13844
+ var _a, _b;
13845
+ return __awaiter(this, void 0, void 0, function* () {
13846
+ const trackOrNull = (_a = stream === null || stream === void 0 ? void 0 : stream.outputStream.getTracks()[0]) !== null && _a !== void 0 ? _a : null;
13847
+ if (((_b = this.sender.track) === null || _b === void 0 ? void 0 : _b.id) !== (trackOrNull === null || trackOrNull === void 0 ? void 0 : trackOrNull.id)) {
13848
+ yield this.sender.replaceTrack(trackOrNull);
13849
+ if (trackOrNull) {
13850
+ logger.log(`Sender source for ${this.mediaType} replaced with track ID ${trackOrNull.id}`);
13851
+ }
13852
+ else {
13853
+ logger.log(`Sender source for ${this.mediaType} set to null, sender stopped`);
13854
+ }
13855
+ }
13856
+ });
13857
+ }
13843
13858
  handleTrackChange() {
13844
- var _a;
13845
13859
  return __awaiter(this, void 0, void 0, function* () {
13846
13860
  if (this.requested) {
13847
- yield this.sender.replaceTrack(((_a = this.publishedStream) === null || _a === void 0 ? void 0 : _a.outputStream.getTracks()[0]) || null);
13861
+ yield this.replaceSenderSource(this.publishedStream);
13848
13862
  }
13849
13863
  });
13850
13864
  }
@@ -13863,12 +13877,11 @@ class SendOnlyTransceiver extends Transceiver {
13863
13877
  const _super = Object.create(null, {
13864
13878
  replaceTransceiver: { get: () => super.replaceTransceiver }
13865
13879
  });
13866
- var _a;
13867
13880
  return __awaiter(this, void 0, void 0, function* () {
13868
13881
  _super.replaceTransceiver.call(this, newRtcRtpTransceiver);
13869
13882
  newRtcRtpTransceiver.direction = this.direction;
13870
13883
  if (this.requested) {
13871
- yield this.sender.replaceTrack(((_a = this.publishedStream) === null || _a === void 0 ? void 0 : _a.outputStream.getTracks()[0]) || null);
13884
+ yield this.replaceSenderSource(this.publishedStream);
13872
13885
  }
13873
13886
  });
13874
13887
  }
@@ -13879,7 +13892,7 @@ class SendOnlyTransceiver extends Transceiver {
13879
13892
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.LocalStreamEventNames.ConstraintsChange, this.handleStreamConstraintsChange);
13880
13893
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.StreamEventNames.MuteStateChange, this.handleStreamMuteStateChange);
13881
13894
  if (this.requested) {
13882
- yield this.sender.replaceTrack((newStream === null || newStream === void 0 ? void 0 : newStream.outputStream.getTracks()[0]) || null);
13895
+ yield this.replaceSenderSource(newStream);
13883
13896
  }
13884
13897
  this.publishedStream = newStream;
13885
13898
  newStream === null || newStream === void 0 ? void 0 : newStream.on(exports.LocalStreamEventNames.OutputTrackChange, this.handleTrackChange);
@@ -13923,29 +13936,27 @@ class SendOnlyTransceiver extends Transceiver {
13923
13936
  updateSendParameters(requestedIdEncodingParamsMap) {
13924
13937
  return __awaiter(this, void 0, void 0, function* () {
13925
13938
  return this.updateSendParametersQueue.push(() => __awaiter(this, void 0, void 0, function* () {
13926
- if (this.publishedStream) {
13927
- const requested = requestedIdEncodingParamsMap.size > 0;
13928
- if (this.requested !== requested) {
13929
- this.sender.replaceTrack(requested ? this.publishedStream.outputStream.getTracks()[0] || null : null);
13930
- }
13931
- const sendParameters = this.sender.getParameters();
13932
- sendParameters.encodings.forEach((encoding, index) => {
13933
- var _a, _b;
13934
- const encodingParams = requestedIdEncodingParamsMap.get(index);
13935
- encoding.active = !!encodingParams;
13936
- if (encodingParams) {
13937
- const { maxPayloadBitsPerSecond, maxFs, maxWidth, maxHeight } = encodingParams;
13938
- const scaleDownRatio = getScaleDownRatio((_a = this.publishedStream) === null || _a === void 0 ? void 0 : _a.getSettings().width, (_b = this.publishedStream) === null || _b === void 0 ? void 0 : _b.getSettings().height, maxFs, maxWidth, maxHeight);
13939
- if (maxPayloadBitsPerSecond !== undefined && maxPayloadBitsPerSecond >= 0) {
13940
- encoding.maxBitrate = maxPayloadBitsPerSecond;
13941
- }
13942
- if (scaleDownRatio !== undefined && scaleDownRatio >= 1.0) {
13943
- encoding.scaleResolutionDownBy = scaleDownRatio;
13944
- }
13945
- }
13946
- });
13947
- yield this.sender.setParameters(sendParameters);
13939
+ const requested = requestedIdEncodingParamsMap.size > 0;
13940
+ if (this.requested !== requested) {
13941
+ yield this.replaceSenderSource(requested ? this.publishedStream : null);
13948
13942
  }
13943
+ const sendParameters = this.sender.getParameters();
13944
+ sendParameters.encodings.forEach((encoding, index) => {
13945
+ var _a, _b;
13946
+ const encodingParams = requestedIdEncodingParamsMap.get(index);
13947
+ encoding.active = !!encodingParams;
13948
+ if (encodingParams) {
13949
+ const { maxPayloadBitsPerSecond, maxFs, maxWidth, maxHeight } = encodingParams;
13950
+ const scaleDownRatio = getScaleDownRatio((_a = this.publishedStream) === null || _a === void 0 ? void 0 : _a.getSettings().width, (_b = this.publishedStream) === null || _b === void 0 ? void 0 : _b.getSettings().height, maxFs, maxWidth, maxHeight);
13951
+ if (maxPayloadBitsPerSecond !== undefined && maxPayloadBitsPerSecond >= 0) {
13952
+ encoding.maxBitrate = maxPayloadBitsPerSecond;
13953
+ }
13954
+ if (scaleDownRatio !== undefined && scaleDownRatio >= 1.0) {
13955
+ encoding.scaleResolutionDownBy = scaleDownRatio;
13956
+ }
13957
+ }
13958
+ });
13959
+ yield this.sender.setParameters(sendParameters);
13949
13960
  this.requestedIdEncodingParamsMap = requestedIdEncodingParamsMap;
13950
13961
  }));
13951
13962
  });