@fishjam-cloud/ts-client 0.8.1 → 0.10.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/dist/index.d.mts +1308 -0
- package/dist/index.mjs +1 -0
- package/package.json +23 -33
- package/dist/src/FishjamClient.d.ts +0 -511
- package/dist/src/FishjamClient.js +0 -669
- package/dist/src/auth.d.ts +0 -3
- package/dist/src/auth.js +0 -8
- package/dist/src/connectEventsHandler.d.ts +0 -2
- package/dist/src/connectEventsHandler.js +0 -22
- package/dist/src/index.d.ts +0 -7
- package/dist/src/index.js +0 -3
- package/dist/src/protos/fishjam/peer_notifications.d.ts +0 -51
- package/dist/src/protos/fishjam/peer_notifications.js +0 -309
- package/dist/src/protos/index.d.ts +0 -1
- package/dist/src/protos/index.js +0 -1
- package/dist/src/reconnection.d.ts +0 -27
- package/dist/src/reconnection.js +0 -119
- package/dist/src/webrtc/CommandsQueue.d.ts +0 -23
- package/dist/src/webrtc/CommandsQueue.js +0 -87
- package/dist/src/webrtc/ConnectionManager.d.ts +0 -27
- package/dist/src/webrtc/ConnectionManager.js +0 -65
- package/dist/src/webrtc/bitrate.d.ts +0 -12
- package/dist/src/webrtc/bitrate.js +0 -12
- package/dist/src/webrtc/deferred.d.ts +0 -8
- package/dist/src/webrtc/deferred.js +0 -17
- package/dist/src/webrtc/index.d.ts +0 -3
- package/dist/src/webrtc/index.js +0 -1
- package/dist/src/webrtc/internal.d.ts +0 -26
- package/dist/src/webrtc/internal.js +0 -34
- package/dist/src/webrtc/mediaEvent.d.ts +0 -10
- package/dist/src/webrtc/mediaEvent.js +0 -16
- package/dist/src/webrtc/tracks/Local.d.ts +0 -50
- package/dist/src/webrtc/tracks/Local.js +0 -280
- package/dist/src/webrtc/tracks/LocalTrack.d.ts +0 -62
- package/dist/src/webrtc/tracks/LocalTrack.js +0 -225
- package/dist/src/webrtc/tracks/LocalTrackManager.d.ts +0 -38
- package/dist/src/webrtc/tracks/LocalTrackManager.js +0 -77
- package/dist/src/webrtc/tracks/Remote.d.ts +0 -38
- package/dist/src/webrtc/tracks/Remote.js +0 -200
- package/dist/src/webrtc/tracks/RemoteTrack.d.ts +0 -39
- package/dist/src/webrtc/tracks/RemoteTrack.js +0 -64
- package/dist/src/webrtc/tracks/TrackCommon.d.ts +0 -8
- package/dist/src/webrtc/tracks/TrackCommon.js +0 -1
- package/dist/src/webrtc/tracks/bandwidth.d.ts +0 -1
- package/dist/src/webrtc/tracks/bandwidth.js +0 -27
- package/dist/src/webrtc/tracks/encodings.d.ts +0 -1
- package/dist/src/webrtc/tracks/encodings.js +0 -5
- package/dist/src/webrtc/tracks/muteTrackUtils.d.ts +0 -3
- package/dist/src/webrtc/tracks/muteTrackUtils.js +0 -19
- package/dist/src/webrtc/tracks/transceivers.d.ts +0 -2
- package/dist/src/webrtc/tracks/transceivers.js +0 -91
- package/dist/src/webrtc/types.d.ts +0 -314
- package/dist/src/webrtc/types.js +0 -2
- package/dist/src/webrtc/voiceActivityDetection.d.ts +0 -2
- package/dist/src/webrtc/voiceActivityDetection.js +0 -2
- package/dist/src/webrtc/webRTCEndpoint.d.ts +0 -297
- package/dist/src/webrtc/webRTCEndpoint.js +0 -686
|
@@ -1,511 +0,0 @@
|
|
|
1
|
-
import type { BandwidthLimit, Encoding, Endpoint, MetadataParser, SimulcastConfig, TrackBandwidthLimit, TrackContext, WebRTCEndpointEvents } from './webrtc';
|
|
2
|
-
import type TypedEmitter from 'typed-emitter';
|
|
3
|
-
import type { ReconnectConfig } from './reconnection';
|
|
4
|
-
import type { AuthErrorReason } from './auth';
|
|
5
|
-
export type Peer<PeerMetadata, TrackMetadata> = Endpoint<PeerMetadata, TrackMetadata> & {
|
|
6
|
-
type: 'webrtc';
|
|
7
|
-
};
|
|
8
|
-
export type Component<PeerMetadata, TrackMetadata> = Omit<Endpoint<PeerMetadata, TrackMetadata>, 'type'> & {
|
|
9
|
-
type: 'recording' | 'hls' | 'file' | 'rtsp' | 'sip';
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Events emitted by the client with their arguments.
|
|
13
|
-
*/
|
|
14
|
-
export interface MessageEvents<PeerMetadata, TrackMetadata> {
|
|
15
|
-
/**
|
|
16
|
-
* Emitted when connect method invoked
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
connectionStarted: () => void;
|
|
20
|
-
/**
|
|
21
|
-
* Emitted when the websocket connection is closed
|
|
22
|
-
*
|
|
23
|
-
* @param {CloseEvent} event - Close event object from the websocket
|
|
24
|
-
*/
|
|
25
|
-
socketClose: (event: CloseEvent) => void;
|
|
26
|
-
/**
|
|
27
|
-
* Emitted when occurs an error in the websocket connection
|
|
28
|
-
*
|
|
29
|
-
* @param {Event} event - Event object from the websocket
|
|
30
|
-
*/
|
|
31
|
-
socketError: (event: Event) => void;
|
|
32
|
-
/**
|
|
33
|
-
* Emitted when the websocket connection is opened
|
|
34
|
-
*
|
|
35
|
-
* @param {Event} event - Event object from the websocket
|
|
36
|
-
*/
|
|
37
|
-
socketOpen: (event: Event) => void;
|
|
38
|
-
/** Emitted when authentication is successful */
|
|
39
|
-
authSuccess: () => void;
|
|
40
|
-
/** Emitted when authentication fails */
|
|
41
|
-
authError: (reason: AuthErrorReason) => void;
|
|
42
|
-
/** Emitted when the connection is closed */
|
|
43
|
-
disconnected: () => void;
|
|
44
|
-
/** Emitted when the process of reconnection starts */
|
|
45
|
-
reconnectionStarted: () => void;
|
|
46
|
-
/** Emitted on successful reconnection */
|
|
47
|
-
reconnected: () => void;
|
|
48
|
-
/** Emitted when the maximum number of reconnection retries is reached */
|
|
49
|
-
reconnectionRetriesLimitReached: () => void;
|
|
50
|
-
/**
|
|
51
|
-
* Called when peer was accepted.
|
|
52
|
-
*/
|
|
53
|
-
joined: (peerId: string, peers: Peer<PeerMetadata, TrackMetadata>[], components: Component<PeerMetadata, TrackMetadata>[]) => void;
|
|
54
|
-
/**
|
|
55
|
-
* Called when peer was not accepted
|
|
56
|
-
* @param metadata - Pass through for client application to communicate further actions to frontend
|
|
57
|
-
*/
|
|
58
|
-
joinError: (metadata: any) => void;
|
|
59
|
-
/**
|
|
60
|
-
* Called when data in a new track arrives.
|
|
61
|
-
*
|
|
62
|
-
* This callback is always called after {@link MessageEvents.trackAdded}.
|
|
63
|
-
* It informs user that data related to the given track arrives and can be played or displayed.
|
|
64
|
-
*/
|
|
65
|
-
trackReady: (ctx: TrackContext<PeerMetadata, TrackMetadata>) => void;
|
|
66
|
-
/**
|
|
67
|
-
* Called each time the peer which was already in the room, adds new track. Fields track and stream will be set to null.
|
|
68
|
-
* These fields will be set to non-null value in {@link MessageEvents.trackReady}
|
|
69
|
-
*/
|
|
70
|
-
trackAdded: (ctx: TrackContext<PeerMetadata, TrackMetadata>) => void;
|
|
71
|
-
/**
|
|
72
|
-
* Called when some track will no longer be sent.
|
|
73
|
-
*
|
|
74
|
-
* It will also be called before {@link MessageEvents.peerLeft} for each track of this peer.
|
|
75
|
-
*/
|
|
76
|
-
trackRemoved: (ctx: TrackContext<PeerMetadata, TrackMetadata>) => void;
|
|
77
|
-
/**
|
|
78
|
-
* Called each time peer has its track metadata updated.
|
|
79
|
-
*/
|
|
80
|
-
trackUpdated: (ctx: TrackContext<PeerMetadata, TrackMetadata>) => void;
|
|
81
|
-
/**
|
|
82
|
-
* Called each time new peer joins the room.
|
|
83
|
-
*/
|
|
84
|
-
peerJoined: (peer: Peer<PeerMetadata, TrackMetadata>) => void;
|
|
85
|
-
/**
|
|
86
|
-
* Called each time peer leaves the room.
|
|
87
|
-
*/
|
|
88
|
-
peerLeft: (peer: Peer<PeerMetadata, TrackMetadata>) => void;
|
|
89
|
-
/**
|
|
90
|
-
* Called each time peer has its metadata updated.
|
|
91
|
-
*/
|
|
92
|
-
peerUpdated: (peer: Peer<PeerMetadata, TrackMetadata>) => void;
|
|
93
|
-
/**
|
|
94
|
-
* Called each time new peer joins the room.
|
|
95
|
-
*/
|
|
96
|
-
componentAdded: (peer: Component<PeerMetadata, TrackMetadata>) => void;
|
|
97
|
-
/**
|
|
98
|
-
* Called each time peer leaves the room.
|
|
99
|
-
*/
|
|
100
|
-
componentRemoved: (peer: Component<PeerMetadata, TrackMetadata>) => void;
|
|
101
|
-
/**
|
|
102
|
-
* Called each time peer has its metadata updated.
|
|
103
|
-
*/
|
|
104
|
-
componentUpdated: (peer: Component<PeerMetadata, TrackMetadata>) => void;
|
|
105
|
-
/**
|
|
106
|
-
* Called in case of errors related to multimedia session e.g. ICE connection.
|
|
107
|
-
*/
|
|
108
|
-
connectionError: (error: {
|
|
109
|
-
message: string;
|
|
110
|
-
event?: Event;
|
|
111
|
-
}) => void;
|
|
112
|
-
/**
|
|
113
|
-
* Currently, this callback is only invoked when DisplayManager in RTC Engine is
|
|
114
|
-
* enabled and simulcast is disabled.
|
|
115
|
-
*
|
|
116
|
-
* Called when priority of video tracks have changed.
|
|
117
|
-
* @param enabledTracks - list of tracks which will be sent to client from SFU
|
|
118
|
-
* @param disabledTracks - list of tracks which will not be sent to client from SFU
|
|
119
|
-
*/
|
|
120
|
-
tracksPriorityChanged: (enabledTracks: TrackContext<PeerMetadata, TrackMetadata>[], disabledTracks: TrackContext<PeerMetadata, TrackMetadata>[]) => void;
|
|
121
|
-
/**
|
|
122
|
-
* Called every time the server estimates client's bandiwdth.
|
|
123
|
-
*
|
|
124
|
-
* @param {bigint} estimation - client's available incoming bitrate estimated
|
|
125
|
-
* by the server. It's measured in bits per second.
|
|
126
|
-
*/
|
|
127
|
-
bandwidthEstimationChanged: (estimation: bigint) => void;
|
|
128
|
-
targetTrackEncodingRequested: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['targetTrackEncodingRequested']>[0]) => void;
|
|
129
|
-
localTrackAdded: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['localTrackAdded']>[0]) => void;
|
|
130
|
-
localTrackRemoved: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['localTrackRemoved']>[0]) => void;
|
|
131
|
-
localTrackReplaced: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['localTrackReplaced']>[0]) => void;
|
|
132
|
-
localTrackMuted: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['localTrackMuted']>[0]) => void;
|
|
133
|
-
localTrackUnmuted: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['localTrackUnmuted']>[0]) => void;
|
|
134
|
-
localTrackBandwidthSet: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['localTrackBandwidthSet']>[0]) => void;
|
|
135
|
-
localTrackEncodingBandwidthSet: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['localTrackEncodingBandwidthSet']>[0]) => void;
|
|
136
|
-
localTrackEncodingEnabled: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['localTrackEncodingEnabled']>[0]) => void;
|
|
137
|
-
localTrackEncodingDisabled: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['localTrackEncodingDisabled']>[0]) => void;
|
|
138
|
-
localPeerMetadataChanged: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['localEndpointMetadataChanged']>[0]) => void;
|
|
139
|
-
localTrackMetadataChanged: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['localTrackMetadataChanged']>[0]) => void;
|
|
140
|
-
disconnectRequested: (event: Parameters<WebRTCEndpointEvents<PeerMetadata, TrackMetadata>['disconnectRequested']>[0]) => void;
|
|
141
|
-
}
|
|
142
|
-
/** Configuration object for the client */
|
|
143
|
-
export interface ConnectConfig<PeerMetadata> {
|
|
144
|
-
/** Metadata for the peer */
|
|
145
|
-
peerMetadata: PeerMetadata;
|
|
146
|
-
/** Token for authentication */
|
|
147
|
-
token: string;
|
|
148
|
-
/** Fishjam url */
|
|
149
|
-
url: string;
|
|
150
|
-
}
|
|
151
|
-
export type CreateConfig<PeerMetadata, TrackMetadata> = {
|
|
152
|
-
peerMetadataParser?: MetadataParser<PeerMetadata>;
|
|
153
|
-
trackMetadataParser?: MetadataParser<TrackMetadata>;
|
|
154
|
-
reconnect?: ReconnectConfig | boolean;
|
|
155
|
-
};
|
|
156
|
-
declare const FishjamClient_base: new <PeerMetadata_1, TrackMetadata_1>() => TypedEmitter<Required<MessageEvents<PeerMetadata_1, TrackMetadata_1>>>;
|
|
157
|
-
/**
|
|
158
|
-
* FishjamClient is the main class to interact with Fishjam.
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* ```typescript
|
|
162
|
-
* const client = new FishjamClient<PeerMetadata, TrackMetadata>();
|
|
163
|
-
* const peerToken = "YOUR_PEER_TOKEN";
|
|
164
|
-
*
|
|
165
|
-
* // You can listen to events emitted by the client
|
|
166
|
-
* client.on("joined", (peerId, peersInRoom) => {
|
|
167
|
-
* console.log("join success");
|
|
168
|
-
* });
|
|
169
|
-
*
|
|
170
|
-
* // Start the peer connection
|
|
171
|
-
* client.connect({
|
|
172
|
-
* peerMetadata: {},
|
|
173
|
-
* isSimulcastOn: false,
|
|
174
|
-
* token: peerToken
|
|
175
|
-
* });
|
|
176
|
-
*
|
|
177
|
-
* // Close the peer connection
|
|
178
|
-
* client.disconnect();
|
|
179
|
-
* ```
|
|
180
|
-
*
|
|
181
|
-
* You can register callbacks to handle the events emitted by the Client.
|
|
182
|
-
*
|
|
183
|
-
* @example
|
|
184
|
-
* ```typescript
|
|
185
|
-
*
|
|
186
|
-
* client.on("trackReady", (ctx) => {
|
|
187
|
-
* console.log("On track ready");
|
|
188
|
-
* });
|
|
189
|
-
* ```
|
|
190
|
-
*/
|
|
191
|
-
export declare class FishjamClient<PeerMetadata, TrackMetadata> extends FishjamClient_base<PeerMetadata, TrackMetadata> {
|
|
192
|
-
private websocket;
|
|
193
|
-
private webrtc;
|
|
194
|
-
private removeEventListeners;
|
|
195
|
-
status: 'new' | 'initialized';
|
|
196
|
-
private connectConfig;
|
|
197
|
-
private reconnectManager;
|
|
198
|
-
private sendStatisticsInterval;
|
|
199
|
-
private readonly peerMetadataParser;
|
|
200
|
-
private readonly trackMetadataParser;
|
|
201
|
-
constructor(config?: CreateConfig<PeerMetadata, TrackMetadata>);
|
|
202
|
-
/**
|
|
203
|
-
* Uses the {@link !WebSocket} connection and {@link !WebRTCEndpoint | WebRTCEndpoint} to join to the room. Registers the callbacks to
|
|
204
|
-
* handle the events emitted by the {@link !WebRTCEndpoint | WebRTCEndpoint}. Make sure that peer metadata is serializable.
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* ```typescript
|
|
208
|
-
* const client = new FishjamClient<PeerMetadata, TrackMetadata>();
|
|
209
|
-
*
|
|
210
|
-
* client.connect({
|
|
211
|
-
* peerMetadata: {},
|
|
212
|
-
* token: peerToken
|
|
213
|
-
* });
|
|
214
|
-
* ```
|
|
215
|
-
*
|
|
216
|
-
* @param {ConnectConfig} config - Configuration object for the client
|
|
217
|
-
*/
|
|
218
|
-
connect(config: ConnectConfig<PeerMetadata>): Promise<void>;
|
|
219
|
-
private initConnection;
|
|
220
|
-
private getUrl;
|
|
221
|
-
private initWebsocket;
|
|
222
|
-
/**
|
|
223
|
-
* Retrieves statistics related to the RTCPeerConnection.
|
|
224
|
-
* These statistics provide insights into the performance and status of the connection.
|
|
225
|
-
*
|
|
226
|
-
* @return {Promise<RTCStatsReport>}
|
|
227
|
-
*
|
|
228
|
-
* @external RTCPeerConnection#getStats()
|
|
229
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getStats | MDN Web Docs: RTCPeerConnection.getStats()}
|
|
230
|
-
*/
|
|
231
|
-
getStatistics(selector?: MediaStreamTrack | null): Promise<RTCStatsReport>;
|
|
232
|
-
/**
|
|
233
|
-
* Returns a snapshot of currently received remote tracks.
|
|
234
|
-
*
|
|
235
|
-
* @example
|
|
236
|
-
* if (client.getRemoteTracks()[trackId]?.simulcastConfig?.enabled) {
|
|
237
|
-
* client.setTargetTrackEncoding(trackId, encoding);
|
|
238
|
-
* }
|
|
239
|
-
*/
|
|
240
|
-
getRemoteTracks(): Readonly<Record<string, TrackContext<PeerMetadata, TrackMetadata>>>;
|
|
241
|
-
/**
|
|
242
|
-
* Returns a snapshot of currently received remote peers.
|
|
243
|
-
*/
|
|
244
|
-
getRemotePeers(): Record<string, Peer<PeerMetadata, TrackMetadata>>;
|
|
245
|
-
getRemoteComponents(): Record<string, Component<PeerMetadata, TrackMetadata>>;
|
|
246
|
-
getLocalPeer(): Endpoint<PeerMetadata, TrackMetadata> | null;
|
|
247
|
-
getBandwidthEstimation(): bigint;
|
|
248
|
-
private setupCallbacks;
|
|
249
|
-
private sendStatistics;
|
|
250
|
-
/**
|
|
251
|
-
* Register a callback to be called when the event is emitted.
|
|
252
|
-
* Full list of callbacks can be found here {@link MessageEvents}.
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* ```ts
|
|
256
|
-
* const callback = ()=>{ };
|
|
257
|
-
*
|
|
258
|
-
* client.on("onJoinSuccess", callback);
|
|
259
|
-
* ```
|
|
260
|
-
*
|
|
261
|
-
* @param event - Event name from {@link MessageEvents}
|
|
262
|
-
* @param listener - Callback function to be called when the event is emitted
|
|
263
|
-
* @returns This
|
|
264
|
-
*/
|
|
265
|
-
on<E extends keyof MessageEvents<PeerMetadata, TrackMetadata>>(event: E, listener: Required<MessageEvents<PeerMetadata, TrackMetadata>>[E]): this;
|
|
266
|
-
/**
|
|
267
|
-
* Remove a callback from the list of callbacks to be called when the event is emitted.
|
|
268
|
-
*
|
|
269
|
-
* @example
|
|
270
|
-
* ```ts
|
|
271
|
-
* const callback = ()=>{ };
|
|
272
|
-
*
|
|
273
|
-
* client.on("onJoinSuccess", callback);
|
|
274
|
-
*
|
|
275
|
-
* client.off("onJoinSuccess", callback);
|
|
276
|
-
* ```
|
|
277
|
-
*
|
|
278
|
-
* @param event - Event name from {@link MessageEvents}
|
|
279
|
-
* @param listener - Reference to function to be removed from called callbacks
|
|
280
|
-
* @returns This
|
|
281
|
-
*/
|
|
282
|
-
off<E extends keyof MessageEvents<PeerMetadata, TrackMetadata>>(event: E, listener: Required<MessageEvents<PeerMetadata, TrackMetadata>>[E]): this;
|
|
283
|
-
private handleWebRTCNotInitialized;
|
|
284
|
-
/**
|
|
285
|
-
* Adds track that will be sent to the RTC Engine.
|
|
286
|
-
*
|
|
287
|
-
* @example
|
|
288
|
-
* ```ts
|
|
289
|
-
* const localStream: MediaStream = new MediaStream();
|
|
290
|
-
* try {
|
|
291
|
-
* const localAudioStream = await navigator.mediaDevices.getUserMedia(
|
|
292
|
-
* { audio: true }
|
|
293
|
-
* );
|
|
294
|
-
* localAudioStream
|
|
295
|
-
* .getTracks()
|
|
296
|
-
* .forEach((track) => localStream.addTrack(track));
|
|
297
|
-
* } catch (error) {
|
|
298
|
-
* console.error("Couldn't get microphone permission:", error);
|
|
299
|
-
* }
|
|
300
|
-
*
|
|
301
|
-
* try {
|
|
302
|
-
* const localVideoStream = await navigator.mediaDevices.getUserMedia(
|
|
303
|
-
* { video: true }
|
|
304
|
-
* );
|
|
305
|
-
* localVideoStream
|
|
306
|
-
* .getTracks()
|
|
307
|
-
* .forEach((track) => localStream.addTrack(track));
|
|
308
|
-
* } catch (error) {
|
|
309
|
-
* console.error("Couldn't get camera permission:", error);
|
|
310
|
-
* }
|
|
311
|
-
*
|
|
312
|
-
* localStream
|
|
313
|
-
* .getTracks()
|
|
314
|
-
* .forEach((track) => client.addTrack(track, localStream));
|
|
315
|
-
* ```
|
|
316
|
-
*
|
|
317
|
-
* @param track - Audio or video track e.g. from your microphone or camera.
|
|
318
|
-
* @param stream - Stream that this track belongs to.
|
|
319
|
-
* @param trackMetadata - Any information about this track that other peers will receive in
|
|
320
|
-
* {@link MessageEvents.peerJoined}. E.g. this can source of the track - wheather it's screensharing, webcam or some
|
|
321
|
-
* other media device.
|
|
322
|
-
* @param simulcastConfig - Simulcast configuration. By default, simulcast is disabled. For more information refer to
|
|
323
|
-
* {@link !SimulcastConfig | SimulcastConfig}.
|
|
324
|
-
* @param maxBandwidth - Maximal bandwidth this track can use. Defaults to 0 which is unlimited. This option has no
|
|
325
|
-
* effect for simulcast and audio tracks. For simulcast tracks use {@link FishjamClient.setTrackBandwidth}.
|
|
326
|
-
* @returns {string} Returns id of added track
|
|
327
|
-
*/
|
|
328
|
-
addTrack(track: MediaStreamTrack, trackMetadata?: TrackMetadata, simulcastConfig?: SimulcastConfig, maxBandwidth?: TrackBandwidthLimit): Promise<string>;
|
|
329
|
-
/**
|
|
330
|
-
* Replaces a track that is being sent to the RTC Engine.
|
|
331
|
-
*
|
|
332
|
-
* @example
|
|
333
|
-
* ```ts
|
|
334
|
-
* // setup camera
|
|
335
|
-
* let localStream: MediaStream = new MediaStream();
|
|
336
|
-
* try {
|
|
337
|
-
* localVideoStream = await navigator.mediaDevices.getUserMedia(
|
|
338
|
-
* VIDEO_CONSTRAINTS
|
|
339
|
-
* );
|
|
340
|
-
* localVideoStream
|
|
341
|
-
* .getTracks()
|
|
342
|
-
* .forEach((track) => localStream.addTrack(track));
|
|
343
|
-
* } catch (error) {
|
|
344
|
-
* console.error("Couldn't get camera permission:", error);
|
|
345
|
-
* }
|
|
346
|
-
* let oldTrackId;
|
|
347
|
-
* localStream
|
|
348
|
-
* .getTracks()
|
|
349
|
-
* .forEach((track) => trackId = webrtc.addTrack(track, localStream));
|
|
350
|
-
*
|
|
351
|
-
* // change camera
|
|
352
|
-
* const oldTrack = localStream.getVideoTracks()[0];
|
|
353
|
-
* let videoDeviceId = "abcd-1234";
|
|
354
|
-
* navigator.mediaDevices.getUserMedia({
|
|
355
|
-
* video: {
|
|
356
|
-
* ...(VIDEO_CONSTRAINTS as {}),
|
|
357
|
-
* deviceId: {
|
|
358
|
-
* exact: videoDeviceId,
|
|
359
|
-
* },
|
|
360
|
-
* }
|
|
361
|
-
* })
|
|
362
|
-
* .then((stream) => {
|
|
363
|
-
* let videoTrack = stream.getVideoTracks()[0];
|
|
364
|
-
* webrtc.replaceTrack(oldTrackId, videoTrack);
|
|
365
|
-
* })
|
|
366
|
-
* .catch((error) => {
|
|
367
|
-
* console.error('Error switching camera', error);
|
|
368
|
-
* })
|
|
369
|
-
* ```
|
|
370
|
-
*
|
|
371
|
-
* @param {string} trackId - Id of audio or video track to replace.
|
|
372
|
-
* @param {MediaStreamTrack} newTrack - New audio or video track.
|
|
373
|
-
* @returns {Promise<boolean>} Success
|
|
374
|
-
*/
|
|
375
|
-
replaceTrack(trackId: string, newTrack: MediaStreamTrack | null): Promise<void>;
|
|
376
|
-
/**
|
|
377
|
-
* Updates maximum bandwidth for the track identified by trackId. This value directly translates to quality of the
|
|
378
|
-
* stream and, in case of video, to the amount of RTP packets being sent. In case trackId points at the simulcast
|
|
379
|
-
* track bandwidth is split between all of the variant streams proportionally to their resolution.
|
|
380
|
-
*
|
|
381
|
-
* @param {string} trackId
|
|
382
|
-
* @param {BandwidthLimit} bandwidth In kbps
|
|
383
|
-
* @returns {Promise<boolean>} Success
|
|
384
|
-
*/
|
|
385
|
-
setTrackBandwidth(trackId: string, bandwidth: BandwidthLimit): Promise<boolean>;
|
|
386
|
-
/**
|
|
387
|
-
* Updates maximum bandwidth for the given simulcast encoding of the given track.
|
|
388
|
-
*
|
|
389
|
-
* @param {string} trackId - Id of the track
|
|
390
|
-
* @param {string} rid - Rid of the encoding
|
|
391
|
-
* @param {BandwidthLimit} bandwidth - Desired max bandwidth used by the encoding (in kbps)
|
|
392
|
-
* @returns
|
|
393
|
-
*/
|
|
394
|
-
setEncodingBandwidth(trackId: string, rid: string, bandwidth: BandwidthLimit): Promise<boolean>;
|
|
395
|
-
/**
|
|
396
|
-
* Removes a track from connection that was being sent to the RTC Engine.
|
|
397
|
-
*
|
|
398
|
-
* @example
|
|
399
|
-
* ```ts
|
|
400
|
-
* // setup camera
|
|
401
|
-
* let localStream: MediaStream = new MediaStream();
|
|
402
|
-
* try {
|
|
403
|
-
* localVideoStream = await navigator.mediaDevices.getUserMedia(
|
|
404
|
-
* VIDEO_CONSTRAINTS
|
|
405
|
-
* );
|
|
406
|
-
* localVideoStream
|
|
407
|
-
* .getTracks()
|
|
408
|
-
* .forEach((track) => localStream.addTrack(track));
|
|
409
|
-
* } catch (error) {
|
|
410
|
-
* console.error("Couldn't get camera permission:", error);
|
|
411
|
-
* }
|
|
412
|
-
*
|
|
413
|
-
* let trackId
|
|
414
|
-
* localStream
|
|
415
|
-
* .getTracks()
|
|
416
|
-
* .forEach((track) => trackId = webrtc.addTrack(track, localStream));
|
|
417
|
-
*
|
|
418
|
-
* // remove track
|
|
419
|
-
* webrtc.removeTrack(trackId)
|
|
420
|
-
* ```
|
|
421
|
-
*
|
|
422
|
-
* @param {string} trackId - Id of audio or video track to remove.
|
|
423
|
-
*/
|
|
424
|
-
removeTrack(trackId: string): Promise<void>;
|
|
425
|
-
/**
|
|
426
|
-
* Sets track encoding that server should send to the client library.
|
|
427
|
-
*
|
|
428
|
-
* The encoding will be sent whenever it is available. If chosen encoding is temporarily unavailable, some other
|
|
429
|
-
* encoding will be sent until chosen encoding becomes active again.
|
|
430
|
-
*
|
|
431
|
-
* @example
|
|
432
|
-
* ```ts
|
|
433
|
-
* webrtc.setTargetTrackEncoding(incomingTrackCtx.trackId, "l")
|
|
434
|
-
* ```
|
|
435
|
-
*
|
|
436
|
-
* @param {string} trackId - Id of track
|
|
437
|
-
* @param {Encoding} encoding - Encoding to receive
|
|
438
|
-
*/
|
|
439
|
-
setTargetTrackEncoding(trackId: string, encoding: Encoding): void;
|
|
440
|
-
/**
|
|
441
|
-
* Enables track encoding so that it will be sent to the server.
|
|
442
|
-
*
|
|
443
|
-
* @example
|
|
444
|
-
* ```ts
|
|
445
|
-
* const trackId = webrtc.addTrack(track, stream, {}, {enabled: true, active_encodings: ["l", "m", "h"]});
|
|
446
|
-
* webrtc.disableTrackEncoding(trackId, "l");
|
|
447
|
-
* // wait some time
|
|
448
|
-
* webrtc.enableTrackEncoding(trackId, "l");
|
|
449
|
-
* ```
|
|
450
|
-
*
|
|
451
|
-
* @param {string} trackId - Id of track
|
|
452
|
-
* @param {Encoding} encoding - Encoding that will be enabled
|
|
453
|
-
*/
|
|
454
|
-
enableTrackEncoding(trackId: string, encoding: Encoding): Promise<void>;
|
|
455
|
-
/**
|
|
456
|
-
* Disables track encoding so that it will be no longer sent to the server.
|
|
457
|
-
*
|
|
458
|
-
* @example
|
|
459
|
-
* ```ts
|
|
460
|
-
* const trackId = webrtc.addTrack(track, stream, {}, {enabled: true, active_encodings: ["l", "m", "h"]});
|
|
461
|
-
* webrtc.disableTrackEncoding(trackId, "l");
|
|
462
|
-
* ```
|
|
463
|
-
*
|
|
464
|
-
* @param {string} trackId - Id of track
|
|
465
|
-
* @param {rackEncoding} encoding - Encoding that will be disabled
|
|
466
|
-
*/
|
|
467
|
-
disableTrackEncoding(trackId: string, encoding: Encoding): Promise<void>;
|
|
468
|
-
/**
|
|
469
|
-
* Updates the metadata for the current peer.
|
|
470
|
-
*
|
|
471
|
-
* @param peerMetadata - Data about this peer that other peers will receive upon joining.
|
|
472
|
-
*
|
|
473
|
-
* If the metadata is different from what is already tracked in the room, the event {@link MessageEvents.peerUpdated} will
|
|
474
|
-
* be emitted for other peers in the room.
|
|
475
|
-
*/
|
|
476
|
-
updatePeerMetadata: (peerMetadata: PeerMetadata) => void;
|
|
477
|
-
/**
|
|
478
|
-
* Updates the metadata for a specific track.
|
|
479
|
-
*
|
|
480
|
-
* @param trackId - TrackId (generated in addTrack) of audio or video track.
|
|
481
|
-
* @param trackMetadata - Data about this track that other peers will receive upon joining.
|
|
482
|
-
*
|
|
483
|
-
* If the metadata is different from what is already tracked in the room, the event {@link MessageEvents.trackUpdated} will
|
|
484
|
-
* be emitted for other peers in the room.
|
|
485
|
-
*/
|
|
486
|
-
updateTrackMetadata: (trackId: string, trackMetadata: TrackMetadata) => void;
|
|
487
|
-
isReconnecting(): boolean;
|
|
488
|
-
/**
|
|
489
|
-
* Leaves the room. This function should be called when user leaves the room in a clean way e.g. by clicking a
|
|
490
|
-
* dedicated, custom button `disconnect`. As a result there will be generated one more media event that should be sent
|
|
491
|
-
* to the RTC Engine. Thanks to it each other peer will be notified that peer left in {@link MessageEvents.peerLeft},
|
|
492
|
-
*/
|
|
493
|
-
leave: () => void;
|
|
494
|
-
private isOpen;
|
|
495
|
-
/**
|
|
496
|
-
* Disconnect from the room, and close the websocket connection. Tries to leave the room gracefully, but if it fails,
|
|
497
|
-
* it will close the websocket anyway.
|
|
498
|
-
*
|
|
499
|
-
* @example
|
|
500
|
-
* ```typescript
|
|
501
|
-
* const client = new FishjamClient<PeerMetadata, TrackMetadata>();
|
|
502
|
-
*
|
|
503
|
-
* client.connect({ ... });
|
|
504
|
-
*
|
|
505
|
-
* client.disconnect();
|
|
506
|
-
* ```
|
|
507
|
-
*/
|
|
508
|
-
disconnect(): void;
|
|
509
|
-
cleanup(): void;
|
|
510
|
-
}
|
|
511
|
-
export {};
|