@stream-io/video-client 0.3.1 → 0.3.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 +12 -0
- package/dist/index.browser.es.js +71 -69
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +72 -68
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +71 -69
- package/dist/index.es.js.map +1 -1
- package/dist/src/devices/index.d.ts +2 -0
- package/dist/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/devices/index.ts +2 -0
- package/src/rtc/Publisher.ts +11 -19
- package/src/rtc/videoLayers.ts +7 -2
|
@@ -2,4 +2,6 @@ export * from './devices';
|
|
|
2
2
|
export * from './InputMediaDeviceManager';
|
|
3
3
|
export * from './InputMediaDeviceManagerState';
|
|
4
4
|
export * from './CameraManager';
|
|
5
|
+
export * from './CameraManagerState';
|
|
5
6
|
export * from './MicrophoneManager';
|
|
7
|
+
export * from './MicrophoneManagerState';
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "0.3.
|
|
1
|
+
export declare const version = "0.3.2";
|
package/package.json
CHANGED
package/src/devices/index.ts
CHANGED
|
@@ -2,4 +2,6 @@ export * from './devices';
|
|
|
2
2
|
export * from './InputMediaDeviceManager';
|
|
3
3
|
export * from './InputMediaDeviceManagerState';
|
|
4
4
|
export * from './CameraManager';
|
|
5
|
+
export * from './CameraManagerState';
|
|
5
6
|
export * from './MicrophoneManager';
|
|
7
|
+
export * from './MicrophoneManagerState';
|
package/src/rtc/Publisher.ts
CHANGED
|
@@ -21,14 +21,11 @@ import {
|
|
|
21
21
|
import { CallState } from '../store';
|
|
22
22
|
import { PublishOptions } from '../types';
|
|
23
23
|
import { isReactNative } from '../helpers/platforms';
|
|
24
|
-
import {
|
|
25
|
-
removeCodec,
|
|
26
|
-
setPreferredCodec,
|
|
27
|
-
toggleDtx,
|
|
28
|
-
} from '../helpers/sdp-munging';
|
|
24
|
+
import { toggleDtx } from '../helpers/sdp-munging';
|
|
29
25
|
import { Logger } from '../coordinator/connection/types';
|
|
30
26
|
import { getLogger } from '../logger';
|
|
31
27
|
import { Dispatcher } from './Dispatcher';
|
|
28
|
+
import { getOSInfo } from '../client-details';
|
|
32
29
|
|
|
33
30
|
const logger: Logger = getLogger(['Publisher']);
|
|
34
31
|
|
|
@@ -239,9 +236,17 @@ export class Publisher {
|
|
|
239
236
|
? findOptimalVideoLayers(track, targetResolution)
|
|
240
237
|
: undefined;
|
|
241
238
|
|
|
239
|
+
let preferredCodec = opts.preferredCodec;
|
|
240
|
+
if (!preferredCodec && trackType === TrackType.VIDEO) {
|
|
241
|
+
const isRNAndroid =
|
|
242
|
+
isReactNative() && getOSInfo()?.name.toLowerCase() === 'android';
|
|
243
|
+
if (isRNAndroid) {
|
|
244
|
+
preferredCodec = 'VP8';
|
|
245
|
+
}
|
|
246
|
+
}
|
|
242
247
|
const codecPreferences = this.getCodecPreferences(
|
|
243
248
|
trackType,
|
|
244
|
-
|
|
249
|
+
preferredCodec,
|
|
245
250
|
);
|
|
246
251
|
|
|
247
252
|
// listen for 'ended' event on the track as it might be ended abruptly
|
|
@@ -546,19 +551,6 @@ export class Publisher {
|
|
|
546
551
|
private mungeCodecs = (sdp?: string) => {
|
|
547
552
|
if (sdp) {
|
|
548
553
|
sdp = toggleDtx(sdp, this.isDtxEnabled);
|
|
549
|
-
if (isReactNative()) {
|
|
550
|
-
if (this.preferredVideoCodec) {
|
|
551
|
-
sdp = setPreferredCodec(sdp, 'video', this.preferredVideoCodec);
|
|
552
|
-
}
|
|
553
|
-
sdp = setPreferredCodec(
|
|
554
|
-
sdp,
|
|
555
|
-
'audio',
|
|
556
|
-
this.isRedEnabled ? 'red' : 'opus',
|
|
557
|
-
);
|
|
558
|
-
if (!this.isRedEnabled) {
|
|
559
|
-
sdp = removeCodec(sdp, 'audio', 'red');
|
|
560
|
-
}
|
|
561
|
-
}
|
|
562
554
|
}
|
|
563
555
|
return sdp;
|
|
564
556
|
};
|
package/src/rtc/videoLayers.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { getOSInfo } from '../client-details';
|
|
1
2
|
import { TargetResolution } from '../gen/coordinator';
|
|
3
|
+
import { isReactNative } from '../helpers/platforms';
|
|
2
4
|
|
|
3
5
|
export type OptimalVideoLayer = RTCRtpEncodingParameters & {
|
|
4
6
|
width: number;
|
|
@@ -27,6 +29,8 @@ export const findOptimalVideoLayers = (
|
|
|
27
29
|
const settings = videoTrack.getSettings();
|
|
28
30
|
const { width: w = 0, height: h = 0 } = settings;
|
|
29
31
|
|
|
32
|
+
const isRNIos = isReactNative() && getOSInfo()?.name.toLowerCase() === 'ios';
|
|
33
|
+
|
|
30
34
|
const maxBitrate = getComputedMaxBitrate(targetResolution, w, h);
|
|
31
35
|
let downscaleFactor = 1;
|
|
32
36
|
['f', 'h', 'q'].forEach((rid) => {
|
|
@@ -40,10 +44,11 @@ export const findOptimalVideoLayers = (
|
|
|
40
44
|
height: Math.round(h / downscaleFactor),
|
|
41
45
|
maxBitrate: Math.round(maxBitrate / downscaleFactor),
|
|
42
46
|
scaleResolutionDownBy: downscaleFactor,
|
|
47
|
+
// Simulcast on iOS React-Native requires all encodings to share the same framerate
|
|
43
48
|
maxFramerate: {
|
|
44
49
|
f: 30,
|
|
45
|
-
h: 25,
|
|
46
|
-
q: 20,
|
|
50
|
+
h: isRNIos ? 30 : 25,
|
|
51
|
+
q: isRNIos ? 30 : 20,
|
|
47
52
|
}[rid],
|
|
48
53
|
});
|
|
49
54
|
downscaleFactor *= 2;
|