livekit-client 2.0.5 → 2.0.7

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 (93) hide show
  1. package/dist/livekit-client.esm.mjs +10343 -9885
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/api/SignalClient.d.ts +1 -2
  6. package/dist/src/api/SignalClient.d.ts.map +1 -1
  7. package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
  8. package/dist/src/index.d.ts +1 -1
  9. package/dist/src/index.d.ts.map +1 -1
  10. package/dist/src/room/PCTransportManager.d.ts +1 -1
  11. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  12. package/dist/src/room/RTCEngine.d.ts +1 -2
  13. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  14. package/dist/src/room/RegionUrlProvider.d.ts +1 -1
  15. package/dist/src/room/RegionUrlProvider.d.ts.map +1 -1
  16. package/dist/src/room/Room.d.ts +1 -1
  17. package/dist/src/room/Room.d.ts.map +1 -1
  18. package/dist/src/room/participant/LocalParticipant.d.ts +1 -1
  19. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  20. package/dist/src/room/participant/Participant.d.ts +1 -1
  21. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  22. package/dist/src/room/participant/ParticipantTrackPermission.d.ts +1 -1
  23. package/dist/src/room/participant/ParticipantTrackPermission.d.ts.map +1 -1
  24. package/dist/src/room/participant/RemoteParticipant.d.ts +1 -1
  25. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  26. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  27. package/dist/src/room/track/LocalTrackPublication.d.ts +1 -1
  28. package/dist/src/room/track/LocalTrackPublication.d.ts.map +1 -1
  29. package/dist/src/room/track/LocalVideoTrack.d.ts +1 -2
  30. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  31. package/dist/src/room/track/RemoteAudioTrack.d.ts.map +1 -1
  32. package/dist/src/room/track/RemoteTrackPublication.d.ts +1 -1
  33. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  34. package/dist/src/room/track/Track.d.ts +1 -2
  35. package/dist/src/room/track/Track.d.ts.map +1 -1
  36. package/dist/src/room/track/TrackPublication.d.ts +2 -3
  37. package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
  38. package/dist/src/room/track/options.d.ts +6 -0
  39. package/dist/src/room/track/options.d.ts.map +1 -1
  40. package/dist/src/room/track/utils.d.ts +1 -1
  41. package/dist/src/room/track/utils.d.ts.map +1 -1
  42. package/dist/src/room/utils.d.ts +1 -1
  43. package/dist/src/room/utils.d.ts.map +1 -1
  44. package/dist/ts4.2/src/api/SignalClient.d.ts +1 -2
  45. package/dist/ts4.2/src/index.d.ts +1 -1
  46. package/dist/ts4.2/src/room/PCTransportManager.d.ts +1 -1
  47. package/dist/ts4.2/src/room/RTCEngine.d.ts +2 -3
  48. package/dist/ts4.2/src/room/RegionUrlProvider.d.ts +1 -1
  49. package/dist/ts4.2/src/room/Room.d.ts +1 -1
  50. package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +1 -1
  51. package/dist/ts4.2/src/room/participant/Participant.d.ts +1 -1
  52. package/dist/ts4.2/src/room/participant/ParticipantTrackPermission.d.ts +1 -1
  53. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +1 -1
  54. package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +1 -1
  55. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +1 -2
  56. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +1 -1
  57. package/dist/ts4.2/src/room/track/Track.d.ts +1 -2
  58. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +2 -3
  59. package/dist/ts4.2/src/room/track/options.d.ts +6 -0
  60. package/dist/ts4.2/src/room/track/utils.d.ts +1 -1
  61. package/dist/ts4.2/src/room/utils.d.ts +1 -1
  62. package/package.json +2 -2
  63. package/src/api/SignalClient.ts +10 -12
  64. package/src/connectionHelper/checks/websocket.ts +1 -1
  65. package/src/e2ee/E2eeManager.ts +1 -1
  66. package/src/index.ts +1 -1
  67. package/src/room/PCTransportManager.ts +1 -1
  68. package/src/room/RTCEngine.ts +21 -23
  69. package/src/room/RegionUrlProvider.ts +1 -1
  70. package/src/room/Room.ts +22 -23
  71. package/src/room/participant/LocalParticipant.ts +18 -7
  72. package/src/room/participant/Participant.ts +4 -4
  73. package/src/room/participant/ParticipantTrackPermission.ts +1 -1
  74. package/src/room/participant/RemoteParticipant.ts +6 -2
  75. package/src/room/track/LocalAudioTrack.ts +5 -2
  76. package/src/room/track/LocalTrackPublication.ts +1 -1
  77. package/src/room/track/LocalVideoTrack.ts +6 -2
  78. package/src/room/track/RemoteAudioTrack.ts +1 -1
  79. package/src/room/track/RemoteTrackPublication.ts +7 -2
  80. package/src/room/track/Track.ts +6 -6
  81. package/src/room/track/TrackPublication.ts +7 -3
  82. package/src/room/track/facingMode.ts +2 -2
  83. package/src/room/track/options.ts +7 -0
  84. package/src/room/track/utils.ts +2 -1
  85. package/src/room/utils.ts +1 -1
  86. package/dist/src/proto/livekit_models_pb.d.ts +0 -1405
  87. package/dist/src/proto/livekit_models_pb.d.ts.map +0 -1
  88. package/dist/src/proto/livekit_rtc_pb.d.ts +0 -1423
  89. package/dist/src/proto/livekit_rtc_pb.d.ts.map +0 -1
  90. package/dist/ts4.2/src/proto/livekit_models_pb.d.ts +0 -1405
  91. package/dist/ts4.2/src/proto/livekit_rtc_pb.d.ts +0 -1423
  92. package/src/proto/livekit_models_pb.ts +0 -2327
  93. package/src/proto/livekit_rtc_pb.ts +0 -2411
