@stream-io/video-client 1.11.5 → 1.11.6
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 +11 -9
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +11 -9
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +11 -9
- package/dist/index.es.js.map +1 -1
- package/dist/src/rtc/codecs.d.ts +2 -1
- package/package.json +1 -1
- package/src/rtc/Publisher.ts +8 -3
- package/src/rtc/codecs.ts +7 -3
package/dist/src/rtc/codecs.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ import type { PreferredCodec } from '../types';
|
|
|
5
5
|
* @param kind the kind of codec to get.
|
|
6
6
|
* @param preferredCodec the codec to prioritize (vp8, h264, vp9, av1...).
|
|
7
7
|
* @param codecToRemove the codec to exclude from the list.
|
|
8
|
+
* @param codecPreferencesSource the source of the codec preferences.
|
|
8
9
|
*/
|
|
9
|
-
export declare const getPreferredCodecs: (kind: "audio" | "video", preferredCodec: string, codecToRemove?: string) =>
|
|
10
|
+
export declare const getPreferredCodecs: (kind: "audio" | "video", preferredCodec: string, codecToRemove?: string, codecPreferencesSource?: "sender" | "receiver") => RTCRtpCodec[] | undefined;
|
|
10
11
|
/**
|
|
11
12
|
* Returns a generic SDP for the given direction.
|
|
12
13
|
* We use this SDP to send it as part of our JoinRequest so that the SFU
|
package/package.json
CHANGED
package/src/rtc/Publisher.ts
CHANGED
|
@@ -459,9 +459,14 @@ export class Publisher {
|
|
|
459
459
|
private getCodecPreferences = (
|
|
460
460
|
trackType: TrackType,
|
|
461
461
|
preferredCodec?: string,
|
|
462
|
+
codecPreferencesSource?: 'sender' | 'receiver',
|
|
462
463
|
) => {
|
|
463
464
|
if (trackType === TrackType.VIDEO) {
|
|
464
|
-
return getPreferredCodecs(
|
|
465
|
+
return getPreferredCodecs(
|
|
466
|
+
'video',
|
|
467
|
+
preferredCodec || 'vp8',
|
|
468
|
+
codecPreferencesSource,
|
|
469
|
+
);
|
|
465
470
|
}
|
|
466
471
|
if (trackType === TrackType.AUDIO) {
|
|
467
472
|
const defaultAudioCodec = this.isRedEnabled ? 'red' : 'opus';
|
|
@@ -575,8 +580,8 @@ export class Publisher {
|
|
|
575
580
|
const opts = this.publishOptsForTrack.get(trackType);
|
|
576
581
|
if (!opts || !opts.forceSingleCodec) return sdp;
|
|
577
582
|
|
|
578
|
-
const codec = opts.forceCodec || opts.preferredCodec;
|
|
579
|
-
const orderedCodecs = this.getCodecPreferences(trackType, codec);
|
|
583
|
+
const codec = opts.forceCodec || getOptimalVideoCodec(opts.preferredCodec);
|
|
584
|
+
const orderedCodecs = this.getCodecPreferences(trackType, codec, 'sender');
|
|
580
585
|
if (!orderedCodecs || orderedCodecs.length === 0) return sdp;
|
|
581
586
|
|
|
582
587
|
const transceiver = this.transceiverCache.get(trackType);
|
package/src/rtc/codecs.ts
CHANGED
|
@@ -9,15 +9,19 @@ import type { PreferredCodec } from '../types';
|
|
|
9
9
|
* @param kind the kind of codec to get.
|
|
10
10
|
* @param preferredCodec the codec to prioritize (vp8, h264, vp9, av1...).
|
|
11
11
|
* @param codecToRemove the codec to exclude from the list.
|
|
12
|
+
* @param codecPreferencesSource the source of the codec preferences.
|
|
12
13
|
*/
|
|
13
14
|
export const getPreferredCodecs = (
|
|
14
15
|
kind: 'audio' | 'video',
|
|
15
16
|
preferredCodec: string,
|
|
16
17
|
codecToRemove?: string,
|
|
17
|
-
|
|
18
|
-
|
|
18
|
+
codecPreferencesSource: 'sender' | 'receiver' = 'receiver',
|
|
19
|
+
): RTCRtpCodec[] | undefined => {
|
|
20
|
+
const source =
|
|
21
|
+
codecPreferencesSource === 'receiver' ? RTCRtpReceiver : RTCRtpSender;
|
|
22
|
+
if (!('getCapabilities' in source)) return;
|
|
19
23
|
|
|
20
|
-
const capabilities =
|
|
24
|
+
const capabilities = source.getCapabilities(kind);
|
|
21
25
|
if (!capabilities) return;
|
|
22
26
|
|
|
23
27
|
const preferred: RTCRtpCodecCapability[] = [];
|