livekit-client 1.15.5 → 1.15.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. package/dist/livekit-client.e2ee.worker.js +1 -1
  2. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  3. package/dist/livekit-client.e2ee.worker.mjs +14 -1
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +561 -328
  6. package/dist/livekit-client.esm.mjs.map +1 -1
  7. package/dist/livekit-client.umd.js +1 -1
  8. package/dist/livekit-client.umd.js.map +1 -1
  9. package/dist/src/api/SignalClient.d.ts +5 -1
  10. package/dist/src/api/SignalClient.d.ts.map +1 -1
  11. package/dist/src/index.d.ts +2 -2
  12. package/dist/src/index.d.ts.map +1 -1
  13. package/dist/src/logger.d.ts +19 -3
  14. package/dist/src/logger.d.ts.map +1 -1
  15. package/dist/src/options.d.ts +1 -0
  16. package/dist/src/options.d.ts.map +1 -1
  17. package/dist/src/room/PCTransport.d.ts +5 -1
  18. package/dist/src/room/PCTransport.d.ts.map +1 -1
  19. package/dist/src/room/PCTransportManager.d.ts +5 -1
  20. package/dist/src/room/PCTransportManager.d.ts.map +1 -1
  21. package/dist/src/room/RTCEngine.d.ts +8 -0
  22. package/dist/src/room/RTCEngine.d.ts.map +1 -1
  23. package/dist/src/room/Room.d.ts +2 -0
  24. package/dist/src/room/Room.d.ts.map +1 -1
  25. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  26. package/dist/src/room/participant/Participant.d.ts +9 -1
  27. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  28. package/dist/src/room/participant/RemoteParticipant.d.ts +2 -1
  29. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  30. package/dist/src/room/participant/publishUtils.d.ts +2 -1
  31. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  32. package/dist/src/room/timers.d.ts +4 -5
  33. package/dist/src/room/timers.d.ts.map +1 -1
  34. package/dist/src/room/track/LocalAudioTrack.d.ts +2 -1
  35. package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
  36. package/dist/src/room/track/LocalTrack.d.ts +2 -1
  37. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  38. package/dist/src/room/track/LocalTrackPublication.d.ts +2 -1
  39. package/dist/src/room/track/LocalTrackPublication.d.ts.map +1 -1
  40. package/dist/src/room/track/LocalVideoTrack.d.ts +2 -1
  41. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  42. package/dist/src/room/track/RemoteAudioTrack.d.ts +2 -1
  43. package/dist/src/room/track/RemoteAudioTrack.d.ts.map +1 -1
  44. package/dist/src/room/track/RemoteTrack.d.ts +2 -1
  45. package/dist/src/room/track/RemoteTrack.d.ts.map +1 -1
  46. package/dist/src/room/track/RemoteTrackPublication.d.ts +2 -1
  47. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  48. package/dist/src/room/track/RemoteVideoTrack.d.ts +2 -1
  49. package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
  50. package/dist/src/room/track/Track.d.ts +10 -1
  51. package/dist/src/room/track/Track.d.ts.map +1 -1
  52. package/dist/src/room/track/TrackPublication.d.ts +7 -1
  53. package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
  54. package/dist/src/room/track/create.d.ts.map +1 -1
  55. package/dist/src/room/track/options.d.ts +8 -3
  56. package/dist/src/room/track/options.d.ts.map +1 -1
  57. package/dist/src/room/track/utils.d.ts +1 -0
  58. package/dist/src/room/track/utils.d.ts.map +1 -1
  59. package/dist/src/room/types.d.ts +4 -0
  60. package/dist/src/room/types.d.ts.map +1 -1
  61. package/dist/src/room/utils.d.ts +1 -0
  62. package/dist/src/room/utils.d.ts.map +1 -1
  63. package/dist/ts4.2/src/api/SignalClient.d.ts +5 -1
  64. package/dist/ts4.2/src/index.d.ts +2 -2
  65. package/dist/ts4.2/src/logger.d.ts +19 -3
  66. package/dist/ts4.2/src/options.d.ts +1 -0
  67. package/dist/ts4.2/src/room/PCTransport.d.ts +5 -1
  68. package/dist/ts4.2/src/room/PCTransportManager.d.ts +5 -1
  69. package/dist/ts4.2/src/room/RTCEngine.d.ts +8 -0
  70. package/dist/ts4.2/src/room/Room.d.ts +2 -0
  71. package/dist/ts4.2/src/room/participant/Participant.d.ts +9 -1
  72. package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +2 -1
  73. package/dist/ts4.2/src/room/participant/publishUtils.d.ts +2 -1
  74. package/dist/ts4.2/src/room/timers.d.ts +4 -5
  75. package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +2 -1
  76. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +2 -1
  77. package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +2 -1
  78. package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +2 -1
  79. package/dist/ts4.2/src/room/track/RemoteAudioTrack.d.ts +2 -1
  80. package/dist/ts4.2/src/room/track/RemoteTrack.d.ts +2 -1
  81. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +2 -1
  82. package/dist/ts4.2/src/room/track/RemoteVideoTrack.d.ts +2 -1
  83. package/dist/ts4.2/src/room/track/Track.d.ts +10 -1
  84. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +7 -1
  85. package/dist/ts4.2/src/room/track/options.d.ts +8 -3
  86. package/dist/ts4.2/src/room/track/utils.d.ts +1 -0
  87. package/dist/ts4.2/src/room/types.d.ts +4 -0
  88. package/dist/ts4.2/src/room/utils.d.ts +1 -0
  89. package/package.json +15 -15
  90. package/src/api/SignalClient.ts +43 -21
  91. package/src/index.ts +2 -1
  92. package/src/logger.ts +32 -8
  93. package/src/options.ts +2 -0
  94. package/src/room/PCTransport.ts +29 -8
  95. package/src/room/PCTransportManager.ts +29 -9
  96. package/src/room/RTCEngine.ts +71 -34
  97. package/src/room/Room.ts +94 -30
  98. package/src/room/participant/LocalParticipant.ts +163 -47
  99. package/src/room/participant/Participant.ts +26 -3
  100. package/src/room/participant/RemoteParticipant.ts +23 -15
  101. package/src/room/participant/publishUtils.test.ts +2 -2
  102. package/src/room/participant/publishUtils.ts +7 -4
  103. package/src/room/track/LocalAudioTrack.ts +8 -7
  104. package/src/room/track/LocalTrack.ts +27 -20
  105. package/src/room/track/LocalTrackPublication.ts +3 -2
  106. package/src/room/track/LocalVideoTrack.ts +31 -13
  107. package/src/room/track/RemoteAudioTrack.ts +4 -3
  108. package/src/room/track/RemoteTrack.ts +4 -1
  109. package/src/room/track/RemoteTrackPublication.ts +21 -13
  110. package/src/room/track/RemoteVideoTrack.ts +5 -4
  111. package/src/room/track/Track.ts +32 -2
  112. package/src/room/track/TrackPublication.ts +18 -3
  113. package/src/room/track/create.ts +4 -3
  114. package/src/room/track/options.ts +12 -5
  115. package/src/room/track/utils.ts +23 -1
  116. package/src/room/types.ts +5 -0
  117. package/src/room/utils.ts +5 -0
