livekit-client 1.4.4 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/livekit-client.esm.mjs +510 -38
- 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/connectionHelper/ConnectionCheck.d.ts +25 -0
- package/dist/src/connectionHelper/ConnectionCheck.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/Checker.d.ts +59 -0
- package/dist/src/connectionHelper/checks/Checker.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/publishAudio.d.ts +6 -0
- package/dist/src/connectionHelper/checks/publishAudio.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/publishVideo.d.ts +6 -0
- package/dist/src/connectionHelper/checks/publishVideo.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/reconnect.d.ts +6 -0
- package/dist/src/connectionHelper/checks/reconnect.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/turn.d.ts +6 -0
- package/dist/src/connectionHelper/checks/turn.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/webrtc.d.ts +6 -0
- package/dist/src/connectionHelper/checks/webrtc.d.ts.map +1 -0
- package/dist/src/connectionHelper/checks/websocket.d.ts +6 -0
- package/dist/src/connectionHelper/checks/websocket.d.ts.map +1 -0
- package/dist/src/index.d.ts +3 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/proto/livekit_rtc.d.ts +8 -0
- package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
- package/dist/src/room/DeviceManager.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +6 -0
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +5 -1
- package/dist/src/room/events.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/RemoteTrackPublication.d.ts +2 -0
- package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +85 -0
- package/dist/ts4.2/src/connectionHelper/ConnectionCheck.d.ts +25 -0
- package/dist/ts4.2/src/connectionHelper/checks/Checker.d.ts +59 -0
- package/dist/ts4.2/src/connectionHelper/checks/publishAudio.d.ts +6 -0
- package/dist/ts4.2/src/connectionHelper/checks/publishVideo.d.ts +6 -0
- package/dist/ts4.2/src/connectionHelper/checks/reconnect.d.ts +6 -0
- package/dist/ts4.2/src/connectionHelper/checks/turn.d.ts +6 -0
- package/dist/ts4.2/src/connectionHelper/checks/webrtc.d.ts +6 -0
- package/dist/ts4.2/src/connectionHelper/checks/websocket.d.ts +6 -0
- package/dist/ts4.2/src/index.d.ts +30 -0
- package/dist/ts4.2/src/logger.d.ts +26 -0
- package/dist/ts4.2/src/options.d.ts +91 -0
- package/dist/ts4.2/src/proto/google/protobuf/timestamp.d.ts +141 -0
- package/dist/ts4.2/src/proto/livekit_models.d.ts +1421 -0
- package/dist/ts4.2/src/proto/livekit_rtc.d.ts +7122 -0
- package/dist/ts4.2/src/room/DefaultReconnectPolicy.d.ts +8 -0
- package/dist/ts4.2/src/room/DeviceManager.d.ts +9 -0
- package/dist/ts4.2/src/room/PCTransport.d.ts +33 -0
- package/dist/ts4.2/src/room/RTCEngine.d.ts +96 -0
- package/dist/ts4.2/src/room/ReconnectPolicy.d.ts +23 -0
- package/dist/ts4.2/src/room/Room.d.ts +203 -0
- package/dist/ts4.2/src/room/defaults.d.ts +8 -0
- package/dist/ts4.2/src/room/errors.d.ts +39 -0
- package/dist/ts4.2/src/room/events.d.ts +422 -0
- package/dist/ts4.2/src/room/participant/LocalParticipant.d.ts +141 -0
- package/dist/ts4.2/src/room/participant/Participant.d.ts +92 -0
- package/dist/ts4.2/src/room/participant/ParticipantTrackPermission.d.ts +26 -0
- package/dist/ts4.2/src/room/participant/RemoteParticipant.d.ts +52 -0
- package/dist/ts4.2/src/room/participant/publishUtils.d.ts +19 -0
- package/dist/ts4.2/src/room/stats.d.ts +67 -0
- package/dist/ts4.2/src/room/track/LocalAudioTrack.d.ts +25 -0
- package/dist/ts4.2/src/room/track/LocalTrack.d.ts +42 -0
- package/dist/ts4.2/src/room/track/LocalTrackPublication.d.ts +38 -0
- package/dist/ts4.2/src/room/track/LocalVideoTrack.d.ts +53 -0
- package/dist/ts4.2/src/room/track/RemoteAudioTrack.d.ts +53 -0
- package/dist/ts4.2/src/room/track/RemoteTrack.d.ts +15 -0
- package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +61 -0
- package/dist/ts4.2/src/room/track/RemoteVideoTrack.d.ts +52 -0
- package/dist/ts4.2/src/room/track/Track.d.ts +121 -0
- package/dist/ts4.2/src/room/track/TrackPublication.d.ts +68 -0
- package/dist/ts4.2/src/room/track/create.d.ts +24 -0
- package/dist/ts4.2/src/room/track/options.d.ts +241 -0
- package/dist/ts4.2/src/room/track/types.d.ts +23 -0
- package/dist/ts4.2/src/room/track/utils.d.ts +14 -0
- package/dist/ts4.2/src/room/utils.d.ts +35 -0
- package/dist/ts4.2/src/test/MockMediaStreamTrack.d.ts +26 -0
- package/dist/ts4.2/src/test/mocks.d.ts +11 -0
- package/dist/ts4.2/src/version.d.ts +3 -0
- package/package.json +13 -3
- package/src/api/SignalClient.ts +2 -2
- package/src/connectionHelper/ConnectionCheck.ts +90 -0
- package/src/connectionHelper/checks/Checker.ts +164 -0
- package/src/connectionHelper/checks/publishAudio.ts +33 -0
- package/src/connectionHelper/checks/publishVideo.ts +33 -0
- package/src/connectionHelper/checks/reconnect.ts +45 -0
- package/src/connectionHelper/checks/turn.ts +53 -0
- package/src/connectionHelper/checks/webrtc.ts +18 -0
- package/src/connectionHelper/checks/websocket.ts +22 -0
- package/src/index.ts +3 -1
- package/src/proto/livekit_rtc.ts +12 -1
- package/src/room/DeviceManager.ts +0 -17
- package/src/room/Room.ts +22 -2
- package/src/room/events.ts +5 -0
- package/src/room/participant/LocalParticipant.ts +15 -8
- package/src/room/track/LocalTrack.ts +3 -0
- package/src/room/track/RemoteTrackPublication.ts +20 -0
@@ -12428,7 +12428,8 @@ function createBaseUpdateTrackSettings() {
|
|
12428
12428
|
disabled: false,
|
12429
12429
|
quality: 0,
|
12430
12430
|
width: 0,
|
12431
|
-
height: 0
|
12431
|
+
height: 0,
|
12432
|
+
fps: 0
|
12432
12433
|
};
|
12433
12434
|
}
|
12434
12435
|
|
@@ -12456,6 +12457,10 @@ const UpdateTrackSettings = {
|
|
12456
12457
|
writer.uint32(48).uint32(message.height);
|
12457
12458
|
}
|
12458
12459
|
|
12460
|
+
if (message.fps !== 0) {
|
12461
|
+
writer.uint32(56).uint32(message.fps);
|
12462
|
+
}
|
12463
|
+
|
12459
12464
|
return writer;
|
12460
12465
|
},
|
12461
12466
|
|
@@ -12488,6 +12493,10 @@ const UpdateTrackSettings = {
|
|
12488
12493
|
message.height = reader.uint32();
|
12489
12494
|
break;
|
12490
12495
|
|
12496
|
+
case 7:
|
12497
|
+
message.fps = reader.uint32();
|
12498
|
+
break;
|
12499
|
+
|
12491
12500
|
default:
|
12492
12501
|
reader.skipType(tag & 7);
|
12493
12502
|
break;
|
@@ -12503,7 +12512,8 @@ const UpdateTrackSettings = {
|
|
12503
12512
|
disabled: isSet(object.disabled) ? Boolean(object.disabled) : false,
|
12504
12513
|
quality: isSet(object.quality) ? videoQualityFromJSON(object.quality) : 0,
|
12505
12514
|
width: isSet(object.width) ? Number(object.width) : 0,
|
12506
|
-
height: isSet(object.height) ? Number(object.height) : 0
|
12515
|
+
height: isSet(object.height) ? Number(object.height) : 0,
|
12516
|
+
fps: isSet(object.fps) ? Number(object.fps) : 0
|
12507
12517
|
};
|
12508
12518
|
},
|
12509
12519
|
|
@@ -12520,11 +12530,12 @@ const UpdateTrackSettings = {
|
|
12520
12530
|
message.quality !== undefined && (obj.quality = videoQualityToJSON(message.quality));
|
12521
12531
|
message.width !== undefined && (obj.width = Math.round(message.width));
|
12522
12532
|
message.height !== undefined && (obj.height = Math.round(message.height));
|
12533
|
+
message.fps !== undefined && (obj.fps = Math.round(message.fps));
|
12523
12534
|
return obj;
|
12524
12535
|
},
|
12525
12536
|
|
12526
12537
|
fromPartial(object) {
|
12527
|
-
var _a, _b, _c, _d, _e;
|
12538
|
+
var _a, _b, _c, _d, _e, _f;
|
12528
12539
|
|
12529
12540
|
const message = createBaseUpdateTrackSettings();
|
12530
12541
|
message.trackSids = ((_a = object.trackSids) === null || _a === void 0 ? void 0 : _a.map(e => e)) || [];
|
@@ -12532,6 +12543,7 @@ const UpdateTrackSettings = {
|
|
12532
12543
|
message.quality = (_c = object.quality) !== null && _c !== void 0 ? _c : 0;
|
12533
12544
|
message.width = (_d = object.width) !== null && _d !== void 0 ? _d : 0;
|
12534
12545
|
message.height = (_e = object.height) !== null && _e !== void 0 ? _e : 0;
|
12546
|
+
message.fps = (_f = object.fps) !== null && _f !== void 0 ? _f : 0;
|
12535
12547
|
return message;
|
12536
12548
|
}
|
12537
12549
|
|
@@ -14466,6 +14478,11 @@ var RoomEvent;
|
|
14466
14478
|
*/
|
14467
14479
|
|
14468
14480
|
RoomEvent["SignalConnected"] = "signalConnected";
|
14481
|
+
/**
|
14482
|
+
* Recording of a room has started/stopped.
|
14483
|
+
*/
|
14484
|
+
|
14485
|
+
RoomEvent["RecordingStatusChanged"] = "recordingStatusChanged";
|
14469
14486
|
})(RoomEvent || (RoomEvent = {}));
|
14470
14487
|
|
14471
14488
|
var ParticipantEvent;
|
@@ -15312,7 +15329,7 @@ var uaParser = {exports: {}};
|
|
15312
15329
|
|
15313
15330
|
var UAParser = uaParser.exports;
|
15314
15331
|
|
15315
|
-
var version$1 = "1.
|
15332
|
+
var version$1 = "1.5.0";
|
15316
15333
|
|
15317
15334
|
const version = version$1;
|
15318
15335
|
const protocolVersion = 8;
|
@@ -15766,25 +15783,6 @@ class DeviceManager {
|
|
15766
15783
|
|
15767
15784
|
if (kind) {
|
15768
15785
|
devices = devices.filter(device => device.kind === kind);
|
15769
|
-
} // Chrome returns 'default' devices, we would filter them out, but put the default
|
15770
|
-
// device at first
|
15771
|
-
// we would only do this if there are more than 1 device though
|
15772
|
-
|
15773
|
-
|
15774
|
-
if (devices.length > 1 && devices[0].deviceId === defaultId) {
|
15775
|
-
// find another device with matching group id, and move that to 0
|
15776
|
-
const defaultDevice = devices[0];
|
15777
|
-
|
15778
|
-
for (let i = 1; i < devices.length; i += 1) {
|
15779
|
-
if (devices[i].groupId === defaultDevice.groupId) {
|
15780
|
-
const temp = devices[0];
|
15781
|
-
devices[0] = devices[i];
|
15782
|
-
devices[i] = temp;
|
15783
|
-
break;
|
15784
|
-
}
|
15785
|
-
}
|
15786
|
-
|
15787
|
-
return devices.filter(device => device !== defaultDevice);
|
15788
15786
|
}
|
15789
15787
|
|
15790
15788
|
return devices;
|
@@ -16748,7 +16746,9 @@ class LocalTrack extends Track {
|
|
16748
16746
|
await this.sender.replaceTrack(track);
|
16749
16747
|
}
|
16750
16748
|
|
16751
|
-
this._mediaStreamTrack = track;
|
16749
|
+
this._mediaStreamTrack = track; // sync muted state with the enabled state of the newly provided track
|
16750
|
+
|
16751
|
+
this._mediaStreamTrack.enabled = !this.isMuted;
|
16752
16752
|
await this.resumeUpstream();
|
16753
16753
|
this.attachedElements.forEach(el => {
|
16754
16754
|
attachToElement(track, el);
|
@@ -19195,6 +19195,23 @@ class RemoteTrackPublication extends TrackPublication {
|
|
19195
19195
|
this.emitTrackUpdate();
|
19196
19196
|
}
|
19197
19197
|
|
19198
|
+
setVideoFPS(fps) {
|
19199
|
+
if (!this.isManualOperationAllowed()) {
|
19200
|
+
return;
|
19201
|
+
}
|
19202
|
+
|
19203
|
+
if (!(this.track instanceof RemoteVideoTrack)) {
|
19204
|
+
return;
|
19205
|
+
}
|
19206
|
+
|
19207
|
+
if (this.fps === fps) {
|
19208
|
+
return;
|
19209
|
+
}
|
19210
|
+
|
19211
|
+
this.fps = fps;
|
19212
|
+
this.emitTrackUpdate();
|
19213
|
+
}
|
19214
|
+
|
19198
19215
|
get videoQuality() {
|
19199
19216
|
return this.currentVideoQuality;
|
19200
19217
|
}
|
@@ -19298,7 +19315,8 @@ class RemoteTrackPublication extends TrackPublication {
|
|
19298
19315
|
emitTrackUpdate() {
|
19299
19316
|
const settings = UpdateTrackSettings.fromPartial({
|
19300
19317
|
trackSids: [this.trackSid],
|
19301
|
-
disabled: this.disabled
|
19318
|
+
disabled: this.disabled,
|
19319
|
+
fps: this.fps
|
19302
19320
|
});
|
19303
19321
|
|
19304
19322
|
if (this.videoDimensions) {
|
@@ -19936,6 +19954,9 @@ class LocalParticipant extends Participant {
|
|
19936
19954
|
const publishPromises = [];
|
19937
19955
|
|
19938
19956
|
for (const localTrack of localTracks) {
|
19957
|
+
livekitLogger.info('publishing track', {
|
19958
|
+
localTrack
|
19959
|
+
});
|
19939
19960
|
publishPromises.push(this.publishTrack(localTrack, publishOptions));
|
19940
19961
|
}
|
19941
19962
|
|
@@ -20077,14 +20098,28 @@ class LocalParticipant extends Participant {
|
|
20077
20098
|
let videoConstraints = true;
|
20078
20099
|
|
20079
20100
|
if (options.resolution) {
|
20080
|
-
|
20081
|
-
|
20082
|
-
|
20083
|
-
|
20084
|
-
|
20085
|
-
|
20086
|
-
|
20087
|
-
|
20101
|
+
if (isSafari()) {
|
20102
|
+
videoConstraints = {
|
20103
|
+
width: {
|
20104
|
+
max: options.resolution.width
|
20105
|
+
},
|
20106
|
+
height: {
|
20107
|
+
max: options.resolution.height
|
20108
|
+
},
|
20109
|
+
frameRate: options.resolution.frameRate
|
20110
|
+
};
|
20111
|
+
} else {
|
20112
|
+
videoConstraints = {
|
20113
|
+
width: {
|
20114
|
+
ideal: options.resolution.width
|
20115
|
+
},
|
20116
|
+
height: {
|
20117
|
+
ideal: options.resolution.height
|
20118
|
+
},
|
20119
|
+
frameRate: options.resolution.frameRate
|
20120
|
+
};
|
20121
|
+
}
|
20122
|
+
}
|
20088
20123
|
|
20089
20124
|
const stream = await navigator.mediaDevices.getDisplayMedia({
|
20090
20125
|
audio: (_a = options.audio) !== null && _a !== void 0 ? _a : false,
|
@@ -20939,8 +20974,8 @@ class SignalClient {
|
|
20939
20974
|
await sleep(this.signalLatency);
|
20940
20975
|
}
|
20941
20976
|
|
20942
|
-
if (!this.ws) {
|
20943
|
-
livekitLogger.error(
|
20977
|
+
if (!this.ws || this.ws.readyState < this.ws.OPEN) {
|
20978
|
+
livekitLogger.error("cannot send signal request before connected, type: ".concat(message === null || message === void 0 ? void 0 : message.$case));
|
20944
20979
|
return;
|
20945
20980
|
}
|
20946
20981
|
|
@@ -23275,6 +23310,7 @@ class Room extends events.exports.EventEmitter {
|
|
23275
23310
|
/** room metadata */
|
23276
23311
|
|
23277
23312
|
this.metadata = undefined;
|
23313
|
+
this._isRecording = false;
|
23278
23314
|
this.audioEnabled = true;
|
23279
23315
|
|
23280
23316
|
this.connect = (url, token, opts) => {
|
@@ -23368,6 +23404,12 @@ class Room extends events.exports.EventEmitter {
|
|
23368
23404
|
this.name = joinResponse.room.name;
|
23369
23405
|
this.sid = joinResponse.room.sid;
|
23370
23406
|
this.metadata = joinResponse.room.metadata;
|
23407
|
+
|
23408
|
+
if (this._isRecording !== joinResponse.room.activeRecording) {
|
23409
|
+
this._isRecording = joinResponse.room.activeRecording;
|
23410
|
+
this.emit(RoomEvent.RecordingStatusChanged, joinResponse.room.activeRecording);
|
23411
|
+
}
|
23412
|
+
|
23371
23413
|
this.emit(RoomEvent.SignalConnected);
|
23372
23414
|
} catch (err) {
|
23373
23415
|
this.recreateEngine();
|
@@ -23682,8 +23724,15 @@ class Room extends events.exports.EventEmitter {
|
|
23682
23724
|
};
|
23683
23725
|
|
23684
23726
|
this.handleRoomUpdate = r => {
|
23685
|
-
this.
|
23686
|
-
|
23727
|
+
if (this._isRecording !== r.activeRecording) {
|
23728
|
+
this._isRecording = r.activeRecording;
|
23729
|
+
this.emit(RoomEvent.RecordingStatusChanged, r.activeRecording);
|
23730
|
+
}
|
23731
|
+
|
23732
|
+
if (this.metadata !== r.metadata) {
|
23733
|
+
this.metadata = r.metadata;
|
23734
|
+
this.emitWhenConnected(RoomEvent.RoomMetadataChanged, r.metadata);
|
23735
|
+
}
|
23687
23736
|
};
|
23688
23737
|
|
23689
23738
|
this.handleConnectionQualityUpdate = update => {
|
@@ -23829,6 +23878,14 @@ class Room extends events.exports.EventEmitter {
|
|
23829
23878
|
clearConnectionFutures() {
|
23830
23879
|
this.connectFuture = undefined;
|
23831
23880
|
}
|
23881
|
+
/**
|
23882
|
+
* if the current room has a participant with `recorder: true` in its JWT grant
|
23883
|
+
**/
|
23884
|
+
|
23885
|
+
|
23886
|
+
get isRecording() {
|
23887
|
+
return this._isRecording;
|
23888
|
+
}
|
23832
23889
|
/**
|
23833
23890
|
* @internal for testing
|
23834
23891
|
*/
|
@@ -24469,5 +24526,420 @@ async function createLocalScreenTracks(options) {
|
|
24469
24526
|
return localTracks;
|
24470
24527
|
}
|
24471
24528
|
|
24472
|
-
|
24529
|
+
var CheckStatus;
|
24530
|
+
|
24531
|
+
(function (CheckStatus) {
|
24532
|
+
CheckStatus[CheckStatus["IDLE"] = 0] = "IDLE";
|
24533
|
+
CheckStatus[CheckStatus["RUNNING"] = 1] = "RUNNING";
|
24534
|
+
CheckStatus[CheckStatus["SKIPPED"] = 2] = "SKIPPED";
|
24535
|
+
CheckStatus[CheckStatus["SUCCESS"] = 3] = "SUCCESS";
|
24536
|
+
CheckStatus[CheckStatus["FAILED"] = 4] = "FAILED";
|
24537
|
+
})(CheckStatus || (CheckStatus = {}));
|
24538
|
+
|
24539
|
+
class Checker extends events.exports.EventEmitter {
|
24540
|
+
constructor(url, token) {
|
24541
|
+
let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
24542
|
+
super();
|
24543
|
+
this.status = CheckStatus.IDLE;
|
24544
|
+
this.logs = [];
|
24545
|
+
this.errorsAsWarnings = false;
|
24546
|
+
this.url = url;
|
24547
|
+
this.token = token;
|
24548
|
+
this.name = this.constructor.name;
|
24549
|
+
this.room = new Room(options.roomOptions);
|
24550
|
+
this.connectOptions = options.connectOptions;
|
24551
|
+
|
24552
|
+
if (options.errorsAsWarnings) {
|
24553
|
+
this.errorsAsWarnings = options.errorsAsWarnings;
|
24554
|
+
}
|
24555
|
+
}
|
24556
|
+
|
24557
|
+
async run(onComplete) {
|
24558
|
+
if (this.status !== CheckStatus.IDLE) {
|
24559
|
+
throw Error('check is running already');
|
24560
|
+
}
|
24561
|
+
|
24562
|
+
this.setStatus(CheckStatus.RUNNING);
|
24563
|
+
this.appendMessage("".concat(this.name, " started."));
|
24564
|
+
|
24565
|
+
try {
|
24566
|
+
await this.perform();
|
24567
|
+
} catch (err) {
|
24568
|
+
if (err instanceof Error) {
|
24569
|
+
if (this.errorsAsWarnings) {
|
24570
|
+
this.appendWarning(err.message);
|
24571
|
+
} else {
|
24572
|
+
this.appendError(err.message);
|
24573
|
+
}
|
24574
|
+
}
|
24575
|
+
}
|
24576
|
+
|
24577
|
+
await this.disconnect(); // sleep for a bit to ensure disconnect
|
24578
|
+
|
24579
|
+
await new Promise(resolve => setTimeout(resolve, 500)); // @ts-ignore
|
24580
|
+
|
24581
|
+
if (this.status !== CheckStatus.SKIPPED) {
|
24582
|
+
this.setStatus(this.isSuccess() ? CheckStatus.SUCCESS : CheckStatus.FAILED);
|
24583
|
+
}
|
24584
|
+
|
24585
|
+
if (onComplete) {
|
24586
|
+
onComplete();
|
24587
|
+
}
|
24588
|
+
|
24589
|
+
return this.getInfo();
|
24590
|
+
}
|
24591
|
+
|
24592
|
+
isSuccess() {
|
24593
|
+
return !this.logs.some(l => l.level === 'error');
|
24594
|
+
}
|
24595
|
+
|
24596
|
+
async connect() {
|
24597
|
+
if (this.room.state === ConnectionState.Connected) {
|
24598
|
+
return this.room;
|
24599
|
+
}
|
24600
|
+
|
24601
|
+
await this.room.connect(this.url, this.token);
|
24602
|
+
return this.room;
|
24603
|
+
}
|
24604
|
+
|
24605
|
+
async disconnect() {
|
24606
|
+
if (this.room && this.room.state !== ConnectionState.Disconnected) {
|
24607
|
+
await this.room.disconnect(); // wait for it to go through
|
24608
|
+
|
24609
|
+
await new Promise(resolve => setTimeout(resolve, 500));
|
24610
|
+
}
|
24611
|
+
}
|
24612
|
+
|
24613
|
+
skip() {
|
24614
|
+
this.setStatus(CheckStatus.SKIPPED);
|
24615
|
+
}
|
24616
|
+
|
24617
|
+
appendMessage(message) {
|
24618
|
+
this.logs.push({
|
24619
|
+
level: 'info',
|
24620
|
+
message
|
24621
|
+
});
|
24622
|
+
this.emit('update', this.getInfo());
|
24623
|
+
}
|
24624
|
+
|
24625
|
+
appendWarning(message) {
|
24626
|
+
this.logs.push({
|
24627
|
+
level: 'warning',
|
24628
|
+
message
|
24629
|
+
});
|
24630
|
+
this.emit('update', this.getInfo());
|
24631
|
+
}
|
24632
|
+
|
24633
|
+
appendError(message) {
|
24634
|
+
this.logs.push({
|
24635
|
+
level: 'error',
|
24636
|
+
message
|
24637
|
+
});
|
24638
|
+
this.emit('update', this.getInfo());
|
24639
|
+
}
|
24640
|
+
|
24641
|
+
setStatus(status) {
|
24642
|
+
this.status = status;
|
24643
|
+
this.emit('update', this.getInfo());
|
24644
|
+
}
|
24645
|
+
|
24646
|
+
get engine() {
|
24647
|
+
var _a;
|
24648
|
+
|
24649
|
+
return (_a = this.room) === null || _a === void 0 ? void 0 : _a.engine;
|
24650
|
+
}
|
24651
|
+
|
24652
|
+
getInfo() {
|
24653
|
+
return {
|
24654
|
+
logs: this.logs,
|
24655
|
+
name: this.name,
|
24656
|
+
status: this.status,
|
24657
|
+
description: this.description
|
24658
|
+
};
|
24659
|
+
}
|
24660
|
+
|
24661
|
+
}
|
24662
|
+
|
24663
|
+
class PublishAudioCheck extends Checker {
|
24664
|
+
get description() {
|
24665
|
+
return 'Can publish audio';
|
24666
|
+
}
|
24667
|
+
|
24668
|
+
async perform() {
|
24669
|
+
var _a;
|
24670
|
+
|
24671
|
+
const room = await this.connect();
|
24672
|
+
const track = await createLocalAudioTrack();
|
24673
|
+
room.localParticipant.publishTrack(track); // wait for a few seconds to publish
|
24674
|
+
|
24675
|
+
await new Promise(resolve => setTimeout(resolve, 3000)); // verify RTC stats that it's publishing
|
24676
|
+
|
24677
|
+
const stats = await ((_a = track.sender) === null || _a === void 0 ? void 0 : _a.getStats());
|
24678
|
+
|
24679
|
+
if (!stats) {
|
24680
|
+
throw new Error('Could not get RTCStats');
|
24681
|
+
}
|
24682
|
+
|
24683
|
+
let numPackets = 0;
|
24684
|
+
stats.forEach(stat => {
|
24685
|
+
if (stat.type === 'outbound-rtp' && stat.mediaType === 'audio') {
|
24686
|
+
numPackets = stat.packetsSent;
|
24687
|
+
}
|
24688
|
+
});
|
24689
|
+
|
24690
|
+
if (numPackets === 0) {
|
24691
|
+
throw new Error('Could not determine packets are sent');
|
24692
|
+
}
|
24693
|
+
|
24694
|
+
this.appendMessage("published ".concat(numPackets, " audio packets"));
|
24695
|
+
}
|
24696
|
+
|
24697
|
+
}
|
24698
|
+
|
24699
|
+
class PublishVideoCheck extends Checker {
|
24700
|
+
get description() {
|
24701
|
+
return 'Can publish video';
|
24702
|
+
}
|
24703
|
+
|
24704
|
+
async perform() {
|
24705
|
+
var _a;
|
24706
|
+
|
24707
|
+
const room = await this.connect();
|
24708
|
+
const track = await createLocalVideoTrack();
|
24709
|
+
room.localParticipant.publishTrack(track); // wait for a few seconds to publish
|
24710
|
+
|
24711
|
+
await new Promise(resolve => setTimeout(resolve, 3000)); // verify RTC stats that it's publishing
|
24712
|
+
|
24713
|
+
const stats = await ((_a = track.sender) === null || _a === void 0 ? void 0 : _a.getStats());
|
24714
|
+
|
24715
|
+
if (!stats) {
|
24716
|
+
throw new Error('Could not get RTCStats');
|
24717
|
+
}
|
24718
|
+
|
24719
|
+
let numPackets = 0;
|
24720
|
+
stats.forEach(stat => {
|
24721
|
+
if (stat.type === 'outbound-rtp' && stat.mediaType === 'video') {
|
24722
|
+
numPackets = stat.packetsSent;
|
24723
|
+
}
|
24724
|
+
});
|
24725
|
+
|
24726
|
+
if (numPackets === 0) {
|
24727
|
+
throw new Error('Could not determine packets are sent');
|
24728
|
+
}
|
24729
|
+
|
24730
|
+
this.appendMessage("published ".concat(numPackets, " video packets"));
|
24731
|
+
}
|
24732
|
+
|
24733
|
+
}
|
24734
|
+
|
24735
|
+
class ReconnectCheck extends Checker {
|
24736
|
+
get description() {
|
24737
|
+
return 'Resuming connection after interruption';
|
24738
|
+
}
|
24739
|
+
|
24740
|
+
async perform() {
|
24741
|
+
var _a;
|
24742
|
+
|
24743
|
+
const room = await this.connect();
|
24744
|
+
let reconnectingTriggered = false;
|
24745
|
+
let reconnected = false;
|
24746
|
+
let reconnectResolver;
|
24747
|
+
const reconnectTimeout = new Promise(resolve => {
|
24748
|
+
setTimeout(resolve, 5000);
|
24749
|
+
reconnectResolver = resolve;
|
24750
|
+
});
|
24751
|
+
room.on(RoomEvent.Reconnecting, () => {
|
24752
|
+
reconnectingTriggered = true;
|
24753
|
+
}).on(RoomEvent.Reconnected, () => {
|
24754
|
+
reconnected = true;
|
24755
|
+
reconnectResolver(true);
|
24756
|
+
});
|
24757
|
+
(_a = room.engine.client.ws) === null || _a === void 0 ? void 0 : _a.close();
|
24758
|
+
const onClose = room.engine.client.onClose;
|
24759
|
+
|
24760
|
+
if (onClose) {
|
24761
|
+
onClose('');
|
24762
|
+
}
|
24763
|
+
|
24764
|
+
await reconnectTimeout;
|
24765
|
+
|
24766
|
+
if (!reconnectingTriggered) {
|
24767
|
+
throw new Error('Did not attempt to reconnect');
|
24768
|
+
} else if (!reconnected || room.state !== ConnectionState.Connected) {
|
24769
|
+
this.appendWarning('reconnection is only possible in Redis-based configurations');
|
24770
|
+
throw new Error('Not able to reconnect');
|
24771
|
+
}
|
24772
|
+
}
|
24773
|
+
|
24774
|
+
}
|
24775
|
+
|
24776
|
+
class TURNCheck extends Checker {
|
24777
|
+
get description() {
|
24778
|
+
return 'Can connect via TURN';
|
24779
|
+
}
|
24780
|
+
|
24781
|
+
async perform() {
|
24782
|
+
var _a, _b;
|
24783
|
+
|
24784
|
+
const signalClient = new SignalClient();
|
24785
|
+
const joinRes = await signalClient.join(this.url, this.token, {
|
24786
|
+
autoSubscribe: true,
|
24787
|
+
maxRetries: 0
|
24788
|
+
});
|
24789
|
+
let hasTLS = false;
|
24790
|
+
let hasTURN = false;
|
24791
|
+
let hasSTUN = false;
|
24792
|
+
|
24793
|
+
for (let iceServer of joinRes.iceServers) {
|
24794
|
+
for (let url of iceServer.urls) {
|
24795
|
+
if (url.startsWith('turn:')) {
|
24796
|
+
hasTURN = true;
|
24797
|
+
hasSTUN = true;
|
24798
|
+
} else if (url.startsWith('turns:')) {
|
24799
|
+
hasTURN = true;
|
24800
|
+
hasSTUN = true;
|
24801
|
+
hasTLS = true;
|
24802
|
+
}
|
24803
|
+
|
24804
|
+
if (url.startsWith('stun:')) {
|
24805
|
+
hasSTUN = true;
|
24806
|
+
}
|
24807
|
+
}
|
24808
|
+
}
|
24809
|
+
|
24810
|
+
if (!hasSTUN) {
|
24811
|
+
this.appendWarning('No STUN servers configured on server side.');
|
24812
|
+
} else if (hasTURN && !hasTLS) {
|
24813
|
+
this.appendWarning('TURN is configured server side, but TURN/TLS is unavailable.');
|
24814
|
+
}
|
24815
|
+
|
24816
|
+
signalClient.close();
|
24817
|
+
|
24818
|
+
if (((_b = (_a = this.connectOptions) === null || _a === void 0 ? void 0 : _a.rtcConfig) === null || _b === void 0 ? void 0 : _b.iceServers) || hasTURN) {
|
24819
|
+
await this.room.connect(this.url, this.token, {
|
24820
|
+
rtcConfig: {
|
24821
|
+
iceTransportPolicy: 'relay'
|
24822
|
+
}
|
24823
|
+
});
|
24824
|
+
} else {
|
24825
|
+
this.appendWarning('No TURN servers configured.');
|
24826
|
+
this.skip();
|
24827
|
+
await new Promise(resolve => setTimeout(resolve, 0));
|
24828
|
+
}
|
24829
|
+
}
|
24830
|
+
|
24831
|
+
}
|
24832
|
+
|
24833
|
+
class WebRTCCheck extends Checker {
|
24834
|
+
get description() {
|
24835
|
+
return 'Establishing WebRTC connection';
|
24836
|
+
}
|
24837
|
+
|
24838
|
+
async perform() {
|
24839
|
+
try {
|
24840
|
+
console.log('initiating room connection');
|
24841
|
+
this.room = await this.connect();
|
24842
|
+
console.log('now the room is connected');
|
24843
|
+
} catch (err) {
|
24844
|
+
this.appendWarning('ports need to be open on firewall in order to connect.');
|
24845
|
+
throw err;
|
24846
|
+
}
|
24847
|
+
}
|
24848
|
+
|
24849
|
+
}
|
24850
|
+
|
24851
|
+
class WebSocketCheck extends Checker {
|
24852
|
+
get description() {
|
24853
|
+
return 'Connecting to signal connection via WebSocket';
|
24854
|
+
}
|
24855
|
+
|
24856
|
+
async perform() {
|
24857
|
+
if (this.url.startsWith('ws:') || this.url.startsWith('http:')) {
|
24858
|
+
this.appendWarning('Server is insecure, clients may block connections to it');
|
24859
|
+
}
|
24860
|
+
|
24861
|
+
let signalClient = new SignalClient();
|
24862
|
+
const joinRes = await signalClient.join(this.url, this.token, {
|
24863
|
+
autoSubscribe: true,
|
24864
|
+
maxRetries: 0
|
24865
|
+
});
|
24866
|
+
this.appendMessage("Connected to server, version ".concat(joinRes.serverVersion, "."));
|
24867
|
+
signalClient.close();
|
24868
|
+
}
|
24869
|
+
|
24870
|
+
}
|
24871
|
+
|
24872
|
+
class ConnectionCheck extends events.exports {
|
24873
|
+
constructor(url, token) {
|
24874
|
+
super();
|
24875
|
+
this.checkResults = new Map();
|
24876
|
+
this.url = url;
|
24877
|
+
this.token = token;
|
24878
|
+
}
|
24879
|
+
|
24880
|
+
getNextCheckId() {
|
24881
|
+
const nextId = this.checkResults.size;
|
24882
|
+
this.checkResults.set(nextId, {
|
24883
|
+
logs: [],
|
24884
|
+
status: CheckStatus.IDLE,
|
24885
|
+
name: '',
|
24886
|
+
description: ''
|
24887
|
+
});
|
24888
|
+
return nextId;
|
24889
|
+
}
|
24890
|
+
|
24891
|
+
updateCheck(checkId, info) {
|
24892
|
+
this.checkResults.set(checkId, info);
|
24893
|
+
this.emit('checkUpdate', checkId, info);
|
24894
|
+
}
|
24895
|
+
|
24896
|
+
isSuccess() {
|
24897
|
+
return Array.from(this.checkResults.values()).every(r => r.status !== CheckStatus.FAILED);
|
24898
|
+
}
|
24899
|
+
|
24900
|
+
getResults() {
|
24901
|
+
return Array.from(this.checkResults.values());
|
24902
|
+
}
|
24903
|
+
|
24904
|
+
async createAndRunCheck(check) {
|
24905
|
+
const checkId = this.getNextCheckId();
|
24906
|
+
const test = new check(this.url, this.token);
|
24907
|
+
|
24908
|
+
const handleUpdate = info => {
|
24909
|
+
this.updateCheck(checkId, info);
|
24910
|
+
};
|
24911
|
+
|
24912
|
+
test.on('update', handleUpdate);
|
24913
|
+
const result = await test.run();
|
24914
|
+
test.off('update', handleUpdate);
|
24915
|
+
return result;
|
24916
|
+
}
|
24917
|
+
|
24918
|
+
async checkWebsocket() {
|
24919
|
+
return this.createAndRunCheck(WebSocketCheck);
|
24920
|
+
}
|
24921
|
+
|
24922
|
+
async checkWebRTC() {
|
24923
|
+
return this.createAndRunCheck(WebRTCCheck);
|
24924
|
+
}
|
24925
|
+
|
24926
|
+
async checkTURN() {
|
24927
|
+
return this.createAndRunCheck(TURNCheck);
|
24928
|
+
}
|
24929
|
+
|
24930
|
+
async checkReconnect() {
|
24931
|
+
return this.createAndRunCheck(ReconnectCheck);
|
24932
|
+
}
|
24933
|
+
|
24934
|
+
async checkPublishAudio() {
|
24935
|
+
return this.createAndRunCheck(PublishAudioCheck);
|
24936
|
+
}
|
24937
|
+
|
24938
|
+
async checkPublishVideo() {
|
24939
|
+
return this.createAndRunCheck(PublishVideoCheck);
|
24940
|
+
}
|
24941
|
+
|
24942
|
+
}
|
24943
|
+
|
24944
|
+
export { AudioPresets, ConnectionCheck, ConnectionError, ConnectionQuality, ConnectionState, DataPacket_Kind, DefaultReconnectPolicy, DisconnectReason, EngineEvent, LivekitError, LocalAudioTrack, LocalParticipant, LocalTrack, LocalTrackPublication, LocalVideoTrack, LogLevel, MediaDeviceFailure, NegotiationError, Participant, ParticipantEvent, PublishDataError, RemoteAudioTrack, RemoteParticipant, RemoteTrack, RemoteTrackPublication, RemoteVideoTrack, Room, RoomEvent, RoomState, ScreenSharePresets, Track, TrackEvent, TrackInvalidError, TrackPublication, UnexpectedConnectionState, UnsupportedServer, VideoPreset, VideoPresets, VideoPresets43, VideoQuality, attachToElement, createLocalAudioTrack, createLocalScreenTracks, createLocalTracks, createLocalVideoTrack, detachTrack, getEmptyAudioStreamTrack, getEmptyVideoStreamTrack, isBackupCodec, isBrowserSupported, protocolVersion, setLogExtension, setLogLevel, supportsAV1, supportsAdaptiveStream, supportsDynacast, version };
|
24473
24945
|
//# sourceMappingURL=livekit-client.esm.mjs.map
|