livekit-client 1.9.6 → 1.10.0

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 (67) hide show
  1. package/dist/livekit-client.esm.mjs +1318 -885
  2. package/dist/livekit-client.esm.mjs.map +1 -1
  3. package/dist/livekit-client.umd.js +1 -1
  4. package/dist/livekit-client.umd.js.map +1 -1
  5. package/dist/src/api/SignalClient.d.ts +2 -1
  6. package/dist/src/api/SignalClient.d.ts.map +1 -1
  7. package/dist/src/index.d.ts +1 -0
  8. package/dist/src/index.d.ts.map +1 -1
  9. package/dist/src/proto/livekit_models.d.ts +108 -10
  10. package/dist/src/proto/livekit_models.d.ts.map +1 -1
  11. package/dist/src/proto/livekit_rtc.d.ts +513 -194
  12. package/dist/src/proto/livekit_rtc.d.ts.map +1 -1
  13. package/dist/src/room/Room.d.ts +3 -2
  14. package/dist/src/room/Room.d.ts.map +1 -1
  15. package/dist/src/room/events.d.ts +5 -1
  16. package/dist/src/room/events.d.ts.map +1 -1
  17. package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
  18. package/dist/src/room/participant/Participant.d.ts +2 -2
  19. package/dist/src/room/participant/Participant.d.ts.map +1 -1
  20. package/dist/src/room/participant/RemoteParticipant.d.ts.map +1 -1
  21. package/dist/src/room/participant/publishUtils.d.ts +8 -0
  22. package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
  23. package/dist/src/room/track/LocalTrack.d.ts +32 -0
  24. package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
  25. package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
  26. package/dist/src/room/track/RemoteTrackPublication.d.ts +4 -1
  27. package/dist/src/room/track/RemoteTrackPublication.d.ts.map +1 -1
  28. package/dist/src/room/track/TrackPublication.d.ts +2 -1
  29. package/dist/src/room/track/TrackPublication.d.ts.map +1 -1
  30. package/dist/src/room/track/options.d.ts +1 -1
  31. package/dist/src/room/track/options.d.ts.map +1 -1
  32. package/dist/src/room/track/processor/types.d.ts +19 -0
  33. package/dist/src/room/track/processor/types.d.ts.map +1 -0
  34. package/dist/src/utils/browserParser.d.ts.map +1 -1
  35. package/dist/ts4.2/src/api/SignalClient.d.ts +2 -1
  36. package/dist/ts4.2/src/index.d.ts +1 -0
  37. package/dist/ts4.2/src/proto/livekit_models.d.ts +126 -12
  38. package/dist/ts4.2/src/proto/livekit_rtc.d.ts +617 -254
  39. package/dist/ts4.2/src/room/Room.d.ts +3 -2
  40. package/dist/ts4.2/src/room/events.d.ts +5 -1
  41. package/dist/ts4.2/src/room/participant/Participant.d.ts +2 -2
  42. package/dist/ts4.2/src/room/participant/publishUtils.d.ts +8 -0
  43. package/dist/ts4.2/src/room/track/LocalTrack.d.ts +32 -0
  44. package/dist/ts4.2/src/room/track/RemoteTrackPublication.d.ts +4 -1
  45. package/dist/ts4.2/src/room/track/TrackPublication.d.ts +2 -1
  46. package/dist/ts4.2/src/room/track/options.d.ts +1 -1
  47. package/dist/ts4.2/src/room/track/processor/types.d.ts +19 -0
  48. package/package.json +14 -13
  49. package/src/api/SignalClient.ts +8 -1
  50. package/src/index.ts +1 -0
  51. package/src/proto/google/protobuf/timestamp.ts +3 -3
  52. package/src/proto/livekit_models.ts +254 -161
  53. package/src/proto/livekit_rtc.ts +334 -180
  54. package/src/room/Room.ts +26 -1
  55. package/src/room/events.ts +4 -0
  56. package/src/room/participant/LocalParticipant.ts +23 -3
  57. package/src/room/participant/Participant.ts +2 -1
  58. package/src/room/participant/RemoteParticipant.ts +4 -1
  59. package/src/room/participant/publishUtils.ts +68 -12
  60. package/src/room/track/LocalTrack.ts +120 -16
  61. package/src/room/track/LocalVideoTrack.ts +96 -33
  62. package/src/room/track/RemoteTrackPublication.ts +8 -1
  63. package/src/room/track/Track.ts +3 -3
  64. package/src/room/track/TrackPublication.ts +2 -1
  65. package/src/room/track/options.ts +1 -1
  66. package/src/room/track/processor/types.ts +20 -0
  67. package/src/utils/browserParser.ts +1 -4
