@stream-io/video-client 1.6.1 → 1.6.3

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
+ ## [1.6.3](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.6.2...@stream-io/video-client-1.6.3) (2024-09-11)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * client instance removal used a wrong key ([#1484](https://github.com/GetStream/stream-video-js/issues/1484)) ([edff5d7](https://github.com/GetStream/stream-video-js/commit/edff5d7ca0cc241a3929da3b752073883f29da32))
11
+
12
+ ## [1.6.2](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.6.1...@stream-io/video-client-1.6.2) (2024-09-09)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * prioritize h264 baseline profile ([#1482](https://github.com/GetStream/stream-video-js/issues/1482)) ([3ea3c5e](https://github.com/GetStream/stream-video-js/commit/3ea3c5ecf57b50d3f909d59a96811f636b07d8aa))
18
+
5
19
  ## [1.6.1](https://github.com/GetStream/stream-video-js/compare/@stream-io/video-client-1.6.0...@stream-io/video-client-1.6.1) (2024-09-05)
6
20
 
7
21
 
@@ -6820,50 +6820,74 @@ const retryable = async (rpc, signal) => {
6820
6820
  return result;
6821
6821
  };
6822
6822
 
6823
+ /**
6824
+ * Returns back a list of sorted codecs, with the preferred codec first.
6825
+ *
6826
+ * @param kind the kind of codec to get.
6827
+ * @param preferredCodec the codec to prioritize (vp8, h264, vp9, av1...).
6828
+ * @param codecToRemove the codec to exclude from the list.
6829
+ */
6823
6830
  const getPreferredCodecs = (kind, preferredCodec, codecToRemove) => {
6824
- const logger = getLogger(['codecs']);
6825
- if (!('getCapabilities' in RTCRtpReceiver)) {
6826
- logger('warn', 'RTCRtpReceiver.getCapabilities is not supported');
6831
+ if (!('getCapabilities' in RTCRtpReceiver))
6827
6832
  return;
6828
- }
6829
- const cap = RTCRtpReceiver.getCapabilities(kind);
6830
- if (!cap)
6833
+ const capabilities = RTCRtpReceiver.getCapabilities(kind);
6834
+ if (!capabilities)
6831
6835
  return;
6832
- const matched = [];
6833
- const partialMatched = [];
6834
- const unmatched = [];
6835
- cap.codecs.forEach((c) => {
6836
- const codec = c.mimeType.toLowerCase();
6837
- logger('debug', `Found supported codec: ${codec}`);
6838
- const shouldRemoveCodec = codecToRemove && codec === `${kind}/${codecToRemove.toLowerCase()}`;
6836
+ const preferred = [];
6837
+ const partiallyPreferred = [];
6838
+ const unpreferred = [];
6839
+ const preferredCodecMimeType = `${kind}/${preferredCodec.toLowerCase()}`;
6840
+ const codecToRemoveMimeType = codecToRemove && `${kind}/${codecToRemove.toLowerCase()}`;
6841
+ for (const codec of capabilities.codecs) {
6842
+ const codecMimeType = codec.mimeType.toLowerCase();
6843
+ const shouldRemoveCodec = codecMimeType === codecToRemoveMimeType;
6839
6844
  if (shouldRemoveCodec)
6840
- return;
6841
- const matchesCodec = codec === `${kind}/${preferredCodec.toLowerCase()}`;
6842
- if (!matchesCodec) {
6843
- unmatched.push(c);
6844
- return;
6845
+ continue; // skip this codec
6846
+ const isPreferredCodec = codecMimeType === preferredCodecMimeType;
6847
+ if (!isPreferredCodec) {
6848
+ unpreferred.push(codec);
6849
+ continue;
6845
6850
  }
6846
- // for h264 codecs that have sdpFmtpLine available, use only if the
6847
- // profile-level-id is 42e01f for cross-browser compatibility
6848
- if (codec === 'h264') {
6849
- if (c.sdpFmtpLine && c.sdpFmtpLine.includes('profile-level-id=42e01f')) {
6850
- matched.push(c);
6851
- }
6852
- else {
6853
- partialMatched.push(c);
6854
- }
6855
- return;
6851
+ // h264 is a special case, we want to prioritize the baseline codec with
6852
+ // profile-level-id is 42e01f and packetization-mode=0 for maximum
6853
+ // cross-browser compatibility.
6854
+ // this branch covers the other cases, such as vp8.
6855
+ if (codecMimeType !== 'video/h264') {
6856
+ preferred.push(codec);
6857
+ continue;
6856
6858
  }
6857
- matched.push(c);
6858
- });
6859
- return [...matched, ...partialMatched, ...unmatched];
6859
+ const sdpFmtpLine = codec.sdpFmtpLine;
6860
+ if (!sdpFmtpLine || !sdpFmtpLine.includes('profile-level-id=42e01f')) {
6861
+ // this is not the baseline h264 codec, prioritize it lower
6862
+ partiallyPreferred.push(codec);
6863
+ continue;
6864
+ }
6865
+ // packetization-mode mode is optional; when not present it defaults to 0:
6866
+ // https://datatracker.ietf.org/doc/html/rfc6184#section-6.2
6867
+ if (sdpFmtpLine.includes('packetization-mode=0') ||
6868
+ !sdpFmtpLine.includes('packetization-mode')) {
6869
+ preferred.unshift(codec);
6870
+ }
6871
+ else {
6872
+ preferred.push(codec);
6873
+ }
6874
+ }
6875
+ // return a sorted list of codecs, with the preferred codecs first
6876
+ return [...preferred, ...partiallyPreferred, ...unpreferred];
6860
6877
  };
6878
+ /**
6879
+ * Returns a generic SDP for the given direction.
6880
+ * We use this SDP to send it as part of our JoinRequest so that the SFU
6881
+ * can use it to determine client's codec capabilities.
6882
+ *
6883
+ * @param direction the direction of the transceiver.
6884
+ */
6861
6885
  const getGenericSdp = async (direction) => {
6862
6886
  const tempPc = new RTCPeerConnection();
6863
6887
  tempPc.addTransceiver('video', { direction });
6864
6888
  tempPc.addTransceiver('audio', { direction });
6865
6889
  const offer = await tempPc.createOffer();
6866
- let sdp = offer.sdp ?? '';
6890
+ const sdp = offer.sdp ?? '';
6867
6891
  tempPc.getTransceivers().forEach((t) => {
6868
6892
  t.stop?.();
6869
6893
  });
@@ -8724,7 +8748,7 @@ const enableHighQualityAudio = (sdp, trackMid, maxBitrate = 510000) => {
8724
8748
  return SDP.write(parsedSdp);
8725
8749
  };
8726
8750
 
8727
- const version = "1.6.1" ;
8751
+ const version = "1.6.3" ;
8728
8752
  const [major, minor, patch] = version.split('.');
8729
8753
  let sdkInfo = {
8730
8754
  type: SdkType.PLAIN_JAVASCRIPT,
@@ -16068,7 +16092,7 @@ class StreamClient {
16068
16092
  });
16069
16093
  };
16070
16094
  this.getUserAgent = () => {
16071
- const version = "1.6.1" ;
16095
+ const version = "1.6.3" ;
16072
16096
  return (this.userAgent ||
16073
16097
  `stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
16074
16098
  };
@@ -16314,6 +16338,7 @@ class StreamVideoClient {
16314
16338
  return;
16315
16339
  }
16316
16340
  const userId = this.streamClient.user?.id;
16341
+ const apiKey = this.streamClient.key;
16317
16342
  const disconnectUser = () => this.streamClient.disconnectUser(timeout);
16318
16343
  this.disconnectionPromise = this.connectionPromise
16319
16344
  ? this.connectionPromise.then(() => disconnectUser())
@@ -16321,7 +16346,7 @@ class StreamVideoClient {
16321
16346
  this.disconnectionPromise.finally(() => (this.disconnectionPromise = undefined));
16322
16347
  await this.disconnectionPromise;
16323
16348
  if (userId) {
16324
- StreamVideoClient._instanceMap.delete(userId);
16349
+ StreamVideoClient._instanceMap.delete(apiKey + userId);
16325
16350
  }
16326
16351
  this.eventHandlersToUnregister.forEach((unregister) => unregister());
16327
16352
  this.eventHandlersToUnregister = [];