livekit-client 1.15.1 → 1.15.3

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.
@@ -324,7 +324,6 @@ function setLogExtension(extension) {
324
324
  };
325
325
  livekitLogger.setLevel(livekitLogger.getLevel()); // Be sure to call setLevel method in order to apply plugin
326
326
  }
327
-
328
327
  loglevelExports.getLogger('lk-e2ee');
329
328
 
330
329
  // Copyright 2021-2023 Buf Technologies, Inc.
@@ -2113,7 +2112,6 @@ function makeBinaryFormatProto3() {
2113
2112
  if (oneof.case !== localName) {
2114
2113
  continue; // field is not selected, skip
2115
2114
  }
2116
-
2117
2115
  value = oneof.value;
2118
2116
  } else {
2119
2117
  value = message[localName];
@@ -2660,7 +2658,6 @@ function writeEnum(type, value, emitIntrinsicDefault, enumAsInteger) {
2660
2658
  const val = type.findNumber(value);
2661
2659
  return (_a = val === null || val === void 0 ? void 0 : val.name) !== null && _a !== void 0 ? _a : value; // if we don't know the enum value, just return the number
2662
2660
  }
2663
-
2664
2661
  function writeScalar(type, value, emitIntrinsicDefault) {
2665
2662
  if (value === undefined) {
2666
2663
  return undefined;
@@ -2738,7 +2735,6 @@ function makeJsonFormatProto3() {
2738
2735
  assert(val !== undefined);
2739
2736
  jsonObj[entryKey.toString()] = val; // JSON standard allows only (double quoted) string as property key
2740
2737
  }
2741
-
2742
2738
  break;
2743
2739
  case "message":
2744
2740
  for (const [entryKey, entryValue] of Object.entries(value)) {
@@ -2754,7 +2750,6 @@ function makeJsonFormatProto3() {
2754
2750
  assert(val !== undefined);
2755
2751
  jsonObj[entryKey.toString()] = val; // JSON standard allows only (double quoted) string as property key
2756
2752
  }
2757
-
2758
2753
  break;
2759
2754
  }
2760
2755
  return options.emitDefaultValues || Object.keys(jsonObj).length > 0 ? jsonObj : undefined;
@@ -6245,7 +6240,6 @@ EventEmitter.prototype.emit = function emit(type) {
6245
6240
  err.context = er;
6246
6241
  throw err; // Unhandled 'error' event
6247
6242
  }
6248
-
6249
6243
  var handler = events[type];
6250
6244
  if (handler === undefined) return false;
6251
6245
  if (typeof handler === 'function') {
@@ -6878,7 +6872,6 @@ function shimGetUserMedia$2(window, browserDetails) {
6878
6872
  if (!dev && devices.length && matches.includes('back')) {
6879
6873
  dev = devices[devices.length - 1]; // more likely the back cam
6880
6874
  }
6881
-
6882
6875
  if (dev) {
6883
6876
  constraints.video.deviceId = face.exact ? {
6884
6877
  exact: dev.deviceId
@@ -7112,7 +7105,6 @@ function shimGetSendersWithDtmf(window) {
7112
7105
  this._senders = this._senders || [];
7113
7106
  return this._senders.slice(); // return a copy of the internal state.
7114
7107
  };
7115
-
7116
7108
  const origAddTrack = window.RTCPeerConnection.prototype.addTrack;
7117
7109
  window.RTCPeerConnection.prototype.addTrack = function addTrack(track, stream) {
7118
7110
  let sender = origAddTrack.apply(this, arguments);
@@ -7736,7 +7728,6 @@ function shimPeerConnection(window, browserDetails) {
7736
7728
  if (typeof window !== 'object' || !(window.RTCPeerConnection || window.mozRTCPeerConnection)) {
7737
7729
  return; // probably media.peerconnection.enabled=false in about:config
7738
7730
  }
7739
-
7740
7731
  if (!window.RTCPeerConnection && window.mozRTCPeerConnection) {
7741
7732
  // very basic support for old versions.
7742
7733
  window.RTCPeerConnection = window.mozRTCPeerConnection;
@@ -8475,7 +8466,6 @@ var sdp$1 = {exports: {}};
8475
8466
  const parsed = {
8476
8467
  payloadType: parseInt(parts.shift(), 10) // was: id
8477
8468
  };
8478
-
8479
8469
  parts = parts[0].split('/');
8480
8470
  parsed.name = parts[0];
8481
8471
  parsed.clockRate = parseInt(parts[1], 10); // was: clockrate
@@ -9013,7 +9003,6 @@ var sdp$1 = {exports: {}};
9013
9003
  // FIXME: What should happen here?
9014
9004
  }
9015
9005
  }
9016
-
9017
9006
  if (sessionpart) {
9018
9007
  return SDPUtils.getDirection(sessionpart);
9019
9008
  }
@@ -9062,7 +9051,6 @@ var sdp$1 = {exports: {}};
9062
9051
  }
9063
9052
  // TODO: check the modifier a bit more.
9064
9053
  }
9065
-
9066
9054
  return true;
9067
9055
  };
9068
9056
 
@@ -10577,7 +10565,7 @@ function getMatch(exp, ua) {
10577
10565
  return match && match.length >= id && match[id] || '';
10578
10566
  }
10579
10567
 
10580
- var version$1 = "1.15.1";
10568
+ var version$1 = "1.15.3";
10581
10569
 
10582
10570
  const version = version$1;
10583
10571
  const protocolVersion = 10;
@@ -13495,6 +13483,10 @@ function supportsAV1() {
13495
13483
  if (!('getCapabilities' in RTCRtpSender)) {
13496
13484
  return false;
13497
13485
  }
13486
+ if (isSafari()) {
13487
+ // Safari 17 on iPhone14 reports AV1 capability, but does not actually support it
13488
+ return false;
13489
+ }
13498
13490
  const capabilities = RTCRtpSender.getCapabilities('video');
13499
13491
  let hasAV1 = false;
13500
13492
  if (capabilities) {
@@ -13516,6 +13508,13 @@ function supportsVP9() {
13516
13508
  // https://bugzilla.mozilla.org/show_bug.cgi?id=1633876
13517
13509
  return false;
13518
13510
  }
13511
+ if (isSafari()) {
13512
+ const browser = getBrowser();
13513
+ if ((browser === null || browser === void 0 ? void 0 : browser.version) && compareVersions(browser.version, '16') < 0) {
13514
+ // Safari 16 and below does not support VP9
13515
+ return false;
13516
+ }
13517
+ }
13519
13518
  const capabilities = RTCRtpSender.getCapabilities('video');
13520
13519
  let hasVP9 = false;
13521
13520
  if (capabilities) {
@@ -14733,12 +14732,27 @@ function canPassThroughQueue(req) {
14733
14732
  });
14734
14733
  return canPass;
14735
14734
  }
14735
+ var SignalConnectionState;
14736
+ (function (SignalConnectionState) {
14737
+ SignalConnectionState[SignalConnectionState["CONNECTING"] = 0] = "CONNECTING";
14738
+ SignalConnectionState[SignalConnectionState["CONNECTED"] = 1] = "CONNECTED";
14739
+ SignalConnectionState[SignalConnectionState["RECONNECTING"] = 2] = "RECONNECTING";
14740
+ SignalConnectionState[SignalConnectionState["DISCONNECTING"] = 3] = "DISCONNECTING";
14741
+ SignalConnectionState[SignalConnectionState["DISCONNECTED"] = 4] = "DISCONNECTED";
14742
+ })(SignalConnectionState || (SignalConnectionState = {}));
14736
14743
  /** @internal */
14737
14744
  class SignalClient {
14745
+ get currentState() {
14746
+ return this.state;
14747
+ }
14748
+ get isDisconnected() {
14749
+ return this.state === SignalConnectionState.DISCONNECTING || this.state === SignalConnectionState.DISCONNECTED;
14750
+ }
14738
14751
  constructor() {
14739
14752
  let useJSON = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
14740
14753
  /** signal rtt in milliseconds */
14741
14754
  this.rtt = 0;
14755
+ this.state = SignalConnectionState.DISCONNECTED;
14742
14756
  /** @internal */
14743
14757
  this.resetCallbacks = () => {
14744
14758
  this.onAnswer = undefined;
@@ -14753,18 +14767,18 @@ class SignalClient {
14753
14767
  this.onTrickle = undefined;
14754
14768
  this.onClose = undefined;
14755
14769
  };
14756
- this.isConnected = false;
14757
- this.isReconnecting = false;
14758
14770
  this.useJSON = useJSON;
14759
14771
  this.requestQueue = new AsyncQueue();
14760
14772
  this.queuedRequests = [];
14761
14773
  this.closingLock = new Mutex();
14774
+ this.connectionLock = new Mutex();
14775
+ this.state = SignalConnectionState.DISCONNECTED;
14762
14776
  }
14763
14777
  join(url, token, opts, abortSignal) {
14764
14778
  return __awaiter(this, void 0, void 0, function* () {
14765
14779
  // during a full reconnect, we'd want to start the sequence even if currently
14766
14780
  // connected
14767
- this.isConnected = false;
14781
+ this.state = SignalConnectionState.CONNECTING;
14768
14782
  this.options = opts;
14769
14783
  const res = yield this.connect(url, token, opts, abortSignal);
14770
14784
  return res;
@@ -14776,7 +14790,7 @@ class SignalClient {
14776
14790
  livekitLogger.warn('attempted to reconnect without signal options being set, ignoring');
14777
14791
  return;
14778
14792
  }
14779
- this.isReconnecting = true;
14793
+ this.state = SignalConnectionState.RECONNECTING;
14780
14794
  // clear ping interval and restart it once reconnected
14781
14795
  this.clearPingInterval();
14782
14796
  const res = yield this.connect(url, token, Object.assign(Object.assign({}, this.options), {
@@ -14796,114 +14810,118 @@ class SignalClient {
14796
14810
  const clientInfo = getClientInfo();
14797
14811
  const params = createConnectionParams(token, clientInfo, opts);
14798
14812
  return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
14799
- const abortHandler = () => __awaiter(this, void 0, void 0, function* () {
14800
- this.close();
14801
- clearTimeout(wsTimeout);
14802
- reject(new ConnectionError('room connection has been cancelled (signal)'));
14803
- });
14804
- const wsTimeout = setTimeout(() => {
14805
- this.close();
14806
- reject(new ConnectionError('room connection has timed out (signal)'));
14807
- }, opts.websocketTimeout);
14808
- if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
14809
- abortHandler();
14810
- }
14811
- abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener('abort', abortHandler);
14812
- livekitLogger.debug("connecting to ".concat(url + params));
14813
- if (this.ws) {
14814
- yield this.close();
14815
- }
14816
- this.ws = new WebSocket(url + params);
14817
- this.ws.binaryType = 'arraybuffer';
14818
- this.ws.onopen = () => {
14819
- clearTimeout(wsTimeout);
14820
- };
14821
- this.ws.onerror = ev => __awaiter(this, void 0, void 0, function* () {
14822
- if (!this.isConnected) {
14813
+ const unlock = yield this.connectionLock.lock();
14814
+ try {
14815
+ const abortHandler = () => __awaiter(this, void 0, void 0, function* () {
14816
+ this.close();
14823
14817
  clearTimeout(wsTimeout);
14824
- try {
14825
- const resp = yield fetch("http".concat(url.substring(2), "/validate").concat(params));
14826
- if (resp.status.toFixed(0).startsWith('4')) {
14827
- const msg = yield resp.text();
14828
- reject(new ConnectionError(msg, 0 /* ConnectionErrorReason.NotAllowed */, resp.status));
14829
- } else {
14830
- reject(new ConnectionError('Internal error', 2 /* ConnectionErrorReason.InternalError */, resp.status));
14831
- }
14832
- } catch (e) {
14833
- reject(new ConnectionError('server was not reachable', 1 /* ConnectionErrorReason.ServerUnreachable */));
14834
- }
14835
-
14836
- return;
14818
+ reject(new ConnectionError('room connection has been cancelled (signal)'));
14819
+ });
14820
+ const wsTimeout = setTimeout(() => {
14821
+ this.close();
14822
+ reject(new ConnectionError('room connection has timed out (signal)'));
14823
+ }, opts.websocketTimeout);
14824
+ if (abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.aborted) {
14825
+ abortHandler();
14837
14826
  }
14838
- // other errors, handle
14839
- this.handleWSError(ev);
14840
- });
14841
- this.ws.onmessage = ev => __awaiter(this, void 0, void 0, function* () {
14842
- var _a, _b, _c, _d;
14843
- // not considered connected until JoinResponse is received
14844
- let resp;
14845
- if (typeof ev.data === 'string') {
14846
- const json = JSON.parse(ev.data);
14847
- resp = SignalResponse.fromJson(json);
14848
- } else if (ev.data instanceof ArrayBuffer) {
14849
- resp = SignalResponse.fromBinary(new Uint8Array(ev.data));
14850
- } else {
14851
- livekitLogger.error("could not decode websocket message: ".concat(typeof ev.data));
14852
- return;
14827
+ abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.addEventListener('abort', abortHandler);
14828
+ livekitLogger.debug("connecting to ".concat(url + params));
14829
+ if (this.ws) {
14830
+ yield this.close();
14853
14831
  }
14854
- if (!this.isConnected) {
14855
- let shouldProcessMessage = false;
14856
- // handle join message only
14857
- if (((_a = resp.message) === null || _a === void 0 ? void 0 : _a.case) === 'join') {
14858
- this.isConnected = true;
14859
- abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', abortHandler);
14860
- this.pingTimeoutDuration = resp.message.value.pingTimeout;
14861
- this.pingIntervalDuration = resp.message.value.pingInterval;
14862
- if (this.pingTimeoutDuration && this.pingTimeoutDuration > 0) {
14863
- livekitLogger.debug('ping config', {
14864
- timeout: this.pingTimeoutDuration,
14865
- interval: this.pingIntervalDuration
14866
- });
14832
+ this.ws = new WebSocket(url + params);
14833
+ this.ws.binaryType = 'arraybuffer';
14834
+ this.ws.onopen = () => {
14835
+ clearTimeout(wsTimeout);
14836
+ };
14837
+ this.ws.onerror = ev => __awaiter(this, void 0, void 0, function* () {
14838
+ if (this.state !== SignalConnectionState.CONNECTED) {
14839
+ clearTimeout(wsTimeout);
14840
+ try {
14841
+ const resp = yield fetch("http".concat(url.substring(2), "/validate").concat(params));
14842
+ if (resp.status.toFixed(0).startsWith('4')) {
14843
+ const msg = yield resp.text();
14844
+ reject(new ConnectionError(msg, 0 /* ConnectionErrorReason.NotAllowed */, resp.status));
14845
+ } else {
14846
+ reject(new ConnectionError('Internal error', 2 /* ConnectionErrorReason.InternalError */, resp.status));
14847
+ }
14848
+ } catch (e) {
14849
+ reject(new ConnectionError('server was not reachable', 1 /* ConnectionErrorReason.ServerUnreachable */));
14850
+ }
14851
+ return;
14852
+ }
14853
+ // other errors, handle
14854
+ this.handleWSError(ev);
14855
+ });
14856
+ this.ws.onmessage = ev => __awaiter(this, void 0, void 0, function* () {
14857
+ var _a, _b, _c, _d;
14858
+ // not considered connected until JoinResponse is received
14859
+ let resp;
14860
+ if (typeof ev.data === 'string') {
14861
+ const json = JSON.parse(ev.data);
14862
+ resp = SignalResponse.fromJson(json);
14863
+ } else if (ev.data instanceof ArrayBuffer) {
14864
+ resp = SignalResponse.fromBinary(new Uint8Array(ev.data));
14865
+ } else {
14866
+ livekitLogger.error("could not decode websocket message: ".concat(typeof ev.data));
14867
+ return;
14868
+ }
14869
+ if (this.state !== SignalConnectionState.CONNECTED) {
14870
+ let shouldProcessMessage = false;
14871
+ // handle join message only
14872
+ if (((_a = resp.message) === null || _a === void 0 ? void 0 : _a.case) === 'join') {
14873
+ this.state = SignalConnectionState.CONNECTED;
14874
+ abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', abortHandler);
14875
+ this.pingTimeoutDuration = resp.message.value.pingTimeout;
14876
+ this.pingIntervalDuration = resp.message.value.pingInterval;
14877
+ if (this.pingTimeoutDuration && this.pingTimeoutDuration > 0) {
14878
+ livekitLogger.debug('ping config', {
14879
+ timeout: this.pingTimeoutDuration,
14880
+ interval: this.pingIntervalDuration
14881
+ });
14882
+ this.startPingInterval();
14883
+ }
14884
+ resolve(resp.message.value);
14885
+ } else if (this.state === SignalConnectionState.RECONNECTING) {
14886
+ // in reconnecting, any message received means signal reconnected
14887
+ this.state = SignalConnectionState.CONNECTED;
14888
+ abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', abortHandler);
14867
14889
  this.startPingInterval();
14890
+ if (((_b = resp.message) === null || _b === void 0 ? void 0 : _b.case) === 'reconnect') {
14891
+ resolve((_c = resp.message) === null || _c === void 0 ? void 0 : _c.value);
14892
+ } else {
14893
+ resolve();
14894
+ shouldProcessMessage = true;
14895
+ }
14896
+ } else if (!opts.reconnect) {
14897
+ // non-reconnect case, should receive join response first
14898
+ reject(new ConnectionError("did not receive join response, got ".concat((_d = resp.message) === null || _d === void 0 ? void 0 : _d.case, " instead")));
14868
14899
  }
14869
- resolve(resp.message.value);
14870
- } else if (opts.reconnect) {
14871
- // in reconnecting, any message received means signal reconnected
14872
- this.isConnected = true;
14873
- abortSignal === null || abortSignal === void 0 ? void 0 : abortSignal.removeEventListener('abort', abortHandler);
14874
- this.startPingInterval();
14875
- if (((_b = resp.message) === null || _b === void 0 ? void 0 : _b.case) === 'reconnect') {
14876
- resolve((_c = resp.message) === null || _c === void 0 ? void 0 : _c.value);
14877
- } else {
14878
- resolve();
14879
- shouldProcessMessage = true;
14900
+ if (!shouldProcessMessage) {
14901
+ return;
14880
14902
  }
14881
- } else if (!opts.reconnect) {
14882
- // non-reconnect case, should receive join response first
14883
- reject(new ConnectionError("did not receive join response, got ".concat((_d = resp.message) === null || _d === void 0 ? void 0 : _d.case, " instead")));
14884
14903
  }
14885
- if (!shouldProcessMessage) {
14886
- return;
14904
+ if (this.signalLatency) {
14905
+ yield sleep(this.signalLatency);
14887
14906
  }
14888
- }
14889
- if (this.signalLatency) {
14890
- yield sleep(this.signalLatency);
14891
- }
14892
- this.handleSignalResponse(resp);
14893
- });
14894
- this.ws.onclose = ev => {
14895
- livekitLogger.warn("websocket closed", {
14896
- ev
14907
+ this.handleSignalResponse(resp);
14897
14908
  });
14898
- this.handleOnClose(ev.reason);
14899
- };
14909
+ this.ws.onclose = ev => {
14910
+ livekitLogger.warn("websocket closed", {
14911
+ ev
14912
+ });
14913
+ this.handleOnClose(ev.reason);
14914
+ };
14915
+ } finally {
14916
+ unlock();
14917
+ }
14900
14918
  }));
14901
14919
  }
14902
14920
  close() {
14903
14921
  return __awaiter(this, void 0, void 0, function* () {
14904
14922
  const unlock = yield this.closingLock.lock();
14905
14923
  try {
14906
- this.isConnected = false;
14924
+ this.state = SignalConnectionState.DISCONNECTING;
14907
14925
  if (this.ws) {
14908
14926
  this.ws.onmessage = null;
14909
14927
  this.ws.onopen = null;
@@ -14926,6 +14944,7 @@ class SignalClient {
14926
14944
  this.ws = undefined;
14927
14945
  }
14928
14946
  } finally {
14947
+ this.state = SignalConnectionState.DISCONNECTED;
14929
14948
  this.clearPingInterval();
14930
14949
  unlock();
14931
14950
  }
@@ -15051,7 +15070,7 @@ class SignalClient {
15051
15070
  // capture all requests while reconnecting and put them in a queue
15052
15071
  // unless the request originates from the queue, then don't enqueue again
15053
15072
  const canQueue = !fromQueue && !canPassThroughQueue(message);
15054
- if (canQueue && this.isReconnecting) {
15073
+ if (canQueue && this.state === SignalConnectionState.RECONNECTING) {
15055
15074
  this.queuedRequests.push(() => __awaiter(this, void 0, void 0, function* () {
15056
15075
  yield this.sendRequest(message, true);
15057
15076
  }));
@@ -15177,11 +15196,10 @@ class SignalClient {
15177
15196
  this.requestQueue.run(req);
15178
15197
  }
15179
15198
  }
15180
- this.isReconnecting = false;
15181
15199
  }
15182
15200
  handleOnClose(reason) {
15183
15201
  return __awaiter(this, void 0, void 0, function* () {
15184
- if (!this.isConnected) return;
15202
+ if (this.state === SignalConnectionState.DISCONNECTED) return;
15185
15203
  const onCloseCallback = this.onClose;
15186
15204
  yield this.close();
15187
15205
  livekitLogger.debug("websocket connection closed: ".concat(reason));
@@ -15797,7 +15815,6 @@ var grammarExports = grammar$2.exports;
15797
15815
  });
15798
15816
  location = media[media.length - 1]; // point at latest media line
15799
15817
  }
15800
-
15801
15818
  for (var j = 0; j < (grammar[type] || []).length; j += 1) {
15802
15819
  var obj = grammar[type][j];
15803
15820
  if (obj.reg.test(content)) {
@@ -15875,7 +15892,6 @@ var format = function (formatStr) {
15875
15892
  if (i >= len) {
15876
15893
  return x; // missing argument
15877
15894
  }
15878
-
15879
15895
  var arg = args[i];
15880
15896
  i += 1;
15881
15897
  switch (x) {
@@ -15891,7 +15907,6 @@ var format = function (formatStr) {
15891
15907
  });
15892
15908
  // NB: we discard excess arguments - they are typically undefined from makeLine
15893
15909
  };
15894
-
15895
15910
  var makeLine = function (type, obj, location) {
15896
15911
  var str = obj.format instanceof Function ? obj.format(obj.push ? location : location[obj.name]) : obj.format;
15897
15912
  var args = [type + '=' + str];
@@ -15921,11 +15936,9 @@ var writer$1 = function (session, opts) {
15921
15936
  if (session.version == null) {
15922
15937
  session.version = 0; // 'v=0' must be there (only defined version atm)
15923
15938
  }
15924
-
15925
15939
  if (session.name == null) {
15926
15940
  session.name = ' '; // 's= ' must be there if no meaningful name set
15927
15941
  }
15928
-
15929
15942
  session.media.forEach(function (mLine) {
15930
15943
  if (mLine.payloads == null) {
15931
15944
  mLine.payloads = '';
@@ -16782,7 +16795,6 @@ class PCTransportManager {
16782
16795
  CriticalTimers.clearTimeout(connectTimeout);
16783
16796
  reject(new ConnectionError('room connection has been cancelled', 3 /* ConnectionErrorReason.Cancelled */));
16784
16797
  };
16785
-
16786
16798
  if (abortController === null || abortController === void 0 ? void 0 : abortController.signal.aborted) {
16787
16799
  abortHandler();
16788
16800
  }
@@ -16973,7 +16985,7 @@ class RTCEngine extends eventsExports.EventEmitter {
16973
16985
  };
16974
16986
  this.handleBrowserOnLine = () => {
16975
16987
  // in case the engine is currently reconnecting, attempt a reconnect immediately after the browser state has changed to 'onLine'
16976
- if (this.client.isReconnecting) {
16988
+ if (this.client.currentState === SignalConnectionState.RECONNECTING) {
16977
16989
  this.clearReconnectTimeout();
16978
16990
  this.attemptReconnect(ReconnectReason.RR_SIGNAL_DISCONNECTED);
16979
16991
  }
@@ -17504,7 +17516,7 @@ class RTCEngine extends eventsExports.EventEmitter {
17504
17516
  }
17505
17517
  livekitLogger.info("reconnecting, attempt: ".concat(this.reconnectAttempts));
17506
17518
  this.emit(EngineEvent.Restarting);
17507
- if (this.client.isConnected) {
17519
+ if (!this.client.isDisconnected) {
17508
17520
  yield this.client.sendLeave();
17509
17521
  }
17510
17522
  yield this.cleanupPeerConnections();
@@ -21074,7 +21086,9 @@ class LocalParticipant extends Participant {
21074
21086
  codec: defaultVideoCodec
21075
21087
  };
21076
21088
  }
21077
- if (opts.backupCodec && videoCodec !== opts.backupCodec.codec) {
21089
+ if (opts.backupCodec && videoCodec !== opts.backupCodec.codec &&
21090
+ // TODO remove this once e2ee is supported for backup codecs
21091
+ req.encryption === Encryption_Type.NONE) {
21078
21092
  // multi-codec simulcast requires dynacast
21079
21093
  if (!this.roomOptions.dynacast) {
21080
21094
  this.roomOptions.dynacast = true;
@@ -21182,6 +21196,10 @@ class LocalParticipant extends Participant {
21182
21196
  publishAdditionalCodecForTrack(track, videoCodec, options) {
21183
21197
  var _a;
21184
21198
  return __awaiter(this, void 0, void 0, function* () {
21199
+ // TODO remove once e2ee is supported for backup tracks
21200
+ if (this.encryptionType !== Encryption_Type.NONE) {
21201
+ return;
21202
+ }
21185
21203
  // is it not published? if so skip
21186
21204
  let existingPublication;
21187
21205
  this.tracks.forEach(publication => {
@@ -21395,7 +21413,7 @@ class LocalParticipant extends Participant {
21395
21413
  let participantTrackPermissions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
21396
21414
  this.participantTrackPermissions = participantTrackPermissions;
21397
21415
  this.allParticipantsAllowedToSubscribe = allParticipantsAllowed;
21398
- if (this.engine.client.isConnected) {
21416
+ if (!this.engine.client.isDisconnected) {
21399
21417
  this.updateTrackSubscriptionPermissions();
21400
21418
  }
21401
21419
  }
@@ -21707,7 +21725,7 @@ class Room extends eventsExports.EventEmitter {
21707
21725
  this.connectFuture = undefined;
21708
21726
  }
21709
21727
  // send leave
21710
- if ((_j = this.engine) === null || _j === void 0 ? void 0 : _j.client.isConnected) {
21728
+ if (!((_j = this.engine) === null || _j === void 0 ? void 0 : _j.client.isDisconnected)) {
21711
21729
  yield this.engine.client.sendLeave();
21712
21730
  }
21713
21731
  // close engine (also closes client)