livekit-client 2.15.5 → 2.15.6

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.
Files changed (40) hide show
  1. package/dist/livekit-client.e2ee.worker.js +1 -1
  2. package/dist/livekit-client.e2ee.worker.js.map +1 -1
  3. package/dist/livekit-client.e2ee.worker.mjs +54 -50
  4. package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
  5. package/dist/livekit-client.esm.mjs +62 -16
  6. package/dist/livekit-client.esm.mjs.map +1 -1
  7. package/dist/livekit-client.umd.js +1 -1
  8. package/dist/livekit-client.umd.js.map +1 -1
  9. package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
  10. package/dist/src/e2ee/worker/FrameCryptor.d.ts +0 -1
  11. package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
  12. package/dist/src/e2ee/worker/sifPayload.d.ts +22 -0
  13. package/dist/src/e2ee/worker/sifPayload.d.ts.map +1 -0
  14. package/dist/src/room/Room.d.ts.map +1 -1
  15. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  16. package/dist/src/room/track/RemoteVideoTrack.d.ts +1 -0
  17. package/dist/src/room/track/RemoteVideoTrack.d.ts.map +1 -1
  18. package/dist/src/room/track/Track.d.ts +4 -1
  19. package/dist/src/room/track/Track.d.ts.map +1 -1
  20. package/dist/src/room/utils.d.ts +8 -0
  21. package/dist/src/room/utils.d.ts.map +1 -1
  22. package/dist/ts4.2/src/e2ee/worker/FrameCryptor.d.ts +0 -1
  23. package/dist/ts4.2/src/e2ee/worker/sifPayload.d.ts +22 -0
  24. package/dist/ts4.2/src/room/track/RemoteVideoTrack.d.ts +1 -0
  25. package/dist/ts4.2/src/room/track/Track.d.ts +4 -1
  26. package/dist/ts4.2/src/room/utils.d.ts +8 -0
  27. package/package.json +7 -7
  28. package/src/e2ee/E2eeManager.ts +18 -1
  29. package/src/e2ee/worker/FrameCryptor.ts +8 -18
  30. package/src/e2ee/worker/e2ee.worker.ts +6 -1
  31. package/src/e2ee/worker/sifPayload.ts +75 -0
  32. package/src/room/Room.ts +11 -2
  33. package/src/room/track/LocalTrack.ts +5 -2
  34. package/src/room/track/RemoteVideoTrack.ts +12 -2
  35. package/src/room/track/Track.ts +10 -1
  36. package/src/room/utils.ts +12 -3
  37. package/dist/src/e2ee/worker/SifGuard.d.ts +0 -11
  38. package/dist/src/e2ee/worker/SifGuard.d.ts.map +0 -1
  39. package/dist/ts4.2/src/e2ee/worker/SifGuard.d.ts +0 -11
  40. package/src/e2ee/worker/SifGuard.ts +0 -47
@@ -38,6 +38,16 @@ export default class RemoteVideoTrack extends RemoteTrack<Track.Kind.Video> {
38
38
  return this.adaptiveStreamSettings !== undefined;
39
39
  }
40
40
 
41
+ override setStreamState(value: Track.StreamState) {
42
+ super.setStreamState(value);
43
+ console.log('setStreamState', value);
44
+ if (value === Track.StreamState.Active) {
45
+ // update visibility for adaptive stream tracks when stream state received from server is active
46
+ // this is needed to ensure the track is stopped when there's no element attached to it at all
47
+ this.updateVisibility();
48
+ }
49
+ }
50
+
41
51
  /**
42
52
  * Note: When using adaptiveStream, you need to use remoteVideoTrack.attach() to add the track to a HTMLVideoElement, otherwise your video tracks might never start
43
53
  */
@@ -220,7 +230,7 @@ export default class RemoteVideoTrack extends RemoteTrack<Track.Kind.Video> {
220
230
  this.updateDimensions();
221
231
  }, REACTION_DELAY);
222
232
 
