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.
- package/dist/livekit-client.e2ee.worker.js +1 -1
- package/dist/livekit-client.e2ee.worker.js.map +1 -1
- package/dist/livekit-client.e2ee.worker.mjs +14 -1
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +561 -328
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/api/SignalClient.d.ts +5 -1
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/logger.d.ts +19 -3
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/options.d.ts +1 -0
- package/dist/src/options.d.ts.map +1 -1
- package/dist/src/room/PCTransport.d.ts +5 -1
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/PCTransportManager.d.ts +5 -1
- package/dist/src/room/PCTransportManager.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +8 -0
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +2 -0
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/Participant.d.ts +9 -1
- package/dist/src/room/participant/Participant.d.ts.map +1 -1
- package/dist/src/room/participant/RemoteParticipant.d.ts +2 -1
- package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/publishUtils.d.ts +2 -1
- package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
- package/dist/src/room/timers.d.ts +4 -5
- package/dist/src/room/timers.d.ts.map +1 -1
- package/dist/src/room/track/LocalAudioTrack.d.ts +2 -1
- package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts +2 -1
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrackPublication.d.ts +2 -1
- package/dist/src/room/track/LocalTrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts +2 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/RemoteAudioTrack.d.ts +2 -1
- package/dist/src/room/track/RemoteAudioTrack.d.ts.map +1 -1
- package/dist/src/room/track/RemoteTrack.d.ts +2 -1
- package/dist/src/room/track/RemoteTrack.d.ts.map +1 -1
- package/dist/src/room/track/RemoteTrackPublication.d.ts +2 -1
- package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/RemoteVideoTrack.d.ts +2 -1
- package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/Track.d.ts +10 -1
- package/dist/src/room/track/Track.d.ts.map +1 -1
- package/dist/src/room/track/TrackPublication.d.ts +7 -1
- package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
- package/dist/src/room/track/create.d.ts.map +1 -1
- package/dist/src/room/track/options.d.ts +8 -3
- package/dist/src/room/track/options.d.ts.map +1 -1
- package/dist/src/room/track/utils.d.ts +1 -0
- package/dist/src/room/track/utils.d.ts.map +1 -1
- package/dist/src/room/types.d.ts +4 -0
- package/dist/src/room/types.d.ts.map +1 -1
- package/dist/src/room/utils.d.ts +1 -0
- package/dist/src/room/utils.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +5 -1
- package/dist/ts4.2/src/index.d.ts +2 -2
- package/dist/ts4.2/src/logger.d.ts +19 -3
- package/dist/ts4.2/src/options.d.ts +1 -0
- package/dist/ts4.2/src/room/PCTransport.d.ts +5 -1
- package/dist/ts4.2/src/room/PCTransportManager.d.ts +5 -1
- package/dist/ts4.2/src/room/RTCEngine.d.ts +8 -0
- package/dist/ts4.2/src/room/Room.d.ts +2 -0
- package/dist/ts4.2/src/room/participant/Participant.d.ts +9 -1
- package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +2 -1
- package/dist/ts4.2/src/room/participant/publishUtils.d.ts +2 -1
- package/dist/ts4.2/src/room/timers.d.ts +4 -5
- package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +2 -1
- package/dist/ts4.2/src/room/track/LocalTrack.d.ts +2 -1
- package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +2 -1
- package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +2 -1
- package/dist/ts4.2/src/room/track/RemoteAudioTrack.d.ts +2 -1
- package/dist/ts4.2/src/room/track/RemoteTrack.d.ts +2 -1
- package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +2 -1
- package/dist/ts4.2/src/room/track/RemoteVideoTrack.d.ts +2 -1
- package/dist/ts4.2/src/room/track/Track.d.ts +10 -1
- package/dist/ts4.2/src/room/track/TrackPublication.d.ts +7 -1
- package/dist/ts4.2/src/room/track/options.d.ts +8 -3
- package/dist/ts4.2/src/room/track/utils.d.ts +1 -0
- package/dist/ts4.2/src/room/types.d.ts +4 -0
- package/dist/ts4.2/src/room/utils.d.ts +1 -0
- package/package.json +15 -15
- package/src/api/SignalClient.ts +43 -21
- package/src/index.ts +2 -1
- package/src/logger.ts +32 -8
- package/src/options.ts +2 -0
- package/src/room/PCTransport.ts +29 -8
- package/src/room/PCTransportManager.ts +29 -9
- package/src/room/RTCEngine.ts +71 -34
- package/src/room/Room.ts +94 -30
- package/src/room/participant/LocalParticipant.ts +163 -47
- package/src/room/participant/Participant.ts +26 -3
- package/src/room/participant/RemoteParticipant.ts +23 -15
- package/src/room/participant/publishUtils.test.ts +2 -2
- package/src/room/participant/publishUtils.ts +7 -4
- package/src/room/track/LocalAudioTrack.ts +8 -7
- package/src/room/track/LocalTrack.ts +27 -20
- package/src/room/track/LocalTrackPublication.ts +3 -2
- package/src/room/track/LocalVideoTrack.ts +31 -13
- package/src/room/track/RemoteAudioTrack.ts +4 -3
- package/src/room/track/RemoteTrack.ts +4 -1
- package/src/room/track/RemoteTrackPublication.ts +21 -13
- package/src/room/track/RemoteVideoTrack.ts +5 -4
- package/src/room/track/Track.ts +32 -2
- package/src/room/track/TrackPublication.ts +18 -3
- package/src/room/track/create.ts +4 -3
- package/src/room/track/options.ts +12 -5
- package/src/room/track/utils.ts +23 -1
- package/src/room/types.ts +5 -0
- 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
|
-
|
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
|
|
package/src/room/track/create.ts
CHANGED
@@ -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.
|
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
|
173
|
-
*
|
174
|
-
* capture.
|
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
|
-
|
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,
|
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;
|
package/src/room/track/utils.ts
CHANGED
@@ -155,7 +155,8 @@ export function screenCaptureToDisplayMediaStreamOptions(
|
|
155
155
|
options: ScreenShareCaptureOptions,
|
156
156
|
): DisplayMediaStreamOptions {
|
157
157
|
let videoConstraints: MediaTrackConstraints | boolean = options.video ?? true;
|
158
|
-
|
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);
|