@webex/web-client-media-engine 3.8.3 → 3.8.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/esm/index.js CHANGED
@@ -13836,11 +13836,23 @@ class SendOnlyTransceiver extends Transceiver {
13836
13836
  this.munger = munger;
13837
13837
  this.mediaType = mediaType;
13838
13838
  }
13839
- handleTrackChange() {
13839
+ replaceSenderSource(stream) {
13840
13840
  var _a;
13841
+ return __awaiter(this, void 0, void 0, function* () {
13842
+ const trackOrNull = (_a = stream === null || stream === void 0 ? void 0 : stream.outputStream.getTracks()[0]) !== null && _a !== void 0 ? _a : null;
13843
+ yield this.sender.replaceTrack(trackOrNull);
13844
+ if (trackOrNull) {
13845
+ logger.log(`Sender source for ${this.mediaType} replaced with track ID ${trackOrNull.id}`);
13846
+ }
13847
+ else {
13848
+ logger.log(`Sender source for ${this.mediaType} set to null, sender stopped`);
13849
+ }
13850
+ });
13851
+ }
13852
+ handleTrackChange() {
13841
13853
  return __awaiter(this, void 0, void 0, function* () {
13842
13854
  if (this.requested) {
13843
- yield this.sender.replaceTrack(((_a = this.publishedStream) === null || _a === void 0 ? void 0 : _a.outputStream.getTracks()[0]) || null);
13855
+ yield this.replaceSenderSource(this.publishedStream);
13844
13856
  }
13845
13857
  });
13846
13858
  }
@@ -13859,12 +13871,11 @@ class SendOnlyTransceiver extends Transceiver {
13859
13871
  const _super = Object.create(null, {
13860
13872
  replaceTransceiver: { get: () => super.replaceTransceiver }
13861
13873
  });
13862
- var _a;
13863
13874
  return __awaiter(this, void 0, void 0, function* () {
13864
13875
  _super.replaceTransceiver.call(this, newRtcRtpTransceiver);
13865
13876
  newRtcRtpTransceiver.direction = this.direction;
13866
13877
  if (this.requested) {
13867
- yield this.sender.replaceTrack(((_a = this.publishedStream) === null || _a === void 0 ? void 0 : _a.outputStream.getTracks()[0]) || null);
13878
+ yield this.replaceSenderSource(this.publishedStream);
13868
13879
  }
13869
13880
  });
13870
13881
  }
@@ -13875,7 +13886,7 @@ class SendOnlyTransceiver extends Transceiver {
13875
13886
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(LocalStreamEventNames.ConstraintsChange, this.handleStreamConstraintsChange);
13876
13887
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(StreamEventNames.MuteStateChange, this.handleStreamMuteStateChange);
13877
13888
  if (this.requested) {
13878
- yield this.sender.replaceTrack((newStream === null || newStream === void 0 ? void 0 : newStream.outputStream.getTracks()[0]) || null);
13889
+ yield this.replaceSenderSource(newStream);
13879
13890
  }
13880
13891
  this.publishedStream = newStream;
13881
13892
  newStream === null || newStream === void 0 ? void 0 : newStream.on(LocalStreamEventNames.OutputTrackChange, this.handleTrackChange);
@@ -13922,7 +13933,7 @@ class SendOnlyTransceiver extends Transceiver {
13922
13933
  if (this.publishedStream) {
13923
13934
  const requested = requestedIdEncodingParamsMap.size > 0;
13924
13935
  if (this.requested !== requested) {
13925
- this.sender.replaceTrack(requested ? this.publishedStream.outputStream.getTracks()[0] || null : null);
13936
+ this.replaceSenderSource(requested ? this.publishedStream : null);
13926
13937
  }
13927
13938
  const sendParameters = this.sender.getParameters();
13928
13939
  sendParameters.encodings.forEach((encoding, index) => {