@dtelecom/livekit-client 1.12.14 → 1.12.16
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/livekit-client.esm.mjs +174 -20
- 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 +1 -0
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/options.d.ts +2 -0
- package/dist/src/options.d.ts.map +1 -1
- package/dist/src/room/DeviceManager.d.ts +3 -0
- package/dist/src/room/DeviceManager.d.ts.map +1 -1
- package/dist/src/room/FallbackUrlProvider.d.ts +9 -0
- package/dist/src/room/FallbackUrlProvider.d.ts.map +1 -0
- package/dist/src/room/RTCEngine.d.ts +2 -0
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +1 -0
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/utils.d.ts +3 -1
- package/dist/src/room/utils.d.ts.map +1 -1
- package/dist/ts4.2/src/api/SignalClient.d.ts +1 -0
- package/dist/ts4.2/src/options.d.ts +2 -0
- package/dist/ts4.2/src/room/DeviceManager.d.ts +3 -0
- package/dist/ts4.2/src/room/FallbackUrlProvider.d.ts +9 -0
- package/dist/ts4.2/src/room/RTCEngine.d.ts +2 -0
- package/dist/ts4.2/src/room/Room.d.ts +1 -0
- package/dist/ts4.2/src/room/utils.d.ts +3 -1
- package/package.json +1 -1
- package/src/api/SignalClient.ts +1 -0
- package/src/options.ts +3 -0
- package/src/room/DeviceManager.ts +32 -5
- package/src/room/FallbackUrlProvider.ts +36 -0
- package/src/room/RTCEngine.ts +17 -1
- package/src/room/Room.ts +104 -8
- package/src/room/utils.ts +14 -1
|
@@ -14198,7 +14198,7 @@ function getMatch(exp, ua) {
|
|
|
14198
14198
|
return match && match.length >= id && match[id] || '';
|
|
14199
14199
|
}
|
|
14200
14200
|
|
|
14201
|
-
var version$1 = "1.12.
|
|
14201
|
+
var version$1 = "1.12.15";
|
|
14202
14202
|
|
|
14203
14203
|
const version = version$1;
|
|
14204
14204
|
const protocolVersion = 9;
|
|
@@ -15195,6 +15195,18 @@ function getNewAudioContext() {
|
|
|
15195
15195
|
});
|
|
15196
15196
|
}
|
|
15197
15197
|
}
|
|
15198
|
+
/**
|
|
15199
|
+
* @internal
|
|
15200
|
+
*/
|
|
15201
|
+
function kindToSource(kind) {
|
|
15202
|
+
if (kind === 'audioinput') {
|
|
15203
|
+
return Track.Source.Microphone;
|
|
15204
|
+
} else if (kind === 'videoinput') {
|
|
15205
|
+
return Track.Source.Camera;
|
|
15206
|
+
} else {
|
|
15207
|
+
return Track.Source.Unknown;
|
|
15208
|
+
}
|
|
15209
|
+
}
|
|
15198
15210
|
/**
|
|
15199
15211
|
* @internal
|
|
15200
15212
|
*/
|
|
@@ -15560,6 +15572,16 @@ function unwrapConstraint(constraint) {
|
|
|
15560
15572
|
}
|
|
15561
15573
|
throw Error('could not unwrap constraint');
|
|
15562
15574
|
}
|
|
15575
|
+
function getDisconnectReasonFromConnectionError(e) {
|
|
15576
|
+
switch (e.reason) {
|
|
15577
|
+
case 3 /* ConnectionErrorReason.Cancelled */:
|
|
15578
|
+
return DisconnectReason.CLIENT_INITIATED;
|
|
15579
|
+
case 1 /* ConnectionErrorReason.ServerUnreachable */:
|
|
15580
|
+
return DisconnectReason.JOIN_FAILURE;
|
|
15581
|
+
default:
|
|
15582
|
+
return DisconnectReason.UNKNOWN_REASON;
|
|
15583
|
+
}
|
|
15584
|
+
}
|
|
15563
15585
|
|
|
15564
15586
|
var QueueTaskStatus;
|
|
15565
15587
|
(function (QueueTaskStatus) {
|
|
@@ -16364,12 +16386,18 @@ const CryptorEvent = {
|
|
|
16364
16386
|
|
|
16365
16387
|
const defaultId = 'default';
|
|
16366
16388
|
class DeviceManager {
|
|
16389
|
+
constructor() {
|
|
16390
|
+
this._previousDevices = [];
|
|
16391
|
+
}
|
|
16367
16392
|
static getInstance() {
|
|
16368
16393
|
if (this.instance === undefined) {
|
|
16369
16394
|
this.instance = new DeviceManager();
|
|
16370
16395
|
}
|
|
16371
16396
|
return this.instance;
|
|
16372
16397
|
}
|
|
16398
|
+
get previousDevices() {
|
|
16399
|
+
return this._previousDevices;
|
|
16400
|
+
}
|
|
16373
16401
|
getDevices(kind) {
|
|
16374
16402
|
let requestPermissions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
16375
16403
|
var _a;
|
|
@@ -16387,10 +16415,10 @@ class DeviceManager {
|
|
|
16387
16415
|
}
|
|
16388
16416
|
}
|
|
16389
16417
|
let devices = yield navigator.mediaDevices.enumerateDevices();
|
|
16390
|
-
if (requestPermissions &&
|
|
16418
|
+
if (requestPermissions &&
|
|
16391
16419
|
// for safari we need to skip this check, as otherwise it will re-acquire user media and fail on iOS https://bugs.webkit.org/show_bug.cgi?id=179363
|
|
16392
|
-
!
|
|
16393
|
-
const isDummyDeviceOrEmpty = devices.length === 0 || devices.some(device => {
|
|
16420
|
+
!(isSafari() && this.hasDeviceInUse(kind))) {
|
|
16421
|
+
const isDummyDeviceOrEmpty = devices.filter(d => d.kind === kind).length === 0 || devices.some(device => {
|
|
16394
16422
|
const noLabel = device.label === '';
|
|
16395
16423
|
const isRelevant = kind ? device.kind === kind : true;
|
|
16396
16424
|
return noLabel && isRelevant;
|
|
@@ -16398,7 +16426,11 @@ class DeviceManager {
|
|
|
16398
16426
|
if (isDummyDeviceOrEmpty) {
|
|
16399
16427
|
const permissionsToAcquire = {
|
|
16400
16428
|
video: kind !== 'audioinput' && kind !== 'audiooutput',
|
|
16401
|
-
audio: kind !== 'videoinput'
|
|
16429
|
+
audio: kind !== 'videoinput' && {
|
|
16430
|
+
deviceId: {
|
|
16431
|
+
ideal: 'default'
|
|
16432
|
+
}
|
|
16433
|
+
}
|
|
16402
16434
|
};
|
|
16403
16435
|
const stream = yield navigator.mediaDevices.getUserMedia(permissionsToAcquire);
|
|
16404
16436
|
devices = yield navigator.mediaDevices.enumerateDevices();
|
|
@@ -16407,6 +16439,7 @@ class DeviceManager {
|
|
|
16407
16439
|
});
|
|
16408
16440
|
}
|
|
16409
16441
|
}
|
|
16442
|
+
this._previousDevices = devices;
|
|
16410
16443
|
if (kind) {
|
|
16411
16444
|
devices = devices.filter(device => device.kind === kind);
|
|
16412
16445
|
}
|
|
@@ -16421,10 +16454,22 @@ class DeviceManager {
|
|
|
16421
16454
|
// resolve actual device id if it's 'default': Chrome returns it when no
|
|
16422
16455
|
// device has been chosen
|
|
16423
16456
|
const devices = yield this.getDevices(kind);
|
|
16424
|
-
const
|
|
16457
|
+
const defaultDevice = devices.find(d => d.deviceId === defaultId);
|
|
16458
|
+
if (!defaultDevice) {
|
|
16459
|
+
livekitLogger.warn('could not reliably determine default device');
|
|
16460
|
+
return undefined;
|
|
16461
|
+
}
|
|
16462
|
+
const device = devices.find(d => d.deviceId !== defaultId && d.groupId === (groupId !== null && groupId !== void 0 ? groupId : defaultDevice.groupId));
|
|
16463
|
+
if (!device) {
|
|
16464
|
+
livekitLogger.warn('could not reliably determine default device');
|
|
16465
|
+
return undefined;
|
|
16466
|
+
}
|
|
16425
16467
|
return device === null || device === void 0 ? void 0 : device.deviceId;
|
|
16426
16468
|
});
|
|
16427
16469
|
}
|
|
16470
|
+
hasDeviceInUse(kind) {
|
|
16471
|
+
return kind ? DeviceManager.userMediaPromiseMap.has(kind) : DeviceManager.userMediaPromiseMap.size > 0;
|
|
16472
|
+
}
|
|
16428
16473
|
}
|
|
16429
16474
|
DeviceManager.mediaDeviceKinds = ['audioinput', 'audiooutput', 'videoinput'];
|
|
16430
16475
|
DeviceManager.userMediaPromiseMap = new Map();
|
|
@@ -19204,6 +19249,34 @@ function videoLayersFromEncodings(width, height, encodings, svc) {
|
|
|
19204
19249
|
});
|
|
19205
19250
|
}
|
|
19206
19251
|
|
|
19252
|
+
class FallbackUrlProvider {
|
|
19253
|
+
constructor(fallbackUrls) {
|
|
19254
|
+
this.attemptedUrls = [];
|
|
19255
|
+
this.fallbackUrls = fallbackUrls;
|
|
19256
|
+
}
|
|
19257
|
+
isAvailable() {
|
|
19258
|
+
return this.fallbackUrls && this.fallbackUrls.length > 0;
|
|
19259
|
+
}
|
|
19260
|
+
getNextUrl() {
|
|
19261
|
+
var _a;
|
|
19262
|
+
if (!this.isAvailable()) {
|
|
19263
|
+
throw Error('no fallback urls proviced');
|
|
19264
|
+
}
|
|
19265
|
+
const urlsLeft = (_a = this.fallbackUrls) === null || _a === void 0 ? void 0 : _a.filter(url => !this.attemptedUrls.find(attempted => attempted === url));
|
|
19266
|
+
if (urlsLeft && urlsLeft.length > 0) {
|
|
19267
|
+
const nextUrl = urlsLeft[0];
|
|
19268
|
+
this.attemptedUrls.push(nextUrl);
|
|
19269
|
+
livekitLogger.debug("next url: ".concat(nextUrl));
|
|
19270
|
+
return nextUrl;
|
|
19271
|
+
} else {
|
|
19272
|
+
return null;
|
|
19273
|
+
}
|
|
19274
|
+
}
|
|
19275
|
+
resetAttempts() {
|
|
19276
|
+
this.attemptedUrls = [];
|
|
19277
|
+
}
|
|
19278
|
+
}
|
|
19279
|
+
|
|
19207
19280
|
const lossyDataChannel = '_lossy';
|
|
19208
19281
|
const reliableDataChannel = '_reliable';
|
|
19209
19282
|
const minReconnectWait = 2 * 1000;
|
|
@@ -19338,6 +19411,9 @@ class RTCEngine extends EventEmitter {
|
|
|
19338
19411
|
if (this.url && this.token && isCloud(new URL(this.url))) {
|
|
19339
19412
|
this.regionUrlProvider = new RegionUrlProvider(this.url, this.token);
|
|
19340
19413
|
}
|
|
19414
|
+
if (this.fallbackUrls) {
|
|
19415
|
+
this.fallbackUrlProvider = new FallbackUrlProvider(this.fallbackUrls);
|
|
19416
|
+
}
|
|
19341
19417
|
this.reconnectTimeout = CriticalTimers.setTimeout(() => this.attemptReconnect(disconnectReason), delay);
|
|
19342
19418
|
};
|
|
19343
19419
|
this.waitForRestarted = () => {
|
|
@@ -19398,6 +19474,8 @@ class RTCEngine extends EventEmitter {
|
|
|
19398
19474
|
this.url = url;
|
|
19399
19475
|
this.token = token;
|
|
19400
19476
|
this.signalOpts = opts;
|
|
19477
|
+
this.maxJoinAttempts = opts.maxRetries;
|
|
19478
|
+
this.fallbackUrls = opts.fallbackUrs;
|
|
19401
19479
|
try {
|
|
19402
19480
|
this.joinAttempts += 1;
|
|
19403
19481
|
const joinResponse = yield this.client.join(url, token, opts, abortSignal);
|
|
@@ -19912,7 +19990,7 @@ class RTCEngine extends EventEmitter {
|
|
|
19912
19990
|
return null;
|
|
19913
19991
|
}
|
|
19914
19992
|
restartConnection(regionUrl) {
|
|
19915
|
-
var _a, _b, _c;
|
|
19993
|
+
var _a, _b, _c, _d, _e;
|
|
19916
19994
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19917
19995
|
try {
|
|
19918
19996
|
if (!this.url || !this.token) {
|
|
@@ -19948,16 +20026,21 @@ class RTCEngine extends EventEmitter {
|
|
|
19948
20026
|
this.emit(EngineEvent.SignalRestarted, joinResponse);
|
|
19949
20027
|
yield this.waitForPCReconnected();
|
|
19950
20028
|
(_a = this.regionUrlProvider) === null || _a === void 0 ? void 0 : _a.resetAttempts();
|
|
20029
|
+
(_b = this.fallbackUrlProvider) === null || _b === void 0 ? void 0 : _b.resetAttempts();
|
|
19951
20030
|
// reconnect success
|
|
19952
20031
|
this.emit(EngineEvent.Restarted);
|
|
19953
20032
|
} catch (error) {
|
|
19954
|
-
|
|
20033
|
+
let nextRegionUrl = yield (_c = this.regionUrlProvider) === null || _c === void 0 ? void 0 : _c.getNextBestRegionUrl();
|
|
20034
|
+
if (this.fallbackUrlProvider && !nextRegionUrl) {
|
|
20035
|
+
nextRegionUrl = this.fallbackUrlProvider.getNextUrl();
|
|
20036
|
+
}
|
|
19955
20037
|
if (nextRegionUrl) {
|
|
19956
20038
|
yield this.restartConnection(nextRegionUrl);
|
|
19957
20039
|
return;
|
|
19958
20040
|
} else {
|
|
19959
20041
|
// no more regions to try (or we're not on cloud)
|
|
19960
|
-
(
|
|
20042
|
+
(_d = this.regionUrlProvider) === null || _d === void 0 ? void 0 : _d.resetAttempts();
|
|
20043
|
+
(_e = this.fallbackUrlProvider) === null || _e === void 0 ? void 0 : _e.resetAttempts();
|
|
19961
20044
|
throw error;
|
|
19962
20045
|
}
|
|
19963
20046
|
}
|
|
@@ -22857,6 +22940,9 @@ class Room extends EventEmitter {
|
|
|
22857
22940
|
}
|
|
22858
22941
|
this.setAndEmitConnectionState(ConnectionState.Connecting);
|
|
22859
22942
|
const urlProvider = new RegionUrlProvider(url, token);
|
|
22943
|
+
if (opts === null || opts === void 0 ? void 0 : opts.fallbackUrls) {
|
|
22944
|
+
this.fallbackUrlProvider = new FallbackUrlProvider(opts.fallbackUrls);
|
|
22945
|
+
}
|
|
22860
22946
|
const connectFn = (resolve, reject, regionUrl) => __awaiter(this, void 0, void 0, function* () {
|
|
22861
22947
|
var _b;
|
|
22862
22948
|
if (this.abortController) {
|
|
@@ -22870,12 +22956,17 @@ class Room extends EventEmitter {
|
|
|
22870
22956
|
this.abortController = undefined;
|
|
22871
22957
|
resolve();
|
|
22872
22958
|
} catch (e) {
|
|
22873
|
-
if (isCloud(new URL(url)) && e instanceof ConnectionError && e.reason !== 3 /* ConnectionErrorReason.Cancelled */) {
|
|
22959
|
+
if ((isCloud(new URL(url)) || this.fallbackUrlProvider) && e instanceof ConnectionError && e.reason !== 3 /* ConnectionErrorReason.Cancelled */) {
|
|
22874
22960
|
let nextUrl = null;
|
|
22875
22961
|
try {
|
|
22876
|
-
|
|
22962
|
+
if (this.fallbackUrlProvider) {
|
|
22963
|
+
nextUrl = this.fallbackUrlProvider.getNextUrl();
|
|
22964
|
+
} else {
|
|
22965
|
+
nextUrl = yield urlProvider.getNextBestRegionUrl((_b = this.abortController) === null || _b === void 0 ? void 0 : _b.signal);
|
|
22966
|
+
}
|
|
22877
22967
|
} catch (error) {
|
|
22878
22968
|
if (error instanceof ConnectionError && (error.status === 401 || error.reason === 3 /* ConnectionErrorReason.Cancelled */)) {
|
|
22969
|
+
this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
|
|
22879
22970
|
reject(error);
|
|
22880
22971
|
return;
|
|
22881
22972
|
}
|
|
@@ -22884,9 +22975,15 @@ class Room extends EventEmitter {
|
|
|
22884
22975
|
livekitLogger.debug('initial connection failed, retrying with another region');
|
|
22885
22976
|
yield connectFn(resolve, reject, nextUrl);
|
|
22886
22977
|
} else {
|
|
22978
|
+
this.handleDisconnect(this.options.stopLocalTrackOnUnpublish, getDisconnectReasonFromConnectionError(e));
|
|
22887
22979
|
reject(e);
|
|
22888
22980
|
}
|
|
22889
22981
|
} else {
|
|
22982
|
+
let disconnectReason = DisconnectReason.UNKNOWN_REASON;
|
|
22983
|
+
if (e instanceof ConnectionError) {
|
|
22984
|
+
disconnectReason = getDisconnectReasonFromConnectionError(e);
|
|
22985
|
+
}
|
|
22986
|
+
this.handleDisconnect(this.options.stopLocalTrackOnUnpublish, disconnectReason);
|
|
22890
22987
|
reject(e);
|
|
22891
22988
|
}
|
|
22892
22989
|
}
|
|
@@ -22902,7 +22999,8 @@ class Room extends EventEmitter {
|
|
|
22902
22999
|
publishOnly: connectOptions.publishOnly,
|
|
22903
23000
|
adaptiveStream: typeof roomOptions.adaptiveStream === 'object' ? true : roomOptions.adaptiveStream,
|
|
22904
23001
|
maxRetries: connectOptions.maxRetries,
|
|
22905
|
-
e2eeEnabled: !!this.e2eeManager
|
|
23002
|
+
e2eeEnabled: !!this.e2eeManager,
|
|
23003
|
+
fallbackUrs: connectOptions.fallbackUrls
|
|
22906
23004
|
}, abortController.signal);
|
|
22907
23005
|
let serverInfo = joinResponse.serverInfo;
|
|
22908
23006
|
if (!serverInfo) {
|
|
@@ -22960,8 +23058,8 @@ class Room extends EventEmitter {
|
|
|
22960
23058
|
this.setupLocalParticipantEvents();
|
|
22961
23059
|
this.emit(RoomEvent.SignalConnected);
|
|
22962
23060
|
} catch (err) {
|
|
23061
|
+
yield this.engine.close();
|
|
22963
23062
|
this.recreateEngine();
|
|
22964
|
-
this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
|
|
22965
23063
|
const resultingError = new ConnectionError("could not establish signal connection");
|
|
22966
23064
|
if (err instanceof Error) {
|
|
22967
23065
|
resultingError.message = "".concat(resultingError.message, ": ").concat(err.message);
|
|
@@ -22976,15 +23074,15 @@ class Room extends EventEmitter {
|
|
|
22976
23074
|
throw resultingError;
|
|
22977
23075
|
}
|
|
22978
23076
|
if (abortController.signal.aborted) {
|
|
23077
|
+
yield this.engine.close();
|
|
22979
23078
|
this.recreateEngine();
|
|
22980
|
-
this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
|
|
22981
23079
|
throw new ConnectionError("Connection attempt aborted");
|
|
22982
23080
|
}
|
|
22983
23081
|
try {
|
|
22984
23082
|
yield this.engine.waitForPCInitialConnection(this.connOptions.peerConnectionTimeout, abortController);
|
|
22985
23083
|
} catch (e) {
|
|
23084
|
+
yield this.engine.close();
|
|
22986
23085
|
this.recreateEngine();
|
|
22987
|
-
this.handleDisconnect(this.options.stopLocalTrackOnUnpublish);
|
|
22988
23086
|
throw e;
|
|
22989
23087
|
}
|
|
22990
23088
|
// also hook unload event
|
|
@@ -23255,6 +23353,50 @@ class Room extends EventEmitter {
|
|
|
23255
23353
|
this.emit(RoomEvent.AudioPlaybackStatusChanged, false);
|
|
23256
23354
|
};
|
|
23257
23355
|
this.handleDeviceChange = () => __awaiter(this, void 0, void 0, function* () {
|
|
23356
|
+
var _j, _k, _l;
|
|
23357
|
+
const previousDevices = DeviceManager.getInstance().previousDevices;
|
|
23358
|
+
// check for available devices, but don't request permissions in order to avoid prompts for kinds that haven't been used before
|
|
23359
|
+
const availableDevices = yield DeviceManager.getInstance().getDevices(undefined, false);
|
|
23360
|
+
const browser = getBrowser();
|
|
23361
|
+
if ((browser === null || browser === void 0 ? void 0 : browser.name) === 'Chrome' && browser.os !== 'iOS') {
|
|
23362
|
+
for (let availableDevice of availableDevices) {
|
|
23363
|
+
const previousDevice = previousDevices.find(info => info.deviceId === availableDevice.deviceId);
|
|
23364
|
+
if (previousDevice && previousDevice.label !== '' && previousDevice.kind === availableDevice.kind && previousDevice.label !== availableDevice.label) {
|
|
23365
|
+
// label has changed on device the same deviceId, indicating that the default device has changed on the OS level
|
|
23366
|
+
if (this.getActiveDevice(availableDevice.kind) === 'default') {
|
|
23367
|
+
// emit an active device change event only if the selected output device is actually on `default`
|
|
23368
|
+
this.emit(RoomEvent.ActiveDeviceChanged, availableDevice.kind, availableDevice.deviceId);
|
|
23369
|
+
}
|
|
23370
|
+
}
|
|
23371
|
+
}
|
|
23372
|
+
}
|
|
23373
|
+
const kinds = ['audiooutput', 'audioinput', 'videoinput'];
|
|
23374
|
+
for (let kind of kinds) {
|
|
23375
|
+
const targetSource = kindToSource(kind);
|
|
23376
|
+
const targetPublication = this.localParticipant.getTrack(targetSource);
|
|
23377
|
+
if (targetPublication && ((_j = targetPublication.track) === null || _j === void 0 ? void 0 : _j.isUserProvided)) {
|
|
23378
|
+
// if the track is user provided, we don't want to switch devices on behalf of the user
|
|
23379
|
+
continue;
|
|
23380
|
+
}
|
|
23381
|
+
const devicesOfKind = availableDevices.filter(d => d.kind === kind);
|
|
23382
|
+
const activeDevice = this.getActiveDevice(kind);
|
|
23383
|
+
if (activeDevice === ((_k = previousDevices.filter(info => info.kind === kind)[0]) === null || _k === void 0 ? void 0 : _k.deviceId)) {
|
|
23384
|
+
// in Safari the first device is always the default, so we assume a user on the default device would like to switch to the default once it changes
|
|
23385
|
+
// FF doesn't emit an event when the default device changes, so we perform the same best effort and switch to the new device once connected and if it's the first in the array
|
|
23386
|
+
if (devicesOfKind.length > 0 && ((_l = devicesOfKind[0]) === null || _l === void 0 ? void 0 : _l.deviceId) !== activeDevice) {
|
|
23387
|
+
yield this.switchActiveDevice(kind, devicesOfKind[0].deviceId);
|
|
23388
|
+
continue;
|
|
23389
|
+
}
|
|
23390
|
+
}
|
|
23391
|
+
if (kind === 'audioinput' && !isSafari() || kind === 'videoinput') {
|
|
23392
|
+
// airpods on Safari need special handling for audioinput as the track doesn't end as soon as you take them out
|
|
23393
|
+
continue;
|
|
23394
|
+
}
|
|
23395
|
+
// switch to first available device if previously active device is not available any more
|
|
23396
|
+
if (devicesOfKind.length > 0 && !devicesOfKind.find(deviceInfo => deviceInfo.deviceId === this.getActiveDevice(kind))) {
|
|
23397
|
+
yield this.switchActiveDevice(kind, devicesOfKind[0].deviceId);
|
|
23398
|
+
}
|
|
23399
|
+
}
|
|
23258
23400
|
this.emit(RoomEvent.MediaDevicesChanged);
|
|
23259
23401
|
});
|
|
23260
23402
|
this.handleRoomUpdate = room => {
|
|
@@ -23292,7 +23434,7 @@ class Room extends EventEmitter {
|
|
|
23292
23434
|
this.emit(RoomEvent.TrackUnmuted, pub, this.localParticipant);
|
|
23293
23435
|
};
|
|
23294
23436
|
this.onLocalTrackPublished = pub => __awaiter(this, void 0, void 0, function* () {
|
|
23295
|
-
var
|
|
23437
|
+
var _m;
|
|
23296
23438
|
this.emit(RoomEvent.LocalTrackPublished, pub, this.localParticipant);
|
|
23297
23439
|
if (pub.track instanceof LocalAudioTrack) {
|
|
23298
23440
|
const trackIsSilent = yield pub.track.checkForSilence();
|
|
@@ -23300,7 +23442,7 @@ class Room extends EventEmitter {
|
|
|
23300
23442
|
this.emit(RoomEvent.LocalAudioSilenceDetected, pub);
|
|
23301
23443
|
}
|
|
23302
23444
|
}
|
|
23303
|
-
const deviceId = yield (
|
|
23445
|
+
const deviceId = yield (_m = pub.track) === null || _m === void 0 ? void 0 : _m.getDeviceId();
|
|
23304
23446
|
const deviceKind = sourceToKind(pub.source);
|
|
23305
23447
|
if (deviceKind && deviceId && deviceId !== this.localParticipant.activeDeviceMap.get(deviceKind)) {
|
|
23306
23448
|
this.localParticipant.activeDeviceMap.set(deviceKind, deviceId);
|
|
@@ -23457,10 +23599,22 @@ class Room extends EventEmitter {
|
|
|
23457
23599
|
* @experimental
|
|
23458
23600
|
*/
|
|
23459
23601
|
prepareConnection(url) {
|
|
23602
|
+
var _a;
|
|
23460
23603
|
return __awaiter(this, void 0, void 0, function* () {
|
|
23461
|
-
|
|
23462
|
-
|
|
23463
|
-
|
|
23604
|
+
if ((_a = this.connOptions) === null || _a === void 0 ? void 0 : _a.fallbackUrls) {
|
|
23605
|
+
this.fallbackUrlProvider = new FallbackUrlProvider(this.connOptions.fallbackUrls);
|
|
23606
|
+
const nextUrl = this.fallbackUrlProvider.getNextUrl();
|
|
23607
|
+
if (nextUrl && this.state === ConnectionState.Disconnected) {
|
|
23608
|
+
yield fetch("http".concat(nextUrl.substring(2)), {
|
|
23609
|
+
method: 'HEAD'
|
|
23610
|
+
});
|
|
23611
|
+
livekitLogger.debug("prepared connection to ".concat(nextUrl));
|
|
23612
|
+
}
|
|
23613
|
+
} else {
|
|
23614
|
+
yield fetch("http".concat(url.substring(2)), {
|
|
23615
|
+
method: 'HEAD'
|
|
23616
|
+
});
|
|
23617
|
+
}
|
|
23464
23618
|
});
|
|
23465
23619
|
}
|
|
23466
23620
|
/**
|