livekit-client 0.17.2 → 0.17.5
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.
- package/dist/api/SignalClient.d.ts +2 -1
- package/dist/api/SignalClient.js +6 -1
- package/dist/api/SignalClient.js.map +1 -1
- package/dist/proto/google/protobuf/timestamp.d.ts +132 -0
- package/dist/proto/google/protobuf/timestamp.js +108 -0
- package/dist/proto/google/protobuf/timestamp.js.map +1 -0
- package/dist/proto/livekit_models.d.ts +596 -16
- package/dist/proto/livekit_models.js +1012 -642
- package/dist/proto/livekit_models.js.map +1 -1
- package/dist/proto/livekit_rtc.d.ts +3416 -29
- package/dist/proto/livekit_rtc.js +830 -1210
- package/dist/proto/livekit_rtc.js.map +1 -1
- package/dist/room/Room.d.ts +2 -1
- package/dist/room/Room.js +16 -1
- package/dist/room/Room.js.map +1 -1
- package/dist/room/events.d.ts +12 -2
- package/dist/room/events.js +10 -0
- package/dist/room/events.js.map +1 -1
- package/dist/room/participant/LocalParticipant.d.ts +4 -1
- package/dist/room/participant/LocalParticipant.js +18 -0
- package/dist/room/participant/LocalParticipant.js.map +1 -1
- package/dist/room/participant/Participant.d.ts +5 -1
- package/dist/room/participant/Participant.js +15 -1
- package/dist/room/participant/Participant.js.map +1 -1
- package/dist/room/track/Track.js +10 -3
- package/dist/room/track/Track.js.map +1 -1
- package/dist/room/track/options.d.ts +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +2 -2
- package/package.json +2 -2
- package/src/api/SignalClient.ts +8 -1
- package/src/proto/google/protobuf/timestamp.ts +232 -0
- package/src/proto/livekit_models.ts +1134 -570
- package/src/proto/livekit_rtc.ts +834 -1135
- package/src/room/Room.ts +30 -9
- package/src/room/events.ts +12 -0
- package/src/room/participant/LocalParticipant.ts +25 -2
- package/src/room/participant/Participant.ts +22 -2
- package/src/room/track/Track.ts +10 -4
- package/src/room/track/options.ts +1 -1
- package/src/version.ts +2 -2
package/src/room/Room.ts
CHANGED
@@ -5,7 +5,7 @@ import log from '../logger';
|
|
5
5
|
import { RoomConnectOptions, RoomOptions } from '../options';
|
6
6
|
import {
|
7
7
|
DataPacket_Kind, ParticipantInfo,
|
8
|
-
ParticipantInfo_State, Room as RoomModel, SpeakerInfo, UserPacket,
|
8
|
+
ParticipantInfo_State, ParticipantPermission, Room as RoomModel, SpeakerInfo, UserPacket,
|
9
9
|
} from '../proto/livekit_models';
|
10
10
|
import {
|
11
11
|
ConnectionQualityUpdate,
|
@@ -93,6 +93,14 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
93
93
|
this.participants = new Map();
|
94
94
|
this.options = options || {};
|
95
95
|
|
96
|
+
switch (this.options?.publishDefaults?.videoCodec) {
|
97
|
+
case 'av1':
|
98
|
+
case 'vp9':
|
99
|
+
this.options.publishDefaults.simulcast = undefined;
|
100
|
+
break;
|
101
|
+
default:
|
102
|
+
}
|
103
|
+
|
96
104
|
this.options.audioCaptureDefaults = {
|
97
105
|
...audioDefaults,
|
98
106
|
...options?.audioCaptureDefaults,
|
@@ -211,12 +219,9 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
211
219
|
this.state = RoomState.Connected;
|
212
220
|
this.emit(RoomEvent.StateChanged, this.state);
|
213
221
|
const pi = joinResponse.participant!;
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
this.engine,
|
218
|
-
this.options,
|
219
|
-
);
|
222
|
+
|
223
|
+
this.localParticipant.sid = pi.sid;
|
224
|
+
this.localParticipant.identity = pi.identity;
|
220
225
|
|
221
226
|
this.localParticipant.updateInfo(pi);
|
222
227
|
// forward metadata changed for the local participant
|
@@ -244,7 +249,15 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
244
249
|
})
|
245
250
|
.on(ParticipantEvent.MediaDevicesError, (e: Error) => {
|
246
251
|
this.emit(RoomEvent.MediaDevicesError, e);
|
247
|
-
})
|
252
|
+
})
|
253
|
+
.on(ParticipantEvent.ParticipantPermissionsChanged,
|
254
|
+
(prevPermissions: ParticipantPermission) => {
|
255
|
+
this.emit(
|
256
|
+
RoomEvent.ParticipantPermissionsChanged,
|
257
|
+
prevPermissions,
|
258
|
+
this.localParticipant,
|
259
|
+
);
|
260
|
+
});
|
248
261
|
|
249
262
|
// populate remote participants, these should not trigger new events
|
250
263
|
joinResponse.otherParticipants.forEach((info) => {
|
@@ -802,7 +815,11 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
|
|
802
815
|
})
|
803
816
|
.on(ParticipantEvent.ConnectionQualityChanged, (quality: ConnectionQuality) => {
|
804
817
|
this.emit(RoomEvent.ConnectionQualityChanged, quality, participant);
|
805
|
-
})
|
818
|
+
})
|
819
|
+
.on(ParticipantEvent.ParticipantPermissionsChanged,
|
820
|
+
(prevPermissions: ParticipantPermission) => {
|
821
|
+
this.emit(RoomEvent.ParticipantPermissionsChanged, prevPermissions, participant);
|
822
|
+
});
|
806
823
|
return participant;
|
807
824
|
}
|
808
825
|
|
@@ -907,6 +924,10 @@ export type RoomEventCallbacks = {
|
|
907
924
|
metadata: string | undefined,
|
908
925
|
participant: RemoteParticipant | LocalParticipant
|
909
926
|
) => void,
|
927
|
+
participantPermissionsChanged: (
|
928
|
+
prevPermissions: ParticipantPermission,
|
929
|
+
participant: RemoteParticipant | LocalParticipant
|
930
|
+
) => void,
|
910
931
|
activeSpeakersChanged: (speakers: Array<Participant>) => void,
|
911
932
|
roomMetadataChanged: (metadata: string) => void,
|
912
933
|
dataReceived: (
|
package/src/room/events.ts
CHANGED
@@ -225,6 +225,12 @@ export enum RoomEvent {
|
|
225
225
|
* args: (error: Error)
|
226
226
|
*/
|
227
227
|
MediaDevicesError = 'mediaDevicesError',
|
228
|
+
|
229
|
+
/**
|
230
|
+
* A participant's permission has changed. Currently only fired on LocalParticipant.
|
231
|
+
* args: (prevPermissions: [[ParticipantPermission]], participant: [[Participant]])
|
232
|
+
*/
|
233
|
+
ParticipantPermissionsChanged = 'participantPermissionsChanged',
|
228
234
|
}
|
229
235
|
|
230
236
|
export enum ParticipantEvent {
|
@@ -370,6 +376,12 @@ export enum ParticipantEvent {
|
|
370
376
|
// fired only on LocalParticipant
|
371
377
|
/** @internal */
|
372
378
|
MediaDevicesError = 'mediaDevicesError',
|
379
|
+
|
380
|
+
/**
|
381
|
+
* A participant's permission has changed. Currently only fired on LocalParticipant.
|
382
|
+
* args: (prevPermissions: [[ParticipantPermission]])
|
383
|
+
*/
|
384
|
+
ParticipantPermissionsChanged = 'participantPermissionsChanged',
|
373
385
|
}
|
374
386
|
|
375
387
|
/** @internal */
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import log from '../../logger';
|
2
2
|
import { RoomOptions } from '../../options';
|
3
3
|
import {
|
4
|
-
DataPacket, DataPacket_Kind,
|
4
|
+
DataPacket, DataPacket_Kind, ParticipantPermission,
|
5
5
|
} from '../../proto/livekit_models';
|
6
6
|
import {
|
7
|
-
AddTrackRequest, DataChannelInfo,
|
7
|
+
AddTrackRequest, DataChannelInfo,
|
8
|
+
SubscribedQualityUpdate, TrackPublishedResponse, TrackUnpublishedResponse,
|
8
9
|
} from '../../proto/livekit_rtc';
|
9
10
|
import {
|
10
11
|
TrackInvalidError,
|
@@ -71,6 +72,8 @@ export default class LocalParticipant extends Participant {
|
|
71
72
|
};
|
72
73
|
|
73
74
|
this.engine.client.onSubscribedQualityUpdate = this.handleSubscribedQualityUpdate;
|
75
|
+
|
76
|
+
this.engine.client.onLocalTrackUnpublished = this.handleLocalTrackUnpublished;
|
74
77
|
}
|
75
78
|
|
76
79
|
get lastCameraError(): Error | undefined {
|
@@ -120,6 +123,16 @@ export default class LocalParticipant extends Participant {
|
|
120
123
|
return this.setTrackEnabled(Track.Source.ScreenShare, enabled);
|
121
124
|
}
|
122
125
|
|
126
|
+
/** @internal */
|
127
|
+
setPermissions(permissions: ParticipantPermission): boolean {
|
128
|
+
const prevPermissions = this.permissions;
|
129
|
+
const changed = super.setPermissions(permissions);
|
130
|
+
if (changed && prevPermissions) {
|
131
|
+
this.emit(ParticipantEvent.ParticipantPermissionsChanged, prevPermissions);
|
132
|
+
}
|
133
|
+
return changed;
|
134
|
+
}
|
135
|
+
|
123
136
|
/**
|
124
137
|
* Enable or disable publishing for a track by source. This serves as a simple
|
125
138
|
* way to manage the common tracks (camera, mic, or screen share)
|
@@ -620,6 +633,16 @@ export default class LocalParticipant extends Participant {
|
|
620
633
|
pub.videoTrack?.setPublishingLayers(update.subscribedQualities);
|
621
634
|
};
|
622
635
|
|
636
|
+
private handleLocalTrackUnpublished = (unpublished: TrackUnpublishedResponse) => {
|
637
|
+
const track = this.tracks.get(unpublished.trackSid);
|
638
|
+
if (!track) {
|
639
|
+
log.warn('handleLocalTrackUnpublished',
|
640
|
+
'received unpublished event for unknown track', unpublished.trackSid);
|
641
|
+
return;
|
642
|
+
}
|
643
|
+
this.unpublishTrack(track.track!);
|
644
|
+
};
|
645
|
+
|
623
646
|
private onTrackUnpublish = (track: LocalTrack) => {
|
624
647
|
this.unpublishTrack(track);
|
625
648
|
};
|
@@ -1,6 +1,8 @@
|
|
1
1
|
import { EventEmitter } from 'events';
|
2
2
|
import type TypedEmitter from 'typed-emitter';
|
3
|
-
import {
|
3
|
+
import {
|
4
|
+
ConnectionQuality as ProtoQuality, DataPacket_Kind, ParticipantInfo, ParticipantPermission,
|
5
|
+
} from '../../proto/livekit_models';
|
4
6
|
import { ParticipantEvent, TrackEvent } from '../events';
|
5
7
|
import LocalTrackPublication from '../track/LocalTrackPublication';
|
6
8
|
import RemoteTrackPublication from '../track/RemoteTrackPublication';
|
@@ -60,6 +62,8 @@ export default class Participant extends (
|
|
60
62
|
|
61
63
|
lastSpokeAt?: Date | undefined;
|
62
64
|
|
65
|
+
permissions?: ParticipantPermission;
|
66
|
+
|
63
67
|
private _connectionQuality: ConnectionQuality = ConnectionQuality.Unknown;
|
64
68
|
|
65
69
|
/** @internal */
|
@@ -153,13 +157,16 @@ export default class Participant extends (
|
|
153
157
|
this.sid = info.sid;
|
154
158
|
this.name = info.name;
|
155
159
|
this.setMetadata(info.metadata);
|
160
|
+
if (info.permission) {
|
161
|
+
this.setPermissions(info.permission);
|
162
|
+
}
|
156
163
|
// set this last so setMetadata can detect changes
|
157
164
|
this.participantInfo = info;
|
158
165
|
}
|
159
166
|
|
160
167
|
/** @internal */
|
161
168
|
setMetadata(md: string) {
|
162
|
-
const changed =
|
169
|
+
const changed = this.metadata !== md;
|
163
170
|
const prevMetadata = this.metadata;
|
164
171
|
this.metadata = md;
|
165
172
|
|
@@ -169,6 +176,18 @@ export default class Participant extends (
|
|
169
176
|
}
|
170
177
|
}
|
171
178
|
|
179
|
+
/** @internal */
|
180
|
+
setPermissions(permissions: ParticipantPermission): boolean {
|
181
|
+
const changed = permissions.canPublish !== this.permissions?.canPublish
|
182
|
+
|| permissions.canSubscribe !== this.permissions?.canSubscribe
|
183
|
+
|| permissions.canPublishData !== this.permissions?.canPublishData
|
184
|
+
|| permissions.hidden !== this.permissions?.hidden
|
185
|
+
|| permissions.recorder !== this.permissions?.recorder;
|
186
|
+
this.permissions = permissions;
|
187
|
+
|
188
|
+
return changed;
|
189
|
+
}
|
190
|
+
|
172
191
|
/** @internal */
|
173
192
|
setIsSpeaking(speaking: boolean) {
|
174
193
|
if (speaking === this.isSpeaking) {
|
@@ -246,4 +265,5 @@ export type ParticipantEventCallbacks = {
|
|
246
265
|
status: TrackPublication.SubscriptionStatus
|
247
266
|
) => void,
|
248
267
|
mediaDevicesError: (error: Error) => void,
|
268
|
+
participantPermissionsChanged: (prevPermissions: ParticipantPermission) => void,
|
249
269
|
};
|
package/src/room/track/Track.ts
CHANGED
@@ -3,7 +3,7 @@ import type TypedEventEmitter from 'typed-emitter';
|
|
3
3
|
import { TrackSource, TrackType } from '../../proto/livekit_models';
|
4
4
|
import { StreamState as ProtoStreamState } from '../../proto/livekit_rtc';
|
5
5
|
import { TrackEvent } from '../events';
|
6
|
-
import { isFireFox, isSafari } from '../utils';
|
6
|
+
import { isFireFox, isSafari, isWeb } from '../utils';
|
7
7
|
|
8
8
|
// keep old audio elements when detached, we would re-use them since on iOS
|
9
9
|
// Safari tracks which audio elements have been "blessed" by the user.
|
@@ -36,8 +36,12 @@ export class Track extends (EventEmitter as new () => TypedEventEmitter<TrackEve
|
|
36
36
|
this.kind = kind;
|
37
37
|
this.mediaStreamTrack = mediaTrack;
|
38
38
|
this.source = Track.Source.Unknown;
|
39
|
-
|
40
|
-
|
39
|
+
if (isWeb()) {
|
40
|
+
this.isInBackground = document.visibilityState === 'hidden';
|
41
|
+
document.addEventListener('visibilitychange', this.appVisibilityChangedListener);
|
42
|
+
} else {
|
43
|
+
this.isInBackground = false;
|
44
|
+
}
|
41
45
|
}
|
42
46
|
|
43
47
|
/** current receive bits per second */
|
@@ -135,7 +139,9 @@ export class Track extends (EventEmitter as new () => TypedEventEmitter<TrackEve
|
|
135
139
|
|
136
140
|
stop() {
|
137
141
|
this.mediaStreamTrack.stop();
|
138
|
-
|
142
|
+
if (isWeb()) {
|
143
|
+
document.removeEventListener('visibilitychange', this.appVisibilityChangedListener);
|
144
|
+
}
|
139
145
|
}
|
140
146
|
|
141
147
|
protected enable() {
|
@@ -198,7 +198,7 @@ export interface AudioPreset {
|
|
198
198
|
maxBitrate: number;
|
199
199
|
}
|
200
200
|
|
201
|
-
export type VideoCodec = 'vp8' | 'h264';
|
201
|
+
export type VideoCodec = 'vp8' | 'h264' | 'av1' | 'vp9';
|
202
202
|
|
203
203
|
export namespace AudioPresets {
|
204
204
|
export const telephone: AudioPreset = {
|
package/src/version.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
export const version = '0.17.
|
2
|
-
export const protocolVersion =
|
1
|
+
export const version = '0.17.5';
|
2
|
+
export const protocolVersion = 7;
|