@stream-io/video-client 1.6.1 → 1.6.2
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 +7 -0
- package/dist/index.browser.es.js +58 -34
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +58 -34
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +58 -34
- package/dist/index.es.js.map +1 -1
- package/dist/src/rtc/codecs.d.ts +14 -0
- package/package.json +1 -1
- package/src/rtc/__tests__/codecs.test.ts +145 -0
- package/src/rtc/__tests__/mocks/webrtc.mocks.ts +7 -0
- package/src/rtc/codecs.ts +67 -35
package/dist/index.es.js
CHANGED
|
@@ -6821,50 +6821,74 @@ const retryable = async (rpc, signal) => {
|
|
|
6821
6821
|
return result;
|
|
6822
6822
|
};
|
|
6823
6823
|
|
|
6824
|
+
/**
|
|
6825
|
+
* Returns back a list of sorted codecs, with the preferred codec first.
|
|
6826
|
+
*
|
|
6827
|
+
* @param kind the kind of codec to get.
|
|
6828
|
+
* @param preferredCodec the codec to prioritize (vp8, h264, vp9, av1...).
|
|
6829
|
+
* @param codecToRemove the codec to exclude from the list.
|
|
6830
|
+
*/
|
|
6824
6831
|
const getPreferredCodecs = (kind, preferredCodec, codecToRemove) => {
|
|
6825
|
-
|
|
6826
|
-
if (!('getCapabilities' in RTCRtpReceiver)) {
|
|
6827
|
-
logger('warn', 'RTCRtpReceiver.getCapabilities is not supported');
|
|
6832
|
+
if (!('getCapabilities' in RTCRtpReceiver))
|
|
6828
6833
|
return;
|
|
6829
|
-
|
|
6830
|
-
|
|
6831
|
-
if (!cap)
|
|
6834
|
+
const capabilities = RTCRtpReceiver.getCapabilities(kind);
|
|
6835
|
+
if (!capabilities)
|
|
6832
6836
|
return;
|
|
6833
|
-
const
|
|
6834
|
-
const
|
|
6835
|
-
const
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
const
|
|
6837
|
+
const preferred = [];
|
|
6838
|
+
const partiallyPreferred = [];
|
|
6839
|
+
const unpreferred = [];
|
|
6840
|
+
const preferredCodecMimeType = `${kind}/${preferredCodec.toLowerCase()}`;
|
|
6841
|
+
const codecToRemoveMimeType = codecToRemove && `${kind}/${codecToRemove.toLowerCase()}`;
|
|
6842
|
+
for (const codec of capabilities.codecs) {
|
|
6843
|
+
const codecMimeType = codec.mimeType.toLowerCase();
|
|
6844
|
+
const shouldRemoveCodec = codecMimeType === codecToRemoveMimeType;
|
|
6840
6845
|
if (shouldRemoveCodec)
|
|
6841
|
-
|
|
6842
|
-
const
|
|
6843
|
-
if (!
|
|
6844
|
-
|
|
6845
|
-
|
|
6846
|
+
continue; // skip this codec
|
|
6847
|
+
const isPreferredCodec = codecMimeType === preferredCodecMimeType;
|
|
6848
|
+
if (!isPreferredCodec) {
|
|
6849
|
+
unpreferred.push(codec);
|
|
6850
|
+
continue;
|
|
6846
6851
|
}
|
|
6847
|
-
//
|
|
6848
|
-
// profile-level-id is 42e01f
|
|
6849
|
-
|
|
6850
|
-
|
|
6851
|
-
|
|
6852
|
-
|
|
6853
|
-
|
|
6854
|
-
partialMatched.push(c);
|
|
6855
|
-
}
|
|
6856
|
-
return;
|
|
6852
|
+
// h264 is a special case, we want to prioritize the baseline codec with
|
|
6853
|
+
// profile-level-id is 42e01f and packetization-mode=0 for maximum
|
|
6854
|
+
// cross-browser compatibility.
|
|
6855
|
+
// this branch covers the other cases, such as vp8.
|
|
6856
|
+
if (codecMimeType !== 'video/h264') {
|
|
6857
|
+
preferred.push(codec);
|
|
6858
|
+
continue;
|
|
6857
6859
|
}
|
|
6858
|
-
|
|
6859
|
-
|
|
6860
|
-
|
|
6860
|
+
const sdpFmtpLine = codec.sdpFmtpLine;
|
|
6861
|
+
if (!sdpFmtpLine || !sdpFmtpLine.includes('profile-level-id=42e01f')) {
|
|
6862
|
+
// this is not the baseline h264 codec, prioritize it lower
|
|
6863
|
+
partiallyPreferred.push(codec);
|
|
6864
|
+
continue;
|
|
6865
|
+
}
|
|
6866
|
+
// packetization-mode mode is optional; when not present it defaults to 0:
|
|
6867
|
+
// https://datatracker.ietf.org/doc/html/rfc6184#section-6.2
|
|
6868
|
+
if (sdpFmtpLine.includes('packetization-mode=0') ||
|
|
6869
|
+
!sdpFmtpLine.includes('packetization-mode')) {
|
|
6870
|
+
preferred.unshift(codec);
|
|
6871
|
+
}
|
|
6872
|
+
else {
|
|
6873
|
+
preferred.push(codec);
|
|
6874
|
+
}
|
|
6875
|
+
}
|
|
6876
|
+
// return a sorted list of codecs, with the preferred codecs first
|
|
6877
|
+
return [...preferred, ...partiallyPreferred, ...unpreferred];
|
|
6861
6878
|
};
|
|
6879
|
+
/**
|
|
6880
|
+
* Returns a generic SDP for the given direction.
|
|
6881
|
+
* We use this SDP to send it as part of our JoinRequest so that the SFU
|
|
6882
|
+
* can use it to determine client's codec capabilities.
|
|
6883
|
+
*
|
|
6884
|
+
* @param direction the direction of the transceiver.
|
|
6885
|
+
*/
|
|
6862
6886
|
const getGenericSdp = async (direction) => {
|
|
6863
6887
|
const tempPc = new RTCPeerConnection();
|
|
6864
6888
|
tempPc.addTransceiver('video', { direction });
|
|
6865
6889
|
tempPc.addTransceiver('audio', { direction });
|
|
6866
6890
|
const offer = await tempPc.createOffer();
|
|
6867
|
-
|
|
6891
|
+
const sdp = offer.sdp ?? '';
|
|
6868
6892
|
tempPc.getTransceivers().forEach((t) => {
|
|
6869
6893
|
t.stop?.();
|
|
6870
6894
|
});
|
|
@@ -8725,7 +8749,7 @@ const enableHighQualityAudio = (sdp, trackMid, maxBitrate = 510000) => {
|
|
|
8725
8749
|
return SDP.write(parsedSdp);
|
|
8726
8750
|
};
|
|
8727
8751
|
|
|
8728
|
-
const version = "1.6.
|
|
8752
|
+
const version = "1.6.2" ;
|
|
8729
8753
|
const [major, minor, patch] = version.split('.');
|
|
8730
8754
|
let sdkInfo = {
|
|
8731
8755
|
type: SdkType.PLAIN_JAVASCRIPT,
|
|
@@ -16067,7 +16091,7 @@ class StreamClient {
|
|
|
16067
16091
|
});
|
|
16068
16092
|
};
|
|
16069
16093
|
this.getUserAgent = () => {
|
|
16070
|
-
const version = "1.6.
|
|
16094
|
+
const version = "1.6.2" ;
|
|
16071
16095
|
return (this.userAgent ||
|
|
16072
16096
|
`stream-video-javascript-client-${this.node ? 'node' : 'browser'}-${version}`);
|
|
16073
16097
|
};
|