livekit-client 0.11.2 → 0.13.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.
Files changed (87) hide show
  1. package/.eslintrc.js +1 -0
  2. package/.github/workflows/publish.yaml +1 -3
  3. package/CHANGELOG.md +5 -0
  4. package/README.md +21 -1
  5. package/dist/api/SignalClient.d.ts +10 -7
  6. package/dist/api/SignalClient.js +19 -10
  7. package/dist/api/SignalClient.js.map +1 -1
  8. package/dist/connect.d.ts +23 -0
  9. package/dist/connect.js +93 -0
  10. package/dist/connect.js.map +1 -0
  11. package/dist/index.d.ts +4 -2
  12. package/dist/index.js +4 -2
  13. package/dist/index.js.map +1 -1
  14. package/dist/options.d.ts +5 -3
  15. package/dist/options.js.map +1 -1
  16. package/dist/proto/livekit_models.d.ts +68 -54
  17. package/dist/proto/livekit_models.js +324 -362
  18. package/dist/proto/livekit_models.js.map +1 -1
  19. package/dist/proto/livekit_rtc.d.ts +31 -61
  20. package/dist/proto/livekit_rtc.js +177 -356
  21. package/dist/proto/livekit_rtc.js.map +1 -1
  22. package/dist/room/DeviceManager.d.ts +10 -0
  23. package/dist/room/DeviceManager.js +77 -0
  24. package/dist/room/DeviceManager.js.map +1 -0
  25. package/dist/room/PCTransport.d.ts +5 -0
  26. package/dist/room/PCTransport.js +43 -0
  27. package/dist/room/PCTransport.js.map +1 -1
  28. package/dist/room/RTCEngine.d.ts +21 -15
  29. package/dist/room/RTCEngine.js +122 -87
  30. package/dist/room/RTCEngine.js.map +1 -1
  31. package/dist/room/Room.d.ts +47 -3
  32. package/dist/room/Room.js +167 -10
  33. package/dist/room/Room.js.map +1 -1
  34. package/dist/room/defaults.d.ts +3 -0
  35. package/dist/room/defaults.js +13 -0
  36. package/dist/room/defaults.js.map +1 -0
  37. package/dist/room/events.d.ts +26 -3
  38. package/dist/room/events.js +25 -2
  39. package/dist/room/events.js.map +1 -1
  40. package/dist/room/participant/LocalParticipant.d.ts +32 -9
  41. package/dist/room/participant/LocalParticipant.js +165 -60
  42. package/dist/room/participant/LocalParticipant.js.map +1 -1
  43. package/dist/room/participant/Participant.d.ts +14 -0
  44. package/dist/room/participant/Participant.js +39 -0
  45. package/dist/room/participant/Participant.js.map +1 -1
  46. package/dist/room/participant/RemoteParticipant.d.ts +2 -0
  47. package/dist/room/participant/RemoteParticipant.js +14 -0
  48. package/dist/room/participant/RemoteParticipant.js.map +1 -1
  49. package/dist/room/track/LocalAudioTrack.d.ts +3 -0
  50. package/dist/room/track/LocalAudioTrack.js +37 -0
  51. package/dist/room/track/LocalAudioTrack.js.map +1 -1
  52. package/dist/room/track/LocalTrack.d.ts +6 -2
  53. package/dist/room/track/LocalTrack.js +49 -6
  54. package/dist/room/track/LocalTrack.js.map +1 -1
  55. package/dist/room/track/LocalTrackPublication.d.ts +6 -3
  56. package/dist/room/track/LocalTrackPublication.js +21 -2
  57. package/dist/room/track/LocalTrackPublication.js.map +1 -1
  58. package/dist/room/track/LocalVideoTrack.d.ts +3 -2
  59. package/dist/room/track/LocalVideoTrack.js +34 -5
  60. package/dist/room/track/LocalVideoTrack.js.map +1 -1
  61. package/dist/room/track/RemoteAudioTrack.d.ts +2 -0
  62. package/dist/room/track/RemoteAudioTrack.js +8 -0
  63. package/dist/room/track/RemoteAudioTrack.js.map +1 -1
  64. package/dist/room/track/RemoteVideoTrack.d.ts +1 -0
  65. package/dist/room/track/RemoteVideoTrack.js +6 -1
  66. package/dist/room/track/RemoteVideoTrack.js.map +1 -1
  67. package/dist/room/track/Track.d.ts +14 -2
  68. package/dist/room/track/Track.js +42 -0
  69. package/dist/room/track/Track.js.map +1 -1
  70. package/dist/room/track/TrackPublication.d.ts +1 -0
  71. package/dist/room/track/TrackPublication.js +2 -0
  72. package/dist/room/track/TrackPublication.js.map +1 -1
  73. package/dist/room/track/create.d.ts +23 -0
  74. package/dist/room/track/create.js +166 -0
  75. package/dist/room/track/create.js.map +1 -0
  76. package/dist/room/track/options.d.ts +47 -17
  77. package/dist/room/track/options.js +11 -6
  78. package/dist/room/track/options.js.map +1 -1
  79. package/dist/version.d.ts +2 -2
  80. package/dist/version.js +2 -2
  81. package/example/index.html +51 -20
  82. package/example/sample.ts +204 -75
  83. package/example/webpack.config.js +8 -2
  84. package/package.json +11 -10
  85. package/dist/livekit.d.ts +0 -42
  86. package/dist/livekit.js +0 -194
  87. package/dist/livekit.js.map +0 -1
