livekit-client 0.18.4-RC8 → 0.18.6

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 (127) hide show
  1. package/README.md +2 -5
  2. package/dist/api/RequestQueue.d.ts +13 -12
  3. package/dist/api/RequestQueue.d.ts.map +1 -0
  4. package/dist/api/SignalClient.d.ts +67 -66
  5. package/dist/api/SignalClient.d.ts.map +1 -0
  6. package/dist/connect.d.ts +24 -23
  7. package/dist/connect.d.ts.map +1 -0
  8. package/dist/index.d.ts +27 -26
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/livekit-client.esm.mjs +593 -507
  11. package/dist/livekit-client.esm.mjs.map +1 -1
  12. package/dist/livekit-client.umd.js +1 -1
  13. package/dist/livekit-client.umd.js.map +1 -1
  14. package/dist/logger.d.ts +26 -25
  15. package/dist/logger.d.ts.map +1 -0
  16. package/dist/options.d.ts +128 -127
  17. package/dist/options.d.ts.map +1 -0
  18. package/dist/proto/google/protobuf/timestamp.d.ts +133 -132
  19. package/dist/proto/google/protobuf/timestamp.d.ts.map +1 -0
  20. package/dist/proto/livekit_models.d.ts +876 -875
  21. package/dist/proto/livekit_models.d.ts.map +1 -0
  22. package/dist/proto/livekit_rtc.d.ts +3904 -3903
  23. package/dist/proto/livekit_rtc.d.ts.map +1 -0
  24. package/dist/room/DeviceManager.d.ts +8 -7
  25. package/dist/room/DeviceManager.d.ts.map +1 -0
  26. package/dist/room/PCTransport.d.ts +16 -15
  27. package/dist/room/PCTransport.d.ts.map +1 -0
  28. package/dist/room/RTCEngine.d.ts +67 -66
  29. package/dist/room/RTCEngine.d.ts.map +1 -0
  30. package/dist/room/Room.d.ts +166 -165
  31. package/dist/room/Room.d.ts.map +1 -0
  32. package/dist/room/errors.d.ts +29 -28
  33. package/dist/room/errors.d.ts.map +1 -0
  34. package/dist/room/events.d.ts +391 -390
  35. package/dist/room/events.d.ts.map +1 -0
  36. package/dist/room/participant/LocalParticipant.d.ts +126 -125
  37. package/dist/room/participant/LocalParticipant.d.ts.map +1 -0
  38. package/dist/room/participant/Participant.d.ts +94 -93
  39. package/dist/room/participant/Participant.d.ts.map +1 -0
  40. package/dist/room/participant/ParticipantTrackPermission.d.ts +26 -25
  41. package/dist/room/participant/ParticipantTrackPermission.d.ts.map +1 -0
  42. package/dist/room/participant/RemoteParticipant.d.ts +40 -39
  43. package/dist/room/participant/RemoteParticipant.d.ts.map +1 -0
  44. package/dist/room/participant/publishUtils.d.ts +18 -17
  45. package/dist/room/participant/publishUtils.d.ts.map +1 -0
  46. package/dist/room/stats.d.ts +66 -65
  47. package/dist/room/stats.d.ts.map +1 -0
  48. package/dist/room/track/LocalAudioTrack.d.ts +20 -19
  49. package/dist/room/track/LocalAudioTrack.d.ts.map +1 -0
  50. package/dist/room/track/LocalTrack.d.ts +28 -27
  51. package/dist/room/track/LocalTrack.d.ts.map +1 -0
  52. package/dist/room/track/LocalTrackPublication.d.ts +38 -37
  53. package/dist/room/track/LocalTrackPublication.d.ts.map +1 -0
  54. package/dist/room/track/LocalVideoTrack.d.ts +31 -30
  55. package/dist/room/track/LocalVideoTrack.d.ts.map +1 -0
  56. package/dist/room/track/RemoteAudioTrack.d.ts +20 -19
  57. package/dist/room/track/RemoteAudioTrack.d.ts.map +1 -0
  58. package/dist/room/track/RemoteTrack.d.ts +16 -15
  59. package/dist/room/track/RemoteTrack.d.ts.map +1 -0
  60. package/dist/room/track/RemoteTrackPublication.d.ts +51 -50
  61. package/dist/room/track/RemoteTrackPublication.d.ts.map +1 -0
  62. package/dist/room/track/RemoteVideoTrack.d.ts +30 -27
  63. package/dist/room/track/RemoteVideoTrack.d.ts.map +1 -0
  64. package/dist/room/track/Track.d.ts +105 -100
  65. package/dist/room/track/Track.d.ts.map +1 -0
  66. package/dist/room/track/TrackPublication.d.ts +50 -49
  67. package/dist/room/track/TrackPublication.d.ts.map +1 -0
  68. package/dist/room/track/create.d.ts +24 -23
  69. package/dist/room/track/create.d.ts.map +1 -0
  70. package/dist/room/track/defaults.d.ts +5 -4
  71. package/dist/room/track/defaults.d.ts.map +1 -0
  72. package/dist/room/track/options.d.ts +232 -222
  73. package/dist/room/track/options.d.ts.map +1 -0
  74. package/dist/room/track/types.d.ts +19 -18
  75. package/dist/room/track/types.d.ts.map +1 -0
  76. package/dist/room/track/utils.d.ts +14 -13
  77. package/dist/room/track/utils.d.ts.map +1 -0
  78. package/dist/room/utils.d.ts +17 -16
  79. package/dist/room/utils.d.ts.map +1 -0
  80. package/dist/test/mocks.d.ts +12 -11
  81. package/dist/test/mocks.d.ts.map +1 -0
  82. package/dist/version.d.ts +3 -2
  83. package/dist/version.d.ts.map +1 -0
  84. package/package.json +6 -6
  85. package/src/api/RequestQueue.ts +53 -0
  86. package/src/api/SignalClient.ts +497 -0
  87. package/src/connect.ts +98 -0
  88. package/src/index.ts +49 -0
  89. package/src/logger.ts +56 -0
  90. package/src/options.ts +156 -0
  91. package/src/proto/google/protobuf/timestamp.ts +216 -0
  92. package/src/proto/livekit_models.ts +2456 -0
  93. package/src/proto/livekit_rtc.ts +2859 -0
  94. package/src/room/DeviceManager.ts +80 -0
  95. package/src/room/PCTransport.ts +88 -0
  96. package/src/room/RTCEngine.ts +695 -0
  97. package/src/room/Room.ts +970 -0
  98. package/src/room/errors.ts +65 -0
  99. package/src/room/events.ts +438 -0
  100. package/src/room/participant/LocalParticipant.ts +779 -0
  101. package/src/room/participant/Participant.ts +287 -0
  102. package/src/room/participant/ParticipantTrackPermission.ts +42 -0
  103. package/src/room/participant/RemoteParticipant.ts +263 -0
  104. package/src/room/participant/publishUtils.test.ts +144 -0
  105. package/src/room/participant/publishUtils.ts +258 -0
  106. package/src/room/stats.ts +134 -0
  107. package/src/room/track/LocalAudioTrack.ts +134 -0
  108. package/src/room/track/LocalTrack.ts +229 -0
  109. package/src/room/track/LocalTrackPublication.ts +87 -0
  110. package/src/room/track/LocalVideoTrack.test.ts +72 -0
  111. package/src/room/track/LocalVideoTrack.ts +295 -0
  112. package/src/room/track/RemoteAudioTrack.ts +86 -0
  113. package/src/room/track/RemoteTrack.ts +62 -0
  114. package/src/room/track/RemoteTrackPublication.ts +207 -0
  115. package/src/room/track/RemoteVideoTrack.ts +253 -0
  116. package/src/room/track/Track.ts +365 -0
  117. package/src/room/track/TrackPublication.ts +120 -0
  118. package/src/room/track/create.ts +122 -0
  119. package/src/room/track/defaults.ts +26 -0
  120. package/src/room/track/options.ts +292 -0
  121. package/src/room/track/types.ts +20 -0
  122. package/src/room/track/utils.test.ts +110 -0
  123. package/src/room/track/utils.ts +113 -0
  124. package/src/room/utils.ts +115 -0
  125. package/src/test/mocks.ts +17 -0
  126. package/src/version.ts +2 -0
  127. package/CHANGELOG.md +0 -5
@@ -325,9 +325,9 @@ livekitLogger.setLevel(LogLevel.info);
325
325
  function setLogLevel(level) {
326
326
  livekitLogger.setLevel(level);
327
327
  }
328
- /**
329
- * use this to hook into the logging function to allow sending internal livekit logs to third party services
330
- * if set, the browser logs will lose their stacktrace information (see https://github.com/pimterry/loglevel#writing-plugins)
328
+ /**
329
+ * use this to hook into the logging function to allow sending internal livekit logs to third party services
330
+ * if set, the browser logs will lose their stacktrace information (see https://github.com/pimterry/loglevel#writing-plugins)
331
331
  */
332
332
 
333
333
  function setLogExtension(extension) {
@@ -9229,237 +9229,237 @@ var MediaDeviceFailure;
9229
9229
  MediaDeviceFailure.getFailure = getFailure;
9230
9230
  })(MediaDeviceFailure || (MediaDeviceFailure = {}));
9231
9231
 
9232
- /**
9233
- * Events are the primary way LiveKit notifies your application of changes.
9234
- *
9235
- * The following are events emitted by [[Room]], listen to room events like
9236
- *
9237
- * ```typescript
9238
- * room.on(RoomEvent.TrackPublished, (track, publication, participant) => {})
9239
- * ```
9232
+ /**
9233
+ * Events are the primary way LiveKit notifies your application of changes.
9234
+ *
9235
+ * The following are events emitted by [[Room]], listen to room events like
9236
+ *
9237
+ * ```typescript
9238
+ * room.on(RoomEvent.TrackPublished, (track, publication, participant) => {})
9239
+ * ```
9240
9240
  */
9241
9241
  var RoomEvent;
9242
9242
 
