@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/esm/index.js CHANGED
@@ -2361,7 +2361,8 @@ var ConnectionState;
2361
2361
  })(ConnectionState || (ConnectionState = {}));
2362
2362
  var ConnectionStateEvents;
2363
2363
  (function (ConnectionStateEvents) {
2364
- ConnectionStateEvents["ConnectionStateChanged"] = "ConnectionStateChanged";
2364
+ ConnectionStateEvents["PeerConnectionStateChanged"] = "PeerConnectionStateChanged";
2365
+ ConnectionStateEvents["IceConnectionStateChanged"] = "IceConnectionStateChanged";
2365
2366
  })(ConnectionStateEvents || (ConnectionStateEvents = {}));
2366
2367
  /**
2367
2368
  * Listens on the connection's ICE and DTLS state changes and emits a single
@@ -2377,29 +2378,20 @@ class ConnectionStateHandler extends EventEmitter$4 {
2377
2378
  constructor(getCurrentStatesCallback) {
2378
2379
  super();
2379
2380
  this.getCurrentStatesCallback = getCurrentStatesCallback;
2380
- this.mediaConnectionState = this.evaluateMediaConnectionState();
2381
2381
  }
2382
2382
  /**
2383
2383
  * Handler for connection state change.
2384
2384
  */
2385
- onConnectionStateChange() {
2386
- this.handleAnyConnectionStateChange();
2385
+ onPeerConnectionStateChange() {
2386
+ const state = this.getPeerConnectionState();
2387
+ this.emit(ConnectionStateEvents.PeerConnectionStateChanged, state);
2387
2388
  }
2388
2389
  /**
2389
2390
  * Handler for ice connection state change.
2390
2391
  */
2391
2392
  onIceConnectionStateChange() {
2392
- this.handleAnyConnectionStateChange();
2393
- }
2394
- /**
2395
- * Method to be called whenever ice connection or dtls connection state is changed.
2396
- */
2397
- handleAnyConnectionStateChange() {
2398
- const newConnectionState = this.evaluateMediaConnectionState();
2399
- if (newConnectionState !== this.mediaConnectionState) {
2400
- this.mediaConnectionState = newConnectionState;
2401
- this.emit(ConnectionStateEvents.ConnectionStateChanged, this.mediaConnectionState);
2402
- }
2393
+ const state = this.getIceConnectionState();
2394
+ this.emit(ConnectionStateEvents.IceConnectionStateChanged, state);
2403
2395
  }
2404
2396
  /**
2405
2397
  * Evaluates the overall connection state based on peer connection's
@@ -2437,8 +2429,26 @@ class ConnectionStateHandler extends EventEmitter$4 {
2437
2429
  *
2438
2430
  * @returns Current connection state.
2439
2431
  */
2432
+ getPeerConnectionState() {
2433
+ const { connectionState } = this.getCurrentStatesCallback();
2434
+ return connectionState;
2435
+ }
2436
+ /**
2437
+ * Gets current ice connection state.
2438
+ *
2439
+ * @returns Current ice connection state.
2440
+ */
2441
+ getIceConnectionState() {
2442
+ const { iceState } = this.getCurrentStatesCallback();
2443
+ return iceState;
2444
+ }
2445
+ /**
2446
+ * Gets current overall connection state.
2447
+ *
2448
+ * @returns Current overall connection state.
2449
+ */
2440
2450
  getConnectionState() {
2441
- return this.mediaConnectionState;
2451
+ return this.evaluateMediaConnectionState();
2442
2452
  }
2443
2453
  }
2444
2454
  ConnectionStateHandler.Events = ConnectionStateEvents;
