livekit-client 1.11.0 → 1.11.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/livekit-client.esm.mjs +139 -89
- 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/room/Room.d.ts +5 -4
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +6 -1
- package/dist/src/room/events.d.ts.map +1 -1
- package/dist/src/room/track/LocalAudioTrack.d.ts +1 -1
- package/dist/src/room/track/LocalAudioTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts +2 -2
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts +1 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/RemoteVideoTrack.d.ts +3 -1
- package/dist/src/room/track/RemoteVideoTrack.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/room/Room.d.ts +5 -4
- package/dist/ts4.2/src/room/events.d.ts +6 -1
- package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +1 -1
- package/dist/ts4.2/src/room/track/LocalTrack.d.ts +2 -2
- package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +1 -1
- package/dist/ts4.2/src/room/track/RemoteVideoTrack.d.ts +3 -1
- package/dist/ts4.2/src/room/utils.d.ts +1 -0
- package/package.json +1 -1
- package/src/room/Room.test.ts +29 -0
- package/src/room/Room.ts +55 -10
- package/src/room/events.ts +6 -0
- package/src/room/track/LocalAudioTrack.ts +4 -3
- package/src/room/track/LocalTrack.ts +13 -10
- package/src/room/track/LocalVideoTrack.ts +8 -4
- package/src/room/track/RemoteVideoTrack.ts +3 -8
- package/src/room/utils.ts +23 -0
@@ -5,7 +5,7 @@ import type { SubscribedCodec, SubscribedQuality } from '../../proto/livekit_rtc
|
|
5
5
|
import { ScalabilityMode } from '../participant/publishUtils';
|
6
6
|
import { computeBitrate, monitorFrequency } from '../stats';
|
7
7
|
import type { VideoSenderStats } from '../stats';
|
8
|
-
import { Mutex, isFireFox, isMobile, isWeb } from '../utils';
|
8
|
+
import { Mutex, isFireFox, isMobile, isWeb, unwrapConstraint } from '../utils';
|
9
9
|
import LocalTrack from './LocalTrack';
|
10
10
|
import { Track } from './Track';
|
11
11
|
import type { VideoCaptureOptions, VideoCodec } from './options';
|
@@ -182,9 +182,12 @@ export default class LocalVideoTrack extends LocalTrack {
|
|
182
182
|
this.setPublishingLayers(qualities);
|
183
183
|
}
|
184
184
|
|
185
|
-
async setDeviceId(deviceId: ConstrainDOMString) {
|
186
|
-
if (
|
187
|
-
|
185
|
+
async setDeviceId(deviceId: ConstrainDOMString): Promise<boolean> {
|
186
|
+
if (
|
187
|
+
this.constraints.deviceId === deviceId &&
|
188
|
+
this._mediaStreamTrack.getSettings().deviceId === unwrapConstraint(deviceId)
|
189
|
+
) {
|
190
|
+
return true;
|
188
191
|
}
|
189
192
|
this.constraints.deviceId = deviceId;
|
190
193
|
// when video is muted, underlying media stream track is stopped and
|
@@ -192,6 +195,7 @@ export default class LocalVideoTrack extends LocalTrack {
|
|
192
195
|
if (!this.isMuted) {
|
193
196
|
await this.restartTrack();
|
194
197
|
}
|
198
|
+
return unwrapConstraint(deviceId) === this._mediaStreamTrack.getSettings().deviceId;
|
195
199
|
}
|
196
200
|
|
197
201
|
async restartTrack(options?: VideoCaptureOptions) {
|
@@ -23,8 +23,6 @@ export default class RemoteVideoTrack extends RemoteTrack {
|
|
23
23
|
|
24
24
|
private lastDimensions?: Track.Dimensions;
|
25
25
|
|
26
|
-
private isObserved: boolean = false;
|
27
|
-
|
28
26
|
constructor(
|
29
27
|
mediaTrack: MediaStreamTrack,
|
30
28
|
sid: string,
|
@@ -39,12 +37,10 @@ export default class RemoteVideoTrack extends RemoteTrack {
|
|
39
37
|
return this.adaptiveStreamSettings !== undefined;
|
40
38
|
}
|
41
39
|
|
40
|
+
/**
|
41
|
+
* Note: When using adaptiveStream, you need to use remoteVideoTrack.attach() to add the track to a HTMLVideoElement, otherwise your video tracks might never start
|
42
|
+
*/
|
42
43
|
get mediaStreamTrack() {
|
43
|
-
if (this.isAdaptiveStream && !this.isObserved) {
|
44
|
-
log.warn(
|
45
|
-
'When using adaptiveStream, you need to use remoteVideoTrack.attach() to add the track to a HTMLVideoElement, otherwise your video tracks might never start',
|
46
|
-
);
|
47
|
-
}
|
48
44
|
return this._mediaStreamTrack;
|
49
45
|
}
|
50
46
|
|
@@ -106,7 +102,6 @@ export default class RemoteVideoTrack extends RemoteTrack {
|
|
106
102
|
// the tab comes into focus for the first time.
|
107
103
|
this.debouncedHandleResize();
|
108
104
|
this.updateVisibility();
|
109
|
-
this.isObserved = true;
|
110
105
|
} else {
|
111
106
|
log.warn('visibility resize observer not triggered');
|
112
107
|
}
|
package/src/room/utils.ts
CHANGED
@@ -455,3 +455,26 @@ export class Mutex {
|
|
455
455
|
return willUnlock;
|
456
456
|
}
|
457
457
|
}
|
458
|
+
|
459
|
+
export function unwrapConstraint(constraint: ConstrainDOMString): string {
|
460
|
+
if (typeof constraint === 'string') {
|
461
|
+
return constraint;
|
462
|
+
}
|
463
|
+
|
464
|
+
if (Array.isArray(constraint)) {
|
465
|
+
return constraint[0];
|
466
|
+
}
|
467
|
+
if (constraint.exact) {
|
468
|
+
if (Array.isArray(constraint.exact)) {
|
469
|
+
return constraint.exact[0];
|
470
|
+
}
|
471
|
+
return constraint.exact;
|
472
|
+
}
|
473
|
+
if (constraint.ideal) {
|
474
|
+
if (Array.isArray(constraint.ideal)) {
|
475
|
+
return constraint.ideal[0];
|
476
|
+
}
|
477
|
+
return constraint.ideal;
|
478
|
+
}
|
479
|
+
throw Error('could not unwrap constraint');
|
480
|
+
}
|