@@ -1,4 +1,4 @@
1
- import { TrackPermission } from '../../proto/livekit_rtc_pb';
1
+ import { TrackPermission } from '@livekit/protocol';
2
2
  export interface ParticipantTrackPermission {
3
3
  /**
4
4
  * The participant identity this permission applies to.
@@ -1,5 +1,5 @@
1
+ import type { ParticipantInfo } from '@livekit/protocol';
1
2
  import type { SignalClient } from '../../api/SignalClient';
2
- import type { ParticipantInfo } from '../../proto/livekit_models_pb';
3
3
  import RemoteTrackPublication from '../track/RemoteTrackPublication';
4
4
  import { Track } from '../track/Track';
5
5
  import type { AudioOutputOptions } from '../track/options';
@@ -1,4 +1,4 @@
1
- import type { TrackInfo } from '../../proto/livekit_models_pb';
1
+ import type { TrackInfo } from '@livekit/protocol';
2
2
  import type { LoggerOptions } from '../types';
3
3
  import type LocalAudioTrack from './LocalAudioTrack';
4
4
  import type LocalTrack from './LocalTrack';
@@ -1,6 +1,5 @@
1
+ import { SubscribedCodec, SubscribedQuality, VideoLayer } from '@livekit/protocol';
1
2
  import type { SignalClient } from '../../api/SignalClient';
2
- import { VideoLayer } from '../../proto/livekit_models_pb';
3
- import { SubscribedCodec, SubscribedQuality } from '../../proto/livekit_rtc_pb';
4
3
  import type { VideoSenderStats } from '../stats';
5
4
  import type { LoggerOptions } from '../types';
6
5
  import LocalTrack from './LocalTrack';
@@ -1,4 +1,4 @@
1
- import { SubscriptionError, TrackInfo } from '../../proto/livekit_models_pb';
1
+ import { SubscriptionError, TrackInfo } from '@livekit/protocol';
2
2
  import type { LoggerOptions } from '../types';
3
3
  import type RemoteTrack from './RemoteTrack';
4
4
  import { Track, VideoQuality } from './Track';
@@ -1,8 +1,7 @@
1
+ import { StreamState as ProtoStreamState, TrackSource, TrackType } from '@livekit/protocol';
1
2
  import type TypedEventEmitter from 'typed-emitter';
2
3
  import type { SignalClient } from '../../api/SignalClient';
3
4
  import { StructuredLogger } from '../../logger';
4
- import { TrackSource, TrackType } from '../../proto/livekit_models_pb';
5
- import { StreamState as ProtoStreamState } from '../../proto/livekit_rtc_pb';
6
5
  import type { LoggerOptions } from '../types';
7
6
  import type { TrackProcessor } from './processor/types';
8
7
  export declare enum VideoQuality {
@@ -1,7 +1,6 @@
1
+ import { Encryption_Type } from '@livekit/protocol';
2
+ import type { SubscriptionError, TrackInfo, UpdateSubscription, UpdateTrackSettings } from '@livekit/protocol';
1
3
  import type TypedEventEmitter from 'typed-emitter';
2
- import { Encryption_Type } from '../../proto/livekit_models_pb';
3
- import type { SubscriptionError, TrackInfo } from '../../proto/livekit_models_pb';
4
- import type { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc_pb';
5
4
  import type { LoggerOptions } from '../types';
6
5
  import LocalAudioTrack from './LocalAudioTrack';
7
6
  import LocalVideoTrack from './LocalVideoTrack';
@@ -165,6 +165,12 @@ export interface ScreenShareCaptureOptions {
165
165
  * local speakers when the tab is captured.
166
166
  */
167
167
  suppressLocalAudioPlayback?: boolean;
168
+ /**
169
+ * Experimental option to instruct the browser to offer the current tab as the most prominent capture source
170
+ * @experimental
171
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#prefercurrenttab
172
+ */
173
+ preferCurrentTab?: boolean;
168
174
  }
