livekit-client 0.15.3 → 0.16.2

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.
Files changed (90) hide show
  1. package/dist/api/SignalClient.d.ts +6 -3
  2. package/dist/api/SignalClient.js +70 -28
  3. package/dist/api/SignalClient.js.map +1 -1
  4. package/dist/options.d.ts +5 -0
  5. package/dist/proto/livekit_models.d.ts +30 -0
  6. package/dist/proto/livekit_models.js +219 -1
  7. package/dist/proto/livekit_models.js.map +1 -1
  8. package/dist/proto/livekit_rtc.d.ts +15 -10
  9. package/dist/proto/livekit_rtc.js +36 -22
  10. package/dist/proto/livekit_rtc.js.map +1 -1
  11. package/dist/room/RTCEngine.d.ts +11 -2
  12. package/dist/room/RTCEngine.js +196 -44
  13. package/dist/room/RTCEngine.js.map +1 -1
  14. package/dist/room/Room.d.ts +7 -0
  15. package/dist/room/Room.js +70 -16
  16. package/dist/room/Room.js.map +1 -1
  17. package/dist/room/events.d.ts +5 -3
  18. package/dist/room/events.js +5 -3
  19. package/dist/room/events.js.map +1 -1
  20. package/dist/room/participant/LocalParticipant.d.ts +1 -2
  21. package/dist/room/participant/LocalParticipant.js +7 -6
  22. package/dist/room/participant/LocalParticipant.js.map +1 -1
  23. package/dist/room/participant/RemoteParticipant.js +3 -0
  24. package/dist/room/participant/RemoteParticipant.js.map +1 -1
  25. package/dist/room/participant/publishUtils.js +1 -1
  26. package/dist/room/participant/publishUtils.js.map +1 -1
  27. package/dist/room/participant/publishUtils.test.js +9 -0
  28. package/dist/room/participant/publishUtils.test.js.map +1 -1
  29. package/dist/room/track/LocalTrackPublication.d.ts +2 -0
  30. package/dist/room/track/LocalTrackPublication.js.map +1 -1
  31. package/dist/room/track/RemoteTrackPublication.d.ts +2 -1
  32. package/dist/room/track/RemoteTrackPublication.js +22 -8
  33. package/dist/room/track/RemoteTrackPublication.js.map +1 -1
  34. package/dist/room/track/RemoteVideoTrack.js +12 -7
  35. package/dist/room/track/RemoteVideoTrack.js.map +1 -1
  36. package/dist/room/track/Track.js +28 -20
  37. package/dist/room/track/Track.js.map +1 -1
  38. package/dist/room/track/create.js +5 -0
  39. package/dist/room/track/create.js.map +1 -1
  40. package/dist/room/utils.d.ts +3 -0
  41. package/dist/room/utils.js +16 -1
  42. package/dist/room/utils.js.map +1 -1
  43. package/dist/version.d.ts +2 -2
  44. package/dist/version.js +2 -2
  45. package/package.json +3 -3
  46. package/src/api/SignalClient.ts +444 -0
  47. package/src/connect.ts +100 -0
  48. package/src/index.ts +47 -0
  49. package/src/logger.ts +22 -0
  50. package/src/options.ts +152 -0
  51. package/src/proto/livekit_models.ts +1863 -0
  52. package/src/proto/livekit_rtc.ts +3415 -0
  53. package/src/room/DeviceManager.ts +57 -0
  54. package/src/room/PCTransport.ts +86 -0
  55. package/src/room/RTCEngine.ts +598 -0
  56. package/src/room/Room.ts +840 -0
  57. package/src/room/errors.ts +65 -0
  58. package/src/room/events.ts +398 -0
  59. package/src/room/participant/LocalParticipant.ts +685 -0
  60. package/src/room/participant/Participant.ts +214 -0
  61. package/src/room/participant/ParticipantTrackPermission.ts +32 -0
  62. package/src/room/participant/RemoteParticipant.ts +241 -0
  63. package/src/room/participant/publishUtils.test.ts +105 -0
  64. package/src/room/participant/publishUtils.ts +180 -0
  65. package/src/room/stats.ts +130 -0
  66. package/src/room/track/LocalAudioTrack.ts +112 -0
  67. package/src/room/track/LocalTrack.ts +124 -0
  68. package/src/room/track/LocalTrackPublication.ts +66 -0
  69. package/src/room/track/LocalVideoTrack.test.ts +70 -0
  70. package/src/room/track/LocalVideoTrack.ts +416 -0
  71. package/src/room/track/RemoteAudioTrack.ts +58 -0
  72. package/src/room/track/RemoteTrack.ts +59 -0
  73. package/src/room/track/RemoteTrackPublication.ts +198 -0
  74. package/src/room/track/RemoteVideoTrack.ts +220 -0
  75. package/src/room/track/Track.ts +307 -0
  76. package/src/room/track/TrackPublication.ts +120 -0
  77. package/src/room/track/create.ts +120 -0
  78. package/src/room/track/defaults.ts +23 -0
  79. package/src/room/track/options.ts +229 -0
  80. package/src/room/track/types.ts +8 -0
  81. package/src/room/track/utils.test.ts +93 -0
  82. package/src/room/track/utils.ts +76 -0
  83. package/src/room/utils.ts +62 -0
  84. package/src/version.ts +2 -0
  85. package/.github/workflows/publish.yaml +0 -55
  86. package/.github/workflows/test.yaml +0 -36
  87. package/example/index.html +0 -247
  88. package/example/sample.ts +0 -632
  89. package/example/styles.css +0 -144
  90. package/example/webpack.config.js +0 -33
