@stream-io/video-client 0.0.28 → 0.0.30
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 +14 -0
- package/dist/index.browser.es.js +2512 -1754
- package/dist/index.browser.es.js.map +1 -1
- package/dist/index.cjs.js +2532 -1752
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +2512 -1754
- package/dist/index.es.js.map +1 -1
- package/dist/src/Call.d.ts +2 -3
- package/dist/src/StreamSfuClient.d.ts +23 -10
- package/dist/src/StreamVideoClient.d.ts +1 -4
- package/dist/src/client-details.d.ts +2 -1
- package/dist/src/coordinator/connection/types.d.ts +2 -2
- package/dist/src/coordinator/connection/utils.d.ts +1 -0
- package/dist/src/events/internal.d.ts +4 -0
- package/dist/src/gen/coordinator/index.d.ts +6 -0
- package/dist/src/gen/google/protobuf/struct.d.ts +8 -15
- package/dist/src/gen/google/protobuf/timestamp.d.ts +2 -9
- package/dist/src/gen/video/sfu/event/events.d.ts +121 -1
- package/dist/src/gen/video/sfu/models/models.d.ts +38 -1
- package/dist/src/gen/video/sfu/signal_rpc/signal.client.d.ts +3 -14
- package/dist/src/gen/video/sfu/signal_rpc/signal.d.ts +4 -12
- package/dist/src/logger.d.ts +4 -2
- package/dist/src/rtc/Dispatcher.d.ts +1 -2
- package/dist/src/rtc/{publisher.d.ts → Publisher.d.ts} +49 -15
- package/dist/src/rtc/Subscriber.d.ts +58 -0
- package/dist/src/rtc/__tests__/Subscriber.test.d.ts +1 -0
- package/dist/src/rtc/flows/join.d.ts +8 -1
- package/dist/src/rtc/index.d.ts +2 -2
- package/dist/src/rtc/signal.d.ts +1 -0
- package/dist/src/stats/state-store-stats-reporter.d.ts +3 -4
- package/dist/src/store/CallState.d.ts +10 -0
- package/package.json +3 -1
- package/src/Call.ts +215 -209
- package/src/StreamSfuClient.ts +48 -21
- package/src/StreamVideoClient.ts +7 -24
- package/src/client-details.ts +33 -1
- package/src/coordinator/connection/client.ts +6 -8
- package/src/coordinator/connection/types.ts +2 -3
- package/src/coordinator/connection/utils.ts +1 -0
- package/src/events/call.ts +0 -1
- package/src/events/callEventHandlers.ts +2 -0
- package/src/events/internal.ts +20 -0
- package/src/events/sessions.ts +0 -1
- package/src/gen/coordinator/index.ts +6 -0
- package/src/gen/google/protobuf/struct.ts +541 -333
- package/src/gen/google/protobuf/timestamp.ts +214 -148
- package/src/gen/video/sfu/event/events.ts +353 -3
- package/src/gen/video/sfu/models/models.ts +37 -0
- package/src/gen/video/sfu/signal_rpc/signal.client.ts +160 -94
- package/src/gen/video/sfu/signal_rpc/signal.ts +1214 -731
- package/src/logger.ts +43 -30
- package/src/rtc/Dispatcher.ts +5 -9
- package/src/rtc/{publisher.ts → Publisher.ts} +245 -111
- package/src/rtc/Subscriber.ts +304 -0
- package/src/rtc/__tests__/{publisher.test.ts → Publisher.test.ts} +77 -9
- package/src/rtc/__tests__/Subscriber.test.ts +121 -0
- package/src/rtc/__tests__/mocks/webrtc.mocks.ts +20 -0
- package/src/rtc/flows/join.ts +42 -1
- package/src/rtc/index.ts +2 -2
- package/src/rtc/signal.ts +6 -5
- package/src/rtc/videoLayers.ts +1 -4
- package/src/stats/state-store-stats-reporter.ts +3 -5
- package/src/store/CallState.ts +20 -0
- package/src/types.ts +0 -1
- package/dist/src/rtc/subscriber.d.ts +0 -9
- package/src/rtc/subscriber.ts +0 -107
- /package/dist/src/rtc/__tests__/{publisher.test.d.ts → Publisher.test.d.ts} +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { StreamSfuClient } from '../StreamSfuClient';
|
|
2
|
-
import { TrackType } from '../gen/video/sfu/models/models';
|
|
2
|
+
import { TrackInfo, TrackType } from '../gen/video/sfu/models/models';
|
|
3
3
|
import { CallState } from '../store';
|
|
4
4
|
import { PublishOptions } from '../types';
|
|
5
5
|
export type PublisherOpts = {
|
|
@@ -15,16 +15,37 @@ export type PublisherOpts = {
|
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
17
|
export declare class Publisher {
|
|
18
|
-
private
|
|
19
|
-
private readonly sfuClient;
|
|
18
|
+
private pc;
|
|
20
19
|
private readonly state;
|
|
21
20
|
private readonly transceiverRegistry;
|
|
22
|
-
private readonly
|
|
23
|
-
private
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
21
|
+
private readonly trackKindMapping;
|
|
22
|
+
private readonly trackLayersCache;
|
|
23
|
+
private readonly isDtxEnabled;
|
|
24
|
+
private readonly isRedEnabled;
|
|
25
|
+
private readonly preferredVideoCodec?;
|
|
26
|
+
private logger;
|
|
27
|
+
/**
|
|
28
|
+
* The SFU client instance to use for publishing and signaling.
|
|
29
|
+
*/
|
|
30
|
+
sfuClient: StreamSfuClient;
|
|
31
|
+
/**
|
|
32
|
+
* Constructs a new `Publisher` instance.
|
|
33
|
+
*
|
|
34
|
+
* @param connectionConfig the connection configuration to use.
|
|
35
|
+
* @param sfuClient the SFU client to use.
|
|
36
|
+
* @param state the call state to use.
|
|
37
|
+
* @param isDtxEnabled whether DTX is enabled.
|
|
38
|
+
* @param isRedEnabled whether RED is enabled.
|
|
39
|
+
* @param preferredVideoCodec the preferred video codec.
|
|
40
|
+
*/
|
|
27
41
|
constructor({ connectionConfig, sfuClient, state, isDtxEnabled, isRedEnabled, preferredVideoCodec, }: PublisherOpts);
|
|
42
|
+
private createPeerConnection;
|
|
43
|
+
/**
|
|
44
|
+
* Closes the publisher PeerConnection and cleans up the resources.
|
|
45
|
+
*/
|
|
46
|
+
close: ({ stopTracks }?: {
|
|
47
|
+
stopTracks?: boolean | undefined;
|
|
48
|
+
}) => void;
|
|
28
49
|
/**
|
|
29
50
|
* Starts publishing the given track of the given media stream.
|
|
30
51
|
*
|
|
@@ -51,25 +72,38 @@ export declare class Publisher {
|
|
|
51
72
|
private notifyTrackMuteStateChanged;
|
|
52
73
|
/**
|
|
53
74
|
* Stops publishing all tracks and stop all tracks.
|
|
54
|
-
*
|
|
55
|
-
* @param options - Options
|
|
56
|
-
* @param options.stopTracks - If `true` (default), all tracks will be stopped.
|
|
57
75
|
*/
|
|
58
|
-
stopPublishing: (
|
|
59
|
-
stopTracks?: boolean;
|
|
60
|
-
}) => void;
|
|
76
|
+
stopPublishing: () => void;
|
|
61
77
|
updateVideoPublishQuality: (enabledRids: string[]) => Promise<void>;
|
|
62
78
|
/**
|
|
63
79
|
* Returns the result of the `RTCPeerConnection.getStats()` method
|
|
64
80
|
* @param selector
|
|
65
81
|
* @returns
|
|
66
82
|
*/
|
|
67
|
-
getStats(selector?: MediaStreamTrack | null | undefined)
|
|
83
|
+
getStats: (selector?: MediaStreamTrack | null | undefined) => Promise<RTCStatsReport>;
|
|
68
84
|
private getCodecPreferences;
|
|
69
85
|
private onIceCandidate;
|
|
86
|
+
/**
|
|
87
|
+
* Performs a migration of this publisher instance to a new SFU.
|
|
88
|
+
*
|
|
89
|
+
* Initiates a new `iceRestart` offer/answer exchange with the new SFU.
|
|
90
|
+
*
|
|
91
|
+
* @param sfuClient the new SFU client to migrate to.
|
|
92
|
+
* @param connectionConfig the new connection configuration to use.
|
|
93
|
+
*/
|
|
94
|
+
migrateTo: (sfuClient: StreamSfuClient, connectionConfig?: RTCConfiguration) => Promise<void>;
|
|
70
95
|
private onNegotiationNeeded;
|
|
96
|
+
/**
|
|
97
|
+
* Initiates a new offer/answer exchange with the currently connected SFU.
|
|
98
|
+
*
|
|
99
|
+
* @param options the optional offer options to use.
|
|
100
|
+
*/
|
|
101
|
+
private negotiate;
|
|
102
|
+
private mungeCodecs;
|
|
103
|
+
getCurrentTrackInfos: (sdp?: string) => TrackInfo[];
|
|
71
104
|
private onIceCandidateError;
|
|
72
105
|
private onIceConnectionStateChange;
|
|
73
106
|
private onIceGatheringStateChange;
|
|
107
|
+
private onSignalingStateChange;
|
|
74
108
|
private ridToVideoQuality;
|
|
75
109
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { StreamSfuClient } from '../StreamSfuClient';
|
|
2
|
+
import { Dispatcher } from './Dispatcher';
|
|
3
|
+
import { CallState } from '../store';
|
|
4
|
+
export type SubscriberOpts = {
|
|
5
|
+
sfuClient: StreamSfuClient;
|
|
6
|
+
dispatcher: Dispatcher;
|
|
7
|
+
state: CallState;
|
|
8
|
+
connectionConfig?: RTCConfiguration;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A wrapper around the `RTCPeerConnection` that handles the incoming
|
|
12
|
+
* media streams from the SFU.
|
|
13
|
+
*/
|
|
14
|
+
export declare class Subscriber {
|
|
15
|
+
private pc;
|
|
16
|
+
private readonly unregisterOnSubscriberOffer;
|
|
17
|
+
private sfuClient;
|
|
18
|
+
private dispatcher;
|
|
19
|
+
private state;
|
|
20
|
+
/**
|
|
21
|
+
* Constructs a new `Subscriber` instance.
|
|
22
|
+
*
|
|
23
|
+
* @param sfuClient the SFU client to use.
|
|
24
|
+
* @param dispatcher the dispatcher to use.
|
|
25
|
+
* @param state the state of the call.
|
|
26
|
+
* @param connectionConfig the connection configuration to use.
|
|
27
|
+
*/
|
|
28
|
+
constructor({ sfuClient, dispatcher, state, connectionConfig, }: SubscriberOpts);
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new `RTCPeerConnection` instance with the given configuration.
|
|
31
|
+
*
|
|
32
|
+
* @param connectionConfig the connection configuration to use.
|
|
33
|
+
*/
|
|
34
|
+
private createPeerConnection;
|
|
35
|
+
/**
|
|
36
|
+
* Closes the `RTCPeerConnection` and unsubscribes from the dispatcher.
|
|
37
|
+
*/
|
|
38
|
+
close: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* Returns the result of the `RTCPeerConnection.getStats()` method
|
|
41
|
+
* @param selector
|
|
42
|
+
* @returns
|
|
43
|
+
*/
|
|
44
|
+
getStats: (selector?: MediaStreamTrack | null | undefined) => Promise<RTCStatsReport>;
|
|
45
|
+
/**
|
|
46
|
+
* Migrates the subscriber to a new SFU client.
|
|
47
|
+
*
|
|
48
|
+
* @param sfuClient the new SFU client to migrate to.
|
|
49
|
+
* @param connectionConfig the new connection configuration to use.
|
|
50
|
+
*/
|
|
51
|
+
migrateTo: (sfuClient: StreamSfuClient, connectionConfig?: RTCConfiguration) => void;
|
|
52
|
+
private handleOnTrack;
|
|
53
|
+
private onIceCandidate;
|
|
54
|
+
private negotiate;
|
|
55
|
+
private onIceConnectionStateChange;
|
|
56
|
+
private onIceGatheringStateChange;
|
|
57
|
+
private onIceCandidateError;
|
|
58
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import './mocks/webrtc.mocks';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JoinCallData } from '../../types';
|
|
1
|
+
import { JoinCallData, StreamVideoLocalParticipant, StreamVideoParticipant } from '../../types';
|
|
2
2
|
import { StreamClient } from '../../coordinator/connection/client';
|
|
3
3
|
/**
|
|
4
4
|
* Collects all necessary information to join a call, talks to the coordinator
|
|
@@ -17,3 +17,10 @@ export declare const join: (httpClient: StreamClient, type: string, id: string,
|
|
|
17
17
|
members: import("../../gen/coordinator").MemberResponse[];
|
|
18
18
|
ownCapabilities: import("../../gen/coordinator").OwnCapability[];
|
|
19
19
|
}>;
|
|
20
|
+
/**
|
|
21
|
+
* Reconciles the local state of the source participant into the target participant.
|
|
22
|
+
*
|
|
23
|
+
* @param target the participant to reconcile into.
|
|
24
|
+
* @param source the participant to reconcile from.
|
|
25
|
+
*/
|
|
26
|
+
export declare const reconcileParticipantLocalState: (target: StreamVideoParticipant | StreamVideoLocalParticipant, source?: StreamVideoParticipant | StreamVideoLocalParticipant) => StreamVideoParticipant | StreamVideoLocalParticipant;
|
package/dist/src/rtc/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from './codecs';
|
|
2
2
|
export * from './Dispatcher';
|
|
3
3
|
export * from './IceTrickleBuffer';
|
|
4
|
-
export * from './
|
|
5
|
-
export * from './
|
|
4
|
+
export * from './Publisher';
|
|
5
|
+
export * from './Subscriber';
|
|
6
6
|
export * from './signal';
|
|
7
7
|
export * from './videoLayers';
|
package/dist/src/rtc/signal.d.ts
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import type { StatsReport } from './types';
|
|
2
2
|
import { CallState } from '../store';
|
|
3
|
-
import { Publisher } from '../rtc';
|
|
3
|
+
import { Publisher, Subscriber } from '../rtc';
|
|
4
4
|
export type StatsReporterOpts = {
|
|
5
|
-
subscriber:
|
|
5
|
+
subscriber: Subscriber;
|
|
6
6
|
publisher: Publisher;
|
|
7
7
|
state: CallState;
|
|
8
8
|
pollingIntervalInMs?: number;
|
|
9
|
-
edgeName?: string;
|
|
10
9
|
};
|
|
11
10
|
export type StatsReporter = {
|
|
12
11
|
/**
|
|
@@ -44,7 +43,7 @@ export type StatsReporter = {
|
|
|
44
43
|
/**
|
|
45
44
|
* Creates a new StatsReporter instance that collects metrics about the ongoing call and reports them to the state store
|
|
46
45
|
*/
|
|
47
|
-
export declare const createStatsReporter: ({ subscriber, publisher, state,
|
|
46
|
+
export declare const createStatsReporter: ({ subscriber, publisher, state, pollingIntervalInMs, }: StatsReporterOpts) => StatsReporter;
|
|
48
47
|
export type StatsTransformOpts = {
|
|
49
48
|
/**
|
|
50
49
|
* The kind of track we are transforming stats for.
|
|
@@ -38,6 +38,10 @@ export declare enum CallingState {
|
|
|
38
38
|
* The call is in the process of reconnecting.
|
|
39
39
|
*/
|
|
40
40
|
RECONNECTING = "reconnecting",
|
|
41
|
+
/**
|
|
42
|
+
* The call is in the process of migrating from one node to another.
|
|
43
|
+
*/
|
|
44
|
+
MIGRATING = "migrating",
|
|
41
45
|
/**
|
|
42
46
|
* The call has failed to reconnect.
|
|
43
47
|
*/
|
|
@@ -393,6 +397,12 @@ export declare class CallState {
|
|
|
393
397
|
* @returns the participant with the given sessionId or undefined if not found.
|
|
394
398
|
*/
|
|
395
399
|
findParticipantBySessionId: (sessionId: string) => StreamVideoParticipant | undefined;
|
|
400
|
+
/**
|
|
401
|
+
* Returns a new lookup table of participants indexed by their session ID.
|
|
402
|
+
*/
|
|
403
|
+
getParticipantLookupBySessionId: () => {
|
|
404
|
+
[sessionId: string]: StreamVideoParticipant | StreamVideoLocalParticipant | undefined;
|
|
405
|
+
};
|
|
396
406
|
/**
|
|
397
407
|
* Updates a participant in the current call identified by the given `sessionId`.
|
|
398
408
|
* If the participant can't be found, this operation is no-op.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stream-io/video-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.30",
|
|
4
4
|
"packageManager": "yarn@3.2.4",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.es.js",
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"isomorphic-ws": "^5.0.0",
|
|
37
37
|
"jsonwebtoken": "^9.0.0",
|
|
38
38
|
"rxjs": "~7.8.1",
|
|
39
|
+
"sdp-transform": "^2.14.1",
|
|
39
40
|
"ua-parser-js": "^1.0.35",
|
|
40
41
|
"webrtc-adapter": "^8.2.2",
|
|
41
42
|
"ws": "^8.13.0"
|
|
@@ -46,6 +47,7 @@
|
|
|
46
47
|
"@rollup/plugin-typescript": "^11.1.0",
|
|
47
48
|
"@types/jsonwebtoken": "^9.0.1",
|
|
48
49
|
"@types/rimraf": "^3.0.2",
|
|
50
|
+
"@types/sdp-transform": "^2.4.6",
|
|
49
51
|
"@types/ua-parser-js": "^0.7.36",
|
|
50
52
|
"@types/ws": "^8.5.4",
|
|
51
53
|
"@vitest/coverage-c8": "^0.31.0",
|