@stream-io/video-client 1.8.4 → 1.9.0
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 +416 -444
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +416 -444
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +416 -444
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +10 -12
- package/dist/src/devices/CameraManager.d.ts +2 -22
- package/dist/src/events/internal.d.ts +0 -4
- package/dist/src/gen/video/sfu/event/events.d.ts +2 -71
- package/dist/src/helpers/sdp-munging.d.ts +8 -0
- package/dist/src/rtc/Publisher.d.ts +18 -23
- package/dist/src/rtc/bitrateLookup.d.ts +2 -0
- package/dist/src/rtc/codecs.d.ts +9 -2
- package/dist/src/rtc/videoLayers.d.ts +31 -4
- package/dist/src/types.d.ts +30 -2
- package/package.json +1 -1
- package/src/Call.ts +21 -38
- package/src/devices/CameraManager.ts +8 -42
- package/src/devices/ScreenShareManager.ts +1 -3
- package/src/devices/__tests__/CameraManager.test.ts +0 -15
- package/src/devices/__tests__/ScreenShareManager.test.ts +0 -14
- package/src/events/callEventHandlers.ts +0 -2
- package/src/events/internal.ts +0 -16
- package/src/gen/video/sfu/event/events.ts +8 -120
- package/src/helpers/sdp-munging.ts +38 -15
- package/src/rtc/Publisher.ts +211 -317
- package/src/rtc/__tests__/Publisher.test.ts +196 -7
- package/src/rtc/__tests__/bitrateLookup.test.ts +12 -0
- package/src/rtc/__tests__/mocks/webrtc.mocks.ts +2 -0
- package/src/rtc/__tests__/videoLayers.test.ts +51 -36
- package/src/rtc/bitrateLookup.ts +61 -0
- package/src/rtc/codecs.ts +56 -9
- package/src/rtc/videoLayers.ts +74 -23
- package/src/types.ts +30 -2
package/dist/src/Call.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { Publisher, Subscriber } from './rtc';
|
|
|
2
2
|
import { CallState } from './store';
|
|
3
3
|
import type { AcceptCallResponse, BlockUserResponse, CollectUserFeedbackResponse, EndCallResponse, GetCallResponse, GetCallStatsResponse, GetOrCreateCallRequest, GetOrCreateCallResponse, GoLiveRequest, GoLiveResponse, JoinCallResponse, ListRecordingsResponse, ListTranscriptionsResponse, MuteUsersResponse, PinRequest, PinResponse, QueryCallMembersRequest, QueryCallMembersResponse, RejectCallResponse, RequestPermissionRequest, RequestPermissionResponse, SendCallEventResponse, SendReactionRequest, SendReactionResponse, StartHLSBroadcastingResponse, StartRecordingRequest, StartRecordingResponse, StartTranscriptionRequest, StartTranscriptionResponse, StopHLSBroadcastingResponse, StopLiveResponse, StopRecordingResponse, StopTranscriptionResponse, UnblockUserResponse, UnpinRequest, UnpinResponse, UpdateCallMembersRequest, UpdateCallMembersResponse, UpdateCallRequest, UpdateCallResponse, UpdateUserPermissionsRequest, UpdateUserPermissionsResponse, VideoResolution } from './gen/coordinator';
|
|
4
4
|
import { AudioTrackType, CallConstructor, CallLeaveOptions, JoinCallData, PublishOptions, TrackMuteType, VideoTrackType } from './types';
|
|
5
|
-
import { VideoLayerSetting } from './gen/video/sfu/event/events';
|
|
6
5
|
import { TrackType } from './gen/video/sfu/models/models';
|
|
7
6
|
import { DynascaleManager } from './helpers/DynascaleManager';
|
|
8
7
|
import { PermissionsContext } from './permissions';
|
|
@@ -70,6 +69,7 @@ export declare class Call {
|
|
|
70
69
|
* @private
|
|
71
70
|
*/
|
|
72
71
|
private readonly dispatcher;
|
|
72
|
+
private publishOptions?;
|
|
73
73
|
private statsReporter?;
|
|
74
74
|
private sfuStatsReporter?;
|
|
75
75
|
private dropTimeout;
|
|
@@ -282,9 +282,8 @@ export declare class Call {
|
|
|
282
282
|
* The previous video stream will be stopped.
|
|
283
283
|
*
|
|
284
284
|
* @param videoStream the video stream to publish.
|
|
285
|
-
* @param opts the options to use when publishing the stream.
|
|
286
285
|
*/
|
|
287
|
-
publishVideoStream: (videoStream: MediaStream
|
|
286
|
+
publishVideoStream: (videoStream: MediaStream) => Promise<void>;
|
|
288
287
|
/**
|
|
289
288
|
* Starts publishing the given audio stream to the call.
|
|
290
289
|
* The stream will be stopped if the user changes an input device, or if the user leaves the call.
|
|
@@ -302,9 +301,8 @@ export declare class Call {
|
|
|
302
301
|
* The previous screen-share stream will be stopped.
|
|
303
302
|
*
|
|
304
303
|
* @param screenShareStream the screen-share stream to publish.
|
|
305
|
-
* @param opts the options to use when publishing the stream.
|
|
306
304
|
*/
|
|
307
|
-
publishScreenShareStream: (screenShareStream: MediaStream
|
|
305
|
+
publishScreenShareStream: (screenShareStream: MediaStream) => Promise<void>;
|
|
308
306
|
/**
|
|
309
307
|
* Stops publishing the given track type to the call, if it is currently being published.
|
|
310
308
|
* Underlying track will be stopped and removed from the publisher.
|
|
@@ -313,6 +311,13 @@ export declare class Call {
|
|
|
313
311
|
* @param stopTrack if `true` the track will be stopped, else it will be just disabled
|
|
314
312
|
*/
|
|
315
313
|
stopPublish: (trackType: TrackType, stopTrack?: boolean) => Promise<void>;
|
|
314
|
+
/**
|
|
315
|
+
* Updates the preferred publishing options
|
|
316
|
+
*
|
|
317
|
+
* @internal
|
|
318
|
+
* @param options the options to use.
|
|
319
|
+
*/
|
|
320
|
+
updatePublishOptions(options: PublishOptions): void;
|
|
316
321
|
/**
|
|
317
322
|
* Notifies the SFU that a noise cancellation process has started.
|
|
318
323
|
*
|
|
@@ -351,13 +356,6 @@ export declare class Call {
|
|
|
351
356
|
* @param criteria the list of criteria to sort the participants by.
|
|
352
357
|
*/
|
|
353
358
|
setSortParticipantsBy: CallState['setSortParticipantsBy'];
|
|
354
|
-
/**
|
|
355
|
-
* Updates the list of video layers to publish.
|
|
356
|
-
*
|
|
357
|
-
* @internal
|
|
358
|
-
* @param enabledLayers the list of layers to enable.
|
|
359
|
-
*/
|
|
360
|
-
updatePublishQuality: (enabledLayers: VideoLayerSetting[]) => Promise<void | undefined>;
|
|
361
359
|
/**
|
|
362
360
|
* Sends a reaction to the other call participants.
|
|
363
361
|
*
|
|
@@ -2,15 +2,9 @@ import { Observable } from 'rxjs';
|
|
|
2
2
|
import { Call } from '../Call';
|
|
3
3
|
import { CameraDirection, CameraManagerState } from './CameraManagerState';
|
|
4
4
|
import { InputMediaDeviceManager } from './InputMediaDeviceManager';
|
|
5
|
-
import { PreferredCodec
|
|
5
|
+
import { PreferredCodec } from '../types';
|
|
6
6
|
export declare class CameraManager extends InputMediaDeviceManager<CameraManagerState> {
|
|
7
7
|
private targetResolution;
|
|
8
|
-
/**
|
|
9
|
-
* The options to use when publishing the video stream.
|
|
10
|
-
*
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
publishOptions: PublishOptions | undefined;
|
|
14
8
|
/**
|
|
15
9
|
* Constructs a new CameraManager.
|
|
16
10
|
*
|
|
@@ -41,24 +35,10 @@ export declare class CameraManager extends InputMediaDeviceManager<CameraManager
|
|
|
41
35
|
* Sets the preferred codec for encoding the video.
|
|
42
36
|
*
|
|
43
37
|
* @internal internal use only, not part of the public API.
|
|
38
|
+
* @deprecated use {@link call.updatePublishOptions} instead.
|
|
44
39
|
* @param codec the codec to use for encoding the video.
|
|
45
40
|
*/
|
|
46
41
|
setPreferredCodec(codec: PreferredCodec | undefined): void;
|
|
47
|
-
/**
|
|
48
|
-
* Updates the preferred publish options for the video stream.
|
|
49
|
-
*
|
|
50
|
-
* @internal
|
|
51
|
-
* @param options the options to use.
|
|
52
|
-
*/
|
|
53
|
-
updatePublishOptions(options: PublishOptions): void;
|
|
54
|
-
/**
|
|
55
|
-
* Returns the capture resolution of the camera.
|
|
56
|
-
*/
|
|
57
|
-
getCaptureResolution(): {
|
|
58
|
-
width: number | undefined;
|
|
59
|
-
height: number | undefined;
|
|
60
|
-
frameRate: number | undefined;
|
|
61
|
-
} | undefined;
|
|
62
42
|
protected getDevices(): Observable<MediaDeviceInfo[]>;
|
|
63
43
|
protected getStream(constraints: MediaTrackConstraints): Promise<MediaStream>;
|
|
64
44
|
protected publishStream(stream: MediaStream): Promise<void>;
|
|
@@ -2,10 +2,6 @@ import { Dispatcher } from '../rtc';
|
|
|
2
2
|
import { Call } from '../Call';
|
|
3
3
|
import { CallState } from '../store';
|
|
4
4
|
import type { PinsChanged } from '../gen/video/sfu/event/events';
|
|
5
|
-
/**
|
|
6
|
-
* An event responder which handles the `changePublishQuality` event.
|
|
7
|
-
*/
|
|
8
|
-
export declare const watchChangePublishQuality: (dispatcher: Dispatcher, call: Call) => () => void;
|
|
9
5
|
export declare const watchConnectionQualityChanged: (dispatcher: Dispatcher, state: CallState) => () => void;
|
|
10
6
|
/**
|
|
11
7
|
* Updates the approximate number of participants in the call by peeking at the
|
|
@@ -635,45 +635,15 @@ export interface AudioLevelChanged {
|
|
|
635
635
|
*/
|
|
636
636
|
audioLevels: AudioLevel[];
|
|
637
637
|
}
|
|
638
|
-
/**
|
|
639
|
-
* @generated from protobuf message stream.video.sfu.event.AudioMediaRequest
|
|
640
|
-
*/
|
|
641
|
-
export interface AudioMediaRequest {
|
|
642
|
-
/**
|
|
643
|
-
* @generated from protobuf field: int32 channel_count = 1;
|
|
644
|
-
*/
|
|
645
|
-
channelCount: number;
|
|
646
|
-
}
|
|
647
638
|
/**
|
|
648
639
|
* @generated from protobuf message stream.video.sfu.event.AudioSender
|
|
649
640
|
*/
|
|
650
641
|
export interface AudioSender {
|
|
651
|
-
/**
|
|
652
|
-
* @generated from protobuf field: stream.video.sfu.event.AudioMediaRequest media_request = 1;
|
|
653
|
-
*/
|
|
654
|
-
mediaRequest?: AudioMediaRequest;
|
|
655
642
|
/**
|
|
656
643
|
* @generated from protobuf field: stream.video.sfu.models.Codec codec = 2;
|
|
657
644
|
*/
|
|
658
645
|
codec?: Codec;
|
|
659
646
|
}
|
|
660
|
-
/**
|
|
661
|
-
* @generated from protobuf message stream.video.sfu.event.VideoMediaRequest
|
|
662
|
-
*/
|
|
663
|
-
export interface VideoMediaRequest {
|
|
664
|
-
/**
|
|
665
|
-
* @generated from protobuf field: int32 ideal_height = 1;
|
|
666
|
-
*/
|
|
667
|
-
idealHeight: number;
|
|
668
|
-
/**
|
|
669
|
-
* @generated from protobuf field: int32 ideal_width = 2;
|
|
670
|
-
*/
|
|
671
|
-
idealWidth: number;
|
|
672
|
-
/**
|
|
673
|
-
* @generated from protobuf field: int32 ideal_frame_rate = 3;
|
|
674
|
-
*/
|
|
675
|
-
idealFrameRate: number;
|
|
676
|
-
}
|
|
677
647
|
/**
|
|
678
648
|
* VideoLayerSetting is used to specify various parameters of a particular encoding in simulcast.
|
|
679
649
|
* The parameters are specified here - https://developer.mozilla.org/en-US/docs/Web/API/RTCRtpEncodingParameters
|
|
@@ -698,10 +668,6 @@ export interface VideoLayerSetting {
|
|
|
698
668
|
* @generated from protobuf field: float scale_resolution_down_by = 4;
|
|
699
669
|
*/
|
|
700
670
|
scaleResolutionDownBy: number;
|
|
701
|
-
/**
|
|
702
|
-
* @generated from protobuf field: stream.video.sfu.event.VideoLayerSetting.Priority priority = 5;
|
|
703
|
-
*/
|
|
704
|
-
priority: VideoLayerSetting_Priority;
|
|
705
671
|
/**
|
|
706
672
|
* @generated from protobuf field: stream.video.sfu.models.Codec codec = 6;
|
|
707
673
|
*/
|
|
@@ -710,36 +676,15 @@ export interface VideoLayerSetting {
|
|
|
710
676
|
* @generated from protobuf field: uint32 max_framerate = 7;
|
|
711
677
|
*/
|
|
712
678
|
maxFramerate: number;
|
|
713
|
-
}
|
|
714
|
-
/**
|
|
715
|
-
* @generated from protobuf enum stream.video.sfu.event.VideoLayerSetting.Priority
|
|
716
|
-
*/
|
|
717
|
-
export declare enum VideoLayerSetting_Priority {
|
|
718
679
|
/**
|
|
719
|
-
* @generated from protobuf
|
|
680
|
+
* @generated from protobuf field: string scalability_mode = 8;
|
|
720
681
|
*/
|
|
721
|
-
|
|
722
|
-
/**
|
|
723
|
-
* @generated from protobuf enum value: PRIORITY_LOW = 1;
|
|
724
|
-
*/
|
|
725
|
-
LOW = 1,
|
|
726
|
-
/**
|
|
727
|
-
* @generated from protobuf enum value: PRIORITY_MEDIUM = 2;
|
|
728
|
-
*/
|
|
729
|
-
MEDIUM = 2,
|
|
730
|
-
/**
|
|
731
|
-
* @generated from protobuf enum value: PRIORITY_VERY_LOW = 3;
|
|
732
|
-
*/
|
|
733
|
-
VERY_LOW = 3
|
|
682
|
+
scalabilityMode: string;
|
|
734
683
|
}
|
|
735
684
|
/**
|
|
736
685
|
* @generated from protobuf message stream.video.sfu.event.VideoSender
|
|
737
686
|
*/
|
|
738
687
|
export interface VideoSender {
|
|
739
|
-
/**
|
|
740
|
-
* @generated from protobuf field: stream.video.sfu.event.VideoMediaRequest media_request = 1;
|
|
741
|
-
*/
|
|
742
|
-
mediaRequest?: VideoMediaRequest;
|
|
743
688
|
/**
|
|
744
689
|
* @generated from protobuf field: stream.video.sfu.models.Codec codec = 2;
|
|
745
690
|
*/
|
|
@@ -1000,13 +945,6 @@ declare class AudioLevelChanged$Type extends MessageType<AudioLevelChanged> {
|
|
|
1000
945
|
* @generated MessageType for protobuf message stream.video.sfu.event.AudioLevelChanged
|
|
1001
946
|
*/
|
|
1002
947
|
export declare const AudioLevelChanged: AudioLevelChanged$Type;
|
|
1003
|
-
declare class AudioMediaRequest$Type extends MessageType<AudioMediaRequest> {
|
|
1004
|
-
constructor();
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* @generated MessageType for protobuf message stream.video.sfu.event.AudioMediaRequest
|
|
1008
|
-
*/
|
|
1009
|
-
export declare const AudioMediaRequest: AudioMediaRequest$Type;
|
|
1010
948
|
declare class AudioSender$Type extends MessageType<AudioSender> {
|
|
1011
949
|
constructor();
|
|
1012
950
|
}
|
|
@@ -1014,13 +952,6 @@ declare class AudioSender$Type extends MessageType<AudioSender> {
|
|
|
1014
952
|
* @generated MessageType for protobuf message stream.video.sfu.event.AudioSender
|
|
1015
953
|
*/
|
|
1016
954
|
export declare const AudioSender: AudioSender$Type;
|
|
1017
|
-
declare class VideoMediaRequest$Type extends MessageType<VideoMediaRequest> {
|
|
1018
|
-
constructor();
|
|
1019
|
-
}
|
|
1020
|
-
/**
|
|
1021
|
-
* @generated MessageType for protobuf message stream.video.sfu.event.VideoMediaRequest
|
|
1022
|
-
*/
|
|
1023
|
-
export declare const VideoMediaRequest: VideoMediaRequest$Type;
|
|
1024
955
|
declare class VideoLayerSetting$Type extends MessageType<VideoLayerSetting> {
|
|
1025
956
|
constructor();
|
|
1026
957
|
}
|
|
@@ -10,3 +10,11 @@ export declare const toggleDtx: (sdp: string, enable: boolean) => string;
|
|
|
10
10
|
* @param maxBitrate the max bitrate to set.
|
|
11
11
|
*/
|
|
12
12
|
export declare const enableHighQualityAudio: (sdp: string, trackMid: string, maxBitrate?: number) => string;
|
|
13
|
+
/**
|
|
14
|
+
* Extracts the mid from the transceiver or the SDP.
|
|
15
|
+
*
|
|
16
|
+
* @param transceiver the transceiver.
|
|
17
|
+
* @param transceiverInitIndex the index of the transceiver in the transceiver's init array.
|
|
18
|
+
* @param sdp the SDP.
|
|
19
|
+
*/
|
|
20
|
+
export declare const extractMid: (transceiver: RTCRtpTransceiver, transceiverInitIndex: number, sdp: string | undefined) => string;
|
|
@@ -3,7 +3,6 @@ import { TrackInfo, TrackType } from '../gen/video/sfu/models/models';
|
|
|
3
3
|
import { CallState } from '../store';
|
|
4
4
|
import { PublishOptions } from '../types';
|
|
5
5
|
import { Dispatcher } from './Dispatcher';
|
|
6
|
-
import { VideoLayerSetting } from '../gen/video/sfu/event/events';
|
|
7
6
|
export type PublisherConstructorOpts = {
|
|
8
7
|
sfuClient: StreamSfuClient;
|
|
9
8
|
state: CallState;
|
|
@@ -23,8 +22,9 @@ export declare class Publisher {
|
|
|
23
22
|
private readonly logger;
|
|
24
23
|
private pc;
|
|
25
24
|
private readonly state;
|
|
26
|
-
private readonly
|
|
27
|
-
private readonly
|
|
25
|
+
private readonly transceiverCache;
|
|
26
|
+
private readonly trackLayersCache;
|
|
27
|
+
private readonly publishOptsForTrack;
|
|
28
28
|
/**
|
|
29
29
|
* An array maintaining the order how transceivers were added to the peer connection.
|
|
30
30
|
* This is needed because some browsers (Firefox) don't reliably report
|
|
@@ -33,29 +33,15 @@ export declare class Publisher {
|
|
|
33
33
|
* @internal
|
|
34
34
|
*/
|
|
35
35
|
private readonly transceiverInitOrder;
|
|
36
|
-
private readonly trackKindMapping;
|
|
37
|
-
private readonly trackLayersCache;
|
|
38
36
|
private readonly isDtxEnabled;
|
|
39
37
|
private readonly isRedEnabled;
|
|
40
38
|
private readonly unsubscribeOnIceRestart;
|
|
39
|
+
private readonly unsubscribeChangePublishQuality;
|
|
41
40
|
private readonly onUnrecoverableError?;
|
|
42
41
|
private isIceRestarting;
|
|
43
|
-
|
|
44
|
-
* The SFU client instance to use for publishing and signaling.
|
|
45
|
-
*/
|
|
46
|
-
sfuClient: StreamSfuClient;
|
|
42
|
+
private sfuClient;
|
|
47
43
|
/**
|
|
48
44
|
* Constructs a new `Publisher` instance.
|
|
49
|
-
*
|
|
50
|
-
* @param connectionConfig the connection configuration to use.
|
|
51
|
-
* @param sfuClient the SFU client to use.
|
|
52
|
-
* @param state the call state to use.
|
|
53
|
-
* @param dispatcher the dispatcher to use.
|
|
54
|
-
* @param isDtxEnabled whether DTX is enabled.
|
|
55
|
-
* @param isRedEnabled whether RED is enabled.
|
|
56
|
-
* @param iceRestartDelay the delay in milliseconds to wait before restarting ICE once connection goes to `disconnected` state.
|
|
57
|
-
* @param onUnrecoverableError a callback to call when an unrecoverable error occurs.
|
|
58
|
-
* @param logTag the log tag to use.
|
|
59
45
|
*/
|
|
60
46
|
constructor({ connectionConfig, sfuClient, dispatcher, state, isDtxEnabled, isRedEnabled, onUnrecoverableError, logTag, }: PublisherConstructorOpts);
|
|
61
47
|
private createPeerConnection;
|
|
@@ -83,6 +69,17 @@ export declare class Publisher {
|
|
|
83
69
|
* @param opts the optional publish options to use.
|
|
84
70
|
*/
|
|
85
71
|
publishStream: (mediaStream: MediaStream, track: MediaStreamTrack, trackType: TrackType, opts?: PublishOptions) => Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Adds a new transceiver to the peer connection.
|
|
74
|
+
* This needs to be called when a new track kind is added to the peer connection.
|
|
75
|
+
* In other cases, use `updateTransceiver` method.
|
|
76
|
+
*/
|
|
77
|
+
private addTransceiver;
|
|
78
|
+
/**
|
|
79
|
+
* Updates the given transceiver with the new track.
|
|
80
|
+
* Stops the previous track and replaces it with the new one.
|
|
81
|
+
*/
|
|
82
|
+
private updateTransceiver;
|
|
86
83
|
/**
|
|
87
84
|
* Stops publishing the given track type to the SFU, if it is currently being published.
|
|
88
85
|
* Underlying track will be stopped and removed from the publisher.
|
|
@@ -101,7 +98,7 @@ export declare class Publisher {
|
|
|
101
98
|
* Stops publishing all tracks and stop all tracks.
|
|
102
99
|
*/
|
|
103
100
|
private stopPublishing;
|
|
104
|
-
|
|
101
|
+
private changePublishQuality;
|
|
105
102
|
/**
|
|
106
103
|
* Returns the result of the `RTCPeerConnection.getStats()` method
|
|
107
104
|
* @param selector
|
|
@@ -128,8 +125,6 @@ export declare class Publisher {
|
|
|
128
125
|
*/
|
|
129
126
|
private negotiate;
|
|
130
127
|
private enableHighQualityAudio;
|
|
131
|
-
private mungeCodecs;
|
|
132
|
-
private extractMid;
|
|
133
128
|
/**
|
|
134
129
|
* Returns a list of tracks that are currently being published.
|
|
135
130
|
*
|
|
@@ -137,9 +132,9 @@ export declare class Publisher {
|
|
|
137
132
|
* @param sdp an optional SDP to extract the `mid` from.
|
|
138
133
|
*/
|
|
139
134
|
getAnnouncedTracks: (sdp?: string) => TrackInfo[];
|
|
135
|
+
private computeLayers;
|
|
140
136
|
private onIceCandidateError;
|
|
141
137
|
private onIceConnectionStateChange;
|
|
142
138
|
private onIceGatheringStateChange;
|
|
143
139
|
private onSignalingStateChange;
|
|
144
|
-
private ridToVideoQuality;
|
|
145
140
|
}
|
package/dist/src/rtc/codecs.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { PreferredCodec } from '../types';
|
|
1
2
|
/**
|
|
2
3
|
* Returns back a list of sorted codecs, with the preferred codec first.
|
|
3
4
|
*
|
|
@@ -15,6 +16,12 @@ export declare const getPreferredCodecs: (kind: "audio" | "video", preferredCode
|
|
|
15
16
|
*/
|
|
16
17
|
export declare const getGenericSdp: (direction: RTCRtpTransceiverDirection) => Promise<string>;
|
|
17
18
|
/**
|
|
18
|
-
* Returns the optimal codec for
|
|
19
|
+
* Returns the optimal video codec for the device.
|
|
19
20
|
*/
|
|
20
|
-
export declare const
|
|
21
|
+
export declare const getOptimalVideoCodec: (preferredCodec: PreferredCodec | undefined) => PreferredCodec;
|
|
22
|
+
/**
|
|
23
|
+
* Returns whether the codec is an SVC codec.
|
|
24
|
+
*
|
|
25
|
+
* @param codecOrMimeType the codec to check.
|
|
26
|
+
*/
|
|
27
|
+
export declare const isSvcCodec: (codecOrMimeType: string | undefined) => boolean;
|
|
@@ -1,18 +1,44 @@
|
|
|
1
|
-
import { PublishOptions } from '../types';
|
|
1
|
+
import { PreferredCodec, PublishOptions } from '../types';
|
|
2
2
|
import { TargetResolutionResponse } from '../gen/shims';
|
|
3
|
+
import { VideoQuality } from '../gen/video/sfu/models/models';
|
|
3
4
|
export type OptimalVideoLayer = RTCRtpEncodingParameters & {
|
|
4
5
|
width: number;
|
|
5
6
|
height: number;
|
|
7
|
+
scalabilityMode?: string;
|
|
6
8
|
};
|
|
9
|
+
/**
|
|
10
|
+
* In SVC, we need to send only one video encoding (layer).
|
|
11
|
+
* this layer will have the additional spatial and temporal layers
|
|
12
|
+
* defined via the scalabilityMode property.
|
|
13
|
+
*
|
|
14
|
+
* @param layers the layers to process.
|
|
15
|
+
*/
|
|
16
|
+
export declare const toSvcEncodings: (layers: OptimalVideoLayer[] | undefined) => {
|
|
17
|
+
rid: string;
|
|
18
|
+
active?: boolean;
|
|
19
|
+
maxBitrate?: number;
|
|
20
|
+
maxFramerate?: number;
|
|
21
|
+
networkPriority?: RTCPriorityType;
|
|
22
|
+
priority?: RTCPriorityType;
|
|
23
|
+
scaleResolutionDownBy?: number;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
scalabilityMode?: string;
|
|
27
|
+
}[] | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* Converts the rid to a video quality.
|
|
30
|
+
*/
|
|
31
|
+
export declare const ridToVideoQuality: (rid: string) => VideoQuality;
|
|
7
32
|
/**
|
|
8
33
|
* Determines the most optimal video layers for simulcasting
|
|
9
34
|
* for the given track.
|
|
10
35
|
*
|
|
11
36
|
* @param videoTrack the video track to find optimal layers for.
|
|
12
37
|
* @param targetResolution the expected target resolution.
|
|
38
|
+
* @param codecInUse the codec in use.
|
|
13
39
|
* @param publishOptions the publish options for the track.
|
|
14
40
|
*/
|
|
15
|
-
export declare const findOptimalVideoLayers: (videoTrack: MediaStreamTrack, targetResolution?: TargetResolutionResponse, publishOptions?: PublishOptions) => OptimalVideoLayer[];
|
|
41
|
+
export declare const findOptimalVideoLayers: (videoTrack: MediaStreamTrack, targetResolution?: TargetResolutionResponse, codecInUse?: PreferredCodec, publishOptions?: PublishOptions) => OptimalVideoLayer[];
|
|
16
42
|
/**
|
|
17
43
|
* Computes the maximum bitrate for a given resolution.
|
|
18
44
|
* If the current resolution is lower than the target resolution,
|
|
@@ -23,7 +49,8 @@ export declare const findOptimalVideoLayers: (videoTrack: MediaStreamTrack, targ
|
|
|
23
49
|
* @param targetResolution the target resolution.
|
|
24
50
|
* @param currentWidth the current width of the track.
|
|
25
51
|
* @param currentHeight the current height of the track.
|
|
26
|
-
* @param
|
|
52
|
+
* @param codecInUse the codec in use.
|
|
53
|
+
* @param publishOptions the publish options.
|
|
27
54
|
*/
|
|
28
|
-
export declare const getComputedMaxBitrate: (targetResolution: TargetResolutionResponse, currentWidth: number, currentHeight: number,
|
|
55
|
+
export declare const getComputedMaxBitrate: (targetResolution: TargetResolutionResponse, currentWidth: number, currentHeight: number, codecInUse?: PreferredCodec, publishOptions?: PublishOptions) => number;
|
|
29
56
|
export declare const findOptimalScreenSharingLayers: (videoTrack: MediaStreamTrack, publishOptions?: PublishOptions, defaultMaxBitrate?: number) => OptimalVideoLayer[];
|
package/dist/src/types.d.ts
CHANGED
|
@@ -113,11 +113,39 @@ export type SubscriptionChanges = {
|
|
|
113
113
|
* A preferred codec to use when publishing a video track.
|
|
114
114
|
* @internal
|
|
115
115
|
*/
|
|
116
|
-
export type PreferredCodec = 'vp8' | 'h264' |
|
|
116
|
+
export type PreferredCodec = 'vp8' | 'h264' | 'vp9' | 'av1';
|
|
117
|
+
/**
|
|
118
|
+
* A collection of track publication options.
|
|
119
|
+
* @internal
|
|
120
|
+
*/
|
|
117
121
|
export type PublishOptions = {
|
|
118
|
-
|
|
122
|
+
/**
|
|
123
|
+
* The preferred codec to use when publishing the video stream.
|
|
124
|
+
*/
|
|
125
|
+
preferredCodec?: PreferredCodec;
|
|
126
|
+
/**
|
|
127
|
+
* Force the codec to use when publishing the video stream.
|
|
128
|
+
* This will override the preferred codec and the internal codec selection logic.
|
|
129
|
+
* Use with caution.
|
|
130
|
+
*/
|
|
131
|
+
forceCodec?: PreferredCodec;
|
|
132
|
+
/**
|
|
133
|
+
* The preferred scalability to use when publishing the video stream.
|
|
134
|
+
* Applicable only for SVC codecs.
|
|
135
|
+
*/
|
|
136
|
+
scalabilityMode?: string;
|
|
137
|
+
/**
|
|
138
|
+
* The preferred bitrate to use when publishing the video stream.
|
|
139
|
+
*/
|
|
119
140
|
preferredBitrate?: number;
|
|
141
|
+
/**
|
|
142
|
+
* The preferred downscale factor to use when publishing the video stream
|
|
143
|
+
* in simulcast mode (non-SVC).
|
|
144
|
+
*/
|
|
120
145
|
bitrateDownscaleFactor?: number;
|
|
146
|
+
/**
|
|
147
|
+
* Screen share settings.
|
|
148
|
+
*/
|
|
121
149
|
screenShareSettings?: ScreenShareSettings;
|
|
122
150
|
};
|
|
123
151
|
export type ScreenShareSettings = {
|
package/package.json
CHANGED
package/src/Call.ts
CHANGED
|
@@ -87,10 +87,7 @@ import {
|
|
|
87
87
|
VideoTrackType,
|
|
88
88
|
} from './types';
|
|
89
89
|
import { BehaviorSubject, Subject, takeWhile } from 'rxjs';
|
|
90
|
-
import {
|
|
91
|
-
ReconnectDetails,
|
|
92
|
-
VideoLayerSetting,
|
|
93
|
-
} from './gen/video/sfu/event/events';
|
|
90
|
+
import { ReconnectDetails } from './gen/video/sfu/event/events';
|
|
94
91
|
import {
|
|
95
92
|
ClientDetails,
|
|
96
93
|
TrackType,
|
|
@@ -202,6 +199,7 @@ export class Call {
|
|
|
202
199
|
*/
|
|
203
200
|
private readonly dispatcher = new Dispatcher();
|
|
204
201
|
|
|
202
|
+
private publishOptions?: PublishOptions;
|
|
205
203
|
private statsReporter?: StatsReporter;
|
|
206
204
|
private sfuStatsReporter?: SfuStatsReporter;
|
|
207
205
|
private dropTimeout: ReturnType<typeof setTimeout> | undefined;
|
|
@@ -1292,19 +1290,12 @@ export class Call {
|
|
|
1292
1290
|
break;
|
|
1293
1291
|
case TrackType.VIDEO:
|
|
1294
1292
|
const videoStream = this.camera.state.mediaStream;
|
|
1295
|
-
if (videoStream)
|
|
1296
|
-
await this.publishVideoStream(
|
|
1297
|
-
videoStream,
|
|
1298
|
-
this.camera.publishOptions,
|
|
1299
|
-
);
|
|
1300
|
-
}
|
|
1293
|
+
if (videoStream) await this.publishVideoStream(videoStream);
|
|
1301
1294
|
break;
|
|
1302
1295
|
case TrackType.SCREEN_SHARE:
|
|
1303
1296
|
const screenShareStream = this.screenShare.state.mediaStream;
|
|
1304
1297
|
if (screenShareStream) {
|
|
1305
|
-
await this.publishScreenShareStream(screenShareStream
|
|
1306
|
-
screenShareSettings: this.screenShare.getSettings(),
|
|
1307
|
-
});
|
|
1298
|
+
await this.publishScreenShareStream(screenShareStream);
|
|
1308
1299
|
}
|
|
1309
1300
|
break;
|
|
1310
1301
|
// screen share audio can't exist without a screen share, so we handle it there
|
|
@@ -1336,12 +1327,8 @@ export class Call {
|
|
|
1336
1327
|
* The previous video stream will be stopped.
|
|
1337
1328
|
*
|
|
1338
1329
|
* @param videoStream the video stream to publish.
|
|
1339
|
-
* @param opts the options to use when publishing the stream.
|
|
1340
1330
|
*/
|
|
1341
|
-
publishVideoStream = async (
|
|
1342
|
-
videoStream: MediaStream,
|
|
1343
|
-
opts: PublishOptions = {},
|
|
1344
|
-
) => {
|
|
1331
|
+
publishVideoStream = async (videoStream: MediaStream) => {
|
|
1345
1332
|
if (!this.sfuClient) throw new Error(`Call not joined yet.`);
|
|
1346
1333
|
// joining is in progress, and we should wait until the client is ready
|
|
1347
1334
|
await this.sfuClient.joinTask;
|
|
@@ -1363,7 +1350,7 @@ export class Call {
|
|
|
1363
1350
|
videoStream,
|
|
1364
1351
|
videoTrack,
|
|
1365
1352
|
TrackType.VIDEO,
|
|
1366
|
-
|
|
1353
|
+
this.publishOptions,
|
|
1367
1354
|
);
|
|
1368
1355
|
};
|
|
1369
1356
|
|
|
@@ -1407,12 +1394,8 @@ export class Call {
|
|
|
1407
1394
|
* The previous screen-share stream will be stopped.
|
|
1408
1395
|
*
|
|
1409
1396
|
* @param screenShareStream the screen-share stream to publish.
|
|
1410
|
-
* @param opts the options to use when publishing the stream.
|
|
1411
1397
|
*/
|
|
1412
|
-
publishScreenShareStream = async (
|
|
1413
|
-
screenShareStream: MediaStream,
|
|
1414
|
-
opts: PublishOptions = {},
|
|
1415
|
-
) => {
|
|
1398
|
+
publishScreenShareStream = async (screenShareStream: MediaStream) => {
|
|
1416
1399
|
if (!this.sfuClient) throw new Error(`Call not joined yet.`);
|
|
1417
1400
|
// joining is in progress, and we should wait until the client is ready
|
|
1418
1401
|
await this.sfuClient.joinTask;
|
|
@@ -1431,6 +1414,9 @@ export class Call {
|
|
|
1431
1414
|
if (!this.trackPublishOrder.includes(TrackType.SCREEN_SHARE)) {
|
|
1432
1415
|
this.trackPublishOrder.push(TrackType.SCREEN_SHARE);
|
|
1433
1416
|
}
|
|
1417
|
+
const opts: PublishOptions = {
|
|
1418
|
+
screenShareSettings: this.screenShare.getSettings(),
|
|
1419
|
+
};
|
|
1434
1420
|
await this.publisher.publishStream(
|
|
1435
1421
|
screenShareStream,
|
|
1436
1422
|
screenShareTrack,
|
|
@@ -1467,6 +1453,16 @@ export class Call {
|
|
|
1467
1453
|
await this.publisher?.unpublishStream(trackType, stopTrack);
|
|
1468
1454
|
};
|
|
1469
1455
|
|
|
1456
|
+
/**
|
|
1457
|
+
* Updates the preferred publishing options
|
|
1458
|
+
*
|
|
1459
|
+
* @internal
|
|
1460
|
+
* @param options the options to use.
|
|
1461
|
+
*/
|
|
1462
|
+
updatePublishOptions(options: PublishOptions) {
|
|
1463
|
+
this.publishOptions = { ...this.publishOptions, ...options };
|
|
1464
|
+
}
|
|
1465
|
+
|
|
1470
1466
|
/**
|
|
1471
1467
|
* Notifies the SFU that a noise cancellation process has started.
|
|
1472
1468
|
*
|
|
@@ -1529,16 +1525,6 @@ export class Call {
|
|
|
1529
1525
|
return this.state.setSortParticipantsBy(criteria);
|
|
1530
1526
|
};
|
|
1531
1527
|
|
|
1532
|
-
/**
|
|
1533
|
-
* Updates the list of video layers to publish.
|
|
1534
|
-
*
|
|
1535
|
-
* @internal
|
|
1536
|
-
* @param enabledLayers the list of layers to enable.
|
|
1537
|
-
*/
|
|
1538
|
-
updatePublishQuality = async (enabledLayers: VideoLayerSetting[]) => {
|
|
1539
|
-
return this.publisher?.updateVideoPublishQuality(enabledLayers);
|
|
1540
|
-
};
|
|
1541
|
-
|
|
1542
1528
|
/**
|
|
1543
1529
|
* Sends a reaction to the other call participants.
|
|
1544
1530
|
*
|
|
@@ -2098,10 +2084,7 @@ export class Call {
|
|
|
2098
2084
|
this.camera.state.mediaStream &&
|
|
2099
2085
|
!this.publisher?.isPublishing(TrackType.VIDEO)
|
|
2100
2086
|
) {
|
|
2101
|
-
await this.publishVideoStream(
|
|
2102
|
-
this.camera.state.mediaStream,
|
|
2103
|
-
this.camera.publishOptions,
|
|
2104
|
-
);
|
|
2087
|
+
await this.publishVideoStream(this.camera.state.mediaStream);
|
|
2105
2088
|
}
|
|
2106
2089
|
|
|
2107
2090
|
// Start camera if backend config specifies, and there is no local setting
|