223
- private updateVisibility() {
233
+ private updateVisibility(forceEmit?: boolean) {
224
234
  const lastVisibilityChange = this.elementInfos.reduce(
225
235
  (prev, info) => Math.max(prev, info.visibilityChangedAt || 0),
226
236
  0,
@@ -234,7 +244,7 @@ export default class RemoteVideoTrack extends RemoteTrack<Track.Kind.Video> {
234
244
  const isVisible =
235
245
  (this.elementInfos.some((info) => info.visible) && !backgroundPause) || isPiPMode;
236
246
 
237
- if (this.lastVisible === isVisible) {
247
+ if (this.lastVisible === isVisible && !forceEmit) {
238
248
  return;
239
249
  }
240
250
 
@@ -37,6 +37,8 @@ export abstract class Track<
37
37
 
38
38
  source: Track.Source;
39
39
 
40
+ private _streamState: Track.StreamState = Track.StreamState.Active;
41
+
40
42
  /**
41
43
  * sid is set after track is published to server, or if it's a remote track
42
44
  */
@@ -51,7 +53,14 @@ export abstract class Track<
51
53
  * indicates current state of stream, it'll indicate `paused` if the track
52
54
  * has been paused by congestion controller
53
55
  */
54
- streamState: Track.StreamState = Track.StreamState.Active;
56
+ get streamState(): Track.StreamState {
57
+ return this._streamState;
58
+ }
59
+
60
+ /** @internal */
61
+ setStreamState(value: Track.StreamState) {
62
+ this._streamState = value;
63
+ }
55
64
 
56
65
  /** @internal */
57
66
  rtpTimestamp: number | undefined;
package/src/room/utils.ts CHANGED
@@ -64,8 +64,9 @@ export function supportsAV1(): boolean {
64
64
  if (!('getCapabilities' in RTCRtpSender)) {
65
65
  return false;
66
66
  }
67
- if (isSafari()) {
67
+ if (isSafari() || isFireFox()) {
68
68
  // Safari 17 on iPhone14 reports AV1 capability, but does not actually support it
69
+ // Firefox does support AV1, but SVC publishing is not supported
69
70
  return false;
70
71
  }
71
72
  const capabilities = RTCRtpSender.getCapabilities('video');
@@ -214,12 +215,12 @@ export function isE2EESimulcastSupported() {
214
215
  } else if (
215
216
  browser.os === 'iOS' &&
216
217
  browser.osVersion &&
217
- compareVersions(supportedSafariVersion, browser.osVersion) >= 0
218
+ compareVersions(browser.osVersion, supportedSafariVersion) >= 0
218
219
  ) {
219
220
  return true;
220
221
  } else if (
221
222
  browser.name === 'Safari' &&
222
- compareVersions(supportedSafariVersion, browser.version) >= 0
223
+ compareVersions(browser.version, supportedSafariVersion) >= 0
223
224
  ) {
224
225
  return true;
225
226
  } else {
@@ -282,6 +283,14 @@ export function getDevicePixelRatio(): number {
282
283
  return 1;
283
284
  }
284
285
 
286
+ /**
287
+ * @param v1 - The first version string to compare.
288
+ * @param v2 - The second version string to compare.
289
+ * @returns A number indicating the order of the versions:
290
+ * - 1 if v1 is greater than v2
291
+ * - -1 if v1 is less than v2
292
+ * - 0 if v1 and v2 are equal
293
+ */
285
294
  export function compareVersions(v1: string, v2: string): number {
286
295
  const parts1 = v1.split('.');
287
296
  const parts2 = v2.split('.');
@@ -1,11 +0,0 @@
1
- export declare class SifGuard {
2
- private consecutiveSifCount;
3
- private sifSequenceStartedAt;
4
- private lastSifReceivedAt;
5
- private userFramesSinceSif;
6
- recordSif(): void;
7
- recordUserFrame(): void;
8
- isSifAllowed(): boolean;
9
- reset(): void;
10
- }
11
- //# sourceMappingURL=SifGuard.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"SifGuard.d.ts","sourceRoot":"","sources":["../../../../src/e2ee/worker/SifGuard.ts"],"names":[],"mappings":"AAEA,qBAAa,QAAQ;IACnB,OAAO,CAAC,mBAAmB,CAAK;IAEhC,OAAO,CAAC,oBAAoB,CAAqB;IAEjD,OAAO,CAAC,iBAAiB,CAAa;IAEtC,OAAO,CAAC,kBAAkB,CAAa;IAEvC,SAAS;IAMT,eAAe;IAgBf,YAAY;IAQZ,KAAK;CAKN"}
@@ -1,11 +0,0 @@
1
- export declare class SifGuard {
2
- private consecutiveSifCount;
3
- private sifSequenceStartedAt;
4
- private lastSifReceivedAt;
5
- private userFramesSinceSif;
6
- recordSif(): void;
7
- recordUserFrame(): void;
8
- isSifAllowed(): boolean;
9
- reset(): void;
10
- }
11
- //# sourceMappingURL=SifGuard.d.ts.map
@@ -1,47 +0,0 @@
1
- import { MAX_SIF_COUNT, MAX_SIF_DURATION } from '../constants';
2
-
3
- export class SifGuard {
4
- private consecutiveSifCount = 0;
5
-
6
- private sifSequenceStartedAt: number | undefined;
7
-
8
- private lastSifReceivedAt: number = 0;
9
-
10
- private userFramesSinceSif: number = 0;
11
-
12
- recordSif() {
13
- this.consecutiveSifCount += 1;
14
- this.sifSequenceStartedAt ??= Date.now();
15
- this.lastSifReceivedAt = Date.now();
16
- }
17
-
18
- recordUserFrame() {
19
- if (this.sifSequenceStartedAt === undefined) {
20
- return;
21
- } else {
22
- this.userFramesSinceSif += 1;
23
- }
24
- if (
25
- // reset if we received more user frames than SIFs
26
- this.userFramesSinceSif > this.consecutiveSifCount ||
27
- // also reset if we got a new user frame and the latest SIF frame hasn't been updated in a while
28
- Date.now() - this.lastSifReceivedAt > MAX_SIF_DURATION
29
- ) {
30
- this.reset();
31
- }
32
- }
33
-
34
- isSifAllowed() {
35
- return (
36
- this.consecutiveSifCount < MAX_SIF_COUNT &&
37
- (this.sifSequenceStartedAt === undefined ||
38
- Date.now() - this.sifSequenceStartedAt < MAX_SIF_DURATION)
39
- );
40
- }
41
-
42
- reset() {
43
- this.userFramesSinceSif = 0;
44
- this.consecutiveSifCount = 0;
45
- this.sifSequenceStartedAt = undefined;
46
- }
47
- }