package/example/sample.ts CHANGED
@@ -1,19 +1,13 @@
1
1
  import {
2
- connect, createLocalScreenTrack, CreateVideoTrackOptions,
3
- LocalAudioTrack,
4
- LocalTrack,
5
- LocalVideoTrack,
6
- LogLevel,
2
+ connect, CreateVideoTrackOptions, DataPacket_Kind, LocalTrack, LogLevel,
7
3
  Participant,
8
4
  ParticipantEvent,
9
5
  RemoteParticipant,
10
6
  RemoteTrack,
11
7
  Room,
12
8
  RoomEvent,
13
- Track,
14
- VideoPresets,
9
+ Track, TrackPublication, VideoPresets,
15
10
  } from '../src/index';
16
- import { DataPacket_Kind } from '../src/proto/livekit_rtc';
17
11
 
18
12
  const $ = (id: string) => document.getElementById(id);
19
13
 
@@ -21,9 +15,10 @@ declare global {
21
15
  interface Window {
22
16
  connectWithFormInput: any;
23
17
  connectToRoom: any;
18
+ handleDeviceSelected: any;
24
19
  shareScreen: any;
25
- muteVideo: any;
26
- muteAudio: any;
20
+ toggleVideo: any;
21
+ toggleAudio: any;
27
22
  enterText: any;
28
23
  disconnectSignal: any;
29
24
  disconnectRoom: any;
@@ -76,10 +71,14 @@ function trackUnsubscribed(
76
71
 
77
72
  const encoder = new TextEncoder();
78
73
  const decoder = new TextDecoder();
79
- function handleData(msg: Uint8Array, participant: RemoteParticipant) {
74
+ function handleData(msg: Uint8Array, participant?: RemoteParticipant) {
80
75
  const str = decoder.decode(msg);
81
76
  const chat = <HTMLTextAreaElement>$('chat');
82
- chat.value += `${participant.identity}: ${str}\n`;
77
+ let from = 'server';
78
+ if (participant) {
79
+ from = participant.identity;
80
+ }
81
+ chat.value += `${from}: ${str}\n`;
83
82
  }
84
83
 
85
84
  function handleSpeakerChanged(speakers: Participant[]) {
@@ -141,21 +140,42 @@ function participantDisconnected(participant: RemoteParticipant) {
141
140
  function handleRoomDisconnect() {
142
141
  appendLog('disconnected from room');
143
142
  setButtonsForState(false);
144
- if (videoTrack) {
145
- videoTrack.stop();
146
- trackUnsubscribed(videoTrack);
143
+ $('local-video')!.innerHTML = '';
144
+
145
+ // clear the chat area on disconnect
146
+ clearChat();
147
+
148
+ // clear remote area on disconnect
149
+ clearRemoteArea();
150
+ }
151
+
152
+ function setButtonState(buttonId: string, buttonText: string, isActive: boolean) {
153
+ const el = $(buttonId);
154
+ if (!el) return;
155
+
156
+ el.innerHTML = buttonText;
157
+ if (isActive) {
158
+ el.classList.add('active');
159
+ } else {
160
+ el.classList.remove('active');
147
161
  }
148
- if (audioTrack) {
149
- audioTrack.stop();
150
- trackUnsubscribed(audioTrack);
162
+ }
163
+
164
+ function clearChat() {
165
+ const chat = <HTMLTextAreaElement>$('chat');
166
+ chat.value = '';
167
+ }
168
+
169
+ function clearRemoteArea() {
170
+ const el = $('remote-area');
171
+ if (!el) return;
172
+
173
+ while (el.firstChild) {
174
+ el.removeChild(el.firstChild);
151
175
  }
152
- $('local-video')!.innerHTML = '';
153
176
  }
154
177
 
155
178
  let currentRoom: Room;
156
- let videoTrack: LocalVideoTrack | undefined;
157
- let audioTrack: LocalAudioTrack;
158
- let screenTrack: LocalVideoTrack | undefined;
159
179
  window.connectWithFormInput = () => {
160
180
  const url = (<HTMLInputElement>$('url')).value;
161
181
  const token = (<HTMLInputElement>$('token')).value;
@@ -176,13 +196,21 @@ window.connectToRoom = async (
176
196
  if (forceTURN) {
177
197
  rtcConfig.iceTransportPolicy = 'relay';
178
198
  }
199
+ const shouldPublish = (<HTMLInputElement>$('publish-option')).checked;
200
+ let audioOptions = true;
201
+ let videoOptions: boolean | CreateVideoTrackOptions = {
202
+ resolution: VideoPresets.qhd.resolution,
203
+ };
204
+ if (!shouldPublish) {
205
+ audioOptions = false;
206
+ videoOptions = false;
207
+ }
208
+
179
209
  try {
180
210
  room = await connect(url, token, {
181
211
  logLevel: LogLevel.debug,
182
- audio: true,
183
- video: {
184
- resolution: VideoPresets.qhd.resolution,
185
- },
212
+ audio: audioOptions,
213
+ video: videoOptions,
186
214
  simulcast,
187
215
  rtcConfig,
188
216
  });
@@ -195,11 +223,11 @@ window.connectToRoom = async (
195
223
  return;
196
224
  }
197
225
 
198
- window.currentRoom = room;
199
226
  appendLog('connected to room', room.name);
200
- setButtonsForState(true);
201
227
  currentRoom = room;
202
228
  window.currentRoom = room;
229
+ setButtonsForState(true);
230
+ updateButtonsForPublishState();
203
231
 
204
232
  room
205
233
  .on(RoomEvent.ParticipantConnected, participantConnected)
@@ -209,6 +237,12 @@ window.connectToRoom = async (
209
237
  .on(RoomEvent.Disconnected, handleRoomDisconnect)
210
238
  .on(RoomEvent.Reconnecting, () => appendLog('Reconnecting to room'))
211
239
  .on(RoomEvent.Reconnected, () => appendLog('Successfully reconnected!'))
240
+ .on(RoomEvent.TrackMuted, (pub: TrackPublication, p: Participant) => appendLog('track was muted', pub.trackSid, p.identity))
241
+ .on(RoomEvent.TrackUnmuted, (pub: TrackPublication, p: Participant) => appendLog('track was unmuted', pub.trackSid, p.identity))
242
+ .on(RoomEvent.RoomMetadataChanged, (metadata) => {
243
+ appendLog('new metadata for room', metadata);
244
+ })
245
+ .on(RoomEvent.MediaDevicesChanged, handleDevicesChanged)
212
246
  .on(RoomEvent.AudioPlaybackStatusChanged, () => {
213
247
  if (room.canPlaybackAudio) {
214
248
  $('start-audio-button')?.setAttribute('disabled', 'true');
@@ -223,48 +257,40 @@ window.connectToRoom = async (
223
257
  });
224
258
 
225
259
  $('local-video')!.innerHTML = `${room.localParticipant.identity} (me)`;
226
-
227
- // add already published tracks
228
- currentRoom.localParticipant.tracks.forEach((publication) => {
229
- if (publication.kind === Track.Kind.Video) {
230
- videoTrack = <LocalVideoTrack>publication.track;
231
- publishLocalVideo(videoTrack);
232
- } else if (publication.kind === Track.Kind.Audio) {
233
- // skip adding local audio track, to avoid your own sound
234
- // only process local video tracks
235
- audioTrack = <LocalAudioTrack>publication.track;
236
- }
237
- });
260
+ attachLocalVideo();
238
261
  };
239
262
 
240
- window.muteVideo = () => {
241
- if (!currentRoom || !videoTrack) return;
263
+ window.toggleVideo = async () => {
264
+ if (!currentRoom) return;
242
265
  const video = getMyVideo();
243
- if (!videoTrack.isMuted) {
244
- appendLog('muting video');
245
- videoTrack.mute();
266
+ if (currentRoom.localParticipant.isCameraEnabled) {
267
+ appendLog('disabling video');
268
+ await currentRoom.localParticipant.setCameraEnabled(false);
246
269
  // hide from display
247
270
  if (video) {
248
271
  video.style.display = 'none';
249
272
  }
250
273
  } else {
251
- appendLog('unmuting video');
252
- videoTrack.unmute();
274
+ appendLog('enabling video');
275
+ await currentRoom.localParticipant.setCameraEnabled(true);
276
+ attachLocalVideo();
253
277
  if (video) {
254
278
  video.style.display = '';
255
279
  }
256
280
  }
281
+ updateButtonsForPublishState();
257
282
  };
258
283
 
259
- window.muteAudio = () => {
260
- if (!currentRoom || !audioTrack) return;
261
- if (!audioTrack.isMuted) {
262
- appendLog('muting audio');
263
- audioTrack.mute();
284
+ window.toggleAudio = async () => {
285
+ if (!currentRoom) return;
286
+ if (currentRoom.localParticipant.isMicrophoneEnabled) {
287
+ appendLog('disabling audio');
288
+ await currentRoom.localParticipant.setMicrophoneEnabled(false);
264
289
  } else {
265
- appendLog('unmuting audio');
266
- audioTrack.unmute();
290
+ appendLog('enabling audio');
291
+ await currentRoom.localParticipant.setMicrophoneEnabled(true);
267
292
  }
293
+ updateButtonsForPublishState();
268
294
  };
269
295
 
270
296
  window.enterText = () => {
@@ -280,16 +306,17 @@ window.enterText = () => {
280
306
  };
281
307
 
282
308
  window.shareScreen = async () => {
283
- if (screenTrack !== undefined) {
284
- currentRoom.localParticipant.unpublishTrack(screenTrack);
285
- screenTrack = undefined;
286
- return;
287
- }
309
+ if (!currentRoom) return;
288
310
 
289
- screenTrack = await createLocalScreenTrack();
290
- await currentRoom.localParticipant.publishTrack(screenTrack, {
291
- videoEncoding: VideoPresets.fhd.encoding,
292
- });
311
+ if (currentRoom.localParticipant.isScreenShareEnabled) {
312
+ appendLog('stopping screen share');
313
+ await currentRoom.localParticipant.setScreenShareEnabled(false);
314
+ } else {
315
+ appendLog('starting screen share');
316
+ await currentRoom.localParticipant.setScreenShareEnabled(true);
317
+ appendLog('started screen share');
318
+ }
319
+ updateButtonsForPublishState();
293
320
  };
294
321
 
295
322
  window.disconnectSignal = () => {
@@ -310,31 +337,59 @@ window.startAudio = () => {
310
337
  currentRoom.startAudio();
311
338
  };
312
339
 
313
- let isFacingForward = true;
340
+ let isFrontFacing = true;
314
341
  window.flipVideo = () => {
315
- if (!videoTrack) {
342
+ const videoPub = currentRoom.localParticipant.getTrack(Track.Source.Camera);
343
+ if (!videoPub) {
316
344
  return;
317
345
  }
318
- isFacingForward = !isFacingForward;
346
+ if (isFrontFacing) {
347
+ setButtonState('flip-video-button', 'Front Camera', false);
348
+ } else {
349
+ setButtonState('flip-video-button', 'Back Camera', false);
350
+ }
351
+ isFrontFacing = !isFrontFacing;
319
352
  const options: CreateVideoTrackOptions = {
320
353
  resolution: VideoPresets.qhd.resolution,
321
- facingMode: isFacingForward ? 'user' : 'environment',
354
+ facingMode: isFrontFacing ? 'user' : 'environment',
322
355
  };
323
- videoTrack.restartTrack(options);
356
+ videoPub.videoTrack?.restartTrack(options);
324
357
  };
325
358
 
326
- async function publishLocalVideo(track: LocalVideoTrack) {
327
- await currentRoom.localParticipant.publishTrack(track);
328
- const video = track.attach();
329
- video.style.transform = 'scale(-1, 1)';
330
- $('local-video')!.appendChild(video);
359
+ window.handleDeviceSelected = async (e: Event) => {
360
+ const deviceId = (<HTMLSelectElement>e.target).value;
361
+ const elementId = (<HTMLSelectElement>e.target).id;
362
+ const kind = elementMapping[elementId];
363
+ if (!kind) {
364
+ return;
365
+ }
366
+
367
+ Room.setDefaultDevice(kind, deviceId || undefined);
368
+ if (currentRoom) {
369
+ await currentRoom.switchActiveDevice(kind, deviceId);
370
+ }
371
+ };
372
+
373
+ setTimeout(handleDevicesChanged, 100);
374
+
375
+ async function attachLocalVideo() {
376
+ const videoPub = currentRoom.localParticipant.getTrack(Track.Source.Camera);
377
+ const videoTrack = videoPub?.videoTrack;
378
+ if (!videoTrack) {
379
+ return;
380
+ }
381
+
382
+ if (videoTrack.attachedElements.length === 0) {
383
+ const video = videoTrack.attach();
384
+ video.style.transform = 'scale(-1, 1)';
385
+ $('local-video')!.appendChild(video);
386
+ }
331
387
  }
332
388
 
333
389
  function setButtonsForState(connected: boolean) {
334
390
  const connectedSet = [
335
391
  'toggle-video-button',
336
- 'mute-video-button',
337
- 'mute-audio-button',
392
+ 'toggle-audio-button',
338
393
  'share-screen-button',
339
394
  'disconnect-ws-button',
340
395
  'disconnect-room-button',
@@ -352,3 +407,77 @@ function setButtonsForState(connected: boolean) {
352
407
  function getMyVideo() {
353
408
  return <HTMLVideoElement>document.querySelector('#local-video video');
354
409
  }
410
+
411
+ const elementMapping: { [k: string]: MediaDeviceKind } = {
412
+ 'video-input': 'videoinput',
413
+ 'audio-input': 'audioinput',
414
+ 'audio-output': 'audiooutput',
415
+ };
416
+ async function handleDevicesChanged() {
417
+ Promise.all(Object.keys(elementMapping).map(async (id) => {
418
+ const kind = elementMapping[id];
419
+ if (!kind) {
420
+ return;
421
+ }
422
+ const devices = await Room.getLocalDevices(kind);
423
+ const element = <HTMLSelectElement>$(id);
424
+ populateSelect(kind, element, devices, Room.getDefaultDevice(kind));
425
+ }));
426
+ }
427
+
428
+ function populateSelect(
429
+ kind: MediaDeviceKind,
430
+ element: HTMLSelectElement,
431
+ devices: MediaDeviceInfo[],
432
+ selectedDeviceId?: string,
433
+ ) {
434
+ // clear all elements
435
+ element.innerHTML = '';
436
+ const initialOption = document.createElement('option');
437
+ if (kind === 'audioinput') {
438
+ initialOption.text = 'Audio Input (default)';
439
+ } else if (kind === 'videoinput') {
440
+ initialOption.text = 'Video Input (default)';
441
+ } else if (kind === 'audiooutput') {
442
+ initialOption.text = 'Audio Output (default)';
443
+ }
444
+ element.appendChild(initialOption);
445
+
446
+ for (const device of devices) {
447
+ const option = document.createElement('option');
448
+ option.text = device.label;
449
+ option.value = device.deviceId;
450
+ if (device.deviceId === selectedDeviceId) {
451
+ option.selected = true;
452
+ }
453
+ element.appendChild(option);
454
+ }
455
+ }
456
+
457
+ function updateButtonsForPublishState() {
458
+ if (!currentRoom) {
459
+ return;
460
+ }
461
+ const lp = currentRoom.localParticipant;
462
+
463
+ // video
464
+ setButtonState(
465
+ 'toggle-video-button',
466
+ `${lp.isCameraEnabled ? 'Disable' : 'Enable'} Video`,
467
+ lp.isCameraEnabled,
468
+ );
469
+
470
+ // audio
471
+ setButtonState(
472
+ 'toggle-audio-button',
473
+ `${lp.isMicrophoneEnabled ? 'Disable' : 'Enable'} Audio`,
474
+ lp.isMicrophoneEnabled,
475
+ );
476
+
477
+ // screen share
478
+ setButtonState(
479
+ 'share-screen-button',
480
+ lp.isScreenShareEnabled ? 'Stop Screen Share' : 'Share Screen',
481
+ lp.isScreenShareEnabled,
482
+ );
483
+ }
@@ -5,8 +5,14 @@ module.exports = {
5
5
  mode: 'development',
6
6
  devtool: 'inline-source-map',
7
7
  devServer: {
8
- open: true,
9
- contentBase: __dirname,
8
+ host: '0.0.0.0',
9
+ open: {
10
+ target: 'http://localhost:8080/',
11
+ },
12
+ port: 8080,
13
+ static: {
14
+ directory: __dirname,
15
+ },
10
16
  },
11
17
  module: {
12
18
  rules: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livekit-client",
3
- "version": "0.11.2",
3
+ "version": "0.13.0",
4
4
  "description": "JavaScript/TypeScript client SDK for LiveKit",
5
5
  "main": "dist/index.js",
6
6
  "source": "src/index.ts",
@@ -12,7 +12,7 @@
12
12
  "build": "yarn exec tsc",
13
13
  "build-docs": "yarn exec typedoc",
14
14
  "proto": "protoc --plugin=node_modules/ts-proto/protoc-gen-ts_proto --ts_proto_opt=esModuleInterop=true --ts_proto_out=./src/proto --ts_proto_opt=outputClientImpl=false,useOptionals=true -I../protocol ../protocol/livekit_rtc.proto ../protocol/livekit_models.proto",
15
- "sample": "cd example && webpack serve --host 0.0.0.0 --public localhost:8080",
15
+ "sample": "cd example && webpack serve",
16
16
  "build-sample": "cd example && webpack && cp index.html dist/",
17
17
  "lint": "yarn exec eslint src",
18
18
  "test": "jest",
@@ -23,22 +23,23 @@
23
23
  "events": "^3.3.0",
24
24
  "loglevel": "^1.7.1",
25
25
  "protobufjs": "^6.10.2",
26
+ "ts-debounce": "^3.0.0",
26
27
  "webrtc-adapter": "^7.7.1"
27
28
  },
28
29
  "devDependencies": {
29
- "@typescript-eslint/eslint-plugin": "^4.4.1",
30
- "@webpack-cli/serve": "^1.2.1",
31
- "eslint": "^7.30.0",
30
+ "@typescript-eslint/eslint-plugin": "^4.31.2",
31
+ "@webpack-cli/serve": "^1.5.2",
32
+ "eslint": "^7.32.0",
32
33
  "eslint-config-airbnb-typescript": "^12.3.1",
33
- "eslint-plugin-import": "^2.22.0",
34
+ "eslint-plugin-import": "^2.24.2",
34
35
  "gh-pages": "^3.2.3",
35
36
  "ts-loader": "^8.1.0",
36
- "ts-proto": "1.79.1",
37
+ "ts-proto": "1.83.1",
37
38
  "typedoc": "^0.20.35",
38
39
  "typedoc-plugin-no-inherit": "^1.2.0",
39
40
  "typescript": "~4.2.3",
40
- "webpack": "^5.9.0",
41
- "webpack-cli": "^4.2.0",
42
- "webpack-dev-server": "^3.11.0"
41
+ "webpack": "^5.53.0",
42
+ "webpack-cli": "^4.8.0",
43
+ "webpack-dev-server": "^4.2.1"
43
44
  }
44
45
  }
package/dist/livekit.d.ts DELETED
@@ -1,42 +0,0 @@
1
- import { ConnectOptions } from './options';
2
- import Room from './room/Room';
3
- import LocalAudioTrack from './room/track/LocalAudioTrack';
4
- import LocalTrack from './room/track/LocalTrack';
5
- import LocalVideoTrack from './room/track/LocalVideoTrack';
6
- import { CreateAudioTrackOptions, CreateLocalTracksOptions, CreateScreenTrackOptions, CreateVideoTrackOptions } from './room/track/options';
7
- export { version } from './version';
8
- /**
9
- * Connects to a LiveKit room
10
- *
11
- * ```typescript
12
- * connect('wss://myhost.livekit.io', token, {
13
- * // publish audio and video tracks on joining
14
- * audio: true,
15
- * video: {
16
- * resolution: VideoPresets.hd,
17
- * facingMode: {
18
- * ideal: "user",
19
- * }
20
- * }
21
- * })
22
- * ```
23
- * @param url URL to LiveKit server
24
- * @param token AccessToken, a JWT token that includes authentication and room details
25
- * @param options
26
- */
27
- export declare function connect(url: string, token: string, options?: ConnectOptions): Promise<Room>;
28
- /**
29
- * Creates a [[LocalVideoTrack]] with getUserMedia()
30
- * @param options
31
- */
32
- export declare function createLocalVideoTrack(options?: CreateVideoTrackOptions): Promise<LocalVideoTrack>;
33
- export declare function createLocalAudioTrack(options?: CreateAudioTrackOptions): Promise<LocalAudioTrack>;
34
- /**
35
- * Creates a [[LocalVideoTrack]] of screen capture with getDisplayMedia()
36
- */
37
- export declare function createLocalScreenTrack(options?: CreateScreenTrackOptions): Promise<LocalVideoTrack>;
38
- /**
39
- * creates a local video and audio track at the same time
40
- * @param options
41
- */
42
- export declare function createLocalTracks(options?: CreateLocalTracksOptions): Promise<Array<LocalTrack>>;