@webex/web-client-media-engine 3.31.4 → 3.31.6

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
@@ -5926,6 +5926,7 @@ class PeerConnection extends EventEmitter$4 {
5926
5926
  */
5927
5927
  constructor(configuration) {
5928
5928
  super();
5929
+ this.iceCandidates = [];
5929
5930
  logger$3.log('PeerConnection init');
5930
5931
  this.pc = createRTCPeerConnection(configuration);
5931
5932
  this.connectionStateHandler = new ConnectionStateHandler(() => {
@@ -5952,6 +5953,9 @@ class PeerConnection extends EventEmitter$4 {
5952
5953
  };
5953
5954
  /* eslint-disable jsdoc/require-jsdoc */
5954
5955
  this.pc.onicecandidate = (ev) => {
5956
+ if (ev.candidate) {
5957
+ this.iceCandidates.push(ev.candidate);
5958
+ }
5955
5959
  this.emit(PeerConnection.Events.IceCandidate, ev);
5956
5960
  };
5957
5961
  this.pc.onicecandidateerror = (ev) => {
@@ -5990,6 +5994,14 @@ class PeerConnection extends EventEmitter$4 {
5990
5994
  getIceConnectionState() {
5991
5995
  return this.connectionStateHandler.getIceConnectionState();
5992
5996
  }
5997
+ /**
5998
+ * Gets the list of ICE candidates that have been gathered.
5999
+ *
6000
+ * @returns An array of RTCIceCandidate objects representing the ICE candidates.
6001
+ */
6002
+ getIceCandidates() {
6003
+ return this.iceCandidates;
6004
+ }
5993
6005
  /**
5994
6006
  * Adds a new media track to the set of tracks which will be transmitted to the other peer.
5995
6007
  *
@@ -14514,6 +14526,7 @@ class SendOnlyTransceiver extends Transceiver {
14514
14526
  this.rtxEnabled = false;
14515
14527
  this.dtxDisabled = true;
14516
14528
  this.streamMuteStateChange = new TypedEvent();
14529
+ this.streamReadyStateChanged = new TypedEvent();
14517
14530
  this.streamPublishStateChange = new TypedEvent();
14518
14531
  this.negotiationNeeded = new TypedEvent();
14519
14532
  this.namedMediaGroupsChange = new TypedEvent();
@@ -14527,6 +14540,7 @@ class SendOnlyTransceiver extends Transceiver {
14527
14540
  this.handleTrackChange = this.handleTrackChange.bind(this);
14528
14541
  this.handleStreamConstraintsChange = this.handleStreamConstraintsChange.bind(this);
14529
14542
  this.handleStreamMuteStateChange = this.handleStreamMuteStateChange.bind(this);
14543
+ this.handleStreamEnded = this.handleStreamEnded.bind(this);
14530
14544
  }
14531
14545
  replaceSenderSource(stream) {
14532
14546
  var _a, _b;
@@ -14558,6 +14572,9 @@ class SendOnlyTransceiver extends Transceiver {
14558
14572
  handleStreamMuteStateChange() {
14559
14573
  this.streamMuteStateChange.emit();
14560
14574
  }
14575
+ handleStreamEnded() {
14576
+ this.streamReadyStateChanged.emit();
14577
+ }
14561
14578
  get requested() {
14562
14579
  return this.requestedIdEncodingParamsMap.size > 0;
14563
14580
  }
@@ -14580,6 +14597,7 @@ class SendOnlyTransceiver extends Transceiver {
14580
14597
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.LocalStreamEventNames.ConstraintsChange, this.handleStreamConstraintsChange);
14581
14598
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.LocalStreamEventNames.UserMuteStateChange, this.handleStreamMuteStateChange);
14582
14599
  oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.LocalStreamEventNames.SystemMuteStateChange, this.handleStreamMuteStateChange);
14600
+ oldStream === null || oldStream === void 0 ? void 0 : oldStream.off(exports.StreamEventNames.Ended, this.handleStreamEnded);
14583
14601
  if (this.requested) {
14584
14602
  yield this.replaceSenderSource(newStream);
14585
14603
  }
@@ -14588,12 +14606,17 @@ class SendOnlyTransceiver extends Transceiver {
14588
14606
  newStream === null || newStream === void 0 ? void 0 : newStream.on(exports.LocalStreamEventNames.ConstraintsChange, this.handleStreamConstraintsChange);
14589
14607
  newStream === null || newStream === void 0 ? void 0 : newStream.on(exports.LocalStreamEventNames.UserMuteStateChange, this.handleStreamMuteStateChange);
14590
14608
  newStream === null || newStream === void 0 ? void 0 : newStream.on(exports.LocalStreamEventNames.SystemMuteStateChange, this.handleStreamMuteStateChange);
14591
- if ((!oldStream && newStream && !newStream.muted) ||
14592
- (oldStream && !newStream && !oldStream.muted)) {
14609
+ newStream === null || newStream === void 0 ? void 0 : newStream.on(exports.StreamEventNames.Ended, this.handleStreamEnded);
14610
+ if ((!oldStream && newStream) || (oldStream && !newStream)) {
14593
14611
  this.streamPublishStateChange.emit();
14594
14612
  }
14595
- else if ((oldStream === null || oldStream === void 0 ? void 0 : oldStream.muted) !== (newStream === null || newStream === void 0 ? void 0 : newStream.muted)) {
14596
- this.streamMuteStateChange.emit();
14613
+ if (oldStream && newStream) {
14614
+ if (oldStream.muted !== newStream.muted) {
14615
+ this.streamMuteStateChange.emit();
14616
+ }
14617
+ if (oldStream.readyState !== newStream.readyState) {
14618
+ this.streamReadyStateChanged.emit();
14619
+ }
14597
14620
  }
14598
14621
  });
14599
14622
  }
@@ -14955,7 +14978,6 @@ class MultistreamConnection extends EventEmitter$2 {
14955
14978
  this.midPredictor = new MidPredictor();
14956
14979
  this.offerAnswerQueue = new AsyncQueue();
14957
14980
  this.currentCreateOfferId = 0;
14958
- this.iceCandidates = [];
14959
14981
  this.metadata = { isMediaBypassEdge: false };
14960
14982
  this.options = Object.assign(Object.assign({}, defaultMultistreamConnectionOptions), userOptions);
14961
14983
  logger.info(`Creating multistream connection with options ${JSON.stringify(this.options)}`);
@@ -15006,9 +15028,6 @@ class MultistreamConnection extends EventEmitter$2 {
15006
15028
  this.emit(exports.MultistreamConnectionEventNames.IceGatheringStateUpdate, this.getIceGatheringState());
15007
15029
  });
15008
15030
  this.pc.on(PeerConnection.Events.IceCandidate, (candidate) => {
15009
- if (candidate.candidate) {
15010
- this.iceCandidates.push(candidate.candidate);
15011
- }
15012
15031
  this.emit(exports.MultistreamConnectionEventNames.IceCandidate, candidate);
15013
15032
  });
15014
15033
  this.pc.on(PeerConnection.Events.IceCandidateError, (error) => {
@@ -15083,6 +15102,10 @@ class MultistreamConnection extends EventEmitter$2 {
15083
15102
  this.sendSourceAdvertisement(mediaType);
15084
15103
  this.sendMediaRequestStatus(mediaType);
15085
15104
  });
15105
+ transceiver.streamReadyStateChanged.on(() => {
15106
+ this.sendSourceAdvertisement(mediaType);
15107
+ this.sendMediaRequestStatus(mediaType);
15108
+ });
15086
15109
  transceiver.negotiationNeeded.on((offerAnswerType) => {
15087
15110
  if (offerAnswerType === OfferAnswerType.Remote) {
15088
15111
  this.emit(exports.MultistreamConnectionEventNames.NegotiationNeeded);
@@ -15316,9 +15339,12 @@ SCTP Max Message Size: ${maxMessageSize}`);
15316
15339
  }
15317
15340
  }
15318
15341
  sendSourceAdvertisement(mediaType) {
15319
- var _a, _b;
15342
+ var _a, _b, _c;
15320
15343
  const transceiver = this.getSendTransceiverOrThrow(mediaType);
15321
- const numLiveSources = ((_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.muted) === false ? 1 : 0;
15344
+ const numLiveSources = ((_a = transceiver.publishedStream) === null || _a === void 0 ? void 0 : _a.muted) === false &&
15345
+ ((_b = transceiver.publishedStream) === null || _b === void 0 ? void 0 : _b.readyState) === 'live'
15346
+ ? 1
15347
+ : 0;
15322
15348
  let task;
15323
15349
  if (getMediaFamily(mediaType) === exports.MediaFamily.Video) {
15324
15350
  const sources = this.getVideoStreamStates(mediaType);
@@ -15342,7 +15368,7 @@ SCTP Max Message Size: ${maxMessageSize}`);
15342
15368
  .get(mediaType)) === null || _a === void 0 ? void 0 : _a.sendSourceAdvertisement(1, numLiveSources, mediaType === exports.MediaType.AudioMain ? transceiver.namedMediaGroups : []);
15343
15369
  };
15344
15370
  }
15345
- if (((_b = this.dataChannel) === null || _b === void 0 ? void 0 : _b.readyState) === 'open') {
15371
+ if (((_c = this.dataChannel) === null || _c === void 0 ? void 0 : _c.readyState) === 'open') {
15346
15372
  task();
15347
15373
  }
15348
15374
  else {
@@ -15615,9 +15641,10 @@ SCTP Max Message Size: ${maxMessageSize}`);
15615
15641
  });
15616
15642
  }
15617
15643
  if (BrowserInfo.isFirefox() && this.options.doFullIce) {
15644
+ const iceCandidates = this.pc.getIceCandidates();
15618
15645
  parsedOffer.media.forEach((media) => {
15619
15646
  media.iceInfo.candidates = [];
15620
- this.iceCandidates.forEach((iceCandidate) => {
15647
+ iceCandidates.forEach((iceCandidate) => {
15621
15648
  const candidateLine = CandidateLine.fromSdpLine(iceCandidate.candidate.toString());
15622
15649
  if (candidateLine) {
15623
15650
  media.addLine(candidateLine);