@stream-io/video-client 1.5.0-0 → 1.5.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 +6 -230
- package/dist/index.browser.es.js +1498 -1963
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +1495 -1961
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1498 -1963
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +9 -93
- package/dist/src/StreamSfuClient.d.ts +56 -72
- package/dist/src/StreamVideoClient.d.ts +10 -2
- package/dist/src/coordinator/connection/client.d.ts +4 -3
- package/dist/src/coordinator/connection/types.d.ts +1 -5
- package/dist/src/devices/InputMediaDeviceManager.d.ts +0 -4
- package/dist/src/devices/MicrophoneManager.d.ts +1 -1
- package/dist/src/events/callEventHandlers.d.ts +3 -1
- package/dist/src/events/internal.d.ts +0 -4
- package/dist/src/gen/video/sfu/event/events.d.ts +4 -106
- package/dist/src/gen/video/sfu/models/models.d.ts +65 -64
- package/dist/src/logger.d.ts +0 -1
- package/dist/src/rpc/createClient.d.ts +0 -2
- package/dist/src/rpc/index.d.ts +0 -1
- package/dist/src/rtc/Dispatcher.d.ts +1 -1
- package/dist/src/rtc/IceTrickleBuffer.d.ts +1 -0
- package/dist/src/rtc/Publisher.d.ts +25 -24
- package/dist/src/rtc/Subscriber.d.ts +11 -12
- package/dist/src/rtc/flows/join.d.ts +20 -0
- package/dist/src/rtc/helpers/tracks.d.ts +3 -3
- package/dist/src/rtc/signal.d.ts +1 -1
- package/dist/src/store/CallState.d.ts +2 -46
- package/package.json +3 -3
- package/src/Call.ts +562 -615
- package/src/StreamSfuClient.ts +246 -277
- package/src/StreamVideoClient.ts +65 -15
- package/src/coordinator/connection/client.ts +8 -25
- package/src/coordinator/connection/connection.ts +0 -1
- package/src/coordinator/connection/token_manager.ts +1 -1
- package/src/coordinator/connection/types.ts +0 -6
- package/src/devices/BrowserPermission.ts +1 -5
- package/src/devices/CameraManager.ts +1 -1
- package/src/devices/InputMediaDeviceManager.ts +3 -12
- package/src/devices/MicrophoneManager.ts +3 -3
- package/src/devices/devices.ts +1 -1
- package/src/events/__tests__/mutes.test.ts +13 -10
- package/src/events/__tests__/participant.test.ts +0 -75
- package/src/events/callEventHandlers.ts +7 -4
- package/src/events/internal.ts +3 -20
- package/src/events/mutes.ts +3 -5
- package/src/events/participant.ts +15 -48
- package/src/gen/video/sfu/event/events.ts +8 -451
- package/src/gen/video/sfu/models/models.ts +204 -211
- package/src/logger.ts +1 -3
- package/src/rpc/createClient.ts +0 -21
- package/src/rpc/index.ts +0 -1
- package/src/rtc/Dispatcher.ts +2 -6
- package/src/rtc/IceTrickleBuffer.ts +2 -2
- package/src/rtc/Publisher.ts +163 -127
- package/src/rtc/Subscriber.ts +155 -94
- package/src/rtc/__tests__/Publisher.test.ts +95 -18
- package/src/rtc/__tests__/Subscriber.test.ts +99 -63
- package/src/rtc/__tests__/videoLayers.test.ts +2 -2
- package/src/rtc/flows/join.ts +65 -0
- package/src/rtc/helpers/tracks.ts +7 -27
- package/src/rtc/signal.ts +3 -3
- package/src/rtc/videoLayers.ts +10 -1
- package/src/stats/SfuStatsReporter.ts +0 -1
- package/src/store/CallState.ts +2 -109
- package/src/store/__tests__/CallState.test.ts +37 -48
- package/dist/src/helpers/ensureExhausted.d.ts +0 -1
- package/dist/src/helpers/withResolvers.d.ts +0 -14
- package/dist/src/rpc/retryable.d.ts +0 -23
- package/dist/src/rtc/helpers/rtcConfiguration.d.ts +0 -2
- package/src/helpers/ensureExhausted.ts +0 -5
- package/src/helpers/withResolvers.ts +0 -43
- package/src/rpc/__tests__/retryable.test.ts +0 -72
- package/src/rpc/retryable.ts +0 -57
- package/src/rtc/helpers/rtcConfiguration.ts +0 -11
|
@@ -270,10 +270,49 @@ export interface TrackInfo {
|
|
|
270
270
|
* @generated from protobuf field: bool red = 9;
|
|
271
271
|
*/
|
|
272
272
|
red: boolean;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* todo remove this
|
|
276
|
+
*
|
|
277
|
+
* @generated from protobuf message stream.video.sfu.models.Call
|
|
278
|
+
*/
|
|
279
|
+
export interface Call {
|
|
280
|
+
/**
|
|
281
|
+
* the call type
|
|
282
|
+
*
|
|
283
|
+
* @generated from protobuf field: string type = 1;
|
|
284
|
+
*/
|
|
285
|
+
type: string;
|
|
273
286
|
/**
|
|
274
|
-
*
|
|
287
|
+
* the call id
|
|
288
|
+
*
|
|
289
|
+
* @generated from protobuf field: string id = 2;
|
|
290
|
+
*/
|
|
291
|
+
id: string;
|
|
292
|
+
/**
|
|
293
|
+
* the id of the user that created this call
|
|
294
|
+
*
|
|
295
|
+
* @generated from protobuf field: string created_by_user_id = 3;
|
|
296
|
+
*/
|
|
297
|
+
createdByUserId: string;
|
|
298
|
+
/**
|
|
299
|
+
* the id of the current host for this call
|
|
300
|
+
*
|
|
301
|
+
* @generated from protobuf field: string host_user_id = 4;
|
|
275
302
|
*/
|
|
276
|
-
|
|
303
|
+
hostUserId: string;
|
|
304
|
+
/**
|
|
305
|
+
* @generated from protobuf field: google.protobuf.Struct custom = 5;
|
|
306
|
+
*/
|
|
307
|
+
custom?: Struct;
|
|
308
|
+
/**
|
|
309
|
+
* @generated from protobuf field: google.protobuf.Timestamp created_at = 6;
|
|
310
|
+
*/
|
|
311
|
+
createdAt?: Timestamp;
|
|
312
|
+
/**
|
|
313
|
+
* @generated from protobuf field: google.protobuf.Timestamp updated_at = 7;
|
|
314
|
+
*/
|
|
315
|
+
updatedAt?: Timestamp;
|
|
277
316
|
}
|
|
278
317
|
/**
|
|
279
318
|
* @generated from protobuf message stream.video.sfu.models.Error
|
|
@@ -377,47 +416,6 @@ export interface Device {
|
|
|
377
416
|
*/
|
|
378
417
|
version: string;
|
|
379
418
|
}
|
|
380
|
-
/**
|
|
381
|
-
* @generated from protobuf message stream.video.sfu.models.Call
|
|
382
|
-
*/
|
|
383
|
-
export interface Call {
|
|
384
|
-
/**
|
|
385
|
-
* the call type
|
|
386
|
-
*
|
|
387
|
-
* @generated from protobuf field: string type = 1;
|
|
388
|
-
*/
|
|
389
|
-
type: string;
|
|
390
|
-
/**
|
|
391
|
-
* the call id
|
|
392
|
-
*
|
|
393
|
-
* @generated from protobuf field: string id = 2;
|
|
394
|
-
*/
|
|
395
|
-
id: string;
|
|
396
|
-
/**
|
|
397
|
-
* the id of the user that created this call
|
|
398
|
-
*
|
|
399
|
-
* @generated from protobuf field: string created_by_user_id = 3;
|
|
400
|
-
*/
|
|
401
|
-
createdByUserId: string;
|
|
402
|
-
/**
|
|
403
|
-
* the id of the current host for this call
|
|
404
|
-
*
|
|
405
|
-
* @generated from protobuf field: string host_user_id = 4;
|
|
406
|
-
*/
|
|
407
|
-
hostUserId: string;
|
|
408
|
-
/**
|
|
409
|
-
* @generated from protobuf field: google.protobuf.Struct custom = 5;
|
|
410
|
-
*/
|
|
411
|
-
custom?: Struct;
|
|
412
|
-
/**
|
|
413
|
-
* @generated from protobuf field: google.protobuf.Timestamp created_at = 6;
|
|
414
|
-
*/
|
|
415
|
-
createdAt?: Timestamp;
|
|
416
|
-
/**
|
|
417
|
-
* @generated from protobuf field: google.protobuf.Timestamp updated_at = 7;
|
|
418
|
-
*/
|
|
419
|
-
updatedAt?: Timestamp;
|
|
420
|
-
}
|
|
421
419
|
/**
|
|
422
420
|
* CallGrants represents the set of permissions given
|
|
423
421
|
* to the user for the current call.
|
|
@@ -726,11 +724,7 @@ export declare enum CallEndedReason {
|
|
|
726
724
|
/**
|
|
727
725
|
* @generated from protobuf enum value: CALL_ENDED_REASON_KICKED = 3;
|
|
728
726
|
*/
|
|
729
|
-
KICKED = 3
|
|
730
|
-
/**
|
|
731
|
-
* @generated from protobuf enum value: CALL_ENDED_REASON_SESSION_ENDED = 4;
|
|
732
|
-
*/
|
|
733
|
-
SESSION_ENDED = 4
|
|
727
|
+
KICKED = 3
|
|
734
728
|
}
|
|
735
729
|
/**
|
|
736
730
|
* WebsocketReconnectStrategy defines the ws strategies available for handling reconnections.
|
|
@@ -743,7 +737,7 @@ export declare enum WebsocketReconnectStrategy {
|
|
|
743
737
|
*/
|
|
744
738
|
UNSPECIFIED = 0,
|
|
745
739
|
/**
|
|
746
|
-
* Sent after reaching the maximum reconnection attempts,
|
|
740
|
+
* Sent after reaching the maximum reconnection attempts, leading to permanent disconnect.
|
|
747
741
|
*
|
|
748
742
|
* @generated from protobuf enum value: WEBSOCKET_RECONNECT_STRATEGY_DISCONNECT = 1;
|
|
749
743
|
*/
|
|
@@ -756,18 +750,25 @@ export declare enum WebsocketReconnectStrategy {
|
|
|
756
750
|
*/
|
|
757
751
|
FAST = 2,
|
|
758
752
|
/**
|
|
759
|
-
* SDK should
|
|
753
|
+
* SDK should drop existing pc instances and creates a fresh WebSocket connection,
|
|
754
|
+
* ensuring a clean state for the reconnection.
|
|
755
|
+
*
|
|
756
|
+
* @generated from protobuf enum value: WEBSOCKET_RECONNECT_STRATEGY_CLEAN = 3;
|
|
757
|
+
*/
|
|
758
|
+
CLEAN = 3,
|
|
759
|
+
/**
|
|
760
|
+
* SDK should obtain new credentials from the coordinator, drops existing pc instances, and initializes
|
|
760
761
|
* a completely new WebSocket connection, ensuring a comprehensive reset.
|
|
761
762
|
*
|
|
762
|
-
* @generated from protobuf enum value:
|
|
763
|
+
* @generated from protobuf enum value: WEBSOCKET_RECONNECT_STRATEGY_FULL = 4;
|
|
763
764
|
*/
|
|
764
|
-
|
|
765
|
+
FULL = 4,
|
|
765
766
|
/**
|
|
766
767
|
* SDK should migrate to a new SFU instance
|
|
767
768
|
*
|
|
768
|
-
* @generated from protobuf enum value: WEBSOCKET_RECONNECT_STRATEGY_MIGRATE =
|
|
769
|
+
* @generated from protobuf enum value: WEBSOCKET_RECONNECT_STRATEGY_MIGRATE = 5;
|
|
769
770
|
*/
|
|
770
|
-
MIGRATE =
|
|
771
|
+
MIGRATE = 5
|
|
771
772
|
}
|
|
772
773
|
declare class CallState$Type extends MessageType<CallState> {
|
|
773
774
|
constructor();
|
|
@@ -869,6 +870,16 @@ declare class TrackInfo$Type extends MessageType<TrackInfo> {
|
|
|
869
870
|
* @generated MessageType for protobuf message stream.video.sfu.models.TrackInfo
|
|
870
871
|
*/
|
|
871
872
|
export declare const TrackInfo: TrackInfo$Type;
|
|
873
|
+
declare class Call$Type extends MessageType<Call> {
|
|
874
|
+
constructor();
|
|
875
|
+
create(value?: PartialMessage<Call>): Call;
|
|
876
|
+
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Call): Call;
|
|
877
|
+
internalBinaryWrite(message: Call, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
878
|
+
}
|
|
879
|
+
/**
|
|
880
|
+
* @generated MessageType for protobuf message stream.video.sfu.models.Call
|
|
881
|
+
*/
|
|
882
|
+
export declare const Call: Call$Type;
|
|
872
883
|
declare class Error$Type extends MessageType<Error> {
|
|
873
884
|
constructor();
|
|
874
885
|
create(value?: PartialMessage<Error>): Error;
|
|
@@ -929,16 +940,6 @@ declare class Device$Type extends MessageType<Device> {
|
|
|
929
940
|
* @generated MessageType for protobuf message stream.video.sfu.models.Device
|
|
930
941
|
*/
|
|
931
942
|
export declare const Device: Device$Type;
|
|
932
|
-
declare class Call$Type extends MessageType<Call> {
|
|
933
|
-
constructor();
|
|
934
|
-
create(value?: PartialMessage<Call>): Call;
|
|
935
|
-
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Call): Call;
|
|
936
|
-
internalBinaryWrite(message: Call, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
|
|
937
|
-
}
|
|
938
|
-
/**
|
|
939
|
-
* @generated MessageType for protobuf message stream.video.sfu.models.Call
|
|
940
|
-
*/
|
|
941
|
-
export declare const Call: Call$Type;
|
|
942
943
|
declare class CallGrants$Type extends MessageType<CallGrants> {
|
|
943
944
|
constructor();
|
|
944
945
|
create(value?: PartialMessage<CallGrants>): CallGrants;
|
package/dist/src/logger.d.ts
CHANGED
|
@@ -3,5 +3,4 @@ export declare const logLevels: Record<LogLevel, number>;
|
|
|
3
3
|
export declare const logToConsole: Logger;
|
|
4
4
|
export declare const setLogger: (l: Logger, lvl?: LogLevel) => void;
|
|
5
5
|
export declare const setLogLevel: (l: LogLevel) => void;
|
|
6
|
-
export declare const getLogLevel: () => LogLevel;
|
|
7
6
|
export declare const getLogger: (withTags?: string[]) => Logger;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { RpcInterceptor } from '@protobuf-ts/runtime-rpc';
|
|
2
2
|
import { TwirpOptions } from '@protobuf-ts/twirp-transport';
|
|
3
3
|
import { SignalServerClient } from '../gen/video/sfu/signal_rpc/signal.client';
|
|
4
|
-
import { Logger, LogLevel } from '../coordinator/connection/types';
|
|
5
4
|
export declare const withHeaders: (headers: Record<string, string>) => RpcInterceptor;
|
|
6
|
-
export declare const withRequestLogger: (logger: Logger, level: LogLevel) => RpcInterceptor;
|
|
7
5
|
/**
|
|
8
6
|
* Creates new SignalServerClient instance.
|
|
9
7
|
*
|
package/dist/src/rpc/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare const isSfuEvent: (eventName: SfuEventKinds | EventTypes) => even
|
|
|
19
19
|
export declare class Dispatcher {
|
|
20
20
|
private readonly logger;
|
|
21
21
|
private subscribers;
|
|
22
|
-
dispatch: <K extends SfuEventKinds>(message: DispatchableMessage<K
|
|
22
|
+
dispatch: <K extends SfuEventKinds>(message: DispatchableMessage<K>) => void;
|
|
23
23
|
on: <E extends keyof AllSfuEvents>(eventName: E, fn: CallEventListener<E>) => () => void;
|
|
24
24
|
off: <E extends keyof AllSfuEvents>(eventName: E, fn: CallEventListener<E>) => void;
|
|
25
25
|
offAll: (eventName?: SfuEventKinds) => void;
|
|
@@ -7,5 +7,6 @@ import { ICETrickle } from '../gen/video/sfu/event/events';
|
|
|
7
7
|
export declare class IceTrickleBuffer {
|
|
8
8
|
readonly subscriberCandidates: ReplaySubject<ICETrickle>;
|
|
9
9
|
readonly publisherCandidates: ReplaySubject<ICETrickle>;
|
|
10
|
+
private readonly logger;
|
|
10
11
|
push: (iceTrickle: ICETrickle) => void;
|
|
11
12
|
}
|
|
@@ -11,16 +11,14 @@ export type PublisherConstructorOpts = {
|
|
|
11
11
|
connectionConfig?: RTCConfiguration;
|
|
12
12
|
isDtxEnabled: boolean;
|
|
13
13
|
isRedEnabled: boolean;
|
|
14
|
+
iceRestartDelay?: number;
|
|
14
15
|
onUnrecoverableError?: () => void;
|
|
15
|
-
logTag: string;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
18
|
* The `Publisher` is responsible for publishing/unpublishing media streams to/from the SFU
|
|
19
|
-
*
|
|
20
19
|
* @internal
|
|
21
20
|
*/
|
|
22
21
|
export declare class Publisher {
|
|
23
|
-
private readonly logger;
|
|
24
22
|
private pc;
|
|
25
23
|
private readonly state;
|
|
26
24
|
private readonly transceiverRegistry;
|
|
@@ -30,16 +28,18 @@ export declare class Publisher {
|
|
|
30
28
|
* This is needed because some browsers (Firefox) don't reliably report
|
|
31
29
|
* trackId and `mid` parameters.
|
|
32
30
|
*
|
|
33
|
-
* @
|
|
31
|
+
* @private
|
|
34
32
|
*/
|
|
35
|
-
private
|
|
33
|
+
private transceiverInitOrder;
|
|
36
34
|
private readonly trackKindMapping;
|
|
37
35
|
private readonly trackLayersCache;
|
|
38
36
|
private readonly isDtxEnabled;
|
|
39
37
|
private readonly isRedEnabled;
|
|
40
38
|
private readonly unsubscribeOnIceRestart;
|
|
41
39
|
private readonly onUnrecoverableError?;
|
|
40
|
+
private readonly iceRestartDelay;
|
|
42
41
|
private isIceRestarting;
|
|
42
|
+
private iceRestartTimeout?;
|
|
43
43
|
private _connectionConfiguration;
|
|
44
44
|
/**
|
|
45
45
|
* Returns the current connection configuration.
|
|
@@ -62,22 +62,15 @@ export declare class Publisher {
|
|
|
62
62
|
* @param isRedEnabled whether RED is enabled.
|
|
63
63
|
* @param iceRestartDelay the delay in milliseconds to wait before restarting ICE once connection goes to `disconnected` state.
|
|
64
64
|
* @param onUnrecoverableError a callback to call when an unrecoverable error occurs.
|
|
65
|
-
* @param logTag the log tag to use.
|
|
66
65
|
*/
|
|
67
|
-
constructor({ connectionConfig, sfuClient, dispatcher, state, isDtxEnabled, isRedEnabled,
|
|
66
|
+
constructor({ connectionConfig, sfuClient, dispatcher, state, isDtxEnabled, isRedEnabled, iceRestartDelay, onUnrecoverableError, }: PublisherConstructorOpts);
|
|
68
67
|
private createPeerConnection;
|
|
69
68
|
/**
|
|
70
69
|
* Closes the publisher PeerConnection and cleans up the resources.
|
|
71
70
|
*/
|
|
72
|
-
close: ({ stopTracks }
|
|
73
|
-
stopTracks
|
|
71
|
+
close: ({ stopTracks }?: {
|
|
72
|
+
stopTracks?: boolean | undefined;
|
|
74
73
|
}) => void;
|
|
75
|
-
/**
|
|
76
|
-
* Detaches the event handlers from the `RTCPeerConnection`.
|
|
77
|
-
* This is useful when we want to replace the `RTCPeerConnection`
|
|
78
|
-
* instance with a new one (in case of migration).
|
|
79
|
-
*/
|
|
80
|
-
detachEventHandlers: () => void;
|
|
81
74
|
/**
|
|
82
75
|
* Starts publishing the given track of the given media stream.
|
|
83
76
|
*
|
|
@@ -103,11 +96,17 @@ export declare class Publisher {
|
|
|
103
96
|
* @param trackType the track type to check.
|
|
104
97
|
*/
|
|
105
98
|
isPublishing: (trackType: TrackType) => boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Returns true if the given track type is currently live
|
|
101
|
+
*
|
|
102
|
+
* @param trackType the track type to check.
|
|
103
|
+
*/
|
|
104
|
+
isLive: (trackType: TrackType) => boolean;
|
|
106
105
|
private notifyTrackMuteStateChanged;
|
|
107
106
|
/**
|
|
108
107
|
* Stops publishing all tracks and stop all tracks.
|
|
109
108
|
*/
|
|
110
|
-
|
|
109
|
+
stopPublishing: () => void;
|
|
111
110
|
updateVideoPublishQuality: (enabledLayers: VideoLayerSetting[]) => Promise<void>;
|
|
112
111
|
/**
|
|
113
112
|
* Returns the result of the `RTCPeerConnection.getStats()` method
|
|
@@ -123,6 +122,15 @@ export declare class Publisher {
|
|
|
123
122
|
* @param sfuClient the SFU client to use.
|
|
124
123
|
*/
|
|
125
124
|
setSfuClient: (sfuClient: StreamSfuClient) => void;
|
|
125
|
+
/**
|
|
126
|
+
* Performs a migration of this publisher instance to a new SFU.
|
|
127
|
+
*
|
|
128
|
+
* Initiates a new `iceRestart` offer/answer exchange with the new SFU.
|
|
129
|
+
*
|
|
130
|
+
* @param sfuClient the new SFU client to migrate to.
|
|
131
|
+
* @param connectionConfig the new connection configuration to use.
|
|
132
|
+
*/
|
|
133
|
+
migrateTo: (sfuClient: StreamSfuClient, connectionConfig?: RTCConfiguration) => Promise<void>;
|
|
126
134
|
/**
|
|
127
135
|
* Restarts the ICE connection and renegotiates with the SFU.
|
|
128
136
|
*/
|
|
@@ -134,16 +142,9 @@ export declare class Publisher {
|
|
|
134
142
|
* @param options the optional offer options to use.
|
|
135
143
|
*/
|
|
136
144
|
private negotiate;
|
|
137
|
-
private enableHighQualityAudio;
|
|
138
145
|
private mungeCodecs;
|
|
139
146
|
private extractMid;
|
|
140
|
-
|
|
141
|
-
* Returns a list of tracks that are currently being published.
|
|
142
|
-
*
|
|
143
|
-
* @internal
|
|
144
|
-
* @param sdp an optional SDP to extract the `mid` from.
|
|
145
|
-
*/
|
|
146
|
-
getAnnouncedTracks: (sdp?: string) => TrackInfo[];
|
|
147
|
+
getCurrentTrackInfos: (sdp?: string) => TrackInfo[];
|
|
147
148
|
private onIceCandidateError;
|
|
148
149
|
private onIceConnectionStateChange;
|
|
149
150
|
private onIceGatheringStateChange;
|
|
@@ -6,24 +6,23 @@ export type SubscriberOpts = {
|
|
|
6
6
|
dispatcher: Dispatcher;
|
|
7
7
|
state: CallState;
|
|
8
8
|
connectionConfig?: RTCConfiguration;
|
|
9
|
+
iceRestartDelay?: number;
|
|
9
10
|
onUnrecoverableError?: () => void;
|
|
10
|
-
logTag: string;
|
|
11
11
|
};
|
|
12
12
|
/**
|
|
13
13
|
* A wrapper around the `RTCPeerConnection` that handles the incoming
|
|
14
14
|
* media streams from the SFU.
|
|
15
|
-
*
|
|
16
|
-
* @internal
|
|
17
15
|
*/
|
|
18
16
|
export declare class Subscriber {
|
|
19
|
-
private readonly logger;
|
|
20
17
|
private pc;
|
|
21
18
|
private sfuClient;
|
|
22
19
|
private state;
|
|
23
20
|
private readonly unregisterOnSubscriberOffer;
|
|
24
21
|
private readonly unregisterOnIceRestart;
|
|
25
22
|
private readonly onUnrecoverableError?;
|
|
23
|
+
private readonly iceRestartDelay;
|
|
26
24
|
private isIceRestarting;
|
|
25
|
+
private iceRestartTimeout?;
|
|
27
26
|
private _connectionConfiguration;
|
|
28
27
|
/**
|
|
29
28
|
* Returns the current connection configuration.
|
|
@@ -40,9 +39,8 @@ export declare class Subscriber {
|
|
|
40
39
|
* @param connectionConfig the connection configuration to use.
|
|
41
40
|
* @param iceRestartDelay the delay in milliseconds to wait before restarting ICE when connection goes to `disconnected` state.
|
|
42
41
|
* @param onUnrecoverableError a callback to call when an unrecoverable error occurs.
|
|
43
|
-
* @param logTag a tag to use for logging.
|
|
44
42
|
*/
|
|
45
|
-
constructor({ sfuClient, dispatcher, state, connectionConfig,
|
|
43
|
+
constructor({ sfuClient, dispatcher, state, connectionConfig, iceRestartDelay, onUnrecoverableError, }: SubscriberOpts);
|
|
46
44
|
/**
|
|
47
45
|
* Creates a new `RTCPeerConnection` instance with the given configuration.
|
|
48
46
|
*
|
|
@@ -53,12 +51,6 @@ export declare class Subscriber {
|
|
|
53
51
|
* Closes the `RTCPeerConnection` and unsubscribes from the dispatcher.
|
|
54
52
|
*/
|
|
55
53
|
close: () => void;
|
|
56
|
-
/**
|
|
57
|
-
* Detaches the event handlers from the `RTCPeerConnection`.
|
|
58
|
-
* This is useful when we want to replace the `RTCPeerConnection`
|
|
59
|
-
* instance with a new one (in case of migration).
|
|
60
|
-
*/
|
|
61
|
-
detachEventHandlers: () => void;
|
|
62
54
|
/**
|
|
63
55
|
* Returns the result of the `RTCPeerConnection.getStats()` method
|
|
64
56
|
* @param selector
|
|
@@ -71,6 +63,13 @@ export declare class Subscriber {
|
|
|
71
63
|
* @param sfuClient the SFU client to use.
|
|
72
64
|
*/
|
|
73
65
|
setSfuClient: (sfuClient: StreamSfuClient) => void;
|
|
66
|
+
/**
|
|
67
|
+
* Migrates the subscriber to a new SFU client.
|
|
68
|
+
*
|
|
69
|
+
* @param sfuClient the new SFU client to migrate to.
|
|
70
|
+
* @param connectionConfig the new connection configuration to use.
|
|
71
|
+
*/
|
|
72
|
+
migrateTo: (sfuClient: StreamSfuClient, connectionConfig?: RTCConfiguration) => void;
|
|
74
73
|
/**
|
|
75
74
|
* Restarts the ICE connection and renegotiates with the SFU.
|
|
76
75
|
*/
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { JoinCallData } from '../../types';
|
|
2
|
+
import { StreamClient } from '../../coordinator/connection/client';
|
|
3
|
+
/**
|
|
4
|
+
* Collects all necessary information to join a call, talks to the coordinator
|
|
5
|
+
* and returns the necessary information to join the call.
|
|
6
|
+
*
|
|
7
|
+
* @param httpClient the http client to use.
|
|
8
|
+
* @param type the type of the call.
|
|
9
|
+
* @param id the id of the call.
|
|
10
|
+
* @param data the data for the call.
|
|
11
|
+
*/
|
|
12
|
+
export declare const join: (httpClient: StreamClient, type: string, id: string, data?: JoinCallData) => Promise<{
|
|
13
|
+
connectionConfig: RTCConfiguration | undefined;
|
|
14
|
+
sfuServer: import("../../gen/coordinator").SFUResponse;
|
|
15
|
+
token: string;
|
|
16
|
+
metadata: import("../../gen/coordinator").CallResponse;
|
|
17
|
+
members: import("../../gen/coordinator").MemberResponse[];
|
|
18
|
+
ownCapabilities: import("../../gen/coordinator").OwnCapability[];
|
|
19
|
+
statsOptions: import("../../gen/coordinator").StatsOptions;
|
|
20
|
+
}>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { TrackType } from '../../gen/video/sfu/models/models';
|
|
2
|
+
import type { StreamVideoParticipant } from '../../types';
|
|
2
3
|
import { TrackMuteType } from '../../types';
|
|
3
|
-
export declare const trackTypeToParticipantStreamKey: (trackType: TrackType) =>
|
|
4
|
-
export declare const muteTypeToTrackType: (muteType: TrackMuteType) => TrackType
|
|
5
|
-
export declare const toTrackType: (trackType: string) => TrackType | undefined;
|
|
4
|
+
export declare const trackTypeToParticipantStreamKey: (trackType: TrackType) => keyof StreamVideoParticipant;
|
|
5
|
+
export declare const muteTypeToTrackType: (muteType: TrackMuteType) => TrackType;
|
package/dist/src/rtc/signal.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import WebSocket from 'isomorphic-ws';
|
|
1
2
|
import { DispatchableMessage, SfuEventKinds } from './Dispatcher';
|
|
2
3
|
export declare const createWebSocketSignalChannel: (opts: {
|
|
3
4
|
endpoint: string;
|
|
4
5
|
onMessage: <K extends SfuEventKinds>(message: DispatchableMessage<K>) => void;
|
|
5
|
-
logTag: string;
|
|
6
6
|
}) => WebSocket;
|
|
@@ -3,8 +3,7 @@ import type { Patch } from './rxUtils';
|
|
|
3
3
|
import { StreamVideoParticipant, StreamVideoParticipantPatch, StreamVideoParticipantPatches } from '../types';
|
|
4
4
|
import { CallStatsReport } from '../stats';
|
|
5
5
|
import { CallIngressResponse, CallResponse, CallSessionResponse, CallSettingsResponse, EgressResponse, MemberResponse, OwnCapability, ThumbnailResponse, UserResponse, WSEvent } from '../gen/coordinator';
|
|
6
|
-
import {
|
|
7
|
-
import { CallState as SfuCallState, Pin, TrackType } from '../gen/video/sfu/models/models';
|
|
6
|
+
import { Pin } from '../gen/video/sfu/models/models';
|
|
8
7
|
import { Comparator } from '../sorting';
|
|
9
8
|
/**
|
|
10
9
|
* Represents the state of the current call.
|
|
@@ -52,12 +51,6 @@ export declare enum CallingState {
|
|
|
52
51
|
*/
|
|
53
52
|
OFFLINE = "offline"
|
|
54
53
|
}
|
|
55
|
-
type OrphanedTrack = {
|
|
56
|
-
id: string;
|
|
57
|
-
trackLookupPrefix: string;
|
|
58
|
-
trackType: TrackType;
|
|
59
|
-
track: MediaStream;
|
|
60
|
-
};
|
|
61
54
|
/**
|
|
62
55
|
* Holds the state of the current call.
|
|
63
56
|
* @react You don't have to use this class directly, as we are exposing the state through Hooks.
|
|
@@ -87,7 +80,6 @@ export declare class CallState {
|
|
|
87
80
|
private anonymousParticipantCountSubject;
|
|
88
81
|
private participantsSubject;
|
|
89
82
|
private callStatsReportSubject;
|
|
90
|
-
private orphanedTracks;
|
|
91
83
|
/**
|
|
92
84
|
* The time the call session actually started.
|
|
93
85
|
* Useful for displaying the call duration.
|
|
@@ -475,7 +467,7 @@ export declare class CallState {
|
|
|
475
467
|
* @param patch the patch to apply to the participants.
|
|
476
468
|
* @returns all participants, with all patch applied.
|
|
477
469
|
*/
|
|
478
|
-
updateParticipants: (patch: StreamVideoParticipantPatches) => StreamVideoParticipant[];
|
|
470
|
+
updateParticipants: (patch: StreamVideoParticipantPatches) => StreamVideoParticipant[] | undefined;
|
|
479
471
|
/**
|
|
480
472
|
* Updates the call state with the data received from the server.
|
|
481
473
|
*
|
|
@@ -490,31 +482,6 @@ export declare class CallState {
|
|
|
490
482
|
* @param pins the latest pins from the server.
|
|
491
483
|
*/
|
|
492
484
|
setServerSidePins: (pins: Pin[]) => StreamVideoParticipant[];
|
|
493
|
-
/**
|
|
494
|
-
* Adds an orphaned track to the call state.
|
|
495
|
-
*
|
|
496
|
-
* @internal
|
|
497
|
-
*
|
|
498
|
-
* @param orphanedTrack the orphaned track to add.
|
|
499
|
-
*/
|
|
500
|
-
registerOrphanedTrack: (orphanedTrack: OrphanedTrack) => void;
|
|
501
|
-
/**
|
|
502
|
-
* Removes an orphaned track from the call state.
|
|
503
|
-
*
|
|
504
|
-
* @internal
|
|
505
|
-
*
|
|
506
|
-
* @param id the ID of the orphaned track to remove.
|
|
507
|
-
*/
|
|
508
|
-
removeOrphanedTrack: (id: string) => void;
|
|
509
|
-
/**
|
|
510
|
-
* Takes all orphaned tracks with the given track lookup prefix.
|
|
511
|
-
* All orphaned tracks with the given track lookup prefix are removed from the call state.
|
|
512
|
-
*
|
|
513
|
-
* @internal
|
|
514
|
-
*
|
|
515
|
-
* @param trackLookupPrefix the track lookup prefix to match the orphaned tracks by.
|
|
516
|
-
*/
|
|
517
|
-
takeOrphanedTracks: (trackLookupPrefix: string) => OrphanedTrack[];
|
|
518
485
|
/**
|
|
519
486
|
* Updates the call state with the data received from the server.
|
|
520
487
|
*
|
|
@@ -523,16 +490,6 @@ export declare class CallState {
|
|
|
523
490
|
* @param call the call response from the server.
|
|
524
491
|
*/
|
|
525
492
|
updateFromCallResponse: (call: CallResponse) => void;
|
|
526
|
-
/**
|
|
527
|
-
* Updates the call state with the data received from the SFU server.
|
|
528
|
-
*
|
|
529
|
-
* @internal
|
|
530
|
-
*
|
|
531
|
-
* @param callState the call state from the SFU server.
|
|
532
|
-
* @param currentSessionId the session ID of the current user.
|
|
533
|
-
* @param reconnectDetails optional reconnect details.
|
|
534
|
-
*/
|
|
535
|
-
updateFromSfuCallState: (callState: SfuCallState, currentSessionId: string, reconnectDetails?: ReconnectDetails) => void;
|
|
536
493
|
private updateFromMemberRemoved;
|
|
537
494
|
private updateFromMemberAdded;
|
|
538
495
|
private updateFromHLSBroadcastStopped;
|
|
@@ -546,4 +503,3 @@ export declare class CallState {
|
|
|
546
503
|
private blockUser;
|
|
547
504
|
private updateOwnCapabilities;
|
|
548
505
|
}
|
|
549
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/video-client",
|
|
3
|
-
"version": "1.5.0
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"packageManager": "yarn@3.2.4",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"@openapitools/openapi-generator-cli": "^2.13.4",
|
|
46
46
|
"@rollup/plugin-replace": "^5.0.5",
|
|
47
47
|
"@rollup/plugin-typescript": "^11.1.6",
|
|
48
|
-
"@stream-io/audio-filters-web": "
|
|
48
|
+
"@stream-io/audio-filters-web": "workspace:^",
|
|
49
49
|
"@stream-io/node-sdk": "^0.3.0",
|
|
50
50
|
"@types/sdp-transform": "^2.4.7",
|
|
51
51
|
"@types/ua-parser-js": "^0.7.37",
|
|
@@ -60,4 +60,4 @@
|
|
|
60
60
|
"vitest": "^1.0.0",
|
|
61
61
|
"vitest-mock-extended": "^1.2.1"
|
|
62
62
|
}
|
|
63
|
-
}
|
|
63
|
+
}
|