@@ -1,7 +1,7 @@
1
1
  import type TypedEmitter from 'typed-emitter';
2
2
  import 'webrtc-adapter';
3
3
  import type { InternalRoomOptions, RoomConnectOptions, RoomOptions } from '../options';
4
- import { DataPacket_Kind, DisconnectReason, ParticipantPermission } from '../proto/livekit_models';
4
+ import { DataPacket_Kind, DisconnectReason, ParticipantPermission, SubscriptionError } from '../proto/livekit_models';
5
5
  import RTCEngine from './RTCEngine';
6
6
  import LocalParticipant from './participant/LocalParticipant';
7
7
  import type Participant from './participant/Participant';
@@ -157,6 +157,7 @@ declare class Room extends Room_base {
157
157
  private handleSpeakersChanged;
158
158
  private handleStreamStateUpdate;
159
159
  private handleSubscriptionPermissionUpdate;
160
+ private handleSubscriptionError;
160
161
  private handleDataPacket;
161
162
  private handleAudioPlaybackStarted;
162
163
  private handleAudioPlaybackFailed;
@@ -207,7 +208,7 @@ export type RoomEventCallbacks = {
207
208
  participantDisconnected: (participant: RemoteParticipant) => void;
208
209
  trackPublished: (publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
209
210
  trackSubscribed: (track: RemoteTrack, publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
210
- trackSubscriptionFailed: (trackSid: string, participant: RemoteParticipant) => void;
211
+ trackSubscriptionFailed: (trackSid: string, participant: RemoteParticipant, reason?: SubscriptionError) => void;
211
212
  trackUnpublished: (publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
212
213
  trackUnsubscribed: (track: RemoteTrack, publication: RemoteTrackPublication, participant: RemoteParticipant) => void;
213
214
  trackMuted: (publication: TrackPublication, participant: Participant) => void;
@@ -451,6 +451,10 @@ export declare enum TrackEvent {
451
451
  /**
452
452
  * Fires on RemoteTrackPublication
453
453
  */
454
- SubscriptionStatusChanged = "subscriptionStatusChanged"
454
+ SubscriptionStatusChanged = "subscriptionStatusChanged",
455
+ /**
456
+ * Fires on RemoteTrackPublication
457
+ */
458
+ SubscriptionFailed = "subscriptionFailed"
455
459
  }
456
460
  //# sourceMappingURL=events.d.ts.map
@@ -1,5 +1,5 @@
1
1
  import type TypedEmitter from 'typed-emitter';
2
- import { DataPacket_Kind, ParticipantInfo, ParticipantPermission, ConnectionQuality as ProtoQuality } from '../../proto/livekit_models';
2
+ import { DataPacket_Kind, ParticipantInfo, ParticipantPermission, ConnectionQuality as ProtoQuality, SubscriptionError } from '../../proto/livekit_models';
3
3
  import type LocalTrackPublication from '../track/LocalTrackPublication';
4
4
  import type RemoteTrack from '../track/RemoteTrack';
5
5
  import type RemoteTrackPublication from '../track/RemoteTrackPublication';
@@ -72,7 +72,7 @@ export default class Participant extends Participant_base {
72
72
  export type ParticipantEventCallbacks = {
73
73
  trackPublished: (publication: RemoteTrackPublication) => void;
74
74
  trackSubscribed: (track: RemoteTrack, publication: RemoteTrackPublication) => void;
75
- trackSubscriptionFailed: (trackSid: string) => void;
75
+ trackSubscriptionFailed: (trackSid: string, reason?: SubscriptionError) => void;
76
76
  trackUnpublished: (publication: RemoteTrackPublication) => void;
77
77
  trackUnsubscribed: (track: RemoteTrack, publication: RemoteTrackPublication) => void;
78
78
  trackMuted: (publication: TrackPublication) => void;
@@ -17,4 +17,12 @@ export declare function presetsForResolution(isScreenShare: boolean, width: numb
17
17
  export declare function defaultSimulcastLayers(isScreenShare: boolean, original: VideoPreset): VideoPreset[];
18
18
  /** @internal */
19
19
  export declare function sortPresets(presets: Array<VideoPreset> | undefined): VideoPreset[] | undefined;
20
+ /** @internal */
21
+ export declare class ScalabilityMode {
22
+ spatial: number;
23
+ temporal: number;
24
+ suffix: undefined | 'h' | '_KEY' | '_KEY_SHIFT';
25
+ constructor(scalabilityMode: string);
26
+ toString(): string;
27
+ }
20
28
  //# sourceMappingURL=publishUtils.d.ts.map
@@ -1,6 +1,7 @@
1
1
  import { Mutex } from '../utils';
2
2
  import { Track } from './Track';
3
3
  import type { VideoCodec } from './options';
4
+ import type { TrackProcessor } from './processor/types';
4
5
  export default abstract class LocalTrack extends Track {
5
6
  /** @internal */
6
7
  sender?: RTCRtpSender;
@@ -11,6 +12,9 @@ export default abstract class LocalTrack extends Track {
11
12
  protected providedByUser: boolean;
12
13
  protected muteLock: Mutex;
13
14
  protected pauseUpstreamLock: Mutex;
15
+ protected processorElement?: HTMLMediaElement;
16
+ protected processor?: TrackProcessor<typeof this.kind>;
17
+ protected isSettingUpProcessor: boolean;
14
18
  /**
15
19
  *
16
20
  * @param mediaTrack
@@ -24,6 +28,7 @@ export default abstract class LocalTrack extends Track {
24
28
  private _isUpstreamPaused;
25
29
  get isUpstreamPaused(): boolean;
26
30
  get isUserProvided(): boolean;
31
+ get mediaStreamTrack(): MediaStreamTrack;
27
32
  waitForDimensions(timeout?: number): Promise<Track.Dimensions>;
28
33
  /**
29
34
  * @returns DeviceID of the device that is currently being used for this track
@@ -37,8 +42,35 @@ export default abstract class LocalTrack extends Track {
37
42
  protected get needsReAcquisition(): boolean;
38
43
  protected handleAppVisibilityChanged(): Promise<void>;
39
44
  private handleEnded;
45
+ stop(): void;
46
+ /**
47
+ * pauses publishing to the server without disabling the local MediaStreamTrack
48
+ * this is used to display a user's own video locally while pausing publishing to
49
+ * the server.
50
+ * this API is unsupported on Safari < 12 due to a bug
51
+ **/
40
52
  pauseUpstream(): Promise<void>;
41
53
  resumeUpstream(): Promise<void>;
54
+ /**
55
+ * Sets a processor on this track.
56
+ * See https://github.com/livekit/track-processors-js for example usage
57
+ *
58
+ * @experimental
59
+ *
60
+ * @param processor
61
+ * @param showProcessedStreamLocally
62
+ * @returns
63
+ */
64
+ setProcessor(processor: TrackProcessor<typeof this.kind>, showProcessedStreamLocally?: boolean): Promise<void>;
65
+ getProcessor(): TrackProcessor<Track.Kind> | undefined;
66
+ /**
67
+ * Stops the track processor
68
+ * See https://github.com/livekit/track-processors-js for example usage
69
+ *
70
+ * @experimental
71
+ * @returns
72
+ */
73
+ stopProcessor(): Promise<void>;
42
74
  protected abstract monitorSender(): void;
43
75
  }
44
76
  //# sourceMappingURL=LocalTrack.d.ts.map
@@ -1,4 +1,4 @@
1
- import { TrackInfo, VideoQuality } from '../../proto/livekit_models';
1
+ import { SubscriptionError, TrackInfo, VideoQuality } from '../../proto/livekit_models';
2
2
  import type RemoteTrack from './RemoteTrack';
3
3
  import { Track } from './Track';
4
4
  import { TrackPublication } from './TrackPublication';
@@ -11,6 +11,7 @@ export default class RemoteTrackPublication extends TrackPublication {
11
11
  protected currentVideoQuality?: VideoQuality;
12
12
  protected videoDimensions?: Track.Dimensions;
13
13
  protected fps?: number;
14
+ protected subscriptionError?: SubscriptionError;
14
15
  constructor(kind: Track.Kind, ti: TrackInfo, autoSubscribe: boolean | undefined);
15
16
  /**
16
17
  * Subscribe or unsubscribe to this remote track
@@ -48,6 +49,8 @@ export default class RemoteTrackPublication extends TrackPublication {
48
49
  /** @internal */
49
50
  setAllowed(allowed: boolean): void;
50
51
  /** @internal */
52
+ setSubscriptionError(error: SubscriptionError): void;
53
+ /** @internal */
51
54
  updateInfo(info: TrackInfo): void;
52
55
  private emitSubscriptionUpdateIfChanged;
53
56
  private emitPermissionUpdateIfChanged;
@@ -1,5 +1,5 @@
1
1
  import type TypedEventEmitter from 'typed-emitter';
2
- import type { TrackInfo } from '../../proto/livekit_models';
2
+ import type { SubscriptionError, TrackInfo } from '../../proto/livekit_models';
3
3
  import type { UpdateSubscription, UpdateTrackSettings } from '../../proto/livekit_rtc';
4
4
  import LocalAudioTrack from './LocalAudioTrack';
5
5
  import LocalVideoTrack from './LocalVideoTrack';
@@ -63,6 +63,7 @@ export type PublicationEventCallbacks = {
63
63
  subscribed: (track: RemoteTrack) => void;
64
64
  unsubscribed: (track: RemoteTrack) => void;
65
65
  subscriptionStatusChanged: (status: TrackPublication.SubscriptionStatus, prevStatus: TrackPublication.SubscriptionStatus) => void;
66
+ subscriptionFailed: (error: SubscriptionError) => void;
66
67
  };
67
68
  export {};
68
69
  //# sourceMappingURL=TrackPublication.d.ts.map
@@ -216,7 +216,7 @@ export declare function isCodecEqual(c1: string | undefined, c2: string | undefi
216
216
  /**
217
217
  * scalability modes for svc, only supprot l3t3 now.
218
218
  */
219
- export type ScalabilityMode = 'L3T3';
219
+ export type ScalabilityMode = 'L3T3' | 'L3T3_KEY';
220
220
  export declare namespace AudioPresets {
221
221
  const telephone: AudioPreset;
222
222
  const speech: AudioPreset;
@@ -0,0 +1,19 @@
1
+ import type { Track } from '../Track';
2
+ /**
3
+ * @experimental
4
+ */
5
+ export type ProcessorOptions<T extends Track.Kind> = {
6
+ kind: T;
7
+ track: MediaStreamTrack;
8
+ element?: HTMLMediaElement;
9
+ };
10
+ /**
11
+ * @experimental
12
+ */
13
+ export interface TrackProcessor<T extends Track.Kind> {
14
+ name: string;
15
+ init: (opts: ProcessorOptions<T>) => void;
16
+ destroy: () => Promise<void>;
17
+ processedTrack?: MediaStreamTrack;
18
+ }
19
+ //# sourceMappingURL=types.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "livekit-client",
3
- "version": "1.9.6",
3
+ "version": "1.10.0",
4
4
  "description": "JavaScript/TypeScript client SDK for LiveKit",
5
5
  "main": "./dist/livekit-client.umd.js",
6
6
  "unpkg": "./dist/livekit-client.umd.js",
@@ -51,43 +51,44 @@
51
51
  "webrtc-adapter": "^8.1.1"
52
52
  },
53
53
  "devDependencies": {
54
- "@babel/core": "7.21.8",
55
- "@babel/preset-env": "7.21.5",
54
+ "@babel/core": "7.22.1",
55
+ "@babel/preset-env": "7.22.4",
56
56
  "@changesets/cli": "2.26.1",
57
57
  "@livekit/changesets-changelog-github": "^0.0.4",
58
58
  "@rollup/plugin-babel": "6.0.3",
59
59
  "@rollup/plugin-commonjs": "24.1.0",
60
60
  "@rollup/plugin-json": "6.0.0",
61
- "@rollup/plugin-node-resolve": "15.0.2",
61
+ "@rollup/plugin-node-resolve": "15.1.0",
62
62
  "@rollup/plugin-terser": "^0.4.0",
63
63
  "@size-limit/file": "^8.2.4",
64
64
  "@size-limit/webpack": "^8.2.4",
65
65
  "@trivago/prettier-plugin-sort-imports": "^4.1.1",
66
66
  "@types/events": "^3.0.0",
67
- "@types/jest": "29.5.1",
67
+ "@types/jest": "29.5.2",
68
68
  "@types/sdp-transform": "2.4.6",
69
69
  "@types/ua-parser-js": "0.7.36",
70
- "@typescript-eslint/eslint-plugin": "5.59.2",
71
- "@typescript-eslint/parser": "5.59.2",
70
+ "@typescript-eslint/eslint-plugin": "5.59.8",
71
+ "@typescript-eslint/parser": "5.59.8",
72
72
  "downlevel-dts": "^0.11.0",
73
- "eslint": "8.39.0",
73
+ "eslint": "8.42.0",
74
74
  "eslint-config-airbnb-typescript": "17.0.0",
75
75
  "eslint-config-prettier": "8.8.0",
76
76
  "eslint-plugin-ecmascript-compat": "^3.0.0",
77
77
  "eslint-plugin-import": "2.27.5",
78
78
  "gh-pages": "5.0.0",
79
79
  "jest": "29.5.0",
80
+ "jest-environment-jsdom": "^29.5.0",
80
81
  "prettier": "^2.8.8",
81
- "rollup": "3.21.3",
82
+ "rollup": "3.23.1",
82
83
  "rollup-plugin-delete": "^2.0.0",
83
84
  "rollup-plugin-re": "1.0.7",
84
85
  "rollup-plugin-typescript2": "0.34.1",
85
86
  "size-limit": "^8.2.4",
86
87
  "ts-jest": "29.1.0",
87
- "ts-proto": "1.147.1",
88
- "typedoc": "0.24.6",
88
+ "ts-proto": "1.148.2",
89
+ "typedoc": "0.24.8",
89
90
  "typedoc-plugin-no-inherit": "1.4.0",
90
- "typescript": "5.0.4",
91
- "vite": "4.3.4"
91
+ "typescript": "5.1.3",
92
+ "vite": "4.3.9"
92
93
  }
93
94
  }
@@ -22,6 +22,7 @@ import {
22
22
  StreamStateUpdate,
23
23
  SubscribedQualityUpdate,
24
24
  SubscriptionPermissionUpdate,
25
+ SubscriptionResponse,
25
26
  SyncState,
26
27
  TrackPermission,
27
28
  TrackPublishedResponse,
@@ -127,6 +128,8 @@ export class SignalClient {
127
128
 
128
129
  onSubscriptionPermissionUpdate?: (update: SubscriptionPermissionUpdate) => void;
129
130
 
131
+ onSubscriptionError?: (update: SubscriptionResponse) => void;
132
+
130
133
  onLocalTrackUnpublished?: (res: TrackUnpublishedResponse) => void;
131
134
 
132
135
  onTokenRefresh?: (token: string) => void;
@@ -214,7 +217,7 @@ export class SignalClient {
214
217
 
215
218
  return new Promise<JoinResponse | ReconnectResponse | void>(async (resolve, reject) => {
216
219
  const abortHandler = async () => {
217
- await this.close();
220
+ this.close();
218
221
  reject(new ConnectionError('room connection has been cancelled (signal)'));
219
222
  };
220
223
 
@@ -593,6 +596,10 @@ export class SignalClient {
593
596
  if (this.onLocalTrackUnpublished) {
594
597
  this.onLocalTrackUnpublished(msg.trackUnpublished);
595
598
  }
599
+ } else if (msg.$case === 'subscriptionResponse') {
600
+ if (this.onSubscriptionError) {
601
+ this.onSubscriptionError(msg.subscriptionResponse);
602
+ }
596
603
  } else if (msg.$case === 'pong') {
597
604
  this.resetPingTimeout();
598
605
  } else if (msg.$case === 'pongResp') {
package/src/index.ts CHANGED
@@ -40,6 +40,7 @@ export * from './room/track/options';
40
40
  export * from './room/track/types';
41
41
  export type { DataPublishOptions, SimulationScenario } from './room/types';
42
42
  export * from './version';
43
+ export * from './room/track/processor/types';
43
44
  export {
44
45
  setLogLevel,
45
46
  setLogExtension,
@@ -134,21 +134,21 @@ export const Timestamp = {
134
134
  const tag = reader.uint32();
135
135
  switch (tag >>> 3) {
136
136
  case 1:
137
- if (tag != 8) {
137
+ if (tag !== 8) {
138
138
  break;
139
139
  }
140
140
 
141
141
  message.seconds = longToNumber(reader.int64() as Long);
142
142
  continue;
143
143
  case 2:
144
- if (tag != 16) {
144
+ if (tag !== 16) {
145
145
  break;
146
146
  }
147
147
 
148
148
  message.nanos = reader.int32();
149
149
  continue;
150
150
  }
151
- if ((tag & 7) == 4 || tag == 0) {
151
+ if ((tag & 7) === 4 || tag === 0) {
152
152
  break;
153
153
  }
154
154
  reader.skipType(tag & 7);