169
175
  export interface AudioCaptureOptions {
170
176
  /**
@@ -1,4 +1,4 @@
1
- import { TrackPublishedResponse } from '../../proto/livekit_rtc_pb';
1
+ import { TrackPublishedResponse } from '@livekit/protocol';
2
2
  import { Track } from './Track';
3
3
  import type { TrackPublication } from './TrackPublication';
4
4
  import type { AudioCaptureOptions, CreateLocalTracksOptions, ScreenShareCaptureOptions, VideoCaptureOptions } from './options';
@@ -1,4 +1,4 @@
1
- import { ClientInfo } from '../proto/livekit_models_pb';
1
+ import { ClientInfo } from '@livekit/protocol';
2
2
  import type LocalAudioTrack from './track/LocalAudioTrack';
3
3
  import type RemoteAudioTrack from './track/RemoteAudioTrack';
4
4
  import { VideoCodec } from './track/options';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livekit-client",
3
- "version": "2.0.5",
3
+ "version": "2.0.7",
4
4
  "description": "JavaScript/TypeScript client SDK for LiveKit",
5
5
  "main": "./dist/livekit-client.umd.js",
6
6
  "unpkg": "./dist/livekit-client.umd.js",
@@ -36,7 +36,7 @@
36
36
  "author": "David Zhao <david@davidzhao.com>",
37
37
  "license": "Apache-2.0",
38
38
  "dependencies": {
39
- "@bufbuild/protobuf": "^1.3.0",
39
+ "@livekit/protocol": "1.10.4",
40
40
  "events": "^3.3.0",
41
41
  "loglevel": "^1.8.0",
42
42
  "sdp-transform": "^2.14.1",
@@ -1,27 +1,22 @@
1
- import { protoInt64 } from '@bufbuild/protobuf';
2
- import log, { LoggerNames, getLogger } from '../logger';
3
- import {
4
- ClientInfo,
5
- DisconnectReason,
6
- ParticipantInfo,
7
- ReconnectReason,
8
- Room,
9
- SpeakerInfo,
10
- VideoLayer,
11
- } from '../proto/livekit_models_pb';
12
1
  import {
13
2
  AddTrackRequest,
3
+ ClientInfo,
14
4
  ConnectionQualityUpdate,
5
+ DisconnectReason,
15
6
  JoinResponse,
16
7
  LeaveRequest,
17
8
  MuteTrackRequest,
9
+ ParticipantInfo,
18
10
  Ping,
11
+ ReconnectReason,
19
12
  ReconnectResponse,
13
+ Room,
20
14
  SessionDescription,
21
15
  SignalRequest,
22
16
  SignalResponse,
23
17
  SignalTarget,
24
18
  SimulateScenario,
19
+ SpeakerInfo,
25
20
  StreamStateUpdate,
26
21
  SubscribedQualityUpdate,
27
22
  SubscriptionPermission,
@@ -36,7 +31,10 @@ import {
36
31
  UpdateSubscription,
37
32
  UpdateTrackSettings,
38
33
  UpdateVideoLayers,
39
- } from '../proto/livekit_rtc_pb';
34
+ VideoLayer,
35
+ protoInt64,
36
+ } from '@livekit/protocol';
37
+ import log, { LoggerNames, getLogger } from '../logger';
40
38
  import { ConnectionError, ConnectionErrorReason } from '../room/errors';
41
39
  import CriticalTimers from '../room/timers';
42
40
  import type { LoggerOptions } from '../room/types';
@@ -1,5 +1,5 @@
1
+ import { ServerInfo_Edition } from '@livekit/protocol';
1
2
  import { SignalClient } from '../../api/SignalClient';
2
- import { ServerInfo_Edition } from '../../proto/livekit_models_pb';
3
3
  import { Checker } from './Checker';
4
4
 
5
5
  export class WebSocketCheck extends Checker {
@@ -1,7 +1,7 @@
1
+ import { Encryption_Type, TrackInfo } from '@livekit/protocol';
1
2
  import { EventEmitter } from 'events';
2
3
  import type TypedEventEmitter from 'typed-emitter';
3
4
  import log, { LogLevel, workerLogger } from '../logger';
4
- import { Encryption_Type, TrackInfo } from '../proto/livekit_models_pb';
5
5
  import type RTCEngine from '../room/RTCEngine';
6
6
  import type Room from '../room/Room';
7
7
  import { ConnectionState } from '../room/Room';
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
+ import { DataPacket_Kind, DisconnectReason } from '@livekit/protocol';
1
2
  import { LogLevel, LoggerNames, getLogger, setLogExtension, setLogLevel } from './logger';
2
- import { DataPacket_Kind, DisconnectReason } from './proto/livekit_models_pb';
3
3
  import DefaultReconnectPolicy from './room/DefaultReconnectPolicy';
4
4
  import Room, { ConnectionState } from './room/Room';
5
5
  import LocalParticipant from './room/participant/LocalParticipant';
@@ -1,5 +1,5 @@
1
+ import { SignalTarget } from '@livekit/protocol';
1
2
  import log, { LoggerNames, getLogger } from '../logger';
2
- import { SignalTarget } from '../proto/livekit_rtc_pb';
3
3
  import PCTransport, { PCEvents } from './PCTransport';
4
4
  import { roomConnectOptionDefaults } from './defaults';
5
5
  import { ConnectionError, ConnectionErrorReason } from './errors';
@@ -1,44 +1,42 @@
1
- import { EventEmitter } from 'events';
2
- import type { MediaAttributes } from 'sdp-transform';
3
- import type TypedEventEmitter from 'typed-emitter';
4
- import type { SignalOptions } from '../api/SignalClient';
5
- import {
6
- SignalClient,
7
- SignalConnectionState,
8
- toProtoSessionDescription,
9
- } from '../api/SignalClient';
10
- import log, { LoggerNames, getLogger } from '../logger';
11
- import type { InternalRoomOptions } from '../options';
12
1
  import {
2
+ type AddTrackRequest,
13
3
  ClientConfigSetting,
14
4
  ClientConfiguration,
5
+ type ConnectionQualityUpdate,
6
+ DataChannelInfo,
15
7
  DataPacket,
16
8
  DataPacket_Kind,
17
9
  DisconnectReason,
18
- ParticipantInfo,
19
- ReconnectReason,
20
- Room as RoomModel,
21
- SpeakerInfo,
22
- TrackInfo,
23
- UserPacket,
24
- } from '../proto/livekit_models_pb';
25
- import {
26
- type AddTrackRequest,
27
- type ConnectionQualityUpdate,
28
- DataChannelInfo,
29
10
  type JoinResponse,
30
11
  type LeaveRequest,
12
+ ParticipantInfo,
13
+ ReconnectReason,
31
14
  type ReconnectResponse,
15
+ Room as RoomModel,
32
16
  SignalTarget,
17
+ SpeakerInfo,
33
18
  type StreamStateUpdate,
34
19
  SubscribedQualityUpdate,
35
20
  type SubscriptionPermissionUpdate,
36
21
  type SubscriptionResponse,
37
22
  SyncState,
23
+ TrackInfo,
38
24
  type TrackPublishedResponse,
39
25
  TrackUnpublishedResponse,
40
26
  UpdateSubscription,
41
- } from '../proto/livekit_rtc_pb';
27
+ UserPacket,
28
+ } from '@livekit/protocol';
29
+ import { EventEmitter } from 'events';
30
+ import type { MediaAttributes } from 'sdp-transform';
31
+ import type TypedEventEmitter from 'typed-emitter';
32
+ import type { SignalOptions } from '../api/SignalClient';
33
+ import {
34
+ SignalClient,
35
+ SignalConnectionState,
36
+ toProtoSessionDescription,
37
+ } from '../api/SignalClient';
38
+ import log, { LoggerNames, getLogger } from '../logger';
39
+ import type { InternalRoomOptions } from '../options';
42
40
  import PCTransport, { PCEvents } from './PCTransport';
43
41
  import { PCTransportManager, PCTransportState } from './PCTransportManager';
44
42
  import type { ReconnectContext, ReconnectPolicy } from './ReconnectPolicy';
@@ -1,5 +1,5 @@
1
+ import type { RegionInfo, RegionSettings } from '@livekit/protocol';
1
2
  import log from '../logger';
2
- import type { RegionInfo, RegionSettings } from '../proto/livekit_rtc_pb';
3
3
  import { ConnectionError, ConnectionErrorReason } from './errors';
4
4
  import { isCloud } from './utils';
5
5
 
package/src/room/Room.ts CHANGED
@@ -1,40 +1,38 @@
1
- import { protoInt64 } from '@bufbuild/protobuf';
2
- import { EventEmitter } from 'events';
3
- import type TypedEmitter from 'typed-emitter';
4
- import 'webrtc-adapter';
5
- import { EncryptionEvent } from '../e2ee';
6
- import { E2EEManager } from '../e2ee/E2eeManager';
7
- import log, { LoggerNames, getLogger } from '../logger';
8
- import type {
9
- InternalRoomConnectOptions,
10
- InternalRoomOptions,
11
- RoomConnectOptions,
12
- RoomOptions,
13
- } from '../options';
14
1
  import {
2
+ ConnectionQualityUpdate,
15
3
  DataPacket_Kind,
16
4
  DisconnectReason,
5
+ JoinResponse,
6
+ LeaveRequest,
17
7
  ParticipantInfo,
18
8
  ParticipantInfo_State,
19
9
  ParticipantPermission,
20
10
  Room as RoomModel,
21
11
  ServerInfo,
12
+ SimulateScenario,
22
13
  SpeakerInfo,
14
+ StreamStateUpdate,
23
15
  SubscriptionError,
16
+ SubscriptionPermissionUpdate,
17
+ SubscriptionResponse,
24
18
  TrackInfo,
25
19
  TrackSource,
26
20
  TrackType,
27
21
  UserPacket,
28
- } from '../proto/livekit_models_pb';
29
- import {
30
- ConnectionQualityUpdate,
31
- JoinResponse,
32
- LeaveRequest,
33
- SimulateScenario,
34
- StreamStateUpdate,
35
- SubscriptionPermissionUpdate,
36
- SubscriptionResponse,
37
- } from '../proto/livekit_rtc_pb';
22
+ protoInt64,
23
+ } from '@livekit/protocol';
24
+ import { EventEmitter } from 'events';
25
+ import type TypedEmitter from 'typed-emitter';
26
+ import 'webrtc-adapter';
27
+ import { EncryptionEvent } from '../e2ee';
28
+ import { E2EEManager } from '../e2ee/E2eeManager';
29
+ import log, { LoggerNames, getLogger } from '../logger';
30
+ import type {
31
+ InternalRoomConnectOptions,
32
+ InternalRoomOptions,
33
+ RoomConnectOptions,
34
+ RoomOptions,
35
+ } from '../options';
38
36
  import { getBrowser } from '../utils/browserParser';
39
37
  import DeviceManager from './DeviceManager';
40
38
  import RTCEngine from './RTCEngine';
@@ -509,6 +507,7 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
509
507
  `Initial connection failed with ConnectionError: ${e.message}. Retrying with another region: ${nextUrl}`,
510
508
  this.logContext,
511
509
  );
510
+ this.recreateEngine();
512
511
  await connectFn(resolve, reject, nextUrl);
513
512
  } else {
514
513
  this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
@@ -1,18 +1,16 @@
1
- import type { InternalRoomOptions } from '../../options';
2
1
  import {
2
+ AddTrackRequest,
3
3
  DataPacket,
4
4
  DataPacket_Kind,
5
5
  Encryption_Type,
6
6
  ParticipantInfo,
7
7
  ParticipantPermission,
8
- UserPacket,
9
- } from '../../proto/livekit_models_pb';
10
- import {
11
- AddTrackRequest,
12
8
  SimulcastCodec,
13
9
  SubscribedQualityUpdate,
14
10
  TrackUnpublishedResponse,
15
- } from '../../proto/livekit_rtc_pb';
11
+ UserPacket,
12
+ } from '@livekit/protocol';
13
+ import type { InternalRoomOptions } from '../../options';
16
14
  import { PCTransportState } from '../PCTransportManager';
17
15
  import type RTCEngine from '../RTCEngine';
18
16
  import { defaultVideoCodec } from '../defaults';
@@ -736,7 +734,20 @@ export default class LocalParticipant extends Participant {
736
734
  if (isSVCCodec(videoCodec)) {
737
735
  // vp9 svc with screenshare has problem to encode, always use L1T3 here
738
736
  if (track.source === Track.Source.ScreenShare && videoCodec === 'vp9') {
739
- opts.scalabilityMode = 'L1T3';
737
+ // Chrome does not allow more than 5 fps with L1T3, and it has encoding bugs with L3T3
738
+ // It has a different path for screenshare handling and it seems to be untested/buggy
739
+ // As a workaround, we are setting contentHint to force it to go through the same
740
+ // path as regular camera video. While this is not optimal, it delivers the performance
741
+ // that we need
742
+ if ('contentHint' in track.mediaStreamTrack) {
743
+ track.mediaStreamTrack.contentHint = 'motion';
744
+ this.log.info('forcing contentHint to motion for screenshare with VP9', {
745
+ ...this.logContext,
746
+ ...getLogContextFromTrack(track),
747
+ });
748
+ } else {
749
+ opts.scalabilityMode = 'L1T3';
750
+ }
740
751
  }
741
752
  // set scalabilityMode to 'L3T3_KEY' by default
742
753
  opts.scalabilityMode = opts.scalabilityMode ?? 'L3T3_KEY';
@@ -1,13 +1,13 @@
1
- import { EventEmitter } from 'events';
2
- import type TypedEmitter from 'typed-emitter';
3
- import log, { LoggerNames, StructuredLogger, getLogger } from '../../logger';
4
1
  import {
5
2
  DataPacket_Kind,
6
3
  ParticipantInfo,
7
4
  ParticipantPermission,
8
5
  ConnectionQuality as ProtoQuality,
9
6
  SubscriptionError,
10
- } from '../../proto/livekit_models_pb';
7
+ } from '@livekit/protocol';
8
+ import { EventEmitter } from 'events';
9
+ import type TypedEmitter from 'typed-emitter';
10
+ import log, { LoggerNames, StructuredLogger, getLogger } from '../../logger';
11
11
  import { ParticipantEvent, TrackEvent } from '../events';
12
12
  import LocalAudioTrack from '../track/LocalAudioTrack';
13
13
  import type LocalTrackPublication from '../track/LocalTrackPublication';
@@ -1,4 +1,4 @@
1
- import { TrackPermission } from '../../proto/livekit_rtc_pb';
1
+ import { TrackPermission } from '@livekit/protocol';
2
2
 
3
3
  export interface ParticipantTrackPermission {
4
4
  /**
@@ -1,6 +1,10 @@
1
+ import type {
2
+ ParticipantInfo,
3
+ SubscriptionError,
4
+ UpdateSubscription,
5
+ UpdateTrackSettings,
6
+ } from '@livekit/protocol';
1
7
  import type { SignalClient } from '../../api/SignalClient';
2
- import type { ParticipantInfo, SubscriptionError } from '../../proto/livekit_models_pb';
3
- import type { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc_pb';
4
8
  import { ParticipantEvent, TrackEvent } from '../events';
5
9
  import RemoteAudioTrack from '../track/RemoteAudioTrack';
6
10
  import type RemoteTrack from '../track/RemoteTrack';
@@ -36,7 +36,10 @@ export default class LocalAudioTrack extends LocalTrack<Track.Kind.Audio> {
36
36
  }
37
37
 
38
38
  async setDeviceId(deviceId: ConstrainDOMString): Promise<boolean> {
39
- if (this._constraints.deviceId === deviceId) {
39
+ if (
40
+ this._constraints.deviceId === deviceId &&
41
+ this._mediaStreamTrack.getSettings().deviceId === unwrapConstraint(deviceId)
42
+ ) {
40
43
  return true;
41
44
  }
42
45
  this._constraints.deviceId = deviceId;
@@ -44,7 +47,7 @@ export default class LocalAudioTrack extends LocalTrack<Track.Kind.Audio> {
44
47
  await this.restartTrack();
45
48
  }
46
49
  return (
47
- this.isMuted || unwrapConstraint(deviceId) === this.mediaStreamTrack.getSettings().deviceId
50
+ this.isMuted || unwrapConstraint(deviceId) === this._mediaStreamTrack.getSettings().deviceId
48
51
  );
49
52
  }
50
53
 
@@ -1,4 +1,4 @@
1
- import type { TrackInfo } from '../../proto/livekit_models_pb';
1
+ import type { TrackInfo } from '@livekit/protocol';
2
2
  import { TrackEvent } from '../events';
3
3
  import type { LoggerOptions } from '../types';
4
4
  import type LocalAudioTrack from './LocalAudioTrack';
@@ -1,7 +1,11 @@
1
+ import {
2
+ VideoQuality as ProtoVideoQuality,
3
+ SubscribedCodec,
4
+ SubscribedQuality,
5
+ VideoLayer,
6
+ } from '@livekit/protocol';
1
7
  import type { SignalClient } from '../../api/SignalClient';
2
8
  import type { StructuredLogger } from '../../logger';
3
- import { VideoQuality as ProtoVideoQuality, VideoLayer } from '../../proto/livekit_models_pb';
4
- import { SubscribedCodec, SubscribedQuality } from '../../proto/livekit_rtc_pb';
5
9
  import { ScalabilityMode } from '../participant/publishUtils';
6
10
  import type { VideoSenderStats } from '../stats';
7
11
  import { computeBitrate, monitorFrequency } from '../stats';
@@ -1,6 +1,6 @@
1
1
  import { TrackEvent } from '../events';
2
- import { computeBitrate } from '../stats';
3
2
  import type { AudioReceiverStats } from '../stats';
3
+ import { computeBitrate } from '../stats';
4
4
  import type { LoggerOptions } from '../types';
5
5
  import { isReactNative, supportsSetSinkId } from '../utils';
6
6
  import RemoteTrack from './RemoteTrack';
@@ -1,5 +1,10 @@
1
- import { ParticipantTracks, SubscriptionError, TrackInfo } from '../../proto/livekit_models_pb';
2
- import { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc_pb';
1
+ import {
2
+ ParticipantTracks,
3
+ SubscriptionError,
4
+ TrackInfo,
5
+ UpdateSubscription,
6
+ UpdateTrackSettings,
7
+ } from '@livekit/protocol';
3
8
  import { TrackEvent } from '../events';
4
9
  import type { LoggerOptions } from '../types';
5
10
  import type RemoteTrack from './RemoteTrack';
@@ -1,13 +1,13 @@
1
- import { EventEmitter } from 'events';
2
- import type TypedEventEmitter from 'typed-emitter';
3
- import type { SignalClient } from '../../api/SignalClient';
4
- import log, { LoggerNames, StructuredLogger, getLogger } from '../../logger';
5
1
  import {
6
2
  VideoQuality as ProtoQuality,
3
+ StreamState as ProtoStreamState,
7
4
  TrackSource,
8
5
  TrackType,
9
- } from '../../proto/livekit_models_pb';
10
- import { StreamState as ProtoStreamState } from '../../proto/livekit_rtc_pb';
6
+ } from '@livekit/protocol';
7
+ import { EventEmitter } from 'events';
8
+ import type TypedEventEmitter from 'typed-emitter';
9
+ import type { SignalClient } from '../../api/SignalClient';
10
+ import log, { LoggerNames, StructuredLogger, getLogger } from '../../logger';
11
11
  import { TrackEvent } from '../events';
12
12
  import type { LoggerOptions } from '../types';
13
13
  import { isFireFox, isSafari, isWeb } from '../utils';
@@ -1,9 +1,13 @@
1
+ import { Encryption_Type } from '@livekit/protocol';
2
+ import type {
3
+ SubscriptionError,
4
+ TrackInfo,
5
+ UpdateSubscription,
6
+ UpdateTrackSettings,
7
+ } from '@livekit/protocol';
1
8
  import { EventEmitter } from 'events';
2
9
  import type TypedEventEmitter from 'typed-emitter';
3
10
  import log, { LoggerNames, getLogger } from '../../logger';
4
- import { Encryption_Type } from '../../proto/livekit_models_pb';
5
- import type { SubscriptionError, TrackInfo } from '../../proto/livekit_models_pb';
6
- import type { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc_pb';
7
11
  import { TrackEvent } from '../events';
8
12
  import type { LoggerOptions } from '../types';
9
13
  import LocalAudioTrack from './LocalAudioTrack';
@@ -47,7 +47,7 @@ export function facingModeFromLocalTrack(
47
47
  // 1. Try to get facingMode from track settings.
48
48
  if ('facingMode' in trackSettings) {
49
49
  const rawFacingMode = trackSettings.facingMode;
50
- log.debug('rawFacingMode', { rawFacingMode });
50
+ log.trace('rawFacingMode', { rawFacingMode });
51
51
  if (rawFacingMode && typeof rawFacingMode === 'string' && isFacingModeValue(rawFacingMode)) {
52
52
  result = { facingMode: rawFacingMode, confidence: 'high' };
53
53
  }
@@ -55,7 +55,7 @@ export function facingModeFromLocalTrack(
55
55
 
56
56
  // 2. If we don't have a high confidence we try to get the facing mode from the device label.
57
57
  if (['low', 'medium'].includes(result.confidence)) {
58
- log.debug(`Try to get facing mode from device label: (${track.label})`);
58
+ log.trace(`Try to get facing mode from device label: (${track.label})`);
59
59
  const labelAnalysisResult = facingModeFromDeviceLabel(track.label);
60
60
  if (labelAnalysisResult !== undefined) {
61
61
  result = labelAnalysisResult;
@@ -190,6 +190,13 @@ export interface ScreenShareCaptureOptions {
190
190
  * local speakers when the tab is captured.
191
191
  */
192
192
  suppressLocalAudioPlayback?: boolean;
193
+
194
+ /**
195
+ * Experimental option to instruct the browser to offer the current tab as the most prominent capture source
196
+ * @experimental
197
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getDisplayMedia#prefercurrenttab
198
+ */
199
+ preferCurrentTab?: boolean;
193
200
  }
194
201
 
195
202
  export interface AudioCaptureOptions {
@@ -1,4 +1,4 @@
1
- import { TrackPublishedResponse } from '../../proto/livekit_rtc_pb';
1
+ import { TrackPublishedResponse } from '@livekit/protocol';
2
2
  import { cloneDeep } from '../../utils/cloneDeep';
3
3
  import { isSafari, sleep } from '../utils';
4
4
  import { Track } from './Track';
@@ -183,6 +183,7 @@ export function screenCaptureToDisplayMediaStreamOptions(
183
183
  selfBrowserSurface: options.selfBrowserSurface,
184
184
  surfaceSwitching: options.surfaceSwitching,
185
185
  systemAudio: options.systemAudio,
186
+ preferCurrentTab: options.preferCurrentTab,
186
187
  };
187
188
  }
188
189
 
package/src/room/utils.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ClientInfo, ClientInfo_SDK } from '../proto/livekit_models_pb';
1
+ import { ClientInfo, ClientInfo_SDK } from '@livekit/protocol';
2
2
  import type { DetectableBrowser } from '../utils/browserParser';
3
3
  import { getBrowser } from '../utils/browserParser';
4
4
  import { protocolVersion, version } from '../version';