@webex/web-client-media-engine 3.20.3 → 3.21.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
@@ -2365,7 +2365,8 @@ exports.ConnectionState = void 0;
2365
2365
  })(exports.ConnectionState || (exports.ConnectionState = {}));
2366
2366
  var ConnectionStateEvents;
2367
2367
  (function (ConnectionStateEvents) {
2368
- ConnectionStateEvents["ConnectionStateChanged"] = "ConnectionStateChanged";
2368
+ ConnectionStateEvents["PeerConnectionStateChanged"] = "PeerConnectionStateChanged";
2369
+ ConnectionStateEvents["IceConnectionStateChanged"] = "IceConnectionStateChanged";
2369
2370
  })(ConnectionStateEvents || (ConnectionStateEvents = {}));
2370
2371
  /**
2371
2372
  * Listens on the connection's ICE and DTLS state changes and emits a single
@@ -2381,29 +2382,20 @@ class ConnectionStateHandler extends EventEmitter$4 {
2381
2382
  constructor(getCurrentStatesCallback) {
2382
2383
  super();
2383
2384
  this.getCurrentStatesCallback = getCurrentStatesCallback;
2384
- this.mediaConnectionState = this.evaluateMediaConnectionState();
2385
2385
  }
2386
2386
  /**
2387
2387
  * Handler for connection state change.
2388
2388
  */
2389
- onConnectionStateChange() {
2390
- this.handleAnyConnectionStateChange();
2389
+ onPeerConnectionStateChange() {
2390
+ const state = this.getPeerConnectionState();
2391
+ this.emit(ConnectionStateEvents.PeerConnectionStateChanged, state);
2391
2392
  }
2392
2393
  /**
2393
2394
  * Handler for ice connection state change.
2394
2395
  */
2395
2396
  onIceConnectionStateChange() {
2396
- this.handleAnyConnectionStateChange();
2397
- }
2398
- /**
2399
- * Method to be called whenever ice connection or dtls connection state is changed.
2400
- */
2401
- handleAnyConnectionStateChange() {
2402
- const newConnectionState = this.evaluateMediaConnectionState();
2403
- if (newConnectionState !== this.mediaConnectionState) {
2404
- this.mediaConnectionState = newConnectionState;
2405
- this.emit(ConnectionStateEvents.ConnectionStateChanged, this.mediaConnectionState);
2406
- }
2397
+ const state = this.getIceConnectionState();
2398
+ this.emit(ConnectionStateEvents.IceConnectionStateChanged, state);
2407
2399
  }
2408
2400
  /**
2409
2401
  * Evaluates the overall connection state based on peer connection's
@@ -2441,8 +2433,26 @@ class ConnectionStateHandler extends EventEmitter$4 {
2441
2433
  *
2442
2434
  * @returns Current connection state.
2443
2435
  */
2436
+ getPeerConnectionState() {
2437
+ const { connectionState } = this.getCurrentStatesCallback();
2438
+ return connectionState;
2439
+ }
2440
+ /**
2441
+ * Gets current ice connection state.
2442
+ *
2443
+ * @returns Current ice connection state.
2444
+ */
2445
+ getIceConnectionState() {
2446
+ const { iceState } = this.getCurrentStatesCallback();
2447
+ return iceState;
2448
+ }
2449
+ /**
2450
+ * Gets current overall connection state.
2451
+ *
2452
+ * @returns Current overall connection state.
2453
+ */
2444
2454
  getConnectionState() {
2445
- return this.mediaConnectionState;
2455
+ return this.evaluateMediaConnectionState();
2446
2456
  }
2447
2457
  }
2448
2458
  ConnectionStateHandler.Events = ConnectionStateEvents;