@@ -0,0 +1,444 @@
1
+ import 'webrtc-adapter';
2
+ import log from '../logger';
3
+ import {
4
+ ClientInfo,
5
+ ParticipantInfo, Room, SpeakerInfo, VideoLayer,
6
+ } from '../proto/livekit_models';
7
+ import {
8
+ AddTrackRequest,
9
+ ConnectionQualityUpdate,
10
+ JoinResponse,
11
+ LeaveRequest,
12
+ SessionDescription,
13
+ SignalRequest,
14
+ SignalResponse,
15
+ SignalTarget, SimulateScenario,
16
+ StreamStateUpdate,
17
+ SubscribedQualityUpdate,
18
+ SubscriptionPermissionUpdate, SyncState, TrackPermission,
19
+ TrackPublishedResponse,
20
+ UpdateSubscription, UpdateTrackSettings,
21
+ } from '../proto/livekit_rtc';
22
+ import { ConnectionError } from '../room/errors';
23
+ import { getClientInfo, sleep } from '../room/utils';
24
+
25
+ // internal options
26
+ interface ConnectOpts {
27
+ autoSubscribe?: boolean;
28
+ /** internal */
29
+ reconnect?: boolean;
30
+ }
31
+
32
+ // public options
33
+ export interface SignalOptions {
34
+ autoSubscribe?: boolean;
35
+ }
36
+
37
+ /** @internal */
38
+ export class SignalClient {
39
+ isConnected: boolean;
40
+
41
+ useJSON: boolean;
42
+
43
+ /** simulate signaling latency by delaying messages */
44
+ signalLatency?: number;
45
+
46
+ onClose?: (reason: string) => void;
47
+
48
+ onAnswer?: (sd: RTCSessionDescriptionInit) => void;
49
+
50
+ onOffer?: (sd: RTCSessionDescriptionInit) => void;
51
+
52
+ // when a new ICE candidate is made available
53
+ onTrickle?: (sd: RTCIceCandidateInit, target: SignalTarget) => void;
54
+
55
+ onParticipantUpdate?: (updates: ParticipantInfo[]) => void;
56
+
57
+ onLocalTrackPublished?: (res: TrackPublishedResponse) => void;
58
+
59
+ onNegotiateRequested?: () => void;
60
+
61
+ onSpeakersChanged?: (res: SpeakerInfo[]) => void;
62
+
63
+ onRemoteMuteChanged?: (trackSid: string, muted: boolean) => void;
64
+
65
+ onRoomUpdate?: (room: Room) => void;
66
+
67
+ onConnectionQuality?: (update: ConnectionQualityUpdate) => void;
68
+
69
+ onStreamStateUpdate?: (update: StreamStateUpdate) => void;
70
+
71
+ onSubscribedQualityUpdate?: (update: SubscribedQualityUpdate) => void;
72
+
73
+ onSubscriptionPermissionUpdate?: (update: SubscriptionPermissionUpdate) => void;
74
+
75
+ onTokenRefresh?: (token: string) => void;
76
+
77
+ onLeave?: (leave: LeaveRequest) => void;
78
+
79
+ ws?: WebSocket;
80
+
81
+ constructor(useJSON: boolean = false) {
82
+ this.isConnected = false;
83
+ this.useJSON = useJSON;
84
+ }
85
+
86
+ async join(
87
+ url: string,
88
+ token: string,
89
+ opts?: SignalOptions,
90
+ ): Promise<JoinResponse> {
91
+ // during a full reconnect, we'd want to start the sequence even if currently
92
+ // connected
93
+ this.isConnected = false;
94
+ const res = await this.connect(url, token, {
95
+ autoSubscribe: opts?.autoSubscribe,
96
+ });
97
+ return res as JoinResponse;
98
+ }
99
+
100
+ async reconnect(url: string, token: string): Promise<void> {
101
+ await this.connect(url, token, {
102
+ reconnect: true,
103
+ });
104
+ }
105
+
106
+ connect(
107
+ url: string,
108
+ token: string,
109
+ opts: ConnectOpts,
110
+ ): Promise<JoinResponse | void> {
111
+ if (url.startsWith('http')) {
112
+ url = url.replace('http', 'ws');
113
+ }
114
+ // strip trailing slash
115
+ url = url.replace(/\/$/, '');
116
+ url += '/rtc';
117
+
118
+ const clientInfo = getClientInfo();
119
+ const params = createConnectionParams(token, clientInfo, opts);
120
+
121
+ return new Promise<JoinResponse | void>((resolve, reject) => {
122
+ log.debug('connecting to', url + params);
123
+ this.ws = undefined;
124
+ const ws = new WebSocket(url + params);
125
+ ws.binaryType = 'arraybuffer';
126
+
127
+ ws.onerror = async (ev: Event) => {
128
+ if (!this.ws) {
129
+ try {
130
+ const resp = await fetch(`http${url.substring(2)}/validate${params}`);
131
+ if (!resp.ok) {
132
+ const msg = await resp.text();
133
+ reject(new ConnectionError(msg));
134
+ } else {
135
+ reject(new ConnectionError('Internal error'));
136
+ }
137
+ } catch (e) {
138
+ reject(new ConnectionError('server was not reachable'));
139
+ }
140
+ return;
141
+ }
142
+ // other errors, handle
143
+ this.handleWSError(ev);
144
+ };
145
+
146
+ ws.onopen = () => {
147
+ this.ws = ws;
148
+ if (opts.reconnect) {
149
+ // upon reconnection, there will not be additional handshake
150
+ this.isConnected = true;
151
+ resolve();
152
+ }
153
+ };
154
+
155
+ ws.onmessage = async (ev: MessageEvent) => {
156
+ // not considered connected until JoinResponse is received
157
+ let msg: SignalResponse;
158
+ if (typeof ev.data === 'string') {
159
+ const json = JSON.parse(ev.data);
160
+ msg = SignalResponse.fromJSON(json);
161
+ } else if (ev.data instanceof ArrayBuffer) {
162
+ msg = SignalResponse.decode(new Uint8Array(ev.data));
163
+ } else {
164
+ log.error('could not decode websocket message', typeof ev.data);
165
+ return;
166
+ }
167
+
168
+ if (!this.isConnected) {
169
+ // handle join message only
170
+ if (msg.join) {
171
+ this.isConnected = true;
172
+ resolve(msg.join);
173
+ } else {
174
+ reject(new ConnectionError('did not receive join response'));
175
+ }
176
+ return;
177
+ }
178
+
179
+ if (this.signalLatency) {
180
+ await sleep(this.signalLatency);
181
+ }
182
+ this.handleSignalResponse(msg);
183
+ };
184
+
185
+ ws.onclose = (ev: CloseEvent) => {
186
+ if (!this.isConnected || this.ws !== ws) return;
187
+
188
+ log.debug('websocket connection closed', ev.reason);
189
+ this.isConnected = false;
190
+ if (this.onClose) this.onClose(ev.reason);
191
+ if (this.ws === ws) {
192
+ this.ws = undefined;
193
+ }
194
+ };
195
+ });
196
+ }
197
+
198
+ close() {
199
+ this.isConnected = false;
200
+ if (this.ws) this.ws.onclose = null;
201
+ this.ws?.close();
202
+ this.ws = undefined;
203
+ }
204
+
205
+ // initial offer after joining
206
+ sendOffer(offer: RTCSessionDescriptionInit) {
207
+ log.debug('sending offer', offer);
208
+ this.sendRequest({
209
+ offer: toProtoSessionDescription(offer),
210
+ });
211
+ }
212
+
213
+ // answer a server-initiated offer
214
+ sendAnswer(answer: RTCSessionDescriptionInit) {
215
+ log.debug('sending answer');
216
+ this.sendRequest({
217
+ answer: toProtoSessionDescription(answer),
218
+ });
219
+ }
220
+
221
+ sendIceCandidate(candidate: RTCIceCandidateInit, target: SignalTarget) {
222
+ log.trace('sending ice candidate', candidate);
223
+ this.sendRequest({
224
+ trickle: {
225
+ candidateInit: JSON.stringify(candidate),
226
+ target,
227
+ },
228
+ });
229
+ }
230
+
231
+ sendMuteTrack(trackSid: string, muted: boolean) {
232
+ this.sendRequest({
233
+ mute: {
234
+ sid: trackSid,
235
+ muted,
236
+ },
237
+ });
238
+ }
239
+
240
+ sendAddTrack(req: AddTrackRequest): void {
241
+ this.sendRequest({
242
+ addTrack: AddTrackRequest.fromPartial(req),
243
+ });
244
+ }
245
+
246
+ sendUpdateTrackSettings(settings: UpdateTrackSettings) {
247
+ this.sendRequest({ trackSetting: settings });
248
+ }
249
+
250
+ sendUpdateSubscription(sub: UpdateSubscription) {
251
+ this.sendRequest({ subscription: sub });
252
+ }
253
+
254
+ sendSyncState(sync: SyncState) {
255
+ this.sendRequest({ syncState: sync });
256
+ }
257
+
258
+ sendUpdateVideoLayers(trackSid: string, layers: VideoLayer[]) {
259
+ this.sendRequest({
260
+ updateLayers: {
261
+ trackSid,
262
+ layers,
263
+ },
264
+ });
265
+ }
266
+
267
+ sendUpdateSubscriptionPermissions(
268
+ allParticipants: boolean,
269
+ trackPermissions: TrackPermission[],
270
+ ) {
271
+ this.sendRequest({
272
+ subscriptionPermission: {
273
+ allParticipants,
274
+ trackPermissions,
275
+ },
276
+ });
277
+ }
278
+
279
+ sendSimulateScenario(scenario: SimulateScenario) {
280
+ this.sendRequest({
281
+ simulate: scenario,
282
+ });
283
+ }
284
+
285
+ sendLeave() {
286
+ this.sendRequest(SignalRequest.fromPartial({ leave: {} }));
287
+ }
288
+
289
+ async sendRequest(req: SignalRequest) {
290
+ if (this.signalLatency) {
291
+ await sleep(this.signalLatency);
292
+ }
293
+ if (!this.ws) {
294
+ log.error('cannot send signal request before connected');
295
+ return;
296
+ }
297
+
298
+ try {
299
+ if (this.useJSON) {
300
+ this.ws.send(JSON.stringify(SignalRequest.toJSON(req)));
301
+ } else {
302
+ this.ws.send(SignalRequest.encode(req).finish());
303
+ }
304
+ } catch (e) {
305
+ log.error('error sending signal message', e);
306
+ }
307
+ }
308
+
309
+ private handleSignalResponse(msg: SignalResponse) {
310
+ if (msg.answer) {
311
+ const sd = fromProtoSessionDescription(msg.answer);
312
+ if (this.onAnswer) {
313
+ this.onAnswer(sd);
314
+ }
315
+ } else if (msg.offer) {
316
+ const sd = fromProtoSessionDescription(msg.offer);
317
+ if (this.onOffer) {
318
+ this.onOffer(sd);
319
+ }
320
+ } else if (msg.trickle) {
321
+ const candidate: RTCIceCandidateInit = JSON.parse(
322
+ msg.trickle.candidateInit,
323
+ );
324
+ if (this.onTrickle) {
325
+ this.onTrickle(candidate, msg.trickle.target);
326
+ }
327
+ } else if (msg.update) {
328
+ if (this.onParticipantUpdate) {
329
+ this.onParticipantUpdate(msg.update.participants);
330
+ }
331
+ } else if (msg.trackPublished) {
332
+ if (this.onLocalTrackPublished) {
333
+ this.onLocalTrackPublished(msg.trackPublished);
334
+ }
335
+ } else if (msg.speakersChanged) {
336
+ if (this.onSpeakersChanged) {
337
+ this.onSpeakersChanged(msg.speakersChanged.speakers);
338
+ }
339
+ } else if (msg.leave) {
340
+ if (this.onLeave) {
341
+ this.onLeave(msg.leave);
342
+ }
343
+ } else if (msg.mute) {
344
+ if (this.onRemoteMuteChanged) {
345
+ this.onRemoteMuteChanged(msg.mute.sid, msg.mute.muted);
346
+ }
347
+ } else if (msg.roomUpdate) {
348
+ if (this.onRoomUpdate) {
349
+ this.onRoomUpdate(msg.roomUpdate.room!);
350
+ }
351
+ } else if (msg.connectionQuality) {
352
+ if (this.onConnectionQuality) {
353
+ this.onConnectionQuality(msg.connectionQuality);
354
+ }
355
+ } else if (msg.streamStateUpdate) {
356
+ if (this.onStreamStateUpdate) {
357
+ this.onStreamStateUpdate(msg.streamStateUpdate);
358
+ }
359
+ } else if (msg.subscribedQualityUpdate) {
360
+ if (this.onSubscribedQualityUpdate) {
361
+ this.onSubscribedQualityUpdate(msg.subscribedQualityUpdate);
362
+ }
363
+ } else if (msg.subscriptionPermissionUpdate) {
364
+ if (this.onSubscriptionPermissionUpdate) {
365
+ this.onSubscriptionPermissionUpdate(msg.subscriptionPermissionUpdate);
366
+ }
367
+ } else if (msg.refreshToken) {
368
+ if (this.onTokenRefresh) {
369
+ this.onTokenRefresh(msg.refreshToken);
370
+ }
371
+ } else {
372
+ log.debug('unsupported message', msg);
373
+ }
374
+ }
375
+
376
+ private handleWSError(ev: Event) {
377
+ log.error('websocket error', ev);
378
+ }
379
+ }
380
+
381
+ function fromProtoSessionDescription(
382
+ sd: SessionDescription,
383
+ ): RTCSessionDescriptionInit {
384
+ const rsd: RTCSessionDescriptionInit = {
385
+ type: 'offer',
386
+ sdp: sd.sdp,
387
+ };
388
+ switch (sd.type) {
389
+ case 'answer':
390
+ case 'offer':
391
+ case 'pranswer':
392
+ case 'rollback':
393
+ rsd.type = sd.type;
394
+ break;
395
+ default:
396
+ break;
397
+ }
398
+ return rsd;
399
+ }
400
+
401
+ export function toProtoSessionDescription(
402
+ rsd: RTCSessionDescription | RTCSessionDescriptionInit,
403
+ ): SessionDescription {
404
+ const sd: SessionDescription = {
405
+ sdp: rsd.sdp!,
406
+ type: rsd.type!,
407
+ };
408
+ return sd;
409
+ }
410
+
411
+ function createConnectionParams(token: string, info: ClientInfo, opts?: ConnectOpts): string {
412
+ const params = new URLSearchParams();
413
+ params.set('access_token', token);
414
+
415
+ // opts
416
+ if (opts?.reconnect) {
417
+ params.set('reconnect', '1');
418
+ }
419
+ if (opts?.autoSubscribe !== undefined) {
420
+ params.set('auto_subscribe', opts.autoSubscribe ? '1' : '0');
421
+ }
422
+
423
+ // ClientInfo
424
+ params.set('sdk', 'js');
425
+ params.set('version', info.version);
426
+ params.set('protocol', info.protocol.toString());
427
+ if (info.deviceModel) {
428
+ params.set('device_model', info.deviceModel);
429
+ }
430
+ if (info.os) {
431
+ params.set('os', info.os);
432
+ }
433
+ if (info.osVersion) {
434
+ params.set('os_version', info.osVersion);
435
+ }
436
+ if (info.browser) {
437
+ params.set('browser', info.browser);
438
+ }
439
+ if (info.browserVersion) {
440
+ params.set('browser_version', info.browserVersion);
441
+ }
442
+
443
+ return `?${params.toString()}`;
444
+ }
package/src/connect.ts ADDED
@@ -0,0 +1,100 @@
1
+ import log, { LogLevel, setLogLevel } from './logger';
2
+ import {
3
+ ConnectOptions,
4
+ } from './options';
5
+ import { MediaDeviceFailure } from './room/errors';
6
+ import { RoomEvent } from './room/events';
7
+ import Room from './room/Room';
8
+
9
+ export { version } from './version';
10
+
11
+ /**
12
+ * Connects to a LiveKit room, shorthand for `new Room()` and [[Room.connect]]
13
+ *
14
+ * ```typescript
15
+ * connect('wss://myhost.livekit.io', token, {
16
+ * // publish audio and video tracks on joining
17
+ * audio: true,
18
+ * video: true,
19
+ * captureDefaults: {
20
+ * facingMode: 'user',
21
+ * },
22
+ * })
23
+ * ```
24
+ * @param url URL to LiveKit server
25
+ * @param token AccessToken, a JWT token that includes authentication and room details
26
+ * @param options
27
+ */
28
+ export async function connect(
29
+ url: string,
30
+ token: string,
31
+ options?: ConnectOptions,
32
+ ): Promise<Room> {
33
+ options ??= {};
34
+ if (options.adaptiveStream === undefined) {
35
+ options.adaptiveStream = options.autoManageVideo;
36
+ }
37
+ setLogLevel(options.logLevel ?? LogLevel.warn);
38
+
39
+ const config: RTCConfiguration = options.rtcConfig ?? {};
40
+ if (options.iceServers) {
41
+ config.iceServers = options.iceServers;
42
+ }
43
+
44
+ const room = new Room(options);
45
+
46
+ // connect to room
47
+ await room.connect(url, token, options);
48
+
49
+ const publishAudio: boolean = options.audio ?? false;
50
+ const publishVideo: boolean = options.video ?? false;
51
+
52
+ if (publishAudio || publishVideo) {
53
+ setTimeout(async () => {
54
+ // if publishing both
55
+ let err: any;
56
+ if (publishAudio && publishVideo) {
57
+ try {
58
+ await room.localParticipant.enableCameraAndMicrophone();
59
+ } catch (e) {
60
+ const errKind = MediaDeviceFailure.getFailure(e);
61
+ log.warn('received error while creating media', errKind);
62
+ if (e instanceof Error) {
63
+ log.warn(e.message);
64
+ }
65
+
66
+ // when it's a device issue, try to publish the other kind
67
+ if (errKind === MediaDeviceFailure.NotFound
68
+ || errKind === MediaDeviceFailure.DeviceInUse) {
69
+ try {
70
+ await room.localParticipant.setMicrophoneEnabled(true);
71
+ } catch (audioErr) {
72
+ err = audioErr;
73
+ }
74
+ } else {
75
+ err = e;
76
+ }
77
+ }
78
+ } else if (publishAudio) {
79
+ try {
80
+ await room.localParticipant.setMicrophoneEnabled(true);
81
+ } catch (e) {
82
+ err = e;
83
+ }
84
+ } else if (publishVideo) {
85
+ try {
86
+ await room.localParticipant.setCameraEnabled(true);
87
+ } catch (e) {
88
+ err = e;
89
+ }
90
+ }
91
+
92
+ if (err) {
93
+ room.emit(RoomEvent.MediaDevicesError, err);
94
+ log.error('could not create media', err);
95
+ }
96
+ });
97
+ }
98
+
99
+ return room;
100
+ }
package/src/index.ts ADDED
@@ -0,0 +1,47 @@
1
+ import { setLogLevel } from './logger';
2
+ import { DataPacket_Kind, VideoQuality } from './proto/livekit_models';
3
+ import LocalParticipant from './room/participant/LocalParticipant';
4
+ import Participant, { ConnectionQuality } from './room/participant/Participant';
5
+ import { ParticipantTrackPermission } from './room/participant/ParticipantTrackPermission';
6
+ import RemoteParticipant from './room/participant/RemoteParticipant';
7
+ import Room, { RoomState } from './room/Room';
8
+ import LocalAudioTrack from './room/track/LocalAudioTrack';
9
+ import LocalTrack from './room/track/LocalTrack';
10
+ import LocalTrackPublication from './room/track/LocalTrackPublication';
11
+ import LocalVideoTrack from './room/track/LocalVideoTrack';
12
+ import RemoteAudioTrack from './room/track/RemoteAudioTrack';
13
+ import RemoteTrack from './room/track/RemoteTrack';
14
+ import RemoteTrackPublication from './room/track/RemoteTrackPublication';
15
+ import RemoteVideoTrack from './room/track/RemoteVideoTrack';
16
+ import { TrackPublication } from './room/track/TrackPublication';
17
+
18
+ export * from './connect';
19
+ export * from './options';
20
+ export * from './room/errors';
21
+ export * from './room/events';
22
+ export * from './room/track/create';
23
+ export * from './room/track/options';
24
+ export * from './room/track/Track';
25
+ export * from './room/track/types';
26
+ export * from './version';
27
+ export {
28
+ setLogLevel,
29
+ Room,
30
+ RoomState,
31
+ DataPacket_Kind,
32
+ ConnectionQuality,
33
+ Participant,
34
+ RemoteParticipant,
35
+ LocalParticipant,
36
+ LocalAudioTrack,
37
+ LocalVideoTrack,
38
+ LocalTrack,
39
+ LocalTrackPublication,
40
+ RemoteTrack,
41
+ RemoteAudioTrack,
42
+ RemoteVideoTrack,
43
+ RemoteTrackPublication,
44
+ ParticipantTrackPermission,
45
+ TrackPublication,
46
+ VideoQuality,
47
+ };
package/src/logger.ts ADDED
@@ -0,0 +1,22 @@
1
+ import log from 'loglevel';
2
+
3
+ export type LogLevelDesc = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent';
4
+
5
+ export enum LogLevel {
6
+ trace = 'trace',
7
+ debug = 'debug',
8
+ info = 'info',
9
+ warn = 'warn',
10
+ error = 'error',
11
+ silent = 'silent',
12
+ }
13
+
14
+ const livekitLogger = log.getLogger('livekit');
15
+
16
+ livekitLogger.setLevel(LogLevel.info);
17
+
18
+ export default livekitLogger;
19
+
20
+ export function setLogLevel(level: LogLevel | LogLevelDesc) {
21
+ livekitLogger.setLevel(level);
22
+ }