@fishjam-cloud/ts-client 0.9.0 → 0.10.1
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 -510
- package/dist/src/FishjamClient.js +0 -668
- 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 -28
- package/dist/src/webrtc/ConnectionManager.js +0 -71
- 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 -286
- package/dist/src/webrtc/tracks/LocalTrack.d.ts +0 -61
- package/dist/src/webrtc/tracks/LocalTrack.js +0 -218
- 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 -691
|
@@ -1,297 +0,0 @@
|
|
|
1
|
-
import type { MediaEvent, SerializedMediaEvent } from './mediaEvent';
|
|
2
|
-
import type TypedEmitter from 'typed-emitter';
|
|
3
|
-
import type { BandwidthLimit, Config, Encoding, SimulcastConfig, TrackBandwidthLimit, TrackContext, WebRTCEndpointEvents } from './types';
|
|
4
|
-
import type { EndpointWithTrackContext } from './internal';
|
|
5
|
-
import { ConnectionManager } from './ConnectionManager';
|
|
6
|
-
declare const WebRTCEndpoint_base: new <EndpointMetadata_1, TrackMetadata_1>() => TypedEmitter<Required<WebRTCEndpointEvents<EndpointMetadata_1, TrackMetadata_1>>>;
|
|
7
|
-
/**
|
|
8
|
-
* Main class that is responsible for connecting to the RTC Engine, sending and receiving media.
|
|
9
|
-
*/
|
|
10
|
-
export declare class WebRTCEndpoint<EndpointMetadata = any, TrackMetadata = any> extends WebRTCEndpoint_base<EndpointMetadata, TrackMetadata> {
|
|
11
|
-
private readonly endpointMetadataParser;
|
|
12
|
-
private readonly trackMetadataParser;
|
|
13
|
-
private readonly localTrackManager;
|
|
14
|
-
private readonly remote;
|
|
15
|
-
private readonly local;
|
|
16
|
-
private readonly commandsQueue;
|
|
17
|
-
bandwidthEstimation: bigint;
|
|
18
|
-
connectionManager?: ConnectionManager;
|
|
19
|
-
private clearConnectionCallbacks;
|
|
20
|
-
constructor(config?: Config<EndpointMetadata, TrackMetadata>);
|
|
21
|
-
/**
|
|
22
|
-
* Tries to connect to the RTC Engine. If user is successfully connected then {@link WebRTCEndpointEvents.connected}
|
|
23
|
-
* will be emitted.
|
|
24
|
-
*
|
|
25
|
-
* @param metadata - Any information that other endpoints will receive in {@link WebRTCEndpointEvents.endpointAdded}
|
|
26
|
-
* after accepting this endpoint
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* ```ts
|
|
30
|
-
* let webrtc = new WebRTCEndpoint();
|
|
31
|
-
* webrtc.connect({displayName: "Bob"});
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
connect: (metadata: EndpointMetadata) => void;
|
|
35
|
-
/**
|
|
36
|
-
* Feeds media event received from RTC Engine to {@link WebRTCEndpoint}.
|
|
37
|
-
* This function should be called whenever some media event from RTC Engine
|
|
38
|
-
* was received and can result in {@link WebRTCEndpoint} generating some other
|
|
39
|
-
* media events.
|
|
40
|
-
*
|
|
41
|
-
* @param mediaEvent - String data received over custom signalling layer.
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* This example assumes phoenix channels as signalling layer.
|
|
45
|
-
* As phoenix channels require objects, RTC Engine encapsulates binary data into
|
|
46
|
-
* map with one field that is converted to object with one field on the TS side.
|
|
47
|
-
* ```ts
|
|
48
|
-
* webrtcChannel.on("mediaEvent", (event) => webrtc.receiveMediaEvent(event.data));
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
receiveMediaEvent: (mediaEvent: SerializedMediaEvent) => Promise<void>;
|
|
52
|
-
private getEndpointId;
|
|
53
|
-
private onTrackReady;
|
|
54
|
-
/**
|
|
55
|
-
* Retrieves statistics related to the RTCPeerConnection.
|
|
56
|
-
* These statistics provide insights into the performance and status of the connection.
|
|
57
|
-
*
|
|
58
|
-
* @return {Promise<RTCStatsReport>}
|
|
59
|
-
*
|
|
60
|
-
* @external RTCPeerConnection#getStats()
|
|
61
|
-
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/getStats | MDN Web Docs: RTCPeerConnection.getStats()}
|
|
62
|
-
*/
|
|
63
|
-
getStatistics(selector?: MediaStreamTrack | null): Promise<RTCStatsReport>;
|
|
64
|
-
/**
|
|
65
|
-
* Returns a snapshot of currently received remote tracks.
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* if (webRTCEndpoint.getRemoteTracks()[trackId]?.simulcastConfig?.enabled) {
|
|
69
|
-
* webRTCEndpoint.setTargetTrackEncoding(trackId, encoding);
|
|
70
|
-
* }
|
|
71
|
-
*/
|
|
72
|
-
getRemoteTracks(): Record<string, TrackContext<EndpointMetadata, TrackMetadata>>;
|
|
73
|
-
/**
|
|
74
|
-
* Returns a snapshot of currently received remote endpoints.
|
|
75
|
-
*/
|
|
76
|
-
getRemoteEndpoints(): Record<string, EndpointWithTrackContext<EndpointMetadata, TrackMetadata>>;
|
|
77
|
-
getLocalEndpoint(): EndpointWithTrackContext<EndpointMetadata, TrackMetadata>;
|
|
78
|
-
getBandwidthEstimation(): bigint;
|
|
79
|
-
private handleMediaEvent;
|
|
80
|
-
private onSdpAnswer;
|
|
81
|
-
/**
|
|
82
|
-
* Adds track that will be sent to the RTC Engine.
|
|
83
|
-
* @param track - Audio or video track e.g. from your microphone or camera.
|
|
84
|
-
* @param trackMetadata - Any information about this track that other endpoints will
|
|
85
|
-
* receive in {@link WebRTCEndpointEvents.endpointAdded}. E.g. this can source of the track - whether it's
|
|
86
|
-
* screensharing, webcam or some other media device.
|
|
87
|
-
* @param simulcastConfig - Simulcast configuration. By default simulcast is disabled.
|
|
88
|
-
* For more information refer to {@link SimulcastConfig}.
|
|
89
|
-
* @param maxBandwidth - maximal bandwidth this track can use.
|
|
90
|
-
* Defaults to 0 which is unlimited.
|
|
91
|
-
* This option has no effect for simulcast and audio tracks.
|
|
92
|
-
* For simulcast tracks use `{@link WebRTCEndpoint.setTrackBandwidth}.
|
|
93
|
-
* @returns {string} Returns id of added track
|
|
94
|
-
* @example
|
|
95
|
-
* ```ts
|
|
96
|
-
* let localStream: MediaStream = new MediaStream();
|
|
97
|
-
* try {
|
|
98
|
-
* localAudioStream = await navigator.mediaDevices.getUserMedia(
|
|
99
|
-
* AUDIO_CONSTRAINTS
|
|
100
|
-
* );
|
|
101
|
-
* localAudioStream
|
|
102
|
-
* .getTracks()
|
|
103
|
-
* .forEach((track) => localStream.addTrack(track));
|
|
104
|
-
* } catch (error) {
|
|
105
|
-
* console.error("Couldn't get microphone permission:", error);
|
|
106
|
-
* }
|
|
107
|
-
*
|
|
108
|
-
* try {
|
|
109
|
-
* localVideoStream = await navigator.mediaDevices.getUserMedia(
|
|
110
|
-
* VIDEO_CONSTRAINTS
|
|
111
|
-
* );
|
|
112
|
-
* localVideoStream
|
|
113
|
-
* .getTracks()
|
|
114
|
-
* .forEach((track) => localStream.addTrack(track));
|
|
115
|
-
* } catch (error) {
|
|
116
|
-
* console.error("Couldn't get camera permission:", error);
|
|
117
|
-
* }
|
|
118
|
-
*
|
|
119
|
-
* localStream
|
|
120
|
-
* .getTracks()
|
|
121
|
-
* .forEach((track) => webrtc.addTrack(track, localStream));
|
|
122
|
-
* ```
|
|
123
|
-
*/
|
|
124
|
-
addTrack(track: MediaStreamTrack, trackMetadata?: TrackMetadata, simulcastConfig?: SimulcastConfig, maxBandwidth?: TrackBandwidthLimit): Promise<string>;
|
|
125
|
-
/**
|
|
126
|
-
* Replaces a track that is being sent to the RTC Engine.
|
|
127
|
-
* @param trackId - Audio or video track.
|
|
128
|
-
* @param {string} trackId - Id of audio or video track to replace.
|
|
129
|
-
* @param {MediaStreamTrack} newTrack
|
|
130
|
-
* @returns {Promise<boolean>} success
|
|
131
|
-
* @example
|
|
132
|
-
* ```ts
|
|
133
|
-
* // setup camera
|
|
134
|
-
* let localStream: MediaStream = new MediaStream();
|
|
135
|
-
* try {
|
|
136
|
-
* localVideoStream = await navigator.mediaDevices.getUserMedia(
|
|
137
|
-
* VIDEO_CONSTRAINTS
|
|
138
|
-
* );
|
|
139
|
-
* localVideoStream
|
|
140
|
-
* .getTracks()
|
|
141
|
-
* .forEach((track) => localStream.addTrack(track));
|
|
142
|
-
* } catch (error) {
|
|
143
|
-
* console.error("Couldn't get camera permission:", error);
|
|
144
|
-
* }
|
|
145
|
-
* let oldTrackId;
|
|
146
|
-
* localStream
|
|
147
|
-
* .getTracks()
|
|
148
|
-
* .forEach((track) => trackId = webrtc.addTrack(track, localStream));
|
|
149
|
-
*
|
|
150
|
-
* // change camera
|
|
151
|
-
* const oldTrack = localStream.getVideoTracks()[0];
|
|
152
|
-
* let videoDeviceId = "abcd-1234";
|
|
153
|
-
* navigator.mediaDevices.getUserMedia({
|
|
154
|
-
* video: {
|
|
155
|
-
* ...(VIDEO_CONSTRAINTS as {}),
|
|
156
|
-
* deviceId: {
|
|
157
|
-
* exact: videoDeviceId,
|
|
158
|
-
* },
|
|
159
|
-
* }
|
|
160
|
-
* })
|
|
161
|
-
* .then((stream) => {
|
|
162
|
-
* let videoTrack = stream.getVideoTracks()[0];
|
|
163
|
-
* webrtc.replaceTrack(oldTrackId, videoTrack);
|
|
164
|
-
* })
|
|
165
|
-
* .catch((error) => {
|
|
166
|
-
* console.error('Error switching camera', error);
|
|
167
|
-
* })
|
|
168
|
-
* ```
|
|
169
|
-
*/
|
|
170
|
-
replaceTrack(trackId: string, newTrack: MediaStreamTrack | null): Promise<void>;
|
|
171
|
-
/**
|
|
172
|
-
* Updates maximum bandwidth for the track identified by trackId.
|
|
173
|
-
* This value directly translates to quality of the stream and, in case of video, to the amount of RTP packets being sent.
|
|
174
|
-
* In case trackId points at the simulcast track bandwidth is split between all of the variant streams proportionally to their resolution.
|
|
175
|
-
*
|
|
176
|
-
* @param {string} trackId
|
|
177
|
-
* @param {BandwidthLimit} bandwidth in kbps
|
|
178
|
-
* @returns {Promise<boolean>} success
|
|
179
|
-
*/
|
|
180
|
-
setTrackBandwidth(trackId: string, bandwidth: BandwidthLimit): Promise<void>;
|
|
181
|
-
/**
|
|
182
|
-
* Updates maximum bandwidth for the given simulcast encoding of the given track.
|
|
183
|
-
*
|
|
184
|
-
* @param {string} trackId - id of the track
|
|
185
|
-
* @param {string} rid - rid of the encoding
|
|
186
|
-
* @param {BandwidthLimit} bandwidth - desired max bandwidth used by the encoding (in kbps)
|
|
187
|
-
* @returns
|
|
188
|
-
*/
|
|
189
|
-
setEncodingBandwidth(trackId: string, rid: string, bandwidth: BandwidthLimit): Promise<void>;
|
|
190
|
-
/**
|
|
191
|
-
* Removes a track from connection that was sent to the RTC Engine.
|
|
192
|
-
* @param {string} trackId - Id of audio or video track to remove.
|
|
193
|
-
* @example
|
|
194
|
-
* ```ts
|
|
195
|
-
* // setup camera
|
|
196
|
-
* let localStream: MediaStream = new MediaStream();
|
|
197
|
-
* try {
|
|
198
|
-
* localVideoStream = await navigator.mediaDevices.getUserMedia(
|
|
199
|
-
* VIDEO_CONSTRAINTS
|
|
200
|
-
* );
|
|
201
|
-
* localVideoStream
|
|
202
|
-
* .getTracks()
|
|
203
|
-
* .forEach((track) => localStream.addTrack(track));
|
|
204
|
-
* } catch (error) {
|
|
205
|
-
* console.error("Couldn't get camera permission:", error);
|
|
206
|
-
* }
|
|
207
|
-
*
|
|
208
|
-
* let trackId
|
|
209
|
-
* localStream
|
|
210
|
-
* .getTracks()
|
|
211
|
-
* .forEach((track) => trackId = webrtc.addTrack(track, localStream));
|
|
212
|
-
*
|
|
213
|
-
* // remove track
|
|
214
|
-
* webrtc.removeTrack(trackId)
|
|
215
|
-
* ```
|
|
216
|
-
*/
|
|
217
|
-
removeTrack(trackId: string): Promise<void>;
|
|
218
|
-
/**
|
|
219
|
-
* Sets track variant that server should send to the client library.
|
|
220
|
-
*
|
|
221
|
-
* The variant will be sent whenever it is available.
|
|
222
|
-
* If chosen variant is temporarily unavailable, some other variant
|
|
223
|
-
* will be sent until the chosen variant becomes active again.
|
|
224
|
-
*
|
|
225
|
-
* @param {string} trackId - id of track
|
|
226
|
-
* @param {Encoding} variant - variant to receive
|
|
227
|
-
* @example
|
|
228
|
-
* ```ts
|
|
229
|
-
* webrtc.setTargetTrackEncoding(incomingTrackCtx.trackId, "l")
|
|
230
|
-
* ```
|
|
231
|
-
*/
|
|
232
|
-
setTargetTrackEncoding(trackId: string, variant: Encoding): void;
|
|
233
|
-
/**
|
|
234
|
-
* Enables track encoding so that it will be sent to the server.
|
|
235
|
-
* @param {string} trackId - id of track
|
|
236
|
-
* @param {Encoding} encoding - encoding that will be enabled
|
|
237
|
-
* @example
|
|
238
|
-
* ```ts
|
|
239
|
-
* const trackId = webrtc.addTrack(track, stream, {}, {enabled: true, activeEncodings: ["l", "m", "h"]});
|
|
240
|
-
* webrtc.disableTrackEncoding(trackId, "l");
|
|
241
|
-
* // wait some time
|
|
242
|
-
* webrtc.enableTrackEncoding(trackId, "l");
|
|
243
|
-
* ```
|
|
244
|
-
*/
|
|
245
|
-
enableTrackEncoding: (trackId: string, encoding: Encoding) => Promise<void>;
|
|
246
|
-
/**
|
|
247
|
-
* Disables track encoding so that it will be no longer sent to the server.
|
|
248
|
-
* @param {string} trackId - id of track
|
|
249
|
-
* @param {Encoding} encoding - encoding that will be disabled
|
|
250
|
-
* @example
|
|
251
|
-
* ```ts
|
|
252
|
-
* const trackId = webrtc.addTrack(track, stream, {}, {enabled: true, activeEncodings: ["l", "m", "h"]});
|
|
253
|
-
* webrtc.disableTrackEncoding(trackId, "l");
|
|
254
|
-
* ```
|
|
255
|
-
*/
|
|
256
|
-
disableTrackEncoding: (trackId: string, encoding: Encoding) => Promise<void>;
|
|
257
|
-
/**
|
|
258
|
-
* Updates the metadata for the current endpoint.
|
|
259
|
-
* @param metadata - Data about this endpoint that other endpoints will receive upon being added.
|
|
260
|
-
*
|
|
261
|
-
* If the metadata is different from what is already tracked in the room, the optional
|
|
262
|
-
* event `endpointUpdated` will be emitted for other endpoint in the room.
|
|
263
|
-
*/
|
|
264
|
-
updateEndpointMetadata: (metadata: any) => void;
|
|
265
|
-
/**
|
|
266
|
-
* Updates the metadata for a specific track.
|
|
267
|
-
* @param trackId - trackId (generated in addTrack) of audio or video track.
|
|
268
|
-
* @param trackMetadata - Data about this track that other endpoint will receive upon being added.
|
|
269
|
-
*
|
|
270
|
-
* If the metadata is different from what is already tracked in the room, the optional
|
|
271
|
-
* event `trackUpdated` will be emitted for other endpoints in the room.
|
|
272
|
-
*/
|
|
273
|
-
updateTrackMetadata: (trackId: string, trackMetadata: any) => void;
|
|
274
|
-
/**
|
|
275
|
-
* Disconnects from the room. This function should be called when user disconnects from the room
|
|
276
|
-
* in a clean way e.g. by clicking a dedicated, custom button `disconnect`.
|
|
277
|
-
* As a result there will be generated one more media event that should be
|
|
278
|
-
* sent to the RTC Engine. Thanks to it each other endpoint will be notified
|
|
279
|
-
* that endpoint was removed in {@link WebRTCEndpointEvents.endpointRemoved},
|
|
280
|
-
*/
|
|
281
|
-
disconnect: () => void;
|
|
282
|
-
/**
|
|
283
|
-
* Cleans up {@link WebRTCEndpoint} instance.
|
|
284
|
-
*/
|
|
285
|
-
cleanUp: () => void;
|
|
286
|
-
private getTrackId;
|
|
287
|
-
sendMediaEvent: (mediaEvent: MediaEvent) => void;
|
|
288
|
-
private createAndSendOffer;
|
|
289
|
-
private onOfferData;
|
|
290
|
-
private setConnection;
|
|
291
|
-
private onRemoteCandidate;
|
|
292
|
-
private onLocalCandidate;
|
|
293
|
-
private onIceCandidateError;
|
|
294
|
-
private onConnectionStateChange;
|
|
295
|
-
private onIceConnectionStateChange;
|
|
296
|
-
}
|
|
297
|
-
export {};
|