9243
9243
  (function (RoomEvent) {
9244
- /**
9245
- * When the connection to the server has been interrupted and it's attempting
9246
- * to reconnect.
9244
+ /**
9245
+ * When the connection to the server has been interrupted and it's attempting
9246
+ * to reconnect.
9247
9247
  */
9248
9248
  RoomEvent["Reconnecting"] = "reconnecting";
9249
- /**
9250
- * Fires when a reconnection has been successful.
9249
+ /**
9250
+ * Fires when a reconnection has been successful.
9251
9251
  */
9252
9252
 
9253
9253
  RoomEvent["Reconnected"] = "reconnected";
9254
- /**
9255
- * When disconnected from room. This fires when room.disconnect() is called or
9256
- * when an unrecoverable connection issue had occured
9254
+ /**
9255
+ * When disconnected from room. This fires when room.disconnect() is called or
9256
+ * when an unrecoverable connection issue had occured
9257
9257
  */
9258
9258
 
9259
9259
  RoomEvent["Disconnected"] = "disconnected";
9260
- /**
9261
- * Whenever the connection state of the room changes
9262
- *
9263
- * args: ([[RoomState]])
9260
+ /**
9261
+ * Whenever the connection state of the room changes
9262
+ *
9263
+ * args: ([[RoomState]])
9264
9264
  */
9265
9265
 
9266
9266
  RoomEvent["StateChanged"] = "stateChanged";
9267
- /**
9268
- * When input or output devices on the machine have changed.
9267
+ /**
9268
+ * When input or output devices on the machine have changed.
9269
9269
  */
9270
9270
 
9271
9271
  RoomEvent["MediaDevicesChanged"] = "mediaDevicesChanged";
9272
- /**
9273
- * When a [[RemoteParticipant]] joins *after* the local
9274
- * participant. It will not emit events for participants that are already
9275
- * in the room
9276
- *
9277
- * args: ([[RemoteParticipant]])
9272
+ /**
9273
+ * When a [[RemoteParticipant]] joins *after* the local
9274
+ * participant. It will not emit events for participants that are already
9275
+ * in the room
9276
+ *
9277
+ * args: ([[RemoteParticipant]])
9278
9278
  */
9279
9279
 
9280
9280
  RoomEvent["ParticipantConnected"] = "participantConnected";
9281
- /**
9282
- * When a [[RemoteParticipant]] leaves *after* the local
9283
- * participant has joined.
9284
- *
9285
- * args: ([[RemoteParticipant]])
9281
+ /**
9282
+ * When a [[RemoteParticipant]] leaves *after* the local
9283
+ * participant has joined.
9284
+ *
9285
+ * args: ([[RemoteParticipant]])
9286
9286
  */
9287
9287
 
9288
9288
  RoomEvent["ParticipantDisconnected"] = "participantDisconnected";
9289
- /**
9290
- * When a new track is published to room *after* the local
9291
- * participant has joined. It will not fire for tracks that are already published.
9292
- *
9293
- * A track published doesn't mean the participant has subscribed to it. It's
9294
- * simply reflecting the state of the room.
9295
- *
9296
- * args: ([[RemoteTrackPublication]], [[RemoteParticipant]])
9289
+ /**
9290
+ * When a new track is published to room *after* the local
9291
+ * participant has joined. It will not fire for tracks that are already published.
9292
+ *
9293
+ * A track published doesn't mean the participant has subscribed to it. It's
9294
+ * simply reflecting the state of the room.
9295
+ *
9296
+ * args: ([[RemoteTrackPublication]], [[RemoteParticipant]])
9297
9297
  */
9298
9298
 
9299
9299
  RoomEvent["TrackPublished"] = "trackPublished";
9300
- /**
9301
- * The [[LocalParticipant]] has subscribed to a new track. This event will **always**
9302
- * fire as long as new tracks are ready for use.
9303
- *
9304
- * args: ([[RemoteTrack]], [[RemoteTrackPublication]], [[RemoteParticipant]])
9300
+ /**
9301
+ * The [[LocalParticipant]] has subscribed to a new track. This event will **always**
9302
+ * fire as long as new tracks are ready for use.
9303
+ *
9304
+ * args: ([[RemoteTrack]], [[RemoteTrackPublication]], [[RemoteParticipant]])
9305
9305
  */
9306
9306
 
9307
9307
  RoomEvent["TrackSubscribed"] = "trackSubscribed";
9308
- /**
9309
- * Could not subscribe to a track
9310
- *
9311
- * args: (track sid, [[RemoteParticipant]])
9308
+ /**
9309
+ * Could not subscribe to a track
9310
+ *
9311
+ * args: (track sid, [[RemoteParticipant]])
9312
9312
  */
9313
9313
 
9314
9314
  RoomEvent["TrackSubscriptionFailed"] = "trackSubscriptionFailed";
9315
- /**
9316
- * A [[RemoteParticipant]] has unpublished a track
9317
- *
9318
- * args: ([[RemoteTrackPublication]], [[RemoteParticipant]])
9315
+ /**
9316
+ * A [[RemoteParticipant]] has unpublished a track
9317
+ *
9318
+ * args: ([[RemoteTrackPublication]], [[RemoteParticipant]])
9319
9319
  */
9320
9320
 
9321
9321
  RoomEvent["TrackUnpublished"] = "trackUnpublished";
9322
- /**
9323
- * A subscribed track is no longer available. Clients should listen to this
9324
- * event and ensure they detach tracks.
9325
- *
9326
- * args: ([[Track]], [[RemoteTrackPublication]], [[RemoteParticipant]])
9322
+ /**
9323
+ * A subscribed track is no longer available. Clients should listen to this
9324
+ * event and ensure they detach tracks.
9325
+ *
9326
+ * args: ([[Track]], [[RemoteTrackPublication]], [[RemoteParticipant]])
9327
9327
  */
9328
9328
 
9329
9329
  RoomEvent["TrackUnsubscribed"] = "trackUnsubscribed";
9330
- /**
9331
- * A track that was muted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
9332
- *
9333
- * args: ([[TrackPublication]], [[Participant]])
9330
+ /**
9331
+ * A track that was muted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
9332
+ *
9333
+ * args: ([[TrackPublication]], [[Participant]])
9334
9334
  */
9335
9335
 
9336
9336
  RoomEvent["TrackMuted"] = "trackMuted";
9337
- /**
9338
- * A track that was unmuted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
9339
- *
9340
- * args: ([[TrackPublication]], [[Participant]])
9337
+ /**
9338
+ * A track that was unmuted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
9339
+ *
9340
+ * args: ([[TrackPublication]], [[Participant]])
9341
9341
  */
9342
9342
 
9343
9343
  RoomEvent["TrackUnmuted"] = "trackUnmuted";
9344
- /**
9345
- * A local track was published successfully. This event is helpful to know
9346
- * when to update your local UI with the newly published track.
9347
- *
9348
- * args: ([[LocalTrackPublication]], [[LocalParticipant]])
9344
+ /**
9345
+ * A local track was published successfully. This event is helpful to know
9346
+ * when to update your local UI with the newly published track.
9347
+ *
9348
+ * args: ([[LocalTrackPublication]], [[LocalParticipant]])
9349
9349
  */
9350
9350
 
9351
9351
  RoomEvent["LocalTrackPublished"] = "localTrackPublished";
9352
- /**
9353
- * A local track was unpublished. This event is helpful to know when to remove
9354
- * the local track from your UI.
9355
- *
9356
- * When a user stops sharing their screen by pressing "End" on the browser UI,
9357
- * this event will also fire.
9358
- *
9359
- * args: ([[LocalTrackPublication]], [[LocalParticipant]])
9352
+ /**
9353
+ * A local track was unpublished. This event is helpful to know when to remove
9354
+ * the local track from your UI.
9355
+ *
9356
+ * When a user stops sharing their screen by pressing "End" on the browser UI,
9357
+ * this event will also fire.
9358
+ *
9359
+ * args: ([[LocalTrackPublication]], [[LocalParticipant]])
9360
9360
  */
9361
9361
 
9362
9362
  RoomEvent["LocalTrackUnpublished"] = "localTrackUnpublished";
9363
- /**
9364
- * Active speakers changed. List of speakers are ordered by their audio level.
9365
- * loudest speakers first. This will include the LocalParticipant too.
9366
- *
9367
- * Speaker updates are sent only to the publishing participant and their subscribers.
9368
- *
9369
- * args: (Array<[[Participant]]>)
9363
+ /**
9364
+ * Active speakers changed. List of speakers are ordered by their audio level.
9365
+ * loudest speakers first. This will include the LocalParticipant too.
9366
+ *
9367
+ * Speaker updates are sent only to the publishing participant and their subscribers.
9368
+ *
9369
+ * args: (Array<[[Participant]]>)
9370
9370
  */
9371
9371
 
9372
9372
  RoomEvent["ActiveSpeakersChanged"] = "activeSpeakersChanged";
9373
- /**
9374
- * @deprecated Use ParticipantMetadataChanged instead
9375
- * @internal
9373
+ /**
9374
+ * @deprecated Use ParticipantMetadataChanged instead
9375
+ * @internal
9376
9376
  */
9377
9377
 
9378
9378
  RoomEvent["MetadataChanged"] = "metadataChanged";
9379
- /**
9380
- * Participant metadata is a simple way for app-specific state to be pushed to
9381
- * all users.
9382
- * When RoomService.UpdateParticipantMetadata is called to change a participant's
9383
- * state, *all* participants in the room will fire this event.
9384
- *
9385
- * args: (prevMetadata: string, [[Participant]])
9386
- *
9379
+ /**
9380
+ * Participant metadata is a simple way for app-specific state to be pushed to
9381
+ * all users.
9382
+ * When RoomService.UpdateParticipantMetadata is called to change a participant's
9383
+ * state, *all* participants in the room will fire this event.
9384
+ *
9385
+ * args: (prevMetadata: string, [[Participant]])
9386
+ *
9387
9387
  */
9388
9388
 
9389
9389
  RoomEvent["ParticipantMetadataChanged"] = "participantMetadataChanged";
9390
- /**
9391
- * Room metadata is a simple way for app-specific state to be pushed to
9392
- * all users.
9393
- * When RoomService.UpdateRoomMetadata is called to change a room's state,
9394
- * *all* participants in the room will fire this event.
9395
- *
9396
- * args: (string)
9390
+ /**
9391
+ * Room metadata is a simple way for app-specific state to be pushed to
9392
+ * all users.
9393
+ * When RoomService.UpdateRoomMetadata is called to change a room's state,
9394
+ * *all* participants in the room will fire this event.
9395
+ *
9396
+ * args: (string)
9397
9397
  */
9398
9398
 
9399
9399
  RoomEvent["RoomMetadataChanged"] = "roomMetadataChanged";
9400
- /**
9401
- * Data received from another participant.
9402
- * Data packets provides the ability to use LiveKit to send/receive arbitrary payloads.
9403
- * All participants in the room will receive the messages sent to the room.
9404
- *
9405
- * args: (payload: Uint8Array, participant: [[Participant]], kind: [[DataPacket_Kind]])
9400
+ /**
9401
+ * Data received from another participant.
9402
+ * Data packets provides the ability to use LiveKit to send/receive arbitrary payloads.
9403
+ * All participants in the room will receive the messages sent to the room.
9404
+ *
9405
+ * args: (payload: Uint8Array, participant: [[Participant]], kind: [[DataPacket_Kind]])
9406
9406
  */
9407
9407
 
9408
9408
  RoomEvent["DataReceived"] = "dataReceived";
9409
- /**
9410
- * Connection quality was changed for a Participant. It'll receive updates
9411
- * from the local participant, as well as any [[RemoteParticipant]]s that we are
9412
- * subscribed to.
9413
- *
9414
- * args: (connectionQuality: [[ConnectionQuality]], participant: [[Participant]])
9409
+ /**
9410
+ * Connection quality was changed for a Participant. It'll receive updates
9411
+ * from the local participant, as well as any [[RemoteParticipant]]s that we are
9412
+ * subscribed to.
9413
+ *
9414
+ * args: (connectionQuality: [[ConnectionQuality]], participant: [[Participant]])
9415
9415
  */
9416
9416
 
9417
9417
  RoomEvent["ConnectionQualityChanged"] = "connectionQualityChanged";
9418
- /**
9419
- * StreamState indicates if a subscribed (remote) track has been paused by the SFU
9420
- * (typically this happens because of subscriber's bandwidth constraints)
9421
- *
9422
- * When bandwidth conditions allow, the track will be resumed automatically.
9423
- * TrackStreamStateChanged will also be emitted when that happens.
9424
- *
9425
- * args: (pub: [[RemoteTrackPublication]], streamState: [[Track.StreamState]],
9426
- * participant: [[RemoteParticipant]])
9418
+ /**
9419
+ * StreamState indicates if a subscribed (remote) track has been paused by the SFU
9420
+ * (typically this happens because of subscriber's bandwidth constraints)
9421
+ *
9422
+ * When bandwidth conditions allow, the track will be resumed automatically.
9423
+ * TrackStreamStateChanged will also be emitted when that happens.
9424
+ *
9425
+ * args: (pub: [[RemoteTrackPublication]], streamState: [[Track.StreamState]],
9426
+ * participant: [[RemoteParticipant]])
9427
9427
  */
9428
9428
 
9429
9429
  RoomEvent["TrackStreamStateChanged"] = "trackStreamStateChanged";
9430
- /**
9431
- * One of subscribed tracks have changed its permissions for the current
9432
- * participant. If permission was revoked, then the track will no longer
9433
- * be subscribed. If permission was granted, a TrackSubscribed event will
9434
- * be emitted.
9435
- *
9436
- * args: (pub: [[RemoteTrackPublication]],
9437
- * status: [[TrackPublication.SubscriptionStatus]],
9438
- * participant: [[RemoteParticipant]])
9430
+ /**
9431
+ * One of subscribed tracks have changed its permissions for the current
9432
+ * participant. If permission was revoked, then the track will no longer
9433
+ * be subscribed. If permission was granted, a TrackSubscribed event will
9434
+ * be emitted.
9435
+ *
9436
+ * args: (pub: [[RemoteTrackPublication]],
9437
+ * status: [[TrackPublication.SubscriptionStatus]],
9438
+ * participant: [[RemoteParticipant]])
9439
9439
  */
9440
9440
 
9441
9441
  RoomEvent["TrackSubscriptionPermissionChanged"] = "trackSubscriptionPermissionChanged";
9442
- /**
9443
- * LiveKit will attempt to autoplay all audio tracks when you attach them to
9444
- * audio elements. However, if that fails, we'll notify you via AudioPlaybackStatusChanged.
9445
- * `Room.canPlayAudio` will indicate if audio playback is permitted.
9442
+ /**
9443
+ * LiveKit will attempt to autoplay all audio tracks when you attach them to
9444
+ * audio elements. However, if that fails, we'll notify you via AudioPlaybackStatusChanged.
9445
+ * `Room.canPlayAudio` will indicate if audio playback is permitted.
9446
9446
  */
9447
9447
 
9448
9448
  RoomEvent["AudioPlaybackStatusChanged"] = "audioPlaybackChanged";
9449
- /**
9450
- * When we have encountered an error while attempting to create a track.
9451
- * The errors take place in getUserMedia().
9452
- * Use MediaDeviceFailure.getFailure(error) to get the reason of failure.
9453
- * [[getAudioCreateError]] and [[getVideoCreateError]] will indicate if it had
9454
- * an error while creating the audio or video track respectively.
9455
- *
9456
- * args: (error: Error)
9449
+ /**
9450
+ * When we have encountered an error while attempting to create a track.
9451
+ * The errors take place in getUserMedia().
9452
+ * Use MediaDeviceFailure.getFailure(error) to get the reason of failure.
9453
+ * [[getAudioCreateError]] and [[getVideoCreateError]] will indicate if it had
9454
+ * an error while creating the audio or video track respectively.
9455
+ *
9456
+ * args: (error: Error)
9457
9457
  */
9458
9458
 
9459
9459
  RoomEvent["MediaDevicesError"] = "mediaDevicesError";
9460
- /**
9461
- * A participant's permission has changed. Currently only fired on LocalParticipant.
9462
- * args: (prevPermissions: [[ParticipantPermission]], participant: [[Participant]])
9460
+ /**
9461
+ * A participant's permission has changed. Currently only fired on LocalParticipant.
9462
+ * args: (prevPermissions: [[ParticipantPermission]], participant: [[Participant]])
9463
9463
  */
9464
9464
 
9465
9465
  RoomEvent["ParticipantPermissionsChanged"] = "participantPermissionsChanged";
@@ -9468,141 +9468,141 @@ var RoomEvent;
9468
9468
  var ParticipantEvent;
9469
9469
 
9470
9470
  (function (ParticipantEvent) {
9471
- /**
9472
- * When a new track is published to room *after* the local
9473
- * participant has joined. It will not fire for tracks that are already published.
9474
- *
9475
- * A track published doesn't mean the participant has subscribed to it. It's
9476
- * simply reflecting the state of the room.
9477
- *
9478
- * args: ([[RemoteTrackPublication]])
9471
+ /**
9472
+ * When a new track is published to room *after* the local
9473
+ * participant has joined. It will not fire for tracks that are already published.
9474
+ *
9475
+ * A track published doesn't mean the participant has subscribed to it. It's
9476
+ * simply reflecting the state of the room.
9477
+ *
9478
+ * args: ([[RemoteTrackPublication]])
9479
9479
  */
9480
9480
  ParticipantEvent["TrackPublished"] = "trackPublished";
9481
- /**
9482
- * Successfully subscribed to the [[RemoteParticipant]]'s track.
9483
- * This event will **always** fire as long as new tracks are ready for use.
9484
- *
9485
- * args: ([[RemoteTrack]], [[RemoteTrackPublication]])
9481
+ /**
9482
+ * Successfully subscribed to the [[RemoteParticipant]]'s track.
9483
+ * This event will **always** fire as long as new tracks are ready for use.
9484
+ *
9485
+ * args: ([[RemoteTrack]], [[RemoteTrackPublication]])
9486
9486
  */
9487
9487
 
9488
9488
  ParticipantEvent["TrackSubscribed"] = "trackSubscribed";
9489
- /**
9490
- * Could not subscribe to a track
9491
- *
9492
- * args: (track sid)
9489
+ /**
9490
+ * Could not subscribe to a track
9491
+ *
9492
+ * args: (track sid)
9493
9493
  */
9494
9494
 
9495
9495
  ParticipantEvent["TrackSubscriptionFailed"] = "trackSubscriptionFailed";
9496
- /**
9497
- * A [[RemoteParticipant]] has unpublished a track
9498
- *
9499
- * args: ([[RemoteTrackPublication]])
9496
+ /**
9497
+ * A [[RemoteParticipant]] has unpublished a track
9498
+ *
9499
+ * args: ([[RemoteTrackPublication]])
9500
9500
  */
9501
9501
 
9502
9502
  ParticipantEvent["TrackUnpublished"] = "trackUnpublished";
9503
- /**
9504
- * A subscribed track is no longer available. Clients should listen to this
9505
- * event and ensure they detach tracks.
9506
- *
9507
- * args: ([[RemoteTrack]], [[RemoteTrackPublication]])
9503
+ /**
9504
+ * A subscribed track is no longer available. Clients should listen to this
9505
+ * event and ensure they detach tracks.
9506
+ *
9507
+ * args: ([[RemoteTrack]], [[RemoteTrackPublication]])
9508
9508
  */
9509
9509
 
9510
9510
  ParticipantEvent["TrackUnsubscribed"] = "trackUnsubscribed";
9511
- /**
9512
- * A track that was muted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
9513
- *
9514
- * args: ([[TrackPublication]])
9511
+ /**
9512
+ * A track that was muted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
9513
+ *
9514
+ * args: ([[TrackPublication]])
9515
9515
  */
9516
9516
 
9517
9517
  ParticipantEvent["TrackMuted"] = "trackMuted";
9518
- /**
9519
- * A track that was unmuted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
9520
- *
9521
- * args: ([[TrackPublication]])
9518
+ /**
9519
+ * A track that was unmuted, fires on both [[RemoteParticipant]]s and [[LocalParticipant]]
9520
+ *
9521
+ * args: ([[TrackPublication]])
9522
9522
  */
9523
9523
 
9524
9524
  ParticipantEvent["TrackUnmuted"] = "trackUnmuted";
9525
- /**
9526
- * A local track was published successfully. This event is helpful to know
9527
- * when to update your local UI with the newly published track.
9528
- *
9529
- * args: ([[LocalTrackPublication]])
9525
+ /**
9526
+ * A local track was published successfully. This event is helpful to know
9527
+ * when to update your local UI with the newly published track.
9528
+ *
9529
+ * args: ([[LocalTrackPublication]])
9530
9530
  */
9531
9531
 
9532
9532
  ParticipantEvent["LocalTrackPublished"] = "localTrackPublished";
9533
- /**
9534
- * A local track was unpublished. This event is helpful to know when to remove
9535
- * the local track from your UI.
9536
- *
9537
- * When a user stops sharing their screen by pressing "End" on the browser UI,
9538
- * this event will also fire.
9539
- *
9540
- * args: ([[LocalTrackPublication]])
9533
+ /**
9534
+ * A local track was unpublished. This event is helpful to know when to remove
9535
+ * the local track from your UI.
9536
+ *
9537
+ * When a user stops sharing their screen by pressing "End" on the browser UI,
9538
+ * this event will also fire.
9539
+ *
9540
+ * args: ([[LocalTrackPublication]])
9541
9541
  */
9542
9542
 
9543
9543
  ParticipantEvent["LocalTrackUnpublished"] = "localTrackUnpublished";
9544
- /**
9545
- * @deprecated Use ParticipantMetadataChanged instead
9546
- * @internal
9544
+ /**
9545
+ * @deprecated Use ParticipantMetadataChanged instead
9546
+ * @internal
9547
9547
  */
9548
9548
 
9549
9549
  ParticipantEvent["MetadataChanged"] = "metadataChanged";
9550
- /**
9551
- * Participant metadata is a simple way for app-specific state to be pushed to
9552
- * all users.
9553
- * When RoomService.UpdateParticipantMetadata is called to change a participant's
9554
- * state, *all* participants in the room will fire this event.
9555
- * To access the current metadata, see [[Participant.metadata]].
9556
- *
9557
- * args: (prevMetadata: string)
9558
- *
9550
+ /**
9551
+ * Participant metadata is a simple way for app-specific state to be pushed to
9552
+ * all users.
9553
+ * When RoomService.UpdateParticipantMetadata is called to change a participant's
9554
+ * state, *all* participants in the room will fire this event.
9555
+ * To access the current metadata, see [[Participant.metadata]].
9556
+ *
9557
+ * args: (prevMetadata: string)
9558
+ *
9559
9559
  */
9560
9560
 
9561
9561
  ParticipantEvent["ParticipantMetadataChanged"] = "participantMetadataChanged";
9562
- /**
9563
- * Data received from this participant as sender.
9564
- * Data packets provides the ability to use LiveKit to send/receive arbitrary payloads.
9565
- * All participants in the room will receive the messages sent to the room.
9566
- *
9567
- * args: (payload: Uint8Array, kind: [[DataPacket_Kind]])
9562
+ /**
9563
+ * Data received from this participant as sender.
9564
+ * Data packets provides the ability to use LiveKit to send/receive arbitrary payloads.
9565
+ * All participants in the room will receive the messages sent to the room.
9566
+ *
9567
+ * args: (payload: Uint8Array, kind: [[DataPacket_Kind]])
9568
9568
  */
9569
9569
 
9570
9570
  ParticipantEvent["DataReceived"] = "dataReceived";
9571
- /**
9572
- * Has speaking status changed for the current participant
9573
- *
9574
- * args: (speaking: boolean)
9571
+ /**
9572
+ * Has speaking status changed for the current participant
9573
+ *
9574
+ * args: (speaking: boolean)
9575
9575
  */
9576
9576
 
9577
9577
  ParticipantEvent["IsSpeakingChanged"] = "isSpeakingChanged";
9578
- /**
9579
- * Connection quality was changed for a Participant. It'll receive updates
9580
- * from the local participant, as well as any [[RemoteParticipant]]s that we are
9581
- * subscribed to.
9582
- *
9583
- * args: (connectionQuality: [[ConnectionQuality]])
9578
+ /**
9579
+ * Connection quality was changed for a Participant. It'll receive updates
9580
+ * from the local participant, as well as any [[RemoteParticipant]]s that we are
9581
+ * subscribed to.
9582
+ *
9583
+ * args: (connectionQuality: [[ConnectionQuality]])
9584
9584
  */
9585
9585
 
9586
9586
  ParticipantEvent["ConnectionQualityChanged"] = "connectionQualityChanged";
9587
- /**
9588
- * StreamState indicates if a subscribed track has been paused by the SFU
9589
- * (typically this happens because of subscriber's bandwidth constraints)
9590
- *
9591
- * When bandwidth conditions allow, the track will be resumed automatically.
9592
- * TrackStreamStateChanged will also be emitted when that happens.
9593
- *
9594
- * args: (pub: [[RemoteTrackPublication]], streamState: [[Track.StreamState]])
9587
+ /**
9588
+ * StreamState indicates if a subscribed track has been paused by the SFU
9589
+ * (typically this happens because of subscriber's bandwidth constraints)
9590
+ *
9591
+ * When bandwidth conditions allow, the track will be resumed automatically.
9592
+ * TrackStreamStateChanged will also be emitted when that happens.
9593
+ *
9594
+ * args: (pub: [[RemoteTrackPublication]], streamState: [[Track.StreamState]])
9595
9595
  */
9596
9596
 
9597
9597
  ParticipantEvent["TrackStreamStateChanged"] = "trackStreamStateChanged";
9598
- /**
9599
- * One of subscribed tracks have changed its permissions for the current
9600
- * participant. If permission was revoked, then the track will no longer
9601
- * be subscribed. If permission was granted, a TrackSubscribed event will
9602
- * be emitted.
9603
- *
9604
- * args: (pub: [[RemoteTrackPublication]],
9605
- * status: [[TrackPublication.SubscriptionStatus]])
9598
+ /**
9599
+ * One of subscribed tracks have changed its permissions for the current
9600
+ * participant. If permission was revoked, then the track will no longer
9601
+ * be subscribed. If permission was granted, a TrackSubscribed event will
9602
+ * be emitted.
9603
+ *
9604
+ * args: (pub: [[RemoteTrackPublication]],
9605
+ * status: [[TrackPublication.SubscriptionStatus]])
9606
9606
  */
9607
9607
 
9608
9608
  ParticipantEvent["TrackSubscriptionPermissionChanged"] = "trackSubscriptionPermissionChanged"; // fired only on LocalParticipant
@@ -9610,9 +9610,9 @@ var ParticipantEvent;
9610
9610
  /** @internal */
9611
9611
 
9612
9612
  ParticipantEvent["MediaDevicesError"] = "mediaDevicesError";
9613
- /**
9614
- * A participant's permission has changed. Currently only fired on LocalParticipant.
9615
- * args: (prevPermissions: [[ParticipantPermission]])
9613
+ /**
9614
+ * A participant's permission has changed. Currently only fired on LocalParticipant.
9615
+ * args: (prevPermissions: [[ParticipantPermission]])
9616
9616
  */
9617
9617
 
9618
9618
  ParticipantEvent["ParticipantPermissionsChanged"] = "participantPermissionsChanged";
@@ -9655,9 +9655,9 @@ var TrackEvent;
9655
9655
  /** @internal */
9656
9656
 
9657
9657
  TrackEvent["AudioPlaybackFailed"] = "audioPlaybackFailed";
9658
- /**
9659
- * @internal
9660
- * Only fires on LocalAudioTrack instances
9658
+ /**
9659
+ * @internal
9660
+ * Only fires on LocalAudioTrack instances
9661
9661
  */
9662
9662
 
9663
9663
  TrackEvent["AudioSilenceDetected"] = "audioSilenceDetected";
@@ -9673,15 +9673,15 @@ var TrackEvent;
9673
9673
  /** @internal */
9674
9674
 
9675
9675
  TrackEvent["ElementDetached"] = "elementDetached";
9676
- /**
9677
- * @internal
9678
- * Only fires on LocalTracks
9676
+ /**
9677
+ * @internal
9678
+ * Only fires on LocalTracks
9679
9679
  */
9680
9680
 
9681
9681
  TrackEvent["UpstreamPaused"] = "upstreamPaused";
9682
- /**
9683
- * @internal
9684
- * Only fires on LocalTracks
9682
+ /**
9683
+ * @internal
9684
+ * Only fires on LocalTracks
9685
9685
  */
9686
9686
 
9687
9687
  TrackEvent["UpstreamResumed"] = "upstreamResumed";
@@ -9783,7 +9783,7 @@ class DeviceManager {
9783
9783
  }
9784
9784
  DeviceManager.mediaDeviceKinds = ['audioinput', 'audiooutput', 'videoinput'];
9785
9785
 
9786
- const version = '0.18.4';
9786
+ const version = '0.18.6';
9787
9787
  const protocolVersion = 7;
9788
9788
 
9789
9789
  const separator = '|';
@@ -10351,7 +10351,7 @@ class Track extends events.exports.EventEmitter {
10351
10351
  };
10352
10352
 
10353
10353
  this.kind = kind;
10354
- this.mediaStreamTrack = mediaTrack;
10354
+ this._mediaStreamTrack = mediaTrack;
10355
10355
  this.source = Track.Source.Unknown;
10356
10356
 
10357
10357
  if (isWeb()) {
@@ -10368,6 +10368,10 @@ class Track extends events.exports.EventEmitter {
10368
10368
  return this._currentBitrate;
10369
10369
  }
10370
10370
 
10371
+ get mediaStreamTrack() {
10372
+ return this._mediaStreamTrack;
10373
+ }
10374
+
10371
10375
  attach(element) {
10372
10376
  let elementType = 'audio';
10373
10377
 
@@ -10401,7 +10405,7 @@ class Track extends events.exports.EventEmitter {
10401
10405
  // we'll want to re-attach it in that case
10402
10406
 
10403
10407
 
10404
- attachToElement(this.mediaStreamTrack, element);
10408
+ attachToElement(this._mediaStreamTrack, element);
10405
10409
 
10406
10410
  if (element instanceof HTMLAudioElement) {
10407
10411
  // manually play audio to detect audio playback status
@@ -10419,7 +10423,7 @@ class Track extends events.exports.EventEmitter {
10419
10423
  detach(element) {
10420
10424
  // detach from a single element
10421
10425
  if (element) {
10422
- detachTrack(this.mediaStreamTrack, element);
10426
+ detachTrack(this._mediaStreamTrack, element);
10423
10427
  const idx = this.attachedElements.indexOf(element);
10424
10428
 
10425
10429
  if (idx >= 0) {
@@ -10433,7 +10437,7 @@ class Track extends events.exports.EventEmitter {
10433
10437
 
10434
10438
  const detached = [];
10435
10439
  this.attachedElements.forEach(elm => {
10436
- detachTrack(this.mediaStreamTrack, elm);
10440
+ detachTrack(this._mediaStreamTrack, elm);
10437
10441
  detached.push(elm);
10438
10442
  this.recycleElement(elm);
10439
10443
  this.emit(TrackEvent.ElementDetached, elm);
@@ -10444,7 +10448,7 @@ class Track extends events.exports.EventEmitter {
10444
10448
  }
10445
10449
 
10446
10450
  stop() {
10447
- this.mediaStreamTrack.stop();
10451
+ this._mediaStreamTrack.stop();
10448
10452
 
10449
10453
  if (isWeb()) {
10450
10454
  document.removeEventListener('visibilitychange', this.appVisibilityChangedListener);
@@ -10452,11 +10456,11 @@ class Track extends events.exports.EventEmitter {
10452
10456
  }
10453
10457
 
10454
10458
  enable() {
10455
- this.mediaStreamTrack.enabled = true;
10459
+ this._mediaStreamTrack.enabled = true;
10456
10460
  }
10457
10461
 
10458
10462
  disable() {
10459
- this.mediaStreamTrack.enabled = false;
10463
+ this._mediaStreamTrack.enabled = false;
10460
10464
  }
10461
10465
 
10462
10466
  recycleElement(element) {
@@ -10686,14 +10690,15 @@ class LocalTrack extends Track {
10686
10690
  this.emit(TrackEvent.Ended, this);
10687
10691
  };
10688
10692
 
10689
- this.mediaStreamTrack.addEventListener('ended', this.handleEnded);
10693
+ this._mediaStreamTrack.addEventListener('ended', this.handleEnded);
10694
+
10690
10695
  this.constraints = constraints !== null && constraints !== void 0 ? constraints : mediaTrack.getConstraints();
10691
10696
  this.reacquireTrack = false;
10692
10697
  this.wasMuted = false;
10693
10698
  }
10694
10699
 
10695
10700
  get id() {
10696
- return this.mediaStreamTrack.id;
10701
+ return this._mediaStreamTrack.id;
10697
10702
  }
10698
10703
 
10699
10704
  get dimensions() {
@@ -10704,7 +10709,7 @@ class LocalTrack extends Track {
10704
10709
  const {
10705
10710
  width,
10706
10711
  height
10707
- } = this.mediaStreamTrack.getSettings();
10712
+ } = this._mediaStreamTrack.getSettings();
10708
10713
 
10709
10714
  if (width && height) {
10710
10715
  return {
@@ -10719,8 +10724,8 @@ class LocalTrack extends Track {
10719
10724
  get isUpstreamPaused() {
10720
10725
  return this._isUpstreamPaused;
10721
10726
  }
10722
- /**
10723
- * @returns DeviceID of the device that is currently being used for this track
10727
+ /**
10728
+ * @returns DeviceID of the device that is currently being used for this track
10724
10729
  */
10725
10730
 
10726
10731
 
@@ -10733,7 +10738,8 @@ class LocalTrack extends Track {
10733
10738
  const {
10734
10739
  deviceId,
10735
10740
  groupId
10736
- } = this.mediaStreamTrack.getSettings();
10741
+ } = this._mediaStreamTrack.getSettings();
10742
+
10737
10743
  const kind = this.kind === Track.Kind.Audio ? 'audioinput' : 'videoinput';
10738
10744
  return DeviceManager.getInstance().normalizeDeviceId(kind, deviceId, groupId);
10739
10745
  }
@@ -10755,17 +10761,20 @@ class LocalTrack extends Track {
10755
10761
 
10756
10762
 
10757
10763
  this.attachedElements.forEach(el => {
10758
- detachTrack(this.mediaStreamTrack, el);
10764
+ detachTrack(this._mediaStreamTrack, el);
10759
10765
  });
10760
- this.mediaStreamTrack.removeEventListener('ended', this.handleEnded); // on Safari, the old audio track must be stopped before attempting to acquire
10766
+
10767
+ this._mediaStreamTrack.removeEventListener('ended', this.handleEnded); // on Safari, the old audio track must be stopped before attempting to acquire
10761
10768
  // the new track, otherwise the new track will stop with
10762
10769
  // 'A MediaStreamTrack ended due to a capture failure`
10763
10770
 
10764
- this.mediaStreamTrack.stop();
10771
+
10772
+ this._mediaStreamTrack.stop();
10773
+
10765
10774
  track.addEventListener('ended', this.handleEnded);
10766
10775
  livekitLogger.debug('replace MediaStreamTrack');
10767
10776
  await this.sender.replaceTrack(track);
10768
- this.mediaStreamTrack = track;
10777
+ this._mediaStreamTrack = track;
10769
10778
  this.attachedElements.forEach(el => {
10770
10779
  attachToElement(track, el);
10771
10780
  });
@@ -10796,20 +10805,23 @@ class LocalTrack extends Track {
10796
10805
 
10797
10806
 
10798
10807
  this.attachedElements.forEach(el => {
10799
- detachTrack(this.mediaStreamTrack, el);
10808
+ detachTrack(this._mediaStreamTrack, el);
10800
10809
  });
10801
- this.mediaStreamTrack.removeEventListener('ended', this.handleEnded); // on Safari, the old audio track must be stopped before attempting to acquire
10810
+
10811
+ this._mediaStreamTrack.removeEventListener('ended', this.handleEnded); // on Safari, the old audio track must be stopped before attempting to acquire
10802
10812
  // the new track, otherwise the new track will stop with
10803
10813
  // 'A MediaStreamTrack ended due to a capture failure`
10804
10814
 
10805
- this.mediaStreamTrack.stop(); // create new track and attach
10815
+
10816
+ this._mediaStreamTrack.stop(); // create new track and attach
10817
+
10806
10818
 
10807
10819
  const mediaStream = await navigator.mediaDevices.getUserMedia(streamConstraints);
10808
10820
  const newTrack = mediaStream.getTracks()[0];
10809
10821
  newTrack.addEventListener('ended', this.handleEnded);
10810
10822
  livekitLogger.debug('re-acquired MediaStreamTrack');
10811
10823
  await this.sender.replaceTrack(newTrack);
10812
- this.mediaStreamTrack = newTrack;
10824
+ this._mediaStreamTrack = newTrack;
10813
10825
  this.attachedElements.forEach(el => {
10814
10826
  attachToElement(newTrack, el);
10815
10827
  });
@@ -10824,12 +10836,12 @@ class LocalTrack extends Track {
10824
10836
  }
10825
10837
 
10826
10838
  this.isMuted = muted;
10827
- this.mediaStreamTrack.enabled = !muted;
10839
+ this._mediaStreamTrack.enabled = !muted;
10828
10840
  this.emit(muted ? TrackEvent.Muted : TrackEvent.Unmuted, this);
10829
10841
  }
10830
10842
 
10831
10843
  get needsReAcquisition() {
10832
- return this.mediaStreamTrack.readyState !== 'live' || this.mediaStreamTrack.muted || !this.mediaStreamTrack.enabled || this.reacquireTrack;
10844
+ return this._mediaStreamTrack.readyState !== 'live' || this._mediaStreamTrack.muted || !this._mediaStreamTrack.enabled || this.reacquireTrack;
10833
10845
  }
10834
10846
 
10835
10847
  async handleAppVisibilityChanged() {
@@ -10879,7 +10891,7 @@ class LocalTrack extends Track {
10879
10891
 
10880
10892
  this._isUpstreamPaused = false;
10881
10893
  this.emit(TrackEvent.UpstreamResumed, this);
10882
- await this.sender.replaceTrack(this.mediaStreamTrack);
10894
+ await this.sender.replaceTrack(this._mediaStreamTrack);
10883
10895
  }
10884
10896
 
10885
10897
  }
@@ -10948,9 +10960,9 @@ function constraintsForOptions(options) {
10948
10960
 
10949
10961
  return constraints;
10950
10962
  }
10951
- /**
10952
- * This function detects silence on a given [[Track]] instance.
10953
- * Returns true if the track seems to be entirely silent.
10963
+ /**
10964
+ * This function detects silence on a given [[Track]] instance.
10965
+ * Returns true if the track seems to be entirely silent.
10954
10966
  */
10955
10967
 
10956
10968
  async function detectSilence(track) {
@@ -10973,8 +10985,8 @@ async function detectSilence(track) {
10973
10985
 
10974
10986
  return false;
10975
10987
  }
10976
- /**
10977
- * @internal
10988
+ /**
10989
+ * @internal
10978
10990
  */
10979
10991
 
10980
10992
  function getNewAudioContext() {
@@ -11004,7 +11016,9 @@ class LocalAudioTrack extends LocalTrack {
11004
11016
  try {
11005
11017
  stats = await this.getSenderStats();
11006
11018
  } catch (e) {
11007
- livekitLogger.error('could not get audio sender stats', e);
11019
+ livekitLogger.error('could not get audio sender stats', {
11020
+ error: e
11021
+ });
11008
11022
  return;
11009
11023
  }
11010
11024
 
@@ -11038,7 +11052,7 @@ class LocalAudioTrack extends LocalTrack {
11038
11052
  if (this.source === Track.Source.Microphone && this.stopOnMute) {
11039
11053
  livekitLogger.debug('stopping mic track'); // also stop the track, so that microphone indicator is turned off
11040
11054
 
11041
- this.mediaStreamTrack.stop();
11055
+ this._mediaStreamTrack.stop();
11042
11056
  }
11043
11057
 
11044
11058
  await super.mute();
@@ -11192,7 +11206,9 @@ class LocalVideoTrack extends LocalTrack {
11192
11206
 
11193
11207
  stop() {
11194
11208
  this.sender = undefined;
11195
- this.mediaStreamTrack.getConstraints();
11209
+
11210
+ this._mediaStreamTrack.getConstraints();
11211
+
11196
11212
  super.stop();
11197
11213
  }
11198
11214
 
@@ -11200,7 +11216,7 @@ class LocalVideoTrack extends LocalTrack {
11200
11216
  if (this.source === Track.Source.Camera) {
11201
11217
  livekitLogger.debug('stopping camera track'); // also stop the track, so that camera indicator is turned off
11202
11218
 
11203
- this.mediaStreamTrack.stop();
11219
+ this._mediaStreamTrack.stop();
11204
11220
  }
11205
11221
 
11206
11222
  await super.mute();
@@ -11302,9 +11318,9 @@ class LocalVideoTrack extends LocalTrack {
11302
11318
 
11303
11319
  await this.restart(constraints);
11304
11320
  }
11305
- /**
11306
- * @internal
11307
- * Sets layers that should be publishing
11321
+ /**
11322
+ * @internal
11323
+ * Sets layers that should be publishing
11308
11324
  */
11309
11325
 
11310
11326
 
@@ -11381,7 +11397,7 @@ class LocalVideoTrack extends LocalTrack {
11381
11397
  if (!isMobile()) return;
11382
11398
 
11383
11399
  if (this.isInBackground && this.source === Track.Source.Camera) {
11384
- this.mediaStreamTrack.enabled = false;
11400
+ this._mediaStreamTrack.enabled = false;
11385
11401
  }
11386
11402
  }
11387
11403
 
@@ -11510,8 +11526,8 @@ class RemoteAudioTrack extends RemoteTrack {
11510
11526
 
11511
11527
  this.elementVolume = 1;
11512
11528
  }
11513
- /**
11514
- * sets the volume for all attached audio elements
11529
+ /**
11530
+ * sets the volume for all attached audio elements
11515
11531
  */
11516
11532
 
11517
11533
 
@@ -11522,8 +11538,8 @@ class RemoteAudioTrack extends RemoteTrack {
11522
11538
 
11523
11539
  this.elementVolume = volume;
11524
11540
  }
11525
- /**
11526
- * gets the volume for all attached audio elements
11541
+ /**
11542
+ * gets the volume for all attached audio elements
11527
11543
  */
11528
11544
 
11529
11545
 
@@ -11625,6 +11641,7 @@ class RemoteVideoTrack extends RemoteTrack {
11625
11641
  constructor(mediaTrack, sid, receiver, adaptiveStreamSettings) {
11626
11642
  super(mediaTrack, sid, Track.Kind.Video, receiver);
11627
11643
  this.elementInfos = [];
11644
+ this.hasUsedAttach = false;
11628
11645
 
11629
11646
  this.monitorReceiver = async () => {
11630
11647
  if (!this.receiver) {
@@ -11672,6 +11689,14 @@ class RemoteVideoTrack extends RemoteTrack {
11672
11689
  get isAdaptiveStream() {
11673
11690
  return this.adaptiveStreamSettings !== undefined;
11674
11691
  }
11692
+
11693
+ get mediaStreamTrack() {
11694
+ if (this.isAdaptiveStream && !this.hasUsedAttach) {
11695
+ livekitLogger.warn('When using adaptiveStream, you need to use remoteVideoTrack.attach() to add the track to a HTMLVideoElement, otherwise your video tracks might never start');
11696
+ }
11697
+
11698
+ return this._mediaStreamTrack;
11699
+ }
11675
11700
  /** @internal */
11676
11701
 
11677
11702
 
@@ -11680,9 +11705,9 @@ class RemoteVideoTrack extends RemoteTrack {
11680
11705
  this.attachedElements.forEach(element => {
11681
11706
  // detach or attach
11682
11707
  if (muted) {
11683
- detachTrack(this.mediaStreamTrack, element);
11708
+ detachTrack(this._mediaStreamTrack, element);
11684
11709
  } else {
11685
- attachToElement(this.mediaStreamTrack, element);
11710
+ attachToElement(this._mediaStreamTrack, element);
11686
11711
  }
11687
11712
  });
11688
11713
  }
@@ -11712,6 +11737,7 @@ class RemoteVideoTrack extends RemoteTrack {
11712
11737
  this.debouncedHandleResize();
11713
11738
  }
11714
11739
 
11740
+ this.hasUsedAttach = true;
11715
11741
  return element;
11716
11742
  }
11717
11743
 
@@ -11876,8 +11902,8 @@ class TrackPublication extends events.exports.EventEmitter {
11876
11902
  get isSubscribed() {
11877
11903
  return this.track !== undefined;
11878
11904
  }
11879
- /**
11880
- * an [AudioTrack] if this publication holds an audio track
11905
+ /**
11906
+ * an [AudioTrack] if this publication holds an audio track
11881
11907
  */
11882
11908
 
11883
11909
 
@@ -11886,8 +11912,8 @@ class TrackPublication extends events.exports.EventEmitter {
11886
11912
  return this.track;
11887
11913
  }
11888
11914
  }
11889
- /**
11890
- * an [VideoTrack] if this publication holds a video track
11915
+ /**
11916
+ * an [VideoTrack] if this publication holds a video track
11891
11917
  */
11892
11918
 
11893
11919
 
@@ -11973,8 +11999,8 @@ class LocalTrackPublication extends TrackPublication {
11973
11999
  get videoTrack() {
11974
12000
  return super.videoTrack;
11975
12001
  }
11976
- /**
11977
- * Mute the track associated with this publication
12002
+ /**
12003
+ * Mute the track associated with this publication
11978
12004
  */
11979
12005
 
11980
12006
 
@@ -11983,8 +12009,8 @@ class LocalTrackPublication extends TrackPublication {
11983
12009
 
11984
12010
  return (_a = this.track) === null || _a === void 0 ? void 0 : _a.mute();
11985
12011
  }
11986
- /**
11987
- * Unmute track associated with this publication
12012
+ /**
12013
+ * Unmute track associated with this publication
11988
12014
  */
11989
12015
 
11990
12016
 
@@ -11993,10 +12019,10 @@ class LocalTrackPublication extends TrackPublication {
11993
12019
 
11994
12020
  return (_a = this.track) === null || _a === void 0 ? void 0 : _a.unmute();
11995
12021
  }
11996
- /**
11997
- * Pauses the media stream track associated with this publication from being sent to the server
11998
- * and signals "muted" event to other participants
11999
- * Useful if you want to pause the stream without pausing the local media stream track
12022
+ /**
12023
+ * Pauses the media stream track associated with this publication from being sent to the server
12024
+ * and signals "muted" event to other participants
12025
+ * Useful if you want to pause the stream without pausing the local media stream track
12000
12026
  */
12001
12027
 
12002
12028
 
@@ -12005,9 +12031,9 @@ class LocalTrackPublication extends TrackPublication {
12005
12031
 
12006
12032
  await ((_a = this.track) === null || _a === void 0 ? void 0 : _a.pauseUpstream());
12007
12033
  }
12008
- /**
12009
- * Resumes sending the media stream track associated with this publication to the server after a call to [[pauseUpstream()]]
12010
- * and signals "unmuted" event to other participants (unless the track is explicitly muted)
12034
+ /**
12035
+ * Resumes sending the media stream track associated with this publication to the server after a call to [[pauseUpstream()]]
12036
+ * and signals "unmuted" event to other participants (unless the track is explicitly muted)
12011
12037
  */
12012
12038
 
12013
12039
 
@@ -12052,8 +12078,8 @@ var AudioPresets;
12052
12078
  maxBitrate: 32000
12053
12079
  };
12054
12080
  })(AudioPresets || (AudioPresets = {}));
12055
- /**
12056
- * Sane presets for video resolution/encoding
12081
+ /**
12082
+ * Sane presets for video resolution/encoding
12057
12083
  */
12058
12084
 
12059
12085
 
@@ -12063,7 +12089,7 @@ const VideoPresets = {
12063
12089
  h216: new VideoPreset(384, 216, 180000, 15),
12064
12090
  h360: new VideoPreset(640, 360, 300000, 20),
12065
12091
  h540: new VideoPreset(960, 540, 600000, 25),
12066
- h720: new VideoPreset(1280, 720, 2000000, 30),
12092
+ h720: new VideoPreset(1280, 720, 1700000, 30),
12067
12093
  h1080: new VideoPreset(1920, 1080, 3000000, 30),
12068
12094
  h1440: new VideoPreset(2560, 1440, 5000000, 30),
12069
12095
  h2160: new VideoPreset(3840, 2160, 8000000, 30),
@@ -12078,13 +12104,13 @@ const VideoPresets = {
12078
12104
  qhd: new VideoPreset(960, 540, 600000, 25),
12079
12105
 
12080
12106
  /** @deprecated */
12081
- hd: new VideoPreset(1280, 720, 2000000, 30),
12107
+ hd: new VideoPreset(1280, 720, 1700000, 30),
12082
12108
 
12083
12109
  /** @deprecated */
12084
12110
  fhd: new VideoPreset(1920, 1080, 3000000, 30)
12085
12111
  };
12086
- /**
12087
- * Four by three presets
12112
+ /**
12113
+ * Four by three presets
12088
12114
  */
12089
12115
 
12090
12116
  const VideoPresets43 = {
@@ -12182,11 +12208,11 @@ class Participant extends events.exports.EventEmitter {
12182
12208
  getTracks() {
12183
12209
  return Array.from(this.tracks.values());
12184
12210
  }
12185
- /**
12186
- * Finds the first track that matches the source filter, for example, getting
12187
- * the user's camera track with getTrackBySource(Track.Source.Camera).
12188
- * @param source
12189
- * @returns
12211
+ /**
12212
+ * Finds the first track that matches the source filter, for example, getting
12213
+ * the user's camera track with getTrackBySource(Track.Source.Camera).
12214
+ * @param source
12215
+ * @returns
12190
12216
  */
12191
12217
 
12192
12218
 
@@ -12219,10 +12245,10 @@ class Participant extends events.exports.EventEmitter {
12219
12245
  }
12220
12246
  }
12221
12247
  }
12222
- /**
12223
- * Finds the first track that matches the track's name.
12224
- * @param name
12225
- * @returns
12248
+ /**
12249
+ * Finds the first track that matches the track's name.
12250
+ * @param name
12251
+ * @returns
12226
12252
  */
12227
12253
 
12228
12254
 
@@ -12432,9 +12458,10 @@ function computeVideoEncodings(isScreenShare, width, height, options) {
12432
12458
  }
12433
12459
 
12434
12460
  const useSimulcast = options === null || options === void 0 ? void 0 : options.simulcast;
12461
+ const scalabilityMode = options === null || options === void 0 ? void 0 : options.scalabilityMode;
12435
12462
 
12436
- if (!videoEncoding && !useSimulcast || !width || !height) {
12437
- // when we aren't simulcasting, will need to return a single encoding without
12463
+ if (!videoEncoding && !useSimulcast && !scalabilityMode || !width || !height) {
12464
+ // when we aren't simulcasting or svc, will need to return a single encoding without
12438
12465
  // capping bandwidth. we always require a encoding for dynacast
12439
12466
  return [{}];
12440
12467
  }
@@ -12445,11 +12472,41 @@ function computeVideoEncodings(isScreenShare, width, height, options) {
12445
12472
  livekitLogger.debug('using video encoding', videoEncoding);
12446
12473
  }
12447
12474
 
12475
+ const original = new VideoPreset(width, height, videoEncoding.maxBitrate, videoEncoding.maxFramerate);
12476
+ livekitLogger.debug("scalabilityMode ".concat(scalabilityMode));
12477
+
12478
+ if (scalabilityMode) {
12479
+ const encodings = []; // svc use first encoding as the original, so we sort encoding from high to low
12480
+
12481
+ switch (scalabilityMode) {
12482
+ case 'L3T3':
12483
+ for (let i = 0; i < 3; i += 1) {
12484
+ encodings.push({
12485
+ rid: videoRids[2 - i],
12486
+ scaleResolutionDownBy: 2 ** i,
12487
+ maxBitrate: videoEncoding ? videoEncoding.maxBitrate / 2 ** i : 0,
12488
+
12489
+ /* @ts-ignore */
12490
+ maxFramerate: original.encoding.maxFramerate,
12491
+
12492
+ /* @ts-ignore */
12493
+ scalabilityMode: 'L3T3'
12494
+ });
12495
+ }
12496
+
12497
+ livekitLogger.debug('encodings', encodings);
12498
+ return encodings;
12499
+
12500
+ default:
12501
+ // TODO : support other scalability modes
12502
+ throw new Error("unsupported scalabilityMode: ".concat(scalabilityMode));
12503
+ }
12504
+ }
12505
+
12448
12506
  if (!useSimulcast) {
12449
12507
  return [videoEncoding];
12450
12508
  }
12451
12509
 
12452
- const original = new VideoPreset(width, height, videoEncoding.maxBitrate, videoEncoding.maxFramerate);
12453
12510
  let presets = [];
12454
12511
 
12455
12512
  if (isScreenShare) {
@@ -12618,9 +12675,9 @@ class RemoteTrackPublication extends TrackPublication {
12618
12675
  this.emitTrackUpdate();
12619
12676
  };
12620
12677
  }
12621
- /**
12622
- * Subscribe or unsubscribe to this remote track
12623
- * @param subscribed true to subscribe to a track, false to unsubscribe
12678
+ /**
12679
+ * Subscribe or unsubscribe to this remote track
12680
+ * @param subscribed true to subscribe to a track, false to unsubscribe
12624
12681
  */
12625
12682
 
12626
12683
 
@@ -12650,8 +12707,8 @@ class RemoteTrackPublication extends TrackPublication {
12650
12707
 
12651
12708
  return TrackPublication.SubscriptionStatus.Subscribed;
12652
12709
  }
12653
- /**
12654
- * Returns true if track is subscribed, and ready for playback
12710
+ /**
12711
+ * Returns true if track is subscribed, and ready for playback
12655
12712
  */
12656
12713
 
12657
12714
 
@@ -12670,11 +12727,11 @@ class RemoteTrackPublication extends TrackPublication {
12670
12727
  get isEnabled() {
12671
12728
  return !this.disabled;
12672
12729
  }
12673
- /**
12674
- * disable server from sending down data for this track. this is useful when
12675
- * the participant is off screen, you may disable streaming down their video
12676
- * to reduce bandwidth requirements
12677
- * @param enabled
12730
+ /**
12731
+ * disable server from sending down data for this track. this is useful when
12732
+ * the participant is off screen, you may disable streaming down their video
12733
+ * to reduce bandwidth requirements
12734
+ * @param enabled
12678
12735
  */
12679
12736
 
12680
12737
 
@@ -12686,12 +12743,12 @@ class RemoteTrackPublication extends TrackPublication {
12686
12743
  this.disabled = !enabled;
12687
12744
  this.emitTrackUpdate();
12688
12745
  }
12689
- /**
12690
- * for tracks that support simulcasting, adjust subscribed quality
12691
- *
12692
- * This indicates the highest quality the client can accept. if network
12693
- * bandwidth does not allow, server will automatically reduce quality to
12694
- * optimize for uninterrupted video
12746
+ /**
12747
+ * for tracks that support simulcasting, adjust subscribed quality
12748
+ *
12749
+ * This indicates the highest quality the client can accept. if network
12750
+ * bandwidth does not allow, server will automatically reduce quality to
12751
+ * optimize for uninterrupted video
12695
12752
  */
12696
12753
 
12697
12754
 
@@ -12851,8 +12908,8 @@ class RemoteParticipant extends Participant {
12851
12908
  return track;
12852
12909
  }
12853
12910
  }
12854
- /**
12855
- * sets the volume on the participant's microphone track if it exists.
12911
+ /**
12912
+ * sets the volume on the participant's microphone track if it exists.
12856
12913
  */
12857
12914
 
12858
12915
 
@@ -12863,9 +12920,9 @@ class RemoteParticipant extends Participant {
12863
12920
  audioPublication.track.setVolume(volume);
12864
12921
  }
12865
12922
  }
12866
- /**
12867
- * gets the volume on the participant's microphone track
12868
- * returns undefined if no microphone track exists
12923
+ /**
12924
+ * gets the volume on the participant's microphone track
12925
+ * returns undefined if no microphone track exists
12869
12926
  */
12870
12927
 
12871
12928
 
@@ -13174,31 +13231,31 @@ class LocalParticipant extends Participant {
13174
13231
  return track;
13175
13232
  }
13176
13233
  }
13177
- /**
13178
- * Enable or disable a participant's camera track.
13179
- *
13180
- * If a track has already published, it'll mute or unmute the track.
13181
- * Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
13234
+ /**
13235
+ * Enable or disable a participant's camera track.
13236
+ *
13237
+ * If a track has already published, it'll mute or unmute the track.
13238
+ * Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
13182
13239
  */
13183
13240
 
13184
13241
 
13185
13242
  setCameraEnabled(enabled) {
13186
13243
  return this.setTrackEnabled(Track.Source.Camera, enabled);
13187
13244
  }
13188
- /**
13189
- * Enable or disable a participant's microphone track.
13190
- *
13191
- * If a track has already published, it'll mute or unmute the track.
13192
- * Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
13245
+ /**
13246
+ * Enable or disable a participant's microphone track.
13247
+ *
13248
+ * If a track has already published, it'll mute or unmute the track.
13249
+ * Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
13193
13250
  */
13194
13251
 
13195
13252
 
13196
13253
  setMicrophoneEnabled(enabled) {
13197
13254
  return this.setTrackEnabled(Track.Source.Microphone, enabled);
13198
13255
  }
13199
- /**
13200
- * Start or stop sharing a participant's screen
13201
- * Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
13256
+ /**
13257
+ * Start or stop sharing a participant's screen
13258
+ * Resolves with a `LocalTrackPublication` instance if successful and `undefined` otherwise
13202
13259
  */
13203
13260
 
13204
13261
 
@@ -13218,10 +13275,10 @@ class LocalParticipant extends Participant {
13218
13275
 
13219
13276
  return changed;
13220
13277
  }
13221
- /**
13222
- * Enable or disable publishing for a track by source. This serves as a simple
13223
- * way to manage the common tracks (camera, mic, or screen share).
13224
- * Resolves with LocalTrackPublication if successful and void otherwise
13278
+ /**
13279
+ * Enable or disable publishing for a track by source. This serves as a simple
13280
+ * way to manage the common tracks (camera, mic, or screen share).
13281
+ * Resolves with LocalTrackPublication if successful and void otherwise
13225
13282
  */
13226
13283
 
13227
13284
 
@@ -13294,9 +13351,9 @@ class LocalParticipant extends Participant {
13294
13351
 
13295
13352
  return track;
13296
13353
  }
13297
- /**
13298
- * Publish both camera and microphone at the same time. This is useful for
13299
- * displaying a single Permission Dialog box to the end user.
13354
+ /**
13355
+ * Publish both camera and microphone at the same time. This is useful for
13356
+ * displaying a single Permission Dialog box to the end user.
13300
13357
  */
13301
13358
 
13302
13359
 
@@ -13320,10 +13377,10 @@ class LocalParticipant extends Participant {
13320
13377
  this.pendingPublishing.delete(Track.Source.Microphone);
13321
13378
  }
13322
13379
  }
13323
- /**
13324
- * Create local camera and/or microphone tracks
13325
- * @param options
13326
- * @returns
13380
+ /**
13381
+ * Create local camera and/or microphone tracks
13382
+ * @param options
13383
+ * @returns
13327
13384
  */
13328
13385
 
13329
13386
 
@@ -13381,10 +13438,10 @@ class LocalParticipant extends Participant {
13381
13438
  return track;
13382
13439
  });
13383
13440
  }
13384
- /**
13385
- * Creates a screen capture tracks with getDisplayMedia().
13386
- * A LocalVideoTrack is always created and returned.
13387
- * If { audio: true }, and the browser supports audio capture, a LocalAudioTrack is also created.
13441
+ /**
13442
+ * Creates a screen capture tracks with getDisplayMedia().
13443
+ * A LocalVideoTrack is always created and returned.
13444
+ * If { audio: true }, and the browser supports audio capture, a LocalAudioTrack is also created.
13388
13445
  */
13389
13446
 
13390
13447
 
@@ -13433,15 +13490,15 @@ class LocalParticipant extends Participant {
13433
13490
 
13434
13491
  return localTracks;
13435
13492
  }
13436
- /**
13437
- * Publish a new track to the room
13438
- * @param track
13439
- * @param options
13493
+ /**
13494
+ * Publish a new track to the room
13495
+ * @param track
13496
+ * @param options
13440
13497
  */
13441
13498
 
13442
13499
 
13443
13500
  async publishTrack(track, options) {
13444
- var _a, _b, _c, _d, _e, _f;
13501
+ var _a, _b, _c, _d, _e, _f, _g;
13445
13502
 
13446
13503
  const opts = _objectSpread2(_objectSpread2({}, (_a = this.roomOptions) === null || _a === void 0 ? void 0 : _a.publishDefaults), options); // convert raw media track into audio or video track
13447
13504
 
@@ -13514,7 +13571,19 @@ class LocalParticipant extends Participant {
13514
13571
  const height = (_e = settings.height) !== null && _e !== void 0 ? _e : (_f = track.dimensions) === null || _f === void 0 ? void 0 : _f.height; // width and height should be defined for video
13515
13572
 
13516
13573
  req.width = width !== null && width !== void 0 ? width : 0;
13517
- req.height = height !== null && height !== void 0 ? height : 0;
13574
+ req.height = height !== null && height !== void 0 ? height : 0; // for svc codecs, disable simulcast and enable scalability L3T3
13575
+ // by default
13576
+
13577
+ if (track instanceof LocalVideoTrack) {
13578
+ if ((opts === null || opts === void 0 ? void 0 : opts.videoCodec) === 'vp9' || (opts === null || opts === void 0 ? void 0 : opts.videoCodec) === 'av1') {
13579
+ opts.simulcast = false;
13580
+ opts.scalabilityMode = (_g = opts.scalabilityMode) !== null && _g !== void 0 ? _g : 'L3T3';
13581
+ } else {
13582
+ // other codecs, unset scalability
13583
+ opts.scalabilityMode = undefined;
13584
+ }
13585
+ }
13586
+
13518
13587
  encodings = computeVideoEncodings(track.source === Track.Source.ScreenShare, width, height, opts);
13519
13588
  req.layers = videoLayersFromEncodings(req.width, req.height, encodings);
13520
13589
  } else if (track.kind === Track.Kind.Audio && opts.audioBitrate) {
@@ -13544,6 +13613,11 @@ class LocalParticipant extends Participant {
13544
13613
  }
13545
13614
 
13546
13615
  const transceiver = this.engine.publisher.pc.addTransceiver(track.mediaStreamTrack, transceiverInit);
13616
+
13617
+ if (opts.videoCodec) {
13618
+ this.setPreferredCodec(transceiver, track.kind, opts.videoCodec);
13619
+ }
13620
+
13547
13621
  this.engine.negotiate(); // store RTPSender
13548
13622
 
13549
13623
  track.sender = transceiver.sender;
@@ -13554,10 +13628,6 @@ class LocalParticipant extends Participant {
13554
13628
  track.startMonitor();
13555
13629
  }
13556
13630
 
13557
- if (opts.videoCodec) {
13558
- this.setPreferredCodec(transceiver, track.kind, opts.videoCodec);
13559
- }
13560
-
13561
13631
  this.addTrackPublication(publication); // send event for publication
13562
13632
 
13563
13633
  this.emit(ParticipantEvent.LocalTrackPublished, publication);
@@ -13649,16 +13719,16 @@ class LocalParticipant extends Participant {
13649
13719
  });
13650
13720
  return publications;
13651
13721
  }
13652
- /**
13653
- * Publish a new data payload to the room. Data will be forwarded to each
13654
- * participant in the room if the destination argument is empty
13655
- *
13656
- * @param data Uint8Array of the payload. To send string data, use TextEncoder.encode
13657
- * @param kind whether to send this as reliable or lossy.
13658
- * For data that you need delivery guarantee (such as chat messages), use Reliable.
13659
- * For data that should arrive as quickly as possible, but you are ok with dropped
13660
- * packets, use Lossy.
13661
- * @param destination the participants who will receive the message
13722
+ /**
13723
+ * Publish a new data payload to the room. Data will be forwarded to each
13724
+ * participant in the room if the destination argument is empty
13725
+ *
13726
+ * @param data Uint8Array of the payload. To send string data, use TextEncoder.encode
13727
+ * @param kind whether to send this as reliable or lossy.
13728
+ * For data that you need delivery guarantee (such as chat messages), use Reliable.
13729
+ * For data that should arrive as quickly as possible, but you are ok with dropped
13730
+ * packets, use Lossy.
13731
+ * @param destination the participants who will receive the message
13662
13732
  */
13663
13733
 
13664
13734
 
@@ -13685,22 +13755,22 @@ class LocalParticipant extends Participant {
13685
13755
  };
13686
13756
  await this.engine.sendDataPacket(packet, kind);
13687
13757
  }
13688
- /**
13689
- * Control who can subscribe to LocalParticipant's published tracks.
13690
- *
13691
- * By default, all participants can subscribe. This allows fine-grained control over
13692
- * who is able to subscribe at a participant and track level.
13693
- *
13694
- * Note: if access is given at a track-level (i.e. both [allParticipantsAllowed] and
13695
- * [ParticipantTrackPermission.allTracksAllowed] are false), any newer published tracks
13696
- * will not grant permissions to any participants and will require a subsequent
13697
- * permissions update to allow subscription.
13698
- *
13699
- * @param allParticipantsAllowed Allows all participants to subscribe all tracks.
13700
- * Takes precedence over [[participantTrackPermissions]] if set to true.
13701
- * By default this is set to true.
13702
- * @param participantTrackPermissions Full list of individual permissions per
13703
- * participant/track. Any omitted participants will not receive any permissions.
13758
+ /**
13759
+ * Control who can subscribe to LocalParticipant's published tracks.
13760
+ *
13761
+ * By default, all participants can subscribe. This allows fine-grained control over
13762
+ * who is able to subscribe at a participant and track level.
13763
+ *
13764
+ * Note: if access is given at a track-level (i.e. both [allParticipantsAllowed] and
13765
+ * [ParticipantTrackPermission.allTracksAllowed] are false), any newer published tracks
13766
+ * will not grant permissions to any participants and will require a subsequent
13767
+ * permissions update to allow subscription.
13768
+ *
13769
+ * @param allParticipantsAllowed Allows all participants to subscribe all tracks.
13770
+ * Takes precedence over [[participantTrackPermissions]] if set to true.
13771
+ * By default this is set to true.
13772
+ * @param participantTrackPermissions Full list of individual permissions per
13773
+ * participant/track. Any omitted participants will not receive any permissions.
13704
13774
  */
13705
13775
 
13706
13776
 
@@ -13739,21 +13809,38 @@ class LocalParticipant extends Participant {
13739
13809
 
13740
13810
  const cap = RTCRtpSender.getCapabilities(kind);
13741
13811
  if (!cap) return;
13742
- const selected = cap.codecs.find(c => {
13812
+ let selected;
13813
+ const codecs = [];
13814
+ cap.codecs.forEach(c => {
13743
13815
  const codec = c.mimeType.toLowerCase();
13744
- const matchesVideoCodec = codec === "video/".concat(videoCodec); // for h264 codecs that have sdpFmtpLine available, use only if the
13816
+ const matchesVideoCodec = codec === "video/".concat(videoCodec);
13817
+
13818
+ if (selected !== undefined) {
13819
+ codecs.push(c);
13820
+ return;
13821
+ } // for h264 codecs that have sdpFmtpLine available, use only if the
13745
13822
  // profile-level-id is 42e01f for cross-browser compatibility
13746
13823
 
13824
+
13747
13825
  if (videoCodec === 'h264' && c.sdpFmtpLine) {
13748
- return matchesVideoCodec && c.sdpFmtpLine.includes('profile-level-id=42e01f');
13826
+ if (matchesVideoCodec && c.sdpFmtpLine.includes('profile-level-id=42e01f')) {
13827
+ selected = c;
13828
+ return;
13829
+ }
13749
13830
  }
13750
13831
 
13751
- return matchesVideoCodec || codec === 'audio/opus';
13832
+ if (matchesVideoCodec || codec === 'audio/opus') {
13833
+ selected = c;
13834
+ return;
13835
+ }
13836
+
13837
+ codecs.push(c);
13752
13838
  });
13753
13839
 
13754
13840
  if (selected && 'setCodecPreferences' in transceiver) {
13755
13841
  // @ts-ignore
13756
- transceiver.setCodecPreferences([selected]);
13842
+ codecs.unshift(selected);
13843
+ transceiver.setCodecPreferences(codecs);
13757
13844
  }
13758
13845
  }
13759
13846
  /** @internal */
@@ -18525,12 +18612,11 @@ const publishDefaults = {
18525
18612
  };
18526
18613
  const audioDefaults = {
18527
18614
  autoGainControl: true,
18528
- channelCount: 1,
18529
18615
  echoCancellation: true,
18530
18616
  noiseSuppression: true
18531
18617
  };
18532
18618
  const videoDefaults = {
18533
- resolution: VideoPresets.h540.resolution
18619
+ resolution: VideoPresets.h720.resolution
18534
18620
  };
18535
18621
 
18536
18622
  var RoomState;
@@ -18540,20 +18626,20 @@ var RoomState;
18540
18626
  RoomState["Connected"] = "connected";
18541
18627
  RoomState["Reconnecting"] = "reconnecting";
18542
18628
  })(RoomState || (RoomState = {}));
18543
- /**
18544
- * In LiveKit, a room is the logical grouping for a list of participants.
18545
- * Participants in a room can publish tracks, and subscribe to others' tracks.
18546
- *
18547
- * a Room fires [[RoomEvent | RoomEvents]].
18548
- *
18549
- * @noInheritDoc
18629
+ /**
18630
+ * In LiveKit, a room is the logical grouping for a list of participants.
18631
+ * Participants in a room can publish tracks, and subscribe to others' tracks.
18632
+ *
18633
+ * a Room fires [[RoomEvent | RoomEvents]].
18634
+ *
18635
+ * @noInheritDoc
18550
18636
  */
18551
18637
 
18552
18638
 
18553
18639
  class Room extends events.exports.EventEmitter {
18554
- /**
18555
- * Creates a new Room, the primary construct for a LiveKit session.
18556
- * @param options
18640
+ /**
18641
+ * Creates a new Room, the primary construct for a LiveKit session.
18642
+ * @param options
18557
18643
  */
18558
18644
  constructor(options) {
18559
18645
  var _this;
@@ -18563,9 +18649,9 @@ class Room extends events.exports.EventEmitter {
18563
18649
  super();
18564
18650
  _this = this;
18565
18651
  this.state = RoomState.Disconnected;
18566
- /**
18567
- * list of participants that are actively speaking. when this changes
18568
- * a [[RoomEvent.ActiveSpeakersChanged]] event is fired
18652
+ /**
18653
+ * list of participants that are actively speaking. when this changes
18654
+ * a [[RoomEvent.ActiveSpeakersChanged]] event is fired
18569
18655
  */
18570
18656
 
18571
18657
  this.activeSpeakers = []; // available after connected
@@ -18677,8 +18763,8 @@ class Room extends events.exports.EventEmitter {
18677
18763
  });
18678
18764
  });
18679
18765
  };
18680
- /**
18681
- * disconnects the room, emits [[RoomEvent.Disconnected]]
18766
+ /**
18767
+ * disconnects the room, emits [[RoomEvent.Disconnected]]
18682
18768
  */
18683
18769
 
18684
18770
 
@@ -18973,13 +19059,13 @@ class Room extends events.exports.EventEmitter {
18973
19059
  }
18974
19060
  }).on(EngineEvent.Restarting, this.handleRestarting).on(EngineEvent.Restarted, this.handleRestarted);
18975
19061
  }
18976
- /**
18977
- * getLocalDevices abstracts navigator.mediaDevices.enumerateDevices.
18978
- * In particular, it handles Chrome's unique behavior of creating `default`
18979
- * devices. When encountered, it'll be removed from the list of devices.
18980
- * The actual default device will be placed at top.
18981
- * @param kind
18982
- * @returns a list of available local devices
19062
+ /**
19063
+ * getLocalDevices abstracts navigator.mediaDevices.enumerateDevices.
19064
+ * In particular, it handles Chrome's unique behavior of creating `default`
19065
+ * devices. When encountered, it'll be removed from the list of devices.
19066
+ * The actual default device will be placed at top.
19067
+ * @param kind
19068
+ * @returns a list of available local devices
18983
19069
  */
18984
19070
 
18985
19071
 
@@ -18987,10 +19073,10 @@ class Room extends events.exports.EventEmitter {
18987
19073
  let requestPermissions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
18988
19074
  return DeviceManager.getInstance().getDevices(kind, requestPermissions);
18989
19075
  }
18990
- /**
18991
- * retrieves a participant by identity
18992
- * @param identity
18993
- * @returns
19076
+ /**
19077
+ * retrieves a participant by identity
19078
+ * @param identity
19079
+ * @returns
18994
19080
  */
18995
19081
 
18996
19082
 
@@ -19005,8 +19091,8 @@ class Room extends events.exports.EventEmitter {
19005
19091
  return this.localParticipant;
19006
19092
  }
19007
19093
  }
19008
- /**
19009
- * @internal for testing
19094
+ /**
19095
+ * @internal for testing
19010
19096
  */
19011
19097
 
19012
19098
 
@@ -19043,12 +19129,12 @@ class Room extends events.exports.EventEmitter {
19043
19129
  this.engine.client.sendSimulateScenario(req);
19044
19130
  }
19045
19131
  }
19046
- /**
19047
- * Browsers have different policies regarding audio playback. Most requiring
19048
- * some form of user interaction (click/tap/etc).
19049
- * In those cases, audio will be silent until a click/tap triggering one of the following
19050
- * - `startAudio`
19051
- * - `getUserMedia`
19132
+ /**
19133
+ * Browsers have different policies regarding audio playback. Most requiring
19134
+ * some form of user interaction (click/tap/etc).
19135
+ * In those cases, audio will be silent until a click/tap triggering one of the following
19136
+ * - `startAudio`
19137
+ * - `getUserMedia`
19052
19138
  */
19053
19139
 
19054
19140
 
@@ -19073,23 +19159,23 @@ class Room extends events.exports.EventEmitter {
19073
19159
  throw err;
19074
19160
  }
19075
19161
  }
19076
- /**
19077
- * Returns true if audio playback is enabled
19162
+ /**
19163
+ * Returns true if audio playback is enabled
19078
19164
  */
19079
19165
 
19080
19166
 
19081
19167
  get canPlaybackAudio() {
19082
19168
  return this.audioEnabled;
19083
19169
  }
19084
- /**
19085
- * Switches all active device used in this room to the given device.
19086
- *
19087
- * Note: setting AudioOutput is not supported on some browsers. See [setSinkId](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/setSinkId#browser_compatibility)
19088
- *
19089
- * @param kind use `videoinput` for camera track,
19090
- * `audioinput` for microphone track,
19091
- * `audiooutput` to set speaker for all incoming audio tracks
19092
- * @param deviceId
19170
+ /**
19171
+ * Switches all active device used in this room to the given device.
19172
+ *
19173
+ * Note: setting AudioOutput is not supported on some browsers. See [setSinkId](https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/setSinkId#browser_compatibility)
19174
+ *
19175
+ * @param kind use `videoinput` for camera track,
19176
+ * `audioinput` for microphone track,
19177
+ * `audiooutput` to set speaker for all incoming audio tracks
19178
+ * @param deviceId
19093
19179
  */
19094
19180
 
19095
19181
 
@@ -19285,10 +19371,10 @@ class Room extends events.exports.EventEmitter {
19285
19371
  }
19286
19372
 
19287
19373
  const previousSdp = this.engine.subscriber.pc.localDescription;
19288
- /* 1. autosubscribe on, so subscribed tracks = all tracks - unsub tracks,
19289
- in this case, we send unsub tracks, so server add all tracks to this
19290
- subscribe pc and unsub special tracks from it.
19291
- 2. autosubscribe off, we send subscribed tracks.
19374
+ /* 1. autosubscribe on, so subscribed tracks = all tracks - unsub tracks,
19375
+ in this case, we send unsub tracks, so server add all tracks to this
19376
+ subscribe pc and unsub special tracks from it.
19377
+ 2. autosubscribe off, we send subscribed tracks.
19292
19378
  */
19293
19379
 
19294
19380
  const sendUnsub = ((_a = this.connOptions) === null || _a === void 0 ? void 0 : _a.autoSubscribe) || false;
@@ -19314,9 +19400,9 @@ class Room extends events.exports.EventEmitter {
19314
19400
  dataChannels: this.localParticipant.dataChannelsInfo()
19315
19401
  });
19316
19402
  }
19317
- /**
19318
- * After resuming, we'll need to notify the server of the current
19319
- * subscription settings.
19403
+ /**
19404
+ * After resuming, we'll need to notify the server of the current
19405
+ * subscription settings.
19320
19406
  */
19321
19407
 
19322
19408
 
@@ -19345,24 +19431,24 @@ class Room extends events.exports.EventEmitter {
19345
19431
 
19346
19432
  }
19347
19433
 
19348
- /**
19349
- * @deprecated Use room.connect() instead
19350
- *
19351
- * Connects to a LiveKit room, shorthand for `new Room()` and [[Room.connect]]
19352
- *
19353
- * ```typescript
19354
- * connect('wss://myhost.livekit.io', token, {
19355
- * // publish audio and video tracks on joining
19356
- * audio: true,
19357
- * video: true,
19358
- * captureDefaults: {
19359
- * facingMode: 'user',
19360
- * },
19361
- * })
19362
- * ```
19363
- * @param url URL to LiveKit server
19364
- * @param token AccessToken, a JWT token that includes authentication and room details
19365
- * @param options
19434
+ /**
19435
+ * @deprecated Use room.connect() instead
19436
+ *
19437
+ * Connects to a LiveKit room, shorthand for `new Room()` and [[Room.connect]]
19438
+ *
19439
+ * ```typescript
19440
+ * connect('wss://myhost.livekit.io', token, {
19441
+ * // publish audio and video tracks on joining
19442
+ * audio: true,
19443
+ * video: true,
19444
+ * captureDefaults: {
19445
+ * facingMode: 'user',
19446
+ * },
19447
+ * })
19448
+ * ```
19449
+ * @param url URL to LiveKit server
19450
+ * @param token AccessToken, a JWT token that includes authentication and room details
19451
+ * @param options
19366
19452
  */
19367
19453
 
19368
19454
  async function connect(url, token, options) {
@@ -19440,11 +19526,11 @@ async function connect(url, token, options) {
19440
19526
  return room;
19441
19527
  }
19442
19528
 
19443
- /**
19444
- * Creates a local video and audio track at the same time. When acquiring both
19445
- * audio and video tracks together, it'll display a single permission prompt to
19446
- * the user instead of two separate ones.
19447
- * @param options
19529
+ /**
19530
+ * Creates a local video and audio track at the same time. When acquiring both
19531
+ * audio and video tracks together, it'll display a single permission prompt to
19532
+ * the user instead of two separate ones.
19533
+ * @param options
19448
19534
  */
19449
19535
 
19450
19536
  async function createLocalTracks(options) {
@@ -19480,9 +19566,9 @@ async function createLocalTracks(options) {
19480
19566
  return track;
19481
19567
  });
19482
19568
  }
19483
- /**
19484
- * Creates a [[LocalVideoTrack]] with getUserMedia()
19485
- * @param options
19569
+ /**
19570
+ * Creates a [[LocalVideoTrack]] with getUserMedia()
19571
+ * @param options
19486
19572
  */
19487
19573
 
19488
19574
  async function createLocalVideoTrack(options) {
@@ -19499,10 +19585,10 @@ async function createLocalAudioTrack(options) {
19499
19585
  });
19500
19586
  return tracks[0];
19501
19587
  }
19502
- /**
19503
- * Creates a screen capture tracks with getDisplayMedia().
19504
- * A LocalVideoTrack is always created and returned.
19505
- * If { audio: true }, and the browser supports audio capture, a LocalAudioTrack is also created.
19588
+ /**
19589
+ * Creates a screen capture tracks with getDisplayMedia().
19590
+ * A LocalVideoTrack is always created and returned.
19591
+ * If { audio: true }, and the browser supports audio capture, a LocalAudioTrack is also created.
19506
19592
  */
19507
19593
 
19508
19594
  async function createLocalScreenTracks(options) {