@stream-io/video-client 0.0.41 → 0.0.43

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ### [0.0.43](https://github.com/GetStream/stream-video-js/compare/client0.0.42...client0.0.43) (2023-07-12)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * Attempt to recover Publisher PeerConnection ([#787](https://github.com/GetStream/stream-video-js/issues/787)) ([0ac2b58](https://github.com/GetStream/stream-video-js/commit/0ac2b5834fba01c01a5d7d0589ce42a5940643af))
11
+
12
+ ### [0.0.42](https://github.com/GetStream/stream-video-js/compare/client0.0.41...client0.0.42) (2023-07-12)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * Heuristic announcement of track mid ([#785](https://github.com/GetStream/stream-video-js/issues/785)) ([21c1da7](https://github.com/GetStream/stream-video-js/commit/21c1da74a7b1691ccea6cad360dd9e18fa357b2d))
18
+
5
19
  ### [0.0.41](https://github.com/GetStream/stream-video-js/compare/client0.0.40...client0.0.41) (2023-07-10)
6
20
 
7
21
 
@@ -6053,6 +6053,14 @@ class Publisher {
6053
6053
  [TrackType.SCREEN_SHARE_AUDIO]: undefined,
6054
6054
  [TrackType.UNSPECIFIED]: undefined,
6055
6055
  };
6056
+ /**
6057
+ * An array maintaining the order how transceivers were added to the peer connection.
6058
+ * This is needed because some browsers (Firefox) don't reliably report
6059
+ * trackId and `mid` parameters.
6060
+ *
6061
+ * @private
6062
+ */
6063
+ this.transceiverInitOrder = [];
6056
6064
  this.trackKindMapping = {
6057
6065
  [TrackType.AUDIO]: 'audio',
6058
6066
  [TrackType.VIDEO]: 'video',
@@ -6146,6 +6154,8 @@ class Publisher {
6146
6154
  : undefined,
6147
6155
  sendEncodings: videoEncodings,
6148
6156
  });
6157
+ this.logger('debug', `Added ${TrackType[trackType]} transceiver`);
6158
+ this.transceiverInitOrder.push(trackType);
6149
6159
  this.transceiverRegistry[trackType] = transceiver;
6150
6160
  if ('setCodecPreferences' in transceiver && codecPreferences) {
6151
6161
  this.logger('info', `Setting ${TrackType[trackType]} codec preferences`, codecPreferences);
@@ -6305,6 +6315,13 @@ class Publisher {
6305
6315
  yield this.negotiate({ iceRestart: true });
6306
6316
  }
6307
6317
  });
6318
+ /**
6319
+ * Restarts the ICE connection and renegotiates with the SFU.
6320
+ */
6321
+ this.restartIce = () => {
6322
+ this.logger('debug', 'Restarting ICE connection');
6323
+ this.pc.restartIce();
6324
+ };
6308
6325
  this.onNegotiationNeeded = () => __awaiter(this, void 0, void 0, function* () {
6309
6326
  yield this.negotiate();
6310
6327
  });
@@ -6368,14 +6385,14 @@ class Publisher {
6368
6385
  this.getCurrentTrackInfos = (sdp) => {
6369
6386
  var _a;
6370
6387
  sdp = sdp || ((_a = this.pc.localDescription) === null || _a === void 0 ? void 0 : _a.sdp);
6371
- const extractMid = (defaultMid, track) => {
6388
+ const extractMid = (defaultMid, track, trackType) => {
6372
6389
  if (defaultMid)
6373
6390
  return defaultMid;
6374
6391
  if (!sdp) {
6375
6392
  this.logger('warn', 'No SDP found. Returning empty mid');
6376
6393
  return '';
6377
6394
  }
6378
- this.logger('warn', 'No mid found for track. Trying to find it from SDP');
6395
+ this.logger('debug', `No 'mid' found for track. Trying to find it from the Offer SDP`);
6379
6396
  const parsedSdp = SDP.parse(sdp);
6380
6397
  const media = parsedSdp.media.find((m) => {
6381
6398
  var _a, _b;
@@ -6384,7 +6401,12 @@ class Publisher {
6384
6401
  ((_b = (_a = m.msid) === null || _a === void 0 ? void 0 : _a.includes(track.id)) !== null && _b !== void 0 ? _b : true));
6385
6402
  });
6386
6403
  if (typeof (media === null || media === void 0 ? void 0 : media.mid) === 'undefined') {
6387
- this.logger('warn', `No mid found in SDP for track type ${track.kind} and id ${track.id}`);
6404
+ this.logger('debug', `No mid found in SDP for track type ${track.kind} and id ${track.id}. Attempting to find a heuristic mid`);
6405
+ const heuristicMid = this.transceiverInitOrder.indexOf(trackType);
6406
+ if (heuristicMid !== -1) {
6407
+ return String(heuristicMid);
6408
+ }
6409
+ this.logger('debug', 'No heuristic mid found. Returning empty mid');
6388
6410
  return '';
6389
6411
  }
6390
6412
  return String(media.mid);
@@ -6426,7 +6448,7 @@ class Publisher {
6426
6448
  trackId: track.id,
6427
6449
  layers: layers,
6428
6450
  trackType,
6429
- mid: extractMid(transceiver.mid, track),
6451
+ mid: extractMid(transceiver.mid, track, trackType),
6430
6452
  // FIXME OL: adjust these values
6431
6453
  stereo: false,
6432
6454
  dtx: TrackType.AUDIO === trackType && this.isDtxEnabled,
@@ -6440,7 +6462,12 @@ class Publisher {
6440
6462
  this.logger('error', `ICE Candidate error`, errorMessage);
6441
6463
  };
6442
6464
  this.onIceConnectionStateChange = () => {
6443
- this.logger('debug', `ICE Connection state changed`, this.pc.iceConnectionState);
6465
+ const state = this.pc.iceConnectionState;
6466
+ this.logger('debug', `ICE Connection state changed`, state);
6467
+ if (state === 'failed' || state === 'disconnected') {
6468
+ this.logger('warn', `ICE Connection state changed to ${state}. Attempting to restart ICE`);
6469
+ this.restartIce();
6470
+ }
6444
6471
  };
6445
6472
  this.onIceGatheringStateChange = () => {
6446
6473
  this.logger('debug', `ICE Gathering State`, this.pc.iceGatheringState);
@@ -6567,6 +6594,13 @@ class Subscriber {
6567
6594
  // replace the PeerConnection instance
6568
6595
  this.pc = pc;
6569
6596
  };
6597
+ /**
6598
+ * Restarts the ICE connection and renegotiates with the SFU.
6599
+ */
6600
+ this.restartIce = () => {
6601
+ logger$1('debug', 'Restarting ICE connection');
6602
+ this.pc.restartIce();
6603
+ };
6570
6604
  this.handleOnTrack = (e) => {
6571
6605
  const [primaryStream] = e.streams;
6572
6606
  // example: `e3f6aaf8-b03d-4911-be36-83f47d37a76a:TRACK_TYPE_VIDEO`
@@ -11753,7 +11787,7 @@ class StreamClient {
11753
11787
  };
11754
11788
  this.getUserAgent = () => {
11755
11789
  return (this.userAgent ||
11756
- `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.40"}`);
11790
+ `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${"0.0.42"}`);
11757
11791
  };
11758
11792
  this.setUserAgent = (userAgent) => {
11759
11793
  this.userAgent = userAgent;