@@ -1,16 +1,18 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import type TypedEventEmitter from 'typed-emitter';
3
- import log from '../../logger';
3
+ import log, { LoggerNames, getLogger } from '../../logger';
4
4
  import { Encryption_Type } from '../../proto/livekit_models_pb';
5
5
  import type { SubscriptionError, TrackInfo } from '../../proto/livekit_models_pb';
6
6
  import type { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc_pb';
7
7
  import { TrackEvent } from '../events';
8
+ import type { LoggerOptions } from '../types';
8
9
  import LocalAudioTrack from './LocalAudioTrack';
9
10
  import LocalVideoTrack from './LocalVideoTrack';
10
11
  import RemoteAudioTrack from './RemoteAudioTrack';
11
12
  import type RemoteTrack from './RemoteTrack';
12
13
  import RemoteVideoTrack from './RemoteVideoTrack';
13
14
  import { Track } from './Track';
15
+ import { getLogContextFromTrack } from './utils';
14
16
 
15
17
  export class TrackPublication extends (EventEmitter as new () => TypedEventEmitter<PublicationEventCallbacks>) {
16
18
  kind: Track.Kind;
@@ -39,8 +41,14 @@ export class TrackPublication extends (EventEmitter as new () => TypedEventEmitt
39
41
 
40
42
  protected encryption: Encryption_Type = Encryption_Type.NONE;
41
43
 
42
- constructor(kind: Track.Kind, id: string, name: string) {
44
+ protected log = log;
45
+
46
+ private loggerContextCb?: LoggerOptions['loggerContextCb'];
47
+
48
+ constructor(kind: Track.Kind, id: string, name: string, loggerOptions?: LoggerOptions) {
43
49
  super();
50
+ this.log = getLogger(loggerOptions?.loggerName ?? LoggerNames.Publication);
51
+ this.loggerContextCb = this.loggerContextCb;
44
52
  this.setMaxListeners(100);
45
53
  this.kind = kind;
46
54
  this.trackSid = id;
@@ -64,6 +72,13 @@ export class TrackPublication extends (EventEmitter as new () => TypedEventEmitt
64
72
  }
65
73
  }
66
74
 
75
+ protected get logContext() {
76
+ return {
77
+ ...this.loggerContextCb?.(),
78
+ ...getLogContextFromTrack(this),
79
+ };
80
+ }
81
+
67
82
  get isMuted(): boolean {
68
83
  return this.metadataMuted;
69
84
  }
@@ -121,7 +136,7 @@ export class TrackPublication extends (EventEmitter as new () => TypedEventEmitt
121
136
  }
122
137
  this.encryption = info.encryption;
123
138
  this.trackInfo = info;
124
- log.debug('update publication info', { info });
139
+ this.log.debug('update publication info', { ...this.logContext, info });
125
140
  }
126
141
  }
127
142
 
@@ -2,17 +2,18 @@ import DeviceManager from '../DeviceManager';
2
2
  import { audioDefaults, videoDefaults } from '../defaults';
3
3
  import { DeviceUnsupportedError, TrackInvalidError } from '../errors';
4
4
  import { mediaTrackToLocalTrack } from '../participant/publishUtils';
5
+ import { isSafari17 } from '../utils';
5
6
  import LocalAudioTrack from './LocalAudioTrack';
6
7
  import type LocalTrack from './LocalTrack';
7
8
  import LocalVideoTrack from './LocalVideoTrack';
8
9
  import { Track } from './Track';
9
- import { ScreenSharePresets } from './options';
10
10
  import type {
11
11
  AudioCaptureOptions,
12
12
  CreateLocalTracksOptions,
13
13
  ScreenShareCaptureOptions,
14
14
  VideoCaptureOptions,
15
15
  } from './options';
16
+ import { ScreenSharePresets } from './options';
16
17
  import {
17
18
  constraintsForOptions,
18
19
  mergeDefaultOptions,
@@ -116,8 +117,8 @@ export async function createLocalScreenTracks(
116
117
  if (options === undefined) {
117
118
  options = {};
118
119
  }
119
- if (options.resolution === undefined) {
120
- options.resolution = ScreenSharePresets.h1080fps15.resolution;
120
+ if (options.resolution === undefined && !isSafari17()) {
121
+ options.resolution = ScreenSharePresets.h1080fps30.resolution;
121
122
  }
122
123
 
123
124
  if (navigator.mediaDevices.getDisplayMedia === undefined) {
@@ -169,9 +169,10 @@ export interface ScreenShareCaptureOptions {
169
169
  video?: true | { displaySurface?: 'window' | 'browser' | 'monitor' };
170
170
 
171
171
  /**
172
- * capture resolution, defaults to screen resolution
173
- * NOTE: In Safari 17, specifying any resolution at all would lead to a low-resolution
174
- * capture. https://bugs.webkit.org/show_bug.cgi?id=263015
172
+ * capture resolution, defaults to 1080 for all browsers other than Safari
173
+ * On Safari 17, default resolution is not capped, due to a bug, specifying
174
+ * any resolution at all would lead to a low-resolution capture.
175
+ * https://bugs.webkit.org/show_bug.cgi?id=263015
175
176
  */
176
177
  resolution?: VideoResolution;
177
178
 
@@ -187,6 +188,9 @@ export interface ScreenShareCaptureOptions {
187
188
  /** specifies whether the browser should include the system audio among the possible audio sources offered to the user */
188
189
  systemAudio?: 'include' | 'exclude';
189
190
 
191
+ /** specify the type of content, see: https://www.w3.org/TR/mst-content-hint/#video-content-hints */
192
+ contentHint?: 'detail' | 'text' | 'motion';
193
+
190
194
  /**
191
195
  * Experimental option to control whether the audio playing in a tab will continue to be played out of a user's
192
196
  * local speakers when the tab is captured.
@@ -367,9 +371,12 @@ export const VideoPresets43 = {
367
371
 
368
372
  export const ScreenSharePresets = {
369
373
  h360fps3: new VideoPreset(640, 360, 200_000, 3, 'medium'),
370
- h720fps5: new VideoPreset(1280, 720, 400_000, 5, 'medium'),
374
+ h360fps15: new VideoPreset(640, 360, 400_000, 15, 'medium'),
375
+ h720fps5: new VideoPreset(1280, 720, 800_000, 5, 'medium'),
371
376
  h720fps15: new VideoPreset(1280, 720, 1_500_000, 15, 'medium'),
372
377
  h720fps30: new VideoPreset(1280, 720, 2_000_000, 30, 'medium'),
373
378
  h1080fps15: new VideoPreset(1920, 1080, 2_500_000, 15, 'medium'),
374
- h1080fps30: new VideoPreset(1920, 1080, 4_000_000, 30, 'medium'),
379
+ h1080fps30: new VideoPreset(1920, 1080, 5_000_000, 30, 'medium'),
380
+ // original resolution, without resizing
381
+ original: new VideoPreset(0, 0, 7_000_000, 30, 'medium'),
375
382
  } as const;
@@ -155,7 +155,8 @@ export function screenCaptureToDisplayMediaStreamOptions(
155
155
  options: ScreenShareCaptureOptions,
156
156
  ): DisplayMediaStreamOptions {
157
157
  let videoConstraints: MediaTrackConstraints | boolean = options.video ?? true;
158
- if (options.resolution) {
158
+ // treat 0 as uncapped
159
+ if (options.resolution && options.resolution.width > 0 && options.resolution.height > 0) {
159
160
  videoConstraints = typeof videoConstraints === 'boolean' ? {} : videoConstraints;
160
161
  if (isSafari()) {
161
162
  videoConstraints = {
@@ -209,3 +210,24 @@ export function getTrackPublicationInfo<T extends TrackPublication>(
209
210
  });
210
211
  return infos;
211
212
  }
213
+
214
+ export function getLogContextFromTrack(track: Track | TrackPublication): Record<string, unknown> {
215
+ if (track instanceof Track) {
216
+ return {
217
+ trackSid: track.sid,
218
+ trackSource: track.source,
219
+ trackMuted: track.isMuted,
220
+ trackEnabled: track.mediaStreamTrack.enabled,
221
+ trackKind: track.kind,
222
+ };
223
+ } else {
224
+ return {
225
+ trackSid: track.trackSid,
226
+ trackName: track.trackName,
227
+ track: track.track ? getLogContextFromTrack(track.track) : undefined,
228
+ trackEnabled: track.isEnabled,
229
+ trackEncrypted: track.isEncrypted,
230
+ trackMimeType: track.mimeType,
231
+ };
232
+ }
233
+ }
package/src/room/types.ts CHANGED
@@ -41,3 +41,8 @@ export type SimulationScenario =
41
41
  // this can be used to test application behavior when congested or
42
42
  // to disable congestion control entirely (by setting bandwidth to 100Mbps)
43
43
  | 'subscriber-bandwidth';
44
+
45
+ export type LoggerOptions = {
46
+ loggerName?: string;
47
+ loggerContextCb?: () => Record<string, unknown>;
48
+ };
package/src/room/utils.ts CHANGED
@@ -148,6 +148,11 @@ export function isSafari(): boolean {
148
148
  return getBrowser()?.name === 'Safari';
149
149
  }
150
150
 
151
+ export function isSafari17(): boolean {
152
+ const b = getBrowser();
153
+ return b?.name === 'Safari' && b.version.startsWith('17.');
154
+ }
155
+
151
156
  export function isMobile(): boolean {
152
157
  if (!isWeb()) return false;
153
158
  return /Tablet|iPad|Mobile|Android|BlackBerry/.test(navigator.userAgent);