@@ -5820,7 +5830,8 @@ var PeerConnectionEvents;
5820
5830
  (function (PeerConnectionEvents) {
5821
5831
  PeerConnectionEvents["IceGatheringStateChange"] = "icegatheringstatechange";
5822
5832
  PeerConnectionEvents["IceCandidate"] = "icecandidate";
5823
- PeerConnectionEvents["ConnectionStateChange"] = "connectionstatechange";
5833
+ PeerConnectionEvents["PeerConnectionStateChange"] = "peerconnectionstatechange";
5834
+ PeerConnectionEvents["IceConnectionStateChange"] = "iceconnectionstatechange";
5824
5835
  PeerConnectionEvents["CreateOfferOnSuccess"] = "createofferonsuccess";
5825
5836
  PeerConnectionEvents["CreateAnswerOnSuccess"] = "createansweronsuccess";
5826
5837
  PeerConnectionEvents["SetLocalDescriptionOnSuccess"] = "setlocaldescriptiononsuccess";
@@ -5845,19 +5856,23 @@ class PeerConnection extends EventEmitter$4 {
5845
5856
  iceState: this.pc.iceConnectionState,
5846
5857
  };
5847
5858
  });
5848
- this.connectionStateHandler.on(ConnectionStateHandler.Events.ConnectionStateChanged, (state) => {
5849
- this.emit(PeerConnection.Events.ConnectionStateChange, state);
5859
+ this.connectionStateHandler.on(ConnectionStateHandler.Events.PeerConnectionStateChanged, (state) => {
5860
+ this.emit(PeerConnection.Events.PeerConnectionStateChange, state);
5861
+ });
5862
+ this.connectionStateHandler.on(ConnectionStateHandler.Events.IceConnectionStateChanged, (state) => {
5863
+ this.emit(PeerConnection.Events.IceConnectionStateChange, state);
5850
5864
  });
5851
5865
  // Forward the connection state related events to connection state handler
5852
5866
  // eslint-disable-next-line jsdoc/require-jsdoc
5853
5867
  this.pc.oniceconnectionstatechange = () => this.connectionStateHandler.onIceConnectionStateChange();
5854
5868
  // eslint-disable-next-line jsdoc/require-jsdoc
5855
- this.pc.onconnectionstatechange = () => this.connectionStateHandler.onConnectionStateChange();
5869
+ this.pc.onconnectionstatechange = () => this.connectionStateHandler.onPeerConnectionStateChange();
5856
5870
  // Subscribe to underlying PeerConnection events and emit them via the EventEmitter
5857
5871
  /* eslint-disable jsdoc/require-jsdoc */
5858
5872
  this.pc.onicegatheringstatechange = (ev) => {
5859
5873
  this.emit(PeerConnection.Events.IceGatheringStateChange, ev);
5860
5874
  };
5875
+ /* eslint-disable jsdoc/require-jsdoc */
5861
5876
  this.pc.onicecandidate = (ev) => {
5862
5877
  this.emit(PeerConnection.Events.IceCandidate, ev);
5863
5878
  };
@@ -5878,6 +5893,22 @@ class PeerConnection extends EventEmitter$4 {
5878
5893
  getConnectionState() {
5879
5894
  return this.connectionStateHandler.getConnectionState();
5880
5895
  }
5896
+ /**
5897
+ * Gets the connection state of the underlying RTCPeerConnection.
5898
+ *
5899
+ * @returns The underlying RTCPeerConnection connection state.
5900
+ */
5901
+ getPeerConnectionState() {
5902
+ return this.connectionStateHandler.getPeerConnectionState();
5903
+ }
5904
+ /**
5905
+ * Gets the ICE connection state of the underlying RTCPeerConnection.
5906
+ *
5907
+ * @returns The underlying RTCPeerConnection ICE connection state.
5908
+ */
5909
+ getIceConnectionState() {
5910
+ return this.connectionStateHandler.getIceConnectionState();
5911
+ }
5881
5912
  /**
5882
5913
  * Adds a new media track to the set of tracks which will be transmitted to the other peer.
5883
5914
  *
@@ -7915,6 +7946,7 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
7915
7946
  var args = arguments;
7916
7947
  trace("on".concat(method), makeEvent(method === 'addIceCandidate' ? arguments[0] : arguments[0].sdp));
7917
7948
  return nativeMethod.apply(this, [arguments[0]]).then(function () {
7949
+ var _a;
7918
7950
  trace("on".concat(method, "OnSuccess"), makeEvent('success'));
7919
7951
  if (method.endsWith('Description')) {
7920
7952
  if (!_this.transportEventsPreviouslyAdded) {
@@ -7956,7 +7988,8 @@ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
7956
7988
  }
7957
7989
  }
7958
7990
  if (!_this.sctpEventsPreviouslyAdded) {
7959
- if (_this.sctp) {
7991
+ // Some Firefox versions prior to 113 have sctp defined but not the events, so check both here.
7992
+ if ((_a = _this.sctp) === null || _a === void 0 ? void 0 : _a.addEventListener) {
7960
7993
  _this.sctp.addEventListener('statechange', function () {
7961
7994
  trace('onsctpStateChange', makeEvent(_this.sctp.state));
7962
7995
  });
@@ -14696,7 +14729,8 @@ var MultistreamConnectionEventNames;
14696
14729
  MultistreamConnectionEventNames["VideoSourceCountUpdate"] = "video-source-count-update";
14697
14730
  MultistreamConnectionEventNames["AudioSourceCountUpdate"] = "audio-source-count-update";
14698
14731
  MultistreamConnectionEventNames["ActiveSpeakerNotification"] = "active-speaker-notification";
14699
- MultistreamConnectionEventNames["ConnectionStateUpdate"] = "connection-state-update";
14732
+ MultistreamConnectionEventNames["PeerConnectionStateUpdate"] = "peer-connection-state-update";
14733
+ MultistreamConnectionEventNames["IceConnectionStateUpdate"] = "ice-connection-state-update";
14700
14734
  MultistreamConnectionEventNames["IceGatheringStateUpdate"] = "ice-gathering-state-update";
14701
14735
  MultistreamConnectionEventNames["NegotiationNeeded"] = "negotiation-needed";
14702
14736
  MultistreamConnectionEventNames["CreateOfferOnSuccess"] = "createofferonsuccess";
@@ -14750,8 +14784,11 @@ class MultistreamConnection extends EventEmitter$2 {
14750
14784
  this.createDataChannel();
14751
14785
  }
14752
14786
  propagatePeerConnectionEvents() {
14753
- this.pc.on(PeerConnection.Events.ConnectionStateChange, (state) => {
14754
- this.emit(MultistreamConnectionEventNames.ConnectionStateUpdate, state);
14787
+ this.pc.on(PeerConnection.Events.PeerConnectionStateChange, (state) => {
14788
+ this.emit(MultistreamConnectionEventNames.PeerConnectionStateUpdate, state);
14789
+ });
14790
+ this.pc.on(PeerConnection.Events.IceConnectionStateChange, (state) => {
14791
+ this.emit(MultistreamConnectionEventNames.IceConnectionStateUpdate, state);
14755
14792
  });
14756
14793
  this.pc.on(PeerConnection.Events.CreateOfferOnSuccess, (description) => {
14757
14794
  this.emit(MultistreamConnectionEventNames.CreateOfferOnSuccess, description);
@@ -14772,6 +14809,15 @@ class MultistreamConnection extends EventEmitter$2 {
14772
14809
  getConnectionState() {
14773
14810
  return this.pc.getConnectionState();
14774
14811
  }
14812
+ getPeerConnectionState() {
14813
+ return this.pc.getPeerConnectionState();
14814
+ }
14815
+ getIceConnectionState() {
14816
+ return this.pc.getIceConnectionState();
14817
+ }
14818
+ getCurrentConnectionType() {
14819
+ return this.pc.getCurrentConnectionType();
14820
+ }
14775
14821
  getIceGatheringState() {
14776
14822
  return this.pc.iceGatheringState;
14777
14823
  }