@@ -5824,7 +5834,8 @@ var PeerConnectionEvents;
5824
5834
  (function (PeerConnectionEvents) {
5825
5835
  PeerConnectionEvents["IceGatheringStateChange"] = "icegatheringstatechange";
5826
5836
  PeerConnectionEvents["IceCandidate"] = "icecandidate";
5827
- PeerConnectionEvents["ConnectionStateChange"] = "connectionstatechange";
5837
+ PeerConnectionEvents["PeerConnectionStateChange"] = "peerconnectionstatechange";
5838
+ PeerConnectionEvents["IceConnectionStateChange"] = "iceconnectionstatechange";
5828
5839
  PeerConnectionEvents["CreateOfferOnSuccess"] = "createofferonsuccess";
5829
5840
  PeerConnectionEvents["CreateAnswerOnSuccess"] = "createansweronsuccess";
5830
5841
  PeerConnectionEvents["SetLocalDescriptionOnSuccess"] = "setlocaldescriptiononsuccess";
@@ -5849,19 +5860,23 @@ class PeerConnection extends EventEmitter$4 {
5849
5860
  iceState: this.pc.iceConnectionState,
5850
5861
  };
5851
5862
  });
5852
- this.connectionStateHandler.on(ConnectionStateHandler.Events.ConnectionStateChanged, (state) => {
5853
- this.emit(PeerConnection.Events.ConnectionStateChange, state);
5863
+ this.connectionStateHandler.on(ConnectionStateHandler.Events.PeerConnectionStateChanged, (state) => {
5864
+ this.emit(PeerConnection.Events.PeerConnectionStateChange, state);
5865
+ });
5866
+ this.connectionStateHandler.on(ConnectionStateHandler.Events.IceConnectionStateChanged, (state) => {
5867
+ this.emit(PeerConnection.Events.IceConnectionStateChange, state);
5854
5868
  });
5855
5869
  // Forward the connection state related events to connection state handler
5856
5870
  // eslint-disable-next-line jsdoc/require-jsdoc
5857
5871
  this.pc.oniceconnectionstatechange = () => this.connectionStateHandler.onIceConnectionStateChange();
5858
5872
  // eslint-disable-next-line jsdoc/require-jsdoc
5859
- this.pc.onconnectionstatechange = () => this.connectionStateHandler.onConnectionStateChange();
5873
+ this.pc.onconnectionstatechange = () => this.connectionStateHandler.onPeerConnectionStateChange();
5860
5874
  // Subscribe to underlying PeerConnection events and emit them via the EventEmitter
5861
5875
  /* eslint-disable jsdoc/require-jsdoc */
5862
5876
  this.pc.onicegatheringstatechange = (ev) => {
5863
5877
  this.emit(PeerConnection.Events.IceGatheringStateChange, ev);
5864
5878
  };
5879
+ /* eslint-disable jsdoc/require-jsdoc */
5865
5880
  this.pc.onicecandidate = (ev) => {
5866
5881
  this.emit(PeerConnection.Events.IceCandidate, ev);
5867
5882
  };
@@ -5882,6 +5897,22 @@ class PeerConnection extends EventEmitter$4 {
5882
5897
  getConnectionState() {
5883
5898
  return this.connectionStateHandler.getConnectionState();
5884
5899
  }
5900
+ /**
5901
+ * Gets the connection state of the underlying RTCPeerConnection.
5902
+ *
5903
+ * @returns The underlying RTCPeerConnection connection state.
5904
+ */
5905
+ getPeerConnectionState() {
5906
+ return this.connectionStateHandler.getPeerConnectionState();
5907
+ }
5908
+ /**
5909
+ * Gets the ICE connection state of the underlying RTCPeerConnection.
5910
+ *
5911
+ * @returns The underlying RTCPeerConnection ICE connection state.
5912
+ */
5913
+ getIceConnectionState() {
5914
+ return this.connectionStateHandler.getIceConnectionState();
5915
+ }
5885
5916
  /**
5886
5917
  * Adds a new media track to the set of tracks which will be transmitted to the other peer.
5887
5918
  *
@@ -7919,6 +7950,7 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
7919
7950
  var args = arguments;
7920
7951
  trace("on".concat(method), makeEvent(method === 'addIceCandidate' ? arguments[0] : arguments[0].sdp));
7921
7952
  return nativeMethod.apply(this, [arguments[0]]).then(function () {
7953
+ var _a;
7922
7954
  trace("on".concat(method, "OnSuccess"), makeEvent('success'));
7923
7955
  if (method.endsWith('Description')) {
7924
7956
  if (!_this.transportEventsPreviouslyAdded) {
@@ -7960,7 +7992,8 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
7960
7992
  }
7961
7993
  }
7962
7994
  if (!_this.sctpEventsPreviouslyAdded) {
7963
- if (_this.sctp) {
7995
+ // Some Firefox versions prior to 113 have sctp defined but not the events, so check both here.
7996
+ if ((_a = _this.sctp) === null || _a === void 0 ? void 0 : _a.addEventListener) {
7964
7997
  _this.sctp.addEventListener('statechange', function () {
7965
7998
  trace('onsctpStateChange', makeEvent(_this.sctp.state));
7966
7999
  });
@@ -14700,7 +14733,8 @@ exports.MultistreamConnectionEventNames = void 0;
14700
14733
  MultistreamConnectionEventNames["VideoSourceCountUpdate"] = "video-source-count-update";
14701
14734
  MultistreamConnectionEventNames["AudioSourceCountUpdate"] = "audio-source-count-update";
14702
14735
  MultistreamConnectionEventNames["ActiveSpeakerNotification"] = "active-speaker-notification";
14703
- MultistreamConnectionEventNames["ConnectionStateUpdate"] = "connection-state-update";
14736
+ MultistreamConnectionEventNames["PeerConnectionStateUpdate"] = "peer-connection-state-update";
14737
+ MultistreamConnectionEventNames["IceConnectionStateUpdate"] = "ice-connection-state-update";
14704
14738
  MultistreamConnectionEventNames["IceGatheringStateUpdate"] = "ice-gathering-state-update";
14705
14739
  MultistreamConnectionEventNames["NegotiationNeeded"] = "negotiation-needed";
14706
14740
  MultistreamConnectionEventNames["CreateOfferOnSuccess"] = "createofferonsuccess";
@@ -14754,8 +14788,11 @@ class MultistreamConnection extends EventEmitter$2 {
14754
14788
  this.createDataChannel();
14755
14789
  }
14756
14790
  propagatePeerConnectionEvents() {
14757
- this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => {
14758
- this.emit(exports.MultistreamConnectionEventNames.ConnectionStateUpdate, state);
14791
+ this.pc.on(PeerConnection.Events.PeerConnectionStateChange, (state) => {
14792
+ this.emit(exports.MultistreamConnectionEventNames.PeerConnectionStateUpdate, state);
14793
+ });
14794
+ this.pc.on(PeerConnection.Events.IceConnectionStateChange, (state) => {
14795
+ this.emit(exports.MultistreamConnectionEventNames.IceConnectionStateUpdate, state);
14759
14796
  });
14760
14797
  this.pc.on(PeerConnection.Events.CreateOfferOnSuccess, (description) => {
14761
14798
  this.emit(exports.MultistreamConnectionEventNames.CreateOfferOnSuccess, description);
@@ -14776,6 +14813,15 @@ class MultistreamConnection extends EventEmitter$2 {
14776
14813
  getConnectionState() {
14777
14814
  return this.pc.getConnectionState();
14778
14815
  }
14816
+ getPeerConnectionState() {
14817
+ return this.pc.getPeerConnectionState();
14818
+ }
14819
+ getIceConnectionState() {
14820
+ return this.pc.getIceConnectionState();
14821
+ }
14822
+ getCurrentConnectionType() {
14823
+ return this.pc.getCurrentConnectionType();
14824
+ }
14779
14825
  getIceGatheringState() {
14780
14826
  return this.pc.iceGatheringState;
14781
14827
  }