@livekit/rtc-node 0.13.13 → 0.13.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.
Files changed (129) hide show
  1. package/README.md +3 -0
  2. package/dist/audio_stream.cjs +3 -2
  3. package/dist/audio_stream.cjs.map +1 -1
  4. package/dist/audio_stream.d.cts +10 -2
  5. package/dist/audio_stream.d.ts +10 -2
  6. package/dist/audio_stream.d.ts.map +1 -1
  7. package/dist/audio_stream.js +2 -1
  8. package/dist/audio_stream.js.map +1 -1
  9. package/dist/data_streams/index.d.cts +2 -2
  10. package/dist/data_streams/index.d.ts +2 -2
  11. package/dist/data_streams/stream_reader.cjs.map +1 -1
  12. package/dist/data_streams/stream_reader.d.cts +2 -2
  13. package/dist/data_streams/stream_reader.d.ts +2 -2
  14. package/dist/data_streams/stream_reader.d.ts.map +1 -1
  15. package/dist/data_streams/stream_reader.js.map +1 -1
  16. package/dist/data_streams/stream_writer.cjs.map +1 -1
  17. package/dist/data_streams/stream_writer.d.cts +2 -2
  18. package/dist/data_streams/stream_writer.d.ts +2 -2
  19. package/dist/data_streams/stream_writer.d.ts.map +1 -1
  20. package/dist/data_streams/stream_writer.js.map +1 -1
  21. package/dist/data_streams/types.d.cts +2 -2
  22. package/dist/data_streams/types.d.ts +2 -2
  23. package/dist/ffi_client.cjs +4 -2
  24. package/dist/ffi_client.cjs.map +1 -1
  25. package/dist/ffi_client.d.cts +4 -1
  26. package/dist/ffi_client.d.ts +4 -1
  27. package/dist/ffi_client.d.ts.map +1 -1
  28. package/dist/ffi_client.js +4 -2
  29. package/dist/ffi_client.js.map +1 -1
  30. package/dist/index.d.cts +11 -8
  31. package/dist/index.d.ts +11 -8
  32. package/dist/participant.cjs +13 -15
  33. package/dist/participant.cjs.map +1 -1
  34. package/dist/participant.d.cts +8 -4
  35. package/dist/participant.d.ts +8 -4
  36. package/dist/participant.d.ts.map +1 -1
  37. package/dist/participant.js +5 -7
  38. package/dist/participant.js.map +1 -1
  39. package/dist/proto/audio_frame_pb.cjs +4 -2
  40. package/dist/proto/audio_frame_pb.cjs.map +1 -1
  41. package/dist/proto/audio_frame_pb.d.cts +8 -0
  42. package/dist/proto/audio_frame_pb.d.ts +8 -0
  43. package/dist/proto/audio_frame_pb.d.ts.map +1 -1
  44. package/dist/proto/audio_frame_pb.js +4 -2
  45. package/dist/proto/audio_frame_pb.js.map +1 -1
  46. package/dist/proto/data_stream_pb.cjs +1549 -0
  47. package/dist/proto/data_stream_pb.cjs.map +1 -0
  48. package/dist/proto/data_stream_pb.d.cts +1358 -0
  49. package/dist/proto/data_stream_pb.d.ts +1358 -0
  50. package/dist/proto/data_stream_pb.d.ts.map +1 -0
  51. package/dist/proto/data_stream_pb.js +1473 -0
  52. package/dist/proto/data_stream_pb.js.map +1 -0
  53. package/dist/proto/ffi_pb.cjs +43 -3
  54. package/dist/proto/ffi_pb.cjs.map +1 -1
  55. package/dist/proto/ffi_pb.d.cts +251 -8
  56. package/dist/proto/ffi_pb.d.ts +251 -8
  57. package/dist/proto/ffi_pb.d.ts.map +1 -1
  58. package/dist/proto/ffi_pb.js +43 -3
  59. package/dist/proto/ffi_pb.js.map +1 -1
  60. package/dist/proto/participant_pb.cjs +5 -1
  61. package/dist/proto/participant_pb.cjs.map +1 -1
  62. package/dist/proto/participant_pb.d.cts +9 -1
  63. package/dist/proto/participant_pb.d.ts +9 -1
  64. package/dist/proto/participant_pb.d.ts.map +1 -1
  65. package/dist/proto/participant_pb.js +5 -1
  66. package/dist/proto/participant_pb.js.map +1 -1
  67. package/dist/proto/room_pb.cjs +99 -2
  68. package/dist/proto/room_pb.cjs.map +1 -1
  69. package/dist/proto/room_pb.d.cts +130 -2
  70. package/dist/proto/room_pb.d.ts +130 -2
  71. package/dist/proto/room_pb.d.ts.map +1 -1
  72. package/dist/proto/room_pb.js +97 -3
  73. package/dist/proto/room_pb.js.map +1 -1
  74. package/dist/proto/track_pb.cjs +27 -1
  75. package/dist/proto/track_pb.cjs.map +1 -1
  76. package/dist/proto/track_pb.d.cts +40 -1
  77. package/dist/proto/track_pb.d.ts +40 -1
  78. package/dist/proto/track_pb.d.ts.map +1 -1
  79. package/dist/proto/track_pb.js +26 -1
  80. package/dist/proto/track_pb.js.map +1 -1
  81. package/dist/room.cjs +79 -3
  82. package/dist/room.cjs.map +1 -1
  83. package/dist/room.d.cts +59 -8
  84. package/dist/room.d.ts +59 -8
  85. package/dist/room.d.ts.map +1 -1
  86. package/dist/room.js +77 -1
  87. package/dist/room.js.map +1 -1
  88. package/dist/{stream_reader-a8_oiaOi.d.cts → stream_reader-Ch2zvjU3.d.cts} +0 -1
  89. package/dist/{stream_reader-DWUV4eJB.d.ts → stream_reader-DRyR29vo.d.ts} +0 -1
  90. package/dist/track.cjs +23 -4
  91. package/dist/track.cjs.map +1 -1
  92. package/dist/track.d.cts +17 -4
  93. package/dist/track.d.ts +17 -4
  94. package/dist/track.d.ts.map +1 -1
  95. package/dist/track.js +23 -4
  96. package/dist/track.js.map +1 -1
  97. package/dist/track_publication.d.cts +9 -1
  98. package/dist/track_publication.d.ts +9 -1
  99. package/dist/version.cjs +1 -1
  100. package/dist/version.cjs.map +1 -1
  101. package/dist/version.d.cts +1 -1
  102. package/dist/version.d.ts +1 -1
  103. package/dist/version.js +1 -1
  104. package/dist/version.js.map +1 -1
  105. package/dist/video_source.d.cts +11 -2
  106. package/dist/video_source.d.ts +11 -2
  107. package/dist/video_stream.cjs +1 -2
  108. package/dist/video_stream.cjs.map +1 -1
  109. package/dist/video_stream.d.cts +8 -1
  110. package/dist/video_stream.d.ts +8 -1
  111. package/dist/video_stream.d.ts.map +1 -1
  112. package/dist/video_stream.js +0 -1
  113. package/dist/video_stream.js.map +1 -1
  114. package/package.json +7 -7
  115. package/src/audio_stream.ts +5 -1
  116. package/src/data_streams/stream_reader.ts +0 -1
  117. package/src/data_streams/stream_writer.ts +0 -1
  118. package/src/ffi_client.ts +9 -5
  119. package/src/participant.ts +13 -15
  120. package/src/proto/audio_frame_pb.ts +12 -0
  121. package/src/proto/data_stream_pb.ts +2515 -0
  122. package/src/proto/ffi_pb.ts +283 -1
  123. package/src/proto/participant_pb.ts +12 -0
  124. package/src/proto/room_pb.ts +212 -1
  125. package/src/proto/track_pb.ts +58 -0
  126. package/src/room.ts +79 -1
  127. package/src/track.ts +28 -4
  128. package/src/version.ts +1 -1
  129. package/src/video_stream.ts +1 -1
package/dist/track.cjs CHANGED
@@ -52,10 +52,14 @@ class Track {
52
52
  var _a;
53
53
  return (_a = this.info) == null ? void 0 : _a.muted;
54
54
  }
55
+ async close() {
56
+ this.ffi_handle.dispose();
57
+ }
55
58
  }
56
59
  class LocalAudioTrack extends Track {
57
- constructor(owned) {
60
+ constructor(owned, source) {
58
61
  super(owned);
62
+ this.source = source;
59
63
  }
60
64
  static createAudioTrack(name, source) {
61
65
  const req = new import_track_pb.CreateAudioTrackRequest({
@@ -65,12 +69,20 @@ class LocalAudioTrack extends Track {
65
69
  const res = import_ffi_client.FfiClient.instance.request({
66
70
  message: { case: "createAudioTrack", value: req }
67
71
  });
68
- return new LocalAudioTrack(res.track);
72
+ return new LocalAudioTrack(res.track, source);
73
+ }
74
+ async close(closeSource = true) {
75
+ var _a;
76
+ await super.close();
77
+ if (closeSource) {
78
+ await ((_a = this.source) == null ? void 0 : _a.close());
79
+ }
69
80
  }
70
81
  }
71
82
  class LocalVideoTrack extends Track {
72
- constructor(owned) {
83
+ constructor(owned, source) {
73
84
  super(owned);
85
+ this.source = source;
74
86
  }
75
87
  static createVideoTrack(name, source) {
76
88
  const req = new import_track_pb.CreateVideoTrackRequest({
@@ -80,7 +92,14 @@ class LocalVideoTrack extends Track {
80
92
  const res = import_ffi_client.FfiClient.instance.request({
81
93
  message: { case: "createVideoTrack", value: req }
82
94
  });
83
- return new LocalVideoTrack(res.track);
95
+ return new LocalVideoTrack(res.track, source);
96
+ }
97
+ async close(closeSource = true) {
98
+ var _a;
99
+ await super.close();
100
+ if (closeSource) {
101
+ await ((_a = this.source) == null ? void 0 : _a.close());
102
+ }
84
103
  }
85
104
  }
86
105
  class RemoteVideoTrack extends Track {
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/track.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { AudioSource } from './audio_source.js';\nimport { FfiClient, FfiHandle } from './ffi_client.js';\nimport type {\n CreateAudioTrackResponse,\n CreateVideoTrackResponse,\n OwnedTrack,\n StreamState,\n TrackInfo,\n TrackKind,\n} from './proto/track_pb.js';\nimport { CreateAudioTrackRequest, CreateVideoTrackRequest } from './proto/track_pb.js';\nimport type { VideoSource } from './video_source.js';\n\nexport abstract class Track {\n /** @internal */\n info?: TrackInfo;\n\n /** @internal */\n ffi_handle: FfiHandle;\n\n constructor(owned: OwnedTrack) {\n this.info = owned.info;\n this.ffi_handle = new FfiHandle(owned.handle!.id!);\n }\n\n get sid(): string | undefined {\n return this.info?.sid;\n }\n\n get name(): string | undefined {\n return this.info?.name;\n }\n\n get kind(): TrackKind | undefined {\n return this.info?.kind;\n }\n\n get stream_state(): StreamState | undefined {\n return this.info?.streamState;\n }\n\n get muted(): boolean | undefined {\n return this.info?.muted;\n }\n}\n\nexport class LocalAudioTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n\n static createAudioTrack(name: string, source: AudioSource): LocalAudioTrack {\n const req = new CreateAudioTrackRequest({\n name: name,\n sourceHandle: source.ffiHandle.handle,\n });\n\n const res = FfiClient.instance.request<CreateAudioTrackResponse>({\n message: { case: 'createAudioTrack', value: req },\n });\n\n return new LocalAudioTrack(res.track!);\n }\n}\n\nexport class LocalVideoTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n\n static createVideoTrack(name: string, source: VideoSource): LocalVideoTrack {\n const req = new CreateVideoTrackRequest({\n name: name,\n sourceHandle: source.ffiHandle.handle,\n });\n\n const res = FfiClient.instance.request<CreateVideoTrackResponse>({\n message: { case: 'createVideoTrack', value: req },\n });\n\n return new LocalVideoTrack(res.track!);\n }\n}\n\nexport class RemoteVideoTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n}\n\nexport class RemoteAudioTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n}\n\nexport type LocalTrack = LocalVideoTrack | LocalAudioTrack;\nexport type RemoteTrack = RemoteVideoTrack | RemoteAudioTrack;\nexport type AudioTrack = LocalAudioTrack | RemoteAudioTrack;\nexport type VideoTrack = LocalVideoTrack | RemoteVideoTrack;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,wBAAqC;AASrC,sBAAiE;AAG1D,MAAe,MAAM;AAAA,EAO1B,YAAY,OAAmB;AAC7B,SAAK,OAAO,MAAM;AAClB,SAAK,aAAa,IAAI,4BAAU,MAAM,OAAQ,EAAG;AAAA,EACnD;AAAA,EAEA,IAAI,MAA0B;AA5BhC;AA6BI,YAAO,UAAK,SAAL,mBAAW;AAAA,EACpB;AAAA,EAEA,IAAI,OAA2B;AAhCjC;AAiCI,YAAO,UAAK,SAAL,mBAAW;AAAA,EACpB;AAAA,EAEA,IAAI,OAA8B;AApCpC;AAqCI,YAAO,UAAK,SAAL,mBAAW;AAAA,EACpB;AAAA,EAEA,IAAI,eAAwC;AAxC9C;AAyCI,YAAO,UAAK,SAAL,mBAAW;AAAA,EACpB;AAAA,EAEA,IAAI,QAA6B;AA5CnC;AA6CI,YAAO,UAAK,SAAL,mBAAW;AAAA,EACpB;AACF;AAEO,MAAM,wBAAwB,MAAM;AAAA,EACzC,YAAY,OAAmB;AAC7B,UAAM,KAAK;AAAA,EACb;AAAA,EAEA,OAAO,iBAAiB,MAAc,QAAsC;AAC1E,UAAM,MAAM,IAAI,wCAAwB;AAAA,MACtC;AAAA,MACA,cAAc,OAAO,UAAU;AAAA,IACjC,CAAC;AAED,UAAM,MAAM,4BAAU,SAAS,QAAkC;AAAA,MAC/D,SAAS,EAAE,MAAM,oBAAoB,OAAO,IAAI;AAAA,IAClD,CAAC;AAED,WAAO,IAAI,gBAAgB,IAAI,KAAM;AAAA,EACvC;AACF;AAEO,MAAM,wBAAwB,MAAM;AAAA,EACzC,YAAY,OAAmB;AAC7B,UAAM,KAAK;AAAA,EACb;AAAA,EAEA,OAAO,iBAAiB,MAAc,QAAsC;AAC1E,UAAM,MAAM,IAAI,wCAAwB;AAAA,MACtC;AAAA,MACA,cAAc,OAAO,UAAU;AAAA,IACjC,CAAC;AAED,UAAM,MAAM,4BAAU,SAAS,QAAkC;AAAA,MAC/D,SAAS,EAAE,MAAM,oBAAoB,OAAO,IAAI;AAAA,IAClD,CAAC;AAED,WAAO,IAAI,gBAAgB,IAAI,KAAM;AAAA,EACvC;AACF;AAEO,MAAM,yBAAyB,MAAM;AAAA,EAC1C,YAAY,OAAmB;AAC7B,UAAM,KAAK;AAAA,EACb;AACF;AAEO,MAAM,yBAAyB,MAAM;AAAA,EAC1C,YAAY,OAAmB;AAC7B,UAAM,KAAK;AAAA,EACb;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/track.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { AudioSource } from './audio_source.js';\nimport { FfiClient, FfiHandle } from './ffi_client.js';\nimport type {\n CreateAudioTrackResponse,\n CreateVideoTrackResponse,\n OwnedTrack,\n StreamState,\n TrackInfo,\n TrackKind,\n} from './proto/track_pb.js';\nimport { CreateAudioTrackRequest, CreateVideoTrackRequest } from './proto/track_pb.js';\nimport type { VideoSource } from './video_source.js';\n\nexport abstract class Track {\n /** @internal */\n info?: TrackInfo;\n\n /** @internal */\n ffi_handle: FfiHandle;\n\n constructor(owned: OwnedTrack) {\n this.info = owned.info;\n this.ffi_handle = new FfiHandle(owned.handle!.id!);\n }\n\n get sid(): string | undefined {\n return this.info?.sid;\n }\n\n get name(): string | undefined {\n return this.info?.name;\n }\n\n get kind(): TrackKind | undefined {\n return this.info?.kind;\n }\n\n get stream_state(): StreamState | undefined {\n return this.info?.streamState;\n }\n\n get muted(): boolean | undefined {\n return this.info?.muted;\n }\n\n async close() {\n this.ffi_handle.dispose();\n }\n}\n\nexport class LocalAudioTrack extends Track {\n private source?: AudioSource;\n\n constructor(owned: OwnedTrack, source?: AudioSource) {\n super(owned);\n this.source = source;\n }\n\n static createAudioTrack(name: string, source: AudioSource): LocalAudioTrack {\n const req = new CreateAudioTrackRequest({\n name: name,\n sourceHandle: source.ffiHandle.handle,\n });\n\n const res = FfiClient.instance.request<CreateAudioTrackResponse>({\n message: { case: 'createAudioTrack', value: req },\n });\n\n return new LocalAudioTrack(res.track!, source);\n }\n\n async close(closeSource = true) {\n await super.close();\n if (closeSource) {\n await this.source?.close();\n }\n }\n}\n\nexport class LocalVideoTrack extends Track {\n private source?: VideoSource;\n\n constructor(owned: OwnedTrack, source?: VideoSource) {\n super(owned);\n this.source = source;\n }\n\n static createVideoTrack(name: string, source: VideoSource): LocalVideoTrack {\n const req = new CreateVideoTrackRequest({\n name: name,\n sourceHandle: source.ffiHandle.handle,\n });\n\n const res = FfiClient.instance.request<CreateVideoTrackResponse>({\n message: { case: 'createVideoTrack', value: req },\n });\n\n return new LocalVideoTrack(res.track!, source);\n }\n\n async close(closeSource = true) {\n await super.close();\n if (closeSource) {\n await this.source?.close();\n }\n }\n}\n\nexport class RemoteVideoTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n}\n\nexport class RemoteAudioTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n}\n\nexport type LocalTrack = LocalVideoTrack | LocalAudioTrack;\nexport type RemoteTrack = RemoteVideoTrack | RemoteAudioTrack;\nexport type AudioTrack = LocalAudioTrack | RemoteAudioTrack;\nexport type VideoTrack = LocalVideoTrack | RemoteVideoTrack;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;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C,YAAY,OAAmB,QAAsB;AACnD,UAAM,KAAK;AACX,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,OAAO,iBAAiB,MAAc,QAAsC;AAC1E,UAAM,MAAM,IAAI,wCAAwB;AAAA,MACtC;AAAA,MACA,cAAc,OAAO,UAAU;AAAA,IACjC,CAAC;AAED,UAAM,MAAM,4BAAU,SAAS,QAAkC;AAAA,MAC/D,SAAS,EAAE,MAAM,oBAAoB,OAAO,IAAI;AAAA,IAClD,CAAC;AAED,WAAO,IAAI,gBAAgB,IAAI,OAAQ,MAAM;AAAA,EAC/C;AAAA,EAEA,MAAM,MAAM,cAAc,MAAM;AAvGlC;AAwGI,UAAM,MAAM,MAAM;AAClB,QAAI,aAAa;AACf,cAAM,UAAK,WAAL,mBAAa;AAAA,IACrB;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,MAAM;AAAA,EAC1C,YAAY,OAAmB;AAC7B,UAAM,KAAK;AAAA,EACb;AACF;AAEO,MAAM,yBAAyB,MAAM;AAAA,EAC1C,YAAY,OAAmB;AAC7B,UAAM,KAAK;AAAA,EACb;AACF;","names":[]}
package/dist/track.d.cts CHANGED
@@ -1,14 +1,22 @@
1
1
  import { AudioSource } from './audio_source.cjs';
2
- import { FfiHandle } from './napi/native.d.cjs';
2
+ import './ffi_client.cjs';
3
3
  import { TrackInfo, OwnedTrack, TrackKind, StreamState } from './proto/track_pb.cjs';
4
4
  import { VideoSource } from './video_source.cjs';
5
+ import { FfiHandle } from './napi/native.d.cjs';
5
6
  import './audio_frame.cjs';
6
7
  import './proto/audio_frame_pb.cjs';
7
8
  import '@bufbuild/protobuf';
8
9
  import './proto/handle_pb.cjs';
10
+ import '@livekit/typed-emitter';
11
+ import './proto/ffi_pb.cjs';
12
+ import './proto/room_pb.cjs';
13
+ import './proto/participant_pb.cjs';
9
14
  import './proto/stats_pb.cjs';
10
- import './proto/e2ee_pb.cjs';
11
15
  import './proto/video_frame_pb.cjs';
16
+ import './proto/e2ee_pb.cjs';
17
+ import './proto/data_stream_pb.cjs';
18
+ import './proto/rpc_pb.cjs';
19
+ import './proto/track_publication_pb.cjs';
12
20
  import './video_frame.cjs';
13
21
 
14
22
  declare abstract class Track {
@@ -22,14 +30,19 @@ declare abstract class Track {
22
30
  get kind(): TrackKind | undefined;
23
31
  get stream_state(): StreamState | undefined;
24
32
  get muted(): boolean | undefined;
33
+ close(): Promise<void>;
25
34
  }
26
35
  declare class LocalAudioTrack extends Track {
27
- constructor(owned: OwnedTrack);
36
+ private source?;
37
+ constructor(owned: OwnedTrack, source?: AudioSource);
28
38
  static createAudioTrack(name: string, source: AudioSource): LocalAudioTrack;
39
+ close(closeSource?: boolean): Promise<void>;
29
40
  }
30
41
  declare class LocalVideoTrack extends Track {
31
- constructor(owned: OwnedTrack);
42
+ private source?;
43
+ constructor(owned: OwnedTrack, source?: VideoSource);
32
44
  static createVideoTrack(name: string, source: VideoSource): LocalVideoTrack;
45
+ close(closeSource?: boolean): Promise<void>;
33
46
  }
34
47
  declare class RemoteVideoTrack extends Track {
35
48
  constructor(owned: OwnedTrack);
package/dist/track.d.ts CHANGED
@@ -1,14 +1,22 @@
1
1
  import { AudioSource } from './audio_source.js';
2
- import { FfiHandle } from './napi/native.d.js';
2
+ import './ffi_client.js';
3
3
  import { TrackInfo, OwnedTrack, TrackKind, StreamState } from './proto/track_pb.js';
4
4
  import { VideoSource } from './video_source.js';
5
+ import { FfiHandle } from './napi/native.d.js';
5
6
  import './audio_frame.js';
6
7
  import './proto/audio_frame_pb.js';
7
8
  import '@bufbuild/protobuf';
8
9
  import './proto/handle_pb.js';
10
+ import '@livekit/typed-emitter';
11
+ import './proto/ffi_pb.js';
12
+ import './proto/room_pb.js';
13
+ import './proto/participant_pb.js';
9
14
  import './proto/stats_pb.js';
10
- import './proto/e2ee_pb.js';
11
15
  import './proto/video_frame_pb.js';
16
+ import './proto/e2ee_pb.js';
17
+ import './proto/data_stream_pb.js';
18
+ import './proto/rpc_pb.js';
19
+ import './proto/track_publication_pb.js';
12
20
  import './video_frame.js';
13
21
 
14
22
  declare abstract class Track {
@@ -22,14 +30,19 @@ declare abstract class Track {
22
30
  get kind(): TrackKind | undefined;
23
31
  get stream_state(): StreamState | undefined;
24
32
  get muted(): boolean | undefined;
33
+ close(): Promise<void>;
25
34
  }
26
35
  declare class LocalAudioTrack extends Track {
27
- constructor(owned: OwnedTrack);
36
+ private source?;
37
+ constructor(owned: OwnedTrack, source?: AudioSource);
28
38
  static createAudioTrack(name: string, source: AudioSource): LocalAudioTrack;
39
+ close(closeSource?: boolean): Promise<void>;
29
40
  }
30
41
  declare class LocalVideoTrack extends Track {
31
- constructor(owned: OwnedTrack);
42
+ private source?;
43
+ constructor(owned: OwnedTrack, source?: VideoSource);
32
44
  static createVideoTrack(name: string, source: VideoSource): LocalVideoTrack;
45
+ close(closeSource?: boolean): Promise<void>;
33
46
  }
34
47
  declare class RemoteVideoTrack extends Track {
35
48
  constructor(owned: OwnedTrack);
@@ -1 +1 @@
1
- {"version":3,"file":"track.d.ts","sourceRoot":"","sources":["../src/track.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAa,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAGV,UAAU,EACV,WAAW,EACX,SAAS,EACT,SAAS,EACV,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,8BAAsB,KAAK;IACzB,gBAAgB;IAChB,IAAI,CAAC,EAAE,SAAS,CAAC;IAEjB,gBAAgB;IAChB,UAAU,EAAE,SAAS,CAAC;gBAEV,KAAK,EAAE,UAAU;IAK7B,IAAI,GAAG,IAAI,MAAM,GAAG,SAAS,CAE5B;IAED,IAAI,IAAI,IAAI,MAAM,GAAG,SAAS,CAE7B;IAED,IAAI,IAAI,IAAI,SAAS,GAAG,SAAS,CAEhC;IAED,IAAI,YAA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.ffi_handle.dispose();
30
+ }
28
31
  }
29
32
  class LocalAudioTrack extends Track {
30
- constructor(owned) {
33
+ constructor(owned, source) {
31
34
  super(owned);
35
+ this.source = source;
32
36
  }
33
37
  static createAudioTrack(name, source) {
34
38
  const req = new CreateAudioTrackRequest({
@@ -38,12 +42,20 @@ class LocalAudioTrack extends Track {
38
42
  const res = FfiClient.instance.request({
39
43
  message: { case: "createAudioTrack", value: req }
40
44
  });
41
- return new LocalAudioTrack(res.track);
45
+ return new LocalAudioTrack(res.track, source);
46
+ }
47
+ async close(closeSource = true) {
48
+ var _a;
49
+ await super.close();
50
+ if (closeSource) {
51
+ await ((_a = this.source) == null ? void 0 : _a.close());
52
+ }
42
53
  }
43
54
  }
44
55
  class LocalVideoTrack extends Track {
45
- constructor(owned) {
56
+ constructor(owned, source) {
46
57
  super(owned);
58
+ this.source = source;
47
59
  }
48
60
  static createVideoTrack(name, source) {
49
61
  const req = new CreateVideoTrackRequest({
@@ -53,7 +65,14 @@ class LocalVideoTrack extends Track {
53
65
  const res = FfiClient.instance.request({
54
66
  message: { case: "createVideoTrack", value: req }
55
67
  });
56
- return new LocalVideoTrack(res.track);
68
+ return new LocalVideoTrack(res.track, source);
69
+ }
70
+ async close(closeSource = true) {
71
+ var _a;
72
+ await super.close();
73
+ if (closeSource) {
74
+ await ((_a = this.source) == null ? void 0 : _a.close());
75
+ }
57
76
  }
58
77
  }
59
78
  class RemoteVideoTrack extends Track {
package/dist/track.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/track.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { AudioSource } from './audio_source.js';\nimport { FfiClient, FfiHandle } from './ffi_client.js';\nimport type {\n CreateAudioTrackResponse,\n CreateVideoTrackResponse,\n OwnedTrack,\n StreamState,\n TrackInfo,\n TrackKind,\n} from './proto/track_pb.js';\nimport { CreateAudioTrackRequest, CreateVideoTrackRequest } from './proto/track_pb.js';\nimport type { VideoSource } from './video_source.js';\n\nexport abstract class Track {\n /** @internal */\n info?: TrackInfo;\n\n /** @internal */\n ffi_handle: FfiHandle;\n\n constructor(owned: OwnedTrack) {\n this.info = owned.info;\n this.ffi_handle = new FfiHandle(owned.handle!.id!);\n }\n\n get sid(): string | undefined {\n return this.info?.sid;\n }\n\n get name(): string | undefined {\n return this.info?.name;\n }\n\n get kind(): TrackKind | undefined {\n return this.info?.kind;\n }\n\n get stream_state(): StreamState | undefined {\n return this.info?.streamState;\n }\n\n get muted(): boolean | undefined {\n return this.info?.muted;\n }\n}\n\nexport class LocalAudioTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n\n static createAudioTrack(name: string, source: AudioSource): LocalAudioTrack {\n const req = new CreateAudioTrackRequest({\n name: name,\n sourceHandle: source.ffiHandle.handle,\n });\n\n const res = FfiClient.instance.request<CreateAudioTrackResponse>({\n message: { case: 'createAudioTrack', value: req },\n });\n\n return new LocalAudioTrack(res.track!);\n }\n}\n\nexport class LocalVideoTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n\n static createVideoTrack(name: string, source: VideoSource): LocalVideoTrack {\n const req = new CreateVideoTrackRequest({\n name: name,\n sourceHandle: source.ffiHandle.handle,\n });\n\n const res = FfiClient.instance.request<CreateVideoTrackResponse>({\n message: { case: 'createVideoTrack', value: req },\n });\n\n return new LocalVideoTrack(res.track!);\n }\n}\n\nexport class RemoteVideoTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n}\n\nexport class RemoteAudioTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n}\n\nexport type LocalTrack = LocalVideoTrack | LocalAudioTrack;\nexport type RemoteTrack = RemoteVideoTrack | RemoteAudioTrack;\nexport type AudioTrack = LocalAudioTrack | RemoteAudioTrack;\nexport type VideoTrack = LocalVideoTrack | RemoteVideoTrack;\n"],"mappings":"AAIA,SAAS,WAAW,iBAAiB;AASrC,S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AClD,CAAC;AAED,WAAO,IAAI,gBAAgB,IAAI,KAAM;AAAA,EACvC;AACF;AAEO,MAAM,yBAAyB,MAAM;AAAA,EAC1C,YAAY,OAAmB;AAC7B,UAAM,KAAK;AAAA,EACb;AACF;AAEO,MAAM,yBAAyB,MAAM;AAAA,EAC1C,YAAY,OAAmB;AAC7B,UAAM,KAAK;AAAA,EACb;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/track.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { AudioSource } from './audio_source.js';\nimport { FfiClient, FfiHandle } from './ffi_client.js';\nimport type {\n CreateAudioTrackResponse,\n CreateVideoTrackResponse,\n OwnedTrack,\n StreamState,\n TrackInfo,\n TrackKind,\n} from './proto/track_pb.js';\nimport { CreateAudioTrackRequest, CreateVideoTrackRequest } from './proto/track_pb.js';\nimport type { VideoSource } from './video_source.js';\n\nexport abstract class Track {\n /** @internal */\n info?: TrackInfo;\n\n /** @internal */\n ffi_handle: FfiHandle;\n\n constructor(owned: OwnedTrack) {\n this.info = owned.info;\n this.ffi_handle = new FfiHandle(owned.handle!.id!);\n }\n\n get sid(): string | undefined {\n return this.info?.sid;\n }\n\n get name(): string | undefined {\n return this.info?.name;\n }\n\n get kind(): TrackKind | undefined {\n return this.info?.kind;\n }\n\n get stream_state(): StreamState | undefined {\n return this.info?.streamState;\n }\n\n get muted(): boolean | undefined {\n return this.info?.muted;\n }\n\n async close() {\n this.ffi_handle.dispose();\n }\n}\n\nexport class LocalAudioTrack extends Track {\n private source?: AudioSource;\n\n constructor(owned: OwnedTrack, source?: AudioSource) {\n super(owned);\n this.source = source;\n }\n\n static createAudioTrack(name: string, source: AudioSource): LocalAudioTrack {\n const req = new CreateAudioTrackRequest({\n name: name,\n sourceHandle: source.ffiHandle.handle,\n });\n\n const res = FfiClient.instance.request<CreateAudioTrackResponse>({\n message: { case: 'createAudioTrack', value: req },\n });\n\n return new LocalAudioTrack(res.track!, source);\n }\n\n async close(closeSource = true) {\n await super.close();\n if (closeSource) {\n await this.source?.close();\n }\n }\n}\n\nexport class LocalVideoTrack extends Track {\n private source?: VideoSource;\n\n constructor(owned: OwnedTrack, source?: VideoSource) {\n super(owned);\n this.source = source;\n }\n\n static createVideoTrack(name: string, source: VideoSource): LocalVideoTrack {\n const req = new CreateVideoTrackRequest({\n name: name,\n sourceHandle: source.ffiHandle.handle,\n });\n\n const res = FfiClient.instance.request<CreateVideoTrackResponse>({\n message: { case: 'createVideoTrack', value: req },\n });\n\n return new LocalVideoTrack(res.track!, source);\n }\n\n async close(closeSource = true) {\n await super.close();\n if (closeSource) {\n await this.source?.close();\n }\n }\n}\n\nexport class RemoteVideoTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n}\n\nexport class RemoteAudioTrack extends Track {\n constructor(owned: OwnedTrack) {\n super(owned);\n }\n}\n\nexport type LocalTrack = LocalVideoTrack | LocalAudioTrack;\nexport type RemoteTrack = RemoteVideoTrack | RemoteAudioTrack;\nexport type AudioTrack = LocalAudioTrack | RemoteAudioTrack;\nexport type VideoTrack = LocalVideoTrack | RemoteVideoTrack;\n"],"mappings":"AAIA,SAAS,WAAW,iBAAiB;AASrC,SAAS,yBAAyB,+BAA+B;AAG1D,MAAe,MAAM;AAAA,EAO1B,YAAY,OAAmB;AAC7B,SAAK,OAAO,MAAM;AAClB,SAAK,aAAa,IAAI,UAAU,MAAM,OAAQ,EAAG;AAAA,EACnD;AAAA,EAEA,IAAI,MAA0B;AA5BhC;AA6BI,YAAO,UAAK,SAAL,mBAAW;AAAA,EACpB;AAAA,EAEA,IAAI,OAA2B;AAhCjC;AAiCI,YAAO,UAAK,SAAL,mBAAW;AAAA,EACpB;AAAA,EAEA,IAAI,OAA8B;AApCpC;AAqCI,YAAO,UAAK,SAAL,mBAAW;AAAA,EACpB;AAAA,EAEA,IAAI,eAAwC;AAxC9C;AAyCI,YAAO,UAAK,SAAL,mBAAW;A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,IACrB;AAAA,EACF;AACF;AAEO,MAAM,yBAAyB,MAAM;AAAA,EAC1C,YAAY,OAAmB;AAC7B,UAAM,KAAK;AAAA,EACb;AACF;AAEO,MAAM,yBAAyB,MAAM;AAAA,EAC1C,YAAY,OAAmB;AAC7B,UAAM,KAAK;AAAA,EACb;AACF;","names":[]}
@@ -8,8 +8,16 @@ import './proto/handle_pb.cjs';
8
8
  import './audio_source.cjs';
9
9
  import './audio_frame.cjs';
10
10
  import './proto/audio_frame_pb.cjs';
11
- import './video_source.cjs';
11
+ import './ffi_client.cjs';
12
+ import '@livekit/typed-emitter';
13
+ import './proto/ffi_pb.cjs';
14
+ import './proto/room_pb.cjs';
15
+ import './proto/participant_pb.cjs';
12
16
  import './proto/video_frame_pb.cjs';
17
+ import './proto/data_stream_pb.cjs';
18
+ import './proto/rpc_pb.cjs';
19
+ import './proto/track_publication_pb.cjs';
20
+ import './video_source.cjs';
13
21
  import './video_frame.cjs';
14
22
 
15
23
  declare abstract class TrackPublication {
@@ -8,8 +8,16 @@ import './proto/handle_pb.js';
8
8
  import './audio_source.js';
9
9
  import './audio_frame.js';
10
10
  import './proto/audio_frame_pb.js';
11
- import './video_source.js';
11
+ import './ffi_client.js';
12
+ import '@livekit/typed-emitter';
13
+ import './proto/ffi_pb.js';
14
+ import './proto/room_pb.js';
15
+ import './proto/participant_pb.js';
12
16
  import './proto/video_frame_pb.js';
17
+ import './proto/data_stream_pb.js';
18
+ import './proto/rpc_pb.js';
19
+ import './proto/track_publication_pb.js';
20
+ import './video_source.js';
13
21
  import './video_frame.js';
14
22
 
15
23
  declare abstract class TrackPublication {
package/dist/version.cjs CHANGED
@@ -21,7 +21,7 @@ __export(version_exports, {
21
21
  SDK_VERSION: () => SDK_VERSION
22
22
  });
23
23
  module.exports = __toCommonJS(version_exports);
24
- const SDK_VERSION = "0.13.13";
24
+ const SDK_VERSION = "0.13.16";
25
25
  // Annotate the CommonJS export names for ESM import in node:
26
26
  0 && (module.exports = {
27
27
  SDK_VERSION
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/version.ts"],"sourcesContent":["export const SDK_VERSION = \"0.13.13\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/version.ts"],"sourcesContent":["export const SDK_VERSION = \"0.13.16\";\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,cAAc;","names":[]}
@@ -1,3 +1,3 @@
1
- declare const SDK_VERSION = "0.13.13";
1
+ declare const SDK_VERSION = "0.13.16";
2
2
 
3
3
  export { SDK_VERSION };
package/dist/version.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- declare const SDK_VERSION = "0.13.13";
1
+ declare const SDK_VERSION = "0.13.16";
2
2
 
3
3
  export { SDK_VERSION };
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
- const SDK_VERSION = "0.13.13";
1
+ const SDK_VERSION = "0.13.16";
2
2
  export {
3
3
  SDK_VERSION
4
4
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/version.ts"],"sourcesContent":["export const SDK_VERSION = \"0.13.13\";\n"],"mappings":"AAAO,MAAM,cAAc;","names":[]}
1
+ {"version":3,"sources":["../src/version.ts"],"sourcesContent":["export const SDK_VERSION = \"0.13.16\";\n"],"mappings":"AAAO,MAAM,cAAc;","names":[]}
@@ -1,11 +1,20 @@
1
- import { FfiHandle } from './napi/native.d.cjs';
1
+ import './ffi_client.cjs';
2
2
  import { VideoSourceInfo, VideoRotation } from './proto/video_frame_pb.cjs';
3
3
  import { VideoFrame } from './video_frame.cjs';
4
+ import { FfiHandle } from './napi/native.d.cjs';
4
5
  import '@bufbuild/protobuf';
6
+ import '@livekit/typed-emitter';
7
+ import './proto/ffi_pb.cjs';
8
+ import './proto/room_pb.cjs';
9
+ import './proto/participant_pb.cjs';
10
+ import './proto/handle_pb.cjs';
5
11
  import './proto/track_pb.cjs';
6
12
  import './proto/stats_pb.cjs';
7
13
  import './proto/e2ee_pb.cjs';
8
- import './proto/handle_pb.cjs';
14
+ import './proto/data_stream_pb.cjs';
15
+ import './proto/audio_frame_pb.cjs';
16
+ import './proto/rpc_pb.cjs';
17
+ import './proto/track_publication_pb.cjs';
9
18
 
10
19
  declare class VideoSource {
11
20
  /** @internal */
@@ -1,11 +1,20 @@
1
- import { FfiHandle } from './napi/native.d.js';
1
+ import './ffi_client.js';
2
2
  import { VideoSourceInfo, VideoRotation } from './proto/video_frame_pb.js';
3
3
  import { VideoFrame } from './video_frame.js';
4
+ import { FfiHandle } from './napi/native.d.js';
4
5
  import '@bufbuild/protobuf';
6
+ import '@livekit/typed-emitter';
7
+ import './proto/ffi_pb.js';
8
+ import './proto/room_pb.js';
9
+ import './proto/participant_pb.js';
10
+ import './proto/handle_pb.js';
5
11
  import './proto/track_pb.js';
6
12
  import './proto/stats_pb.js';
7
13
  import './proto/e2ee_pb.js';
8
- import './proto/handle_pb.js';
14
+ import './proto/data_stream_pb.js';
15
+ import './proto/audio_frame_pb.js';
16
+ import './proto/rpc_pb.js';
17
+ import './proto/track_publication_pb.js';
9
18
 
10
19
  declare class VideoSource {
11
20
  /** @internal */
@@ -21,7 +21,6 @@ __export(video_stream_exports, {
21
21
  VideoStream: () => VideoStream
22
22
  });
23
23
  module.exports = __toCommonJS(video_stream_exports);
24
- var import_web = require("node:stream/web");
25
24
  var import_ffi_client = require("./ffi_client.cjs");
26
25
  var import_video_frame_pb = require("./proto/video_frame_pb.cjs");
27
26
  var import_video_frame = require("./video_frame.cjs");
@@ -75,7 +74,7 @@ class VideoStreamSource {
75
74
  this.ffiHandle.dispose();
76
75
  }
77
76
  }
78
- class VideoStream extends import_web.ReadableStream {
77
+ class VideoStream extends ReadableStream {
79
78
  constructor(track) {
80
79
  super(new VideoStreamSource(track));
81
80
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/video_stream.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { ReadableStream, type UnderlyingSource } from 'node:stream/web';\nimport type { FfiEvent } from './ffi_client.js';\nimport { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';\nimport type { NewVideoStreamResponse, VideoRotation } from './proto/video_frame_pb.js';\nimport { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';\nimport type { Track } from './track.js';\nimport { VideoFrame } from './video_frame.js';\n\nexport type VideoFrameEvent = {\n frame: VideoFrame;\n timestampUs: bigint;\n rotation: VideoRotation;\n};\n\nclass VideoStreamSource implements UnderlyingSource<VideoFrameEvent> {\n private controller?: ReadableStreamDefaultController<VideoFrameEvent>;\n private ffiHandle: FfiHandle;\n\n constructor(track: Track) {\n const req = new NewVideoStreamRequest({\n type: VideoStreamType.VIDEO_STREAM_NATIVE,\n trackHandle: track.ffi_handle.handle,\n });\n\n const res = FfiClient.instance.request<NewVideoStreamResponse>({\n message: {\n case: 'newVideoStream',\n value: req,\n },\n });\n\n this.ffiHandle = new FfiHandle(res.stream!.handle!.id!);\n FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);\n }\n\n private onEvent = (ev: FfiEvent) => {\n if (!this.controller) {\n throw new Error('Stream controller not initialized');\n }\n\n if (\n ev.message.case != 'videoStreamEvent' ||\n ev.message.value.streamHandle != this.ffiHandle.handle\n ) {\n return;\n }\n\n const streamEvent = ev.message.value.message;\n switch (streamEvent.case) {\n case 'frameReceived':\n const rotation = streamEvent.value.rotation;\n const timestampUs = streamEvent.value.timestampUs;\n const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer!);\n const value = { rotation, timestampUs, frame };\n const videoFrameEvent = {\n frame: value.frame,\n timestampUs: value.timestampUs!,\n rotation: value.rotation!,\n };\n this.controller.enqueue(videoFrameEvent);\n break;\n case 'eos':\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n this.controller.close();\n break;\n }\n };\n\n start(controller: ReadableStreamDefaultController<VideoFrameEvent>) {\n this.controller = controller;\n }\n\n cancel() {\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n this.ffiHandle.dispose();\n }\n}\n\nexport class VideoStream extends ReadableStream<VideoFrameEvent> {\n constructor(track: Track) {\n super(new VideoStreamSource(track));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAsD;AAEtD,wBAAqD;AAErD,4BAAuD;AAEvD,yBAA2B;AAQ3B,MAAM,kBAA+D;AAAA,EAInE,YAAY,OAAc;AAiB1B,SAAQ,UAAU,CAAC,OAAiB;AAClC,UAAI,CAAC,KAAK,YAAY;AACpB,cAAM,IAAI,MAAM,mCAAmC;AAAA,MACrD;AAEA,UACE,GAAG,QAAQ,QAAQ,sBACnB,GAAG,QAAQ,MAAM,gBAAgB,KAAK,UAAU,QAChD;AACA;AAAA,MACF;AAEA,YAAM,cAAc,GAAG,QAAQ,MAAM;AACrC,cAAQ,YAAY,MAAM;AAAA,QACxB,KAAK;AACH,gBAAM,WAAW,YAAY,MAAM;AACnC,gBAAM,cAAc,YAAY,MAAM;AACtC,gBAAM,QAAQ,8BAAW,cAAc,YAAY,MAAM,MAAO;AAChE,gBAAM,QAAQ,EAAE,UAAU,aAAa,MAAM;AAC7C,gBAAM,kBAAkB;AAAA,YACtB,OAAO,MAAM;AAAA,YACb,aAAa,MAAM;AAAA,YACnB,UAAU,MAAM;AAAA,UAClB;AACA,eAAK,WAAW,QAAQ,eAAe;AACvC;AAAA,QACF,KAAK;AACH,sCAAU,SAAS,IAAI,iCAAe,UAAU,KAAK,OAAO;AAC5D,eAAK,WAAW,MAAM;AACtB;AAAA,MACJ;AAAA,IACF;AA/CE,UAAM,MAAM,IAAI,4CAAsB;AAAA,MACpC,MAAM,sCAAgB;AAAA,MACtB,aAAa,MAAM,WAAW;AAAA,IAChC,CAAC;AAED,UAAM,MAAM,4BAAU,SAAS,QAAgC;AAAA,MAC7D,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,SAAK,YAAY,IAAI,4BAAU,IAAI,OAAQ,OAAQ,EAAG;AACtD,gCAAU,SAAS,GAAG,iCAAe,UAAU,KAAK,OAAO;AAAA,EAC7D;AAAA,EAmCA,MAAM,YAA8D;AAClE,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,SAAS;AACP,gCAAU,SAAS,IAAI,iCAAe,UAAU,KAAK,OAAO;AAC5D,SAAK,UAAU,QAAQ;AAAA,EACzB;AACF;AAEO,MAAM,oBAAoB,0BAAgC;AAAA,EAC/D,YAAY,OAAc;AACxB,UAAM,IAAI,kBAAkB,KAAK,CAAC;AAAA,EACpC;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/video_stream.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { UnderlyingSource } from 'node:stream/web';\nimport type { FfiEvent } from './ffi_client.js';\nimport { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';\nimport type { NewVideoStreamResponse, VideoRotation } from './proto/video_frame_pb.js';\nimport { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';\nimport type { Track } from './track.js';\nimport { VideoFrame } from './video_frame.js';\n\nexport type VideoFrameEvent = {\n frame: VideoFrame;\n timestampUs: bigint;\n rotation: VideoRotation;\n};\n\nclass VideoStreamSource implements UnderlyingSource<VideoFrameEvent> {\n private controller?: ReadableStreamDefaultController<VideoFrameEvent>;\n private ffiHandle: FfiHandle;\n\n constructor(track: Track) {\n const req = new NewVideoStreamRequest({\n type: VideoStreamType.VIDEO_STREAM_NATIVE,\n trackHandle: track.ffi_handle.handle,\n });\n\n const res = FfiClient.instance.request<NewVideoStreamResponse>({\n message: {\n case: 'newVideoStream',\n value: req,\n },\n });\n\n this.ffiHandle = new FfiHandle(res.stream!.handle!.id!);\n FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);\n }\n\n private onEvent = (ev: FfiEvent) => {\n if (!this.controller) {\n throw new Error('Stream controller not initialized');\n }\n\n if (\n ev.message.case != 'videoStreamEvent' ||\n ev.message.value.streamHandle != this.ffiHandle.handle\n ) {\n return;\n }\n\n const streamEvent = ev.message.value.message;\n switch (streamEvent.case) {\n case 'frameReceived':\n const rotation = streamEvent.value.rotation;\n const timestampUs = streamEvent.value.timestampUs;\n const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer!);\n const value = { rotation, timestampUs, frame };\n const videoFrameEvent = {\n frame: value.frame,\n timestampUs: value.timestampUs!,\n rotation: value.rotation!,\n };\n this.controller.enqueue(videoFrameEvent);\n break;\n case 'eos':\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n this.controller.close();\n break;\n }\n };\n\n start(controller: ReadableStreamDefaultController<VideoFrameEvent>) {\n this.controller = controller;\n }\n\n cancel() {\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n this.ffiHandle.dispose();\n }\n}\n\nexport class VideoStream extends ReadableStream<VideoFrameEvent> {\n constructor(track: Track) {\n super(new VideoStreamSource(track));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,wBAAqD;AAErD,4BAAuD;AAEvD,yBAA2B;AAQ3B,MAAM,kBAA+D;AAAA,EAInE,YAAY,OAAc;AAiB1B,SAAQ,UAAU,CAAC,OAAiB;AAClC,UAAI,CAAC,KAAK,YAAY;AACpB,cAAM,IAAI,MAAM,mCAAmC;AAAA,MACrD;AAEA,UACE,GAAG,QAAQ,QAAQ,sBACnB,GAAG,QAAQ,MAAM,gBAAgB,KAAK,UAAU,QAChD;AACA;AAAA,MACF;AAEA,YAAM,cAAc,GAAG,QAAQ,MAAM;AACrC,cAAQ,YAAY,MAAM;AAAA,QACxB,KAAK;AACH,gBAAM,WAAW,YAAY,MAAM;AACnC,gBAAM,cAAc,YAAY,MAAM;AACtC,gBAAM,QAAQ,8BAAW,cAAc,YAAY,MAAM,MAAO;AAChE,gBAAM,QAAQ,EAAE,UAAU,aAAa,MAAM;AAC7C,gBAAM,kBAAkB;AAAA,YACtB,OAAO,MAAM;AAAA,YACb,aAAa,MAAM;AAAA,YACnB,UAAU,MAAM;AAAA,UAClB;AACA,eAAK,WAAW,QAAQ,eAAe;AACvC;AAAA,QACF,KAAK;AACH,sCAAU,SAAS,IAAI,iCAAe,UAAU,KAAK,OAAO;AAC5D,eAAK,WAAW,MAAM;AACtB;AAAA,MACJ;AAAA,IACF;AA/CE,UAAM,MAAM,IAAI,4CAAsB;AAAA,MACpC,MAAM,sCAAgB;AAAA,MACtB,aAAa,MAAM,WAAW;AAAA,IAChC,CAAC;AAED,UAAM,MAAM,4BAAU,SAAS,QAAgC;AAAA,MAC7D,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,SAAK,YAAY,IAAI,4BAAU,IAAI,OAAQ,OAAQ,EAAG;AACtD,gCAAU,SAAS,GAAG,iCAAe,UAAU,KAAK,OAAO;AAAA,EAC7D;AAAA,EAmCA,MAAM,YAA8D;AAClE,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,SAAS;AACP,gCAAU,SAAS,IAAI,iCAAe,UAAU,KAAK,OAAO;AAC5D,SAAK,UAAU,QAAQ;AAAA,EACzB;AACF;AAEO,MAAM,oBAAoB,eAAgC;AAAA,EAC/D,YAAY,OAAc;AACxB,UAAM,IAAI,kBAAkB,KAAK,CAAC;AAAA,EACpC;AACF;","names":[]}
@@ -1,4 +1,3 @@
1
- import { ReadableStream } from 'node:stream/web';
2
1
  import { VideoRotation } from './proto/video_frame_pb.cjs';
3
2
  import { Track } from './track.cjs';
4
3
  import { VideoFrame } from './video_frame.cjs';
@@ -11,6 +10,14 @@ import './audio_source.cjs';
11
10
  import './audio_frame.cjs';
12
11
  import './proto/audio_frame_pb.cjs';
13
12
  import './napi/native.d.cjs';
13
+ import './ffi_client.cjs';
14
+ import '@livekit/typed-emitter';
15
+ import './proto/ffi_pb.cjs';
16
+ import './proto/room_pb.cjs';
17
+ import './proto/participant_pb.cjs';
18
+ import './proto/data_stream_pb.cjs';
19
+ import './proto/rpc_pb.cjs';
20
+ import './proto/track_publication_pb.cjs';
14
21
  import './video_source.cjs';
15
22
 
16
23
  type VideoFrameEvent = {
@@ -1,4 +1,3 @@
1
- import { ReadableStream } from 'node:stream/web';
2
1
  import { VideoRotation } from './proto/video_frame_pb.js';
3
2
  import { Track } from './track.js';
4
3
  import { VideoFrame } from './video_frame.js';
@@ -11,6 +10,14 @@ import './audio_source.js';
11
10
  import './audio_frame.js';
12
11
  import './proto/audio_frame_pb.js';
13
12
  import './napi/native.d.js';
13
+ import './ffi_client.js';
14
+ import '@livekit/typed-emitter';
15
+ import './proto/ffi_pb.js';
16
+ import './proto/room_pb.js';
17
+ import './proto/participant_pb.js';
18
+ import './proto/data_stream_pb.js';
19
+ import './proto/rpc_pb.js';
20
+ import './proto/track_publication_pb.js';
14
21
  import './video_source.js';
15
22
 
16
23
  type VideoFrameEvent = {
@@ -1 +1 @@
1
- {"version":3,"file":"video_stream.d.ts","sourceRoot":"","sources":["../src/video_stream.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAyB,MAAM,iBAAiB,CAAC;AAGxE,OAAO,KAAK,EAA0B,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAEvF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,aAAa,CAAC;CACzB,CAAC;AAkEF,qBAAa,WAAY,SAAQ,cAAc,CAAC,eAAe,CAAC;gBAClD,KAAK,EAAE,KAAK;CAGzB"}
1
+ {"version":3,"file":"video_stream.d.ts","sourceRoot":"","sources":["../src/video_stream.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAA0B,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAEvF,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,EAAE,UAAU,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,aAAa,CAAC;CACzB,CAAC;AAkEF,qBAAa,WAAY,SAAQ,cAAc,CAAC,eAAe,CAAC;gBAClD,KAAK,EAAE,KAAK;CAGzB"}
@@ -1,4 +1,3 @@
1
- import { ReadableStream } from "node:stream/web";
2
1
  import { FfiClient, FfiClientEvent, FfiHandle } from "./ffi_client.js";
3
2
  import { NewVideoStreamRequest, VideoStreamType } from "./proto/video_frame_pb.js";
4
3
  import { VideoFrame } from "./video_frame.js";
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/video_stream.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { ReadableStream, type UnderlyingSource } from 'node:stream/web';\nimport type { FfiEvent } from './ffi_client.js';\nimport { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';\nimport type { NewVideoStreamResponse, VideoRotation } from './proto/video_frame_pb.js';\nimport { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';\nimport type { Track } from './track.js';\nimport { VideoFrame } from './video_frame.js';\n\nexport type VideoFrameEvent = {\n frame: VideoFrame;\n timestampUs: bigint;\n rotation: VideoRotation;\n};\n\nclass VideoStreamSource implements UnderlyingSource<VideoFrameEvent> {\n private controller?: ReadableStreamDefaultController<VideoFrameEvent>;\n private ffiHandle: FfiHandle;\n\n constructor(track: Track) {\n const req = new NewVideoStreamRequest({\n type: VideoStreamType.VIDEO_STREAM_NATIVE,\n trackHandle: track.ffi_handle.handle,\n });\n\n const res = FfiClient.instance.request<NewVideoStreamResponse>({\n message: {\n case: 'newVideoStream',\n value: req,\n },\n });\n\n this.ffiHandle = new FfiHandle(res.stream!.handle!.id!);\n FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);\n }\n\n private onEvent = (ev: FfiEvent) => {\n if (!this.controller) {\n throw new Error('Stream controller not initialized');\n }\n\n if (\n ev.message.case != 'videoStreamEvent' ||\n ev.message.value.streamHandle != this.ffiHandle.handle\n ) {\n return;\n }\n\n const streamEvent = ev.message.value.message;\n switch (streamEvent.case) {\n case 'frameReceived':\n const rotation = streamEvent.value.rotation;\n const timestampUs = streamEvent.value.timestampUs;\n const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer!);\n const value = { rotation, timestampUs, frame };\n const videoFrameEvent = {\n frame: value.frame,\n timestampUs: value.timestampUs!,\n rotation: value.rotation!,\n };\n this.controller.enqueue(videoFrameEvent);\n break;\n case 'eos':\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n this.controller.close();\n break;\n }\n };\n\n start(controller: ReadableStreamDefaultController<VideoFrameEvent>) {\n this.controller = controller;\n }\n\n cancel() {\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n this.ffiHandle.dispose();\n }\n}\n\nexport class VideoStream extends ReadableStream<VideoFrameEvent> {\n constructor(track: Track) {\n super(new VideoStreamSource(track));\n }\n}\n"],"mappings":"AAGA,SAAS,sBAA6C;AAEtD,SAAS,WAAW,gBAAgB,iBAAiB;AAErD,SAAS,uBAAuB,uBAAuB;AAEvD,SAAS,kBAAkB;AAQ3B,MAAM,kBAA+D;AAAA,EAInE,YAAY,OAAc;AAiB1B,SAAQ,UAAU,CAAC,OAAiB;AAClC,UAAI,CAAC,KAAK,YAAY;AACpB,cAAM,IAAI,MAAM,mCAAmC;AAAA,MACrD;AAEA,UACE,GAAG,QAAQ,QA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esContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { UnderlyingSource } from 'node:stream/web';\nimport type { FfiEvent } from './ffi_client.js';\nimport { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';\nimport type { NewVideoStreamResponse, VideoRotation } from './proto/video_frame_pb.js';\nimport { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';\nimport type { Track } from './track.js';\nimport { VideoFrame } from './video_frame.js';\n\nexport type VideoFrameEvent = {\n frame: VideoFrame;\n timestampUs: bigint;\n rotation: VideoRotation;\n};\n\nclass VideoStreamSource implements UnderlyingSource<VideoFrameEvent> {\n private controller?: ReadableStreamDefaultController<VideoFrameEvent>;\n private ffiHandle: FfiHandle;\n\n constructor(track: Track) {\n const req = new NewVideoStreamRequest({\n type: VideoStreamType.VIDEO_STREAM_NATIVE,\n trackHandle: track.ffi_handle.handle,\n });\n\n const res = FfiClient.instance.request<NewVideoStreamResponse>({\n message: {\n case: 'newVideoStream',\n value: req,\n },\n });\n\n this.ffiHandle = new FfiHandle(res.stream!.handle!.id!);\n FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);\n }\n\n private onEvent = (ev: FfiEvent) => {\n if (!this.controller) {\n throw new Error('Stream controller not initialized');\n }\n\n if (\n ev.message.case != 'videoStreamEvent' ||\n ev.message.value.streamHandle != this.ffiHandle.handle\n ) {\n return;\n }\n\n const streamEvent = ev.message.value.message;\n switch (streamEvent.case) {\n case 'frameReceived':\n const rotation = streamEvent.value.rotation;\n const timestampUs = streamEvent.value.timestampUs;\n const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer!);\n const value = { rotation, timestampUs, frame };\n const videoFrameEvent = {\n frame: value.frame,\n timestampUs: value.timestampUs!,\n rotation: value.rotation!,\n };\n this.controller.enqueue(videoFrameEvent);\n break;\n case 'eos':\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n this.controller.close();\n break;\n }\n };\n\n start(controller: ReadableStreamDefaultController<VideoFrameEvent>) {\n this.controller = controller;\n }\n\n cancel() {\n FfiClient.instance.off(FfiClientEvent.FfiEvent, this.onEvent);\n this.ffiHandle.dispose();\n }\n}\n\nexport class VideoStream extends ReadableStream<VideoFrameEvent> {\n constructor(track: Track) {\n super(new VideoStreamSource(track));\n }\n}\n"],"mappings":"AAKA,SAAS,WAAW,gBAAgB,iBAAiB;AAErD,SAAS,uBAAuB,uBAAuB;AAEvD,SAAS,kBAAkB;AAQ3B,MAAM,kBAA+D;AAAA,EAInE,YAAY,OAAc;AAiB1B,SAAQ,UAAU,CAAC,OAAiB;AAClC,UAAI,CAAC,KAAK,YAAY;AACpB,cAAM,IAAI,MAAM,mCAAmC;AAAA,MACrD;AAEA,UACE,GAAG,QAAQ,QAAQ,sBACnB,GAAG,QAAQ,MAAM,gBAAgB,KAAK,UAAU,QAChD;AACA;AAAA,MACF;AAEA,YAAM,cAAc,GAAG,QAAQ,MAAM;AACrC,cAAQ,YAAY,MAAM;AAAA,QACxB,KAAK;AACH,gBAAM,WAAW,YAAY,MAAM;AACnC,gBAAM,cAAc,YAAY,MAAM;AACtC,gBAAM,QAAQ,WAAW,cAAc,YAAY,MAAM,MAAO;AAChE,gBAAM,QAAQ,EAAE,UAAU,aAAa,MAAM;AAC7C,gBAAM,kBAAkB;AAAA,YACtB,OAAO,MAAM;AAAA,YACb,aAAa,MAAM;AAAA,YACnB,UAAU,MAAM;AAAA,UAClB;AACA,eAAK,WAAW,QAAQ,eAAe;AACvC;AAAA,QACF,KAAK;AACH,oBAAU,SAAS,IAAI,eAAe,UAAU,KAAK,OAAO;AAC5D,eAAK,WAAW,MAAM;AACtB;AAAA,MACJ;AAAA,IACF;AA/CE,UAAM,MAAM,IAAI,sBAAsB;AAAA,MACpC,MAAM,gBAAgB;AAAA,MACtB,aAAa,MAAM,WAAW;AAAA,IAChC,CAAC;AAED,UAAM,MAAM,UAAU,SAAS,QAAgC;AAAA,MAC7D,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,SAAK,YAAY,IAAI,UAAU,IAAI,OAAQ,OAAQ,EAAG;AACtD,cAAU,SAAS,GAAG,eAAe,UAAU,KAAK,OAAO;AAAA,EAC7D;AAAA,EAmCA,MAAM,YAA8D;AAClE,SAAK,aAAa;AAAA,EACpB;AAAA,EAEA,SAAS;AACP,cAAU,SAAS,IAAI,eAAe,UAAU,KAAK,OAAO;AAC5D,SAAK,UAAU,QAAQ;AAAA,EACzB;AACF;AAEO,MAAM,oBAAoB,eAAgC;AAAA,EAC/D,YAAY,OAAc;AACxB,UAAM,IAAI,kBAAkB,KAAK,CAAC;AAAA,EACpC;AACF;","names":[]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "LiveKit RTC Node",
4
4
  "license": "Apache-2.0",
5
5
  "author": "LiveKit",
6
- "version": "0.13.13",
6
+ "version": "0.13.16",
7
7
  "main": "dist/index.js",
8
8
  "require": "dist/index.cjs",
9
9
  "types": "dist/index.d.ts",
@@ -54,18 +54,18 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@napi-rs/cli": "^2.18.0",
57
- "@types/node": "^20.9.2",
57
+ "@types/node": "^22.13.10",
58
58
  "prettier": "^3.0.3",
59
59
  "tsup": "^8.3.5",
60
60
  "typescript": "^5.2.2",
61
61
  "@bufbuild/protoc-gen-es": "^1.10.0"
62
62
  },
63
63
  "optionalDependencies": {
64
- "@livekit/rtc-node-darwin-arm64": "0.13.13",
65
- "@livekit/rtc-node-darwin-x64": "0.13.13",
66
- "@livekit/rtc-node-linux-arm64-gnu": "0.13.13",
67
- "@livekit/rtc-node-linux-x64-gnu": "0.13.13",
68
- "@livekit/rtc-node-win32-x64-msvc": "0.13.13"
64
+ "@livekit/rtc-node-darwin-arm64": "0.13.16",
65
+ "@livekit/rtc-node-darwin-x64": "0.13.16",
66
+ "@livekit/rtc-node-linux-arm64-gnu": "0.13.16",
67
+ "@livekit/rtc-node-linux-x64-gnu": "0.13.16",
68
+ "@livekit/rtc-node-win32-x64-msvc": "0.13.16"
69
69
  },
70
70
  "engines": {
71
71
  "node": ">= 18"
@@ -1,7 +1,7 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { ReadableStream, type UnderlyingSource } from 'node:stream/web';
4
+ import type { UnderlyingSource } from 'node:stream/web';
5
5
  import { AudioFrame } from './audio_frame.js';
6
6
  import type { FfiEvent } from './ffi_client.js';
7
7
  import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
@@ -13,6 +13,7 @@ export interface AudioStreamOptions {
13
13
  noiseCancellation?: NoiseCancellationOptions;
14
14
  sampleRate?: number;
15
15
  numChannels?: number;
16
+ frameSizeMs?: number;
16
17
  }
17
18
 
18
19
  export interface NoiseCancellationOptions {
@@ -26,6 +27,7 @@ class AudioStreamSource implements UnderlyingSource<AudioFrame> {
26
27
  private sampleRate: number;
27
28
  private numChannels: number;
28
29
  private ncOptions?: NoiseCancellationOptions;
30
+ private frameSizeMs?: number;
29
31
 
30
32
  constructor(
31
33
  track: Track,
@@ -36,6 +38,7 @@ class AudioStreamSource implements UnderlyingSource<AudioFrame> {
36
38
  this.sampleRate = sampleRateOrOptions.sampleRate ?? 48000;
37
39
  this.numChannels = sampleRateOrOptions.numChannels ?? 1;
38
40
  this.ncOptions = sampleRateOrOptions.noiseCancellation;
41
+ this.frameSizeMs = sampleRateOrOptions.frameSizeMs;
39
42
  } else {
40
43
  this.sampleRate = (sampleRateOrOptions as number) ?? 48000;
41
44
  this.numChannels = numChannels ?? 1;
@@ -46,6 +49,7 @@ class AudioStreamSource implements UnderlyingSource<AudioFrame> {
46
49
  trackHandle: track.ffi_handle.handle,
47
50
  sampleRate: this.sampleRate,
48
51
  numChannels: this.numChannels,
52
+ frameSizeMs: this.frameSizeMs,
49
53
  ...(this.ncOptions
50
54
  ? {
51
55
  audioFilterModuleId: this.ncOptions.moduleId,
@@ -1,7 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import type { ReadableStream } from 'node:stream/web';
5
4
  import { log } from '../log.js';
6
5
  import type { DataStream_Chunk } from '../proto/room_pb.js';
7
6
  import { bigIntToNumber } from '../utils.js';
@@ -1,7 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import type { WritableStream } from 'node:stream/web';
5
4
  import type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types.js';
6
5
 
7
6
  class BaseStreamWriter<T, InfoType extends BaseStreamInfo> {
package/src/ffi_client.ts CHANGED
@@ -25,14 +25,18 @@ export enum FfiClientEvent {
25
25
  FfiEvent = 'ffi_event',
26
26
  }
27
27
 
28
- export class FfiClient extends (EventEmitter as new () => TypedEmitter<FfiClientCallbacks>) {
29
- static _client?: FfiClient;
28
+ declare global {
29
+ // eslint-disable-next-line no-var
30
+ var _ffiClientInstance: FfiClient | undefined;
31
+ }
30
32
 
33
+ export class FfiClient extends (EventEmitter as new () => TypedEmitter<FfiClientCallbacks>) {
31
34
  /** @internal */
32
35
  static get instance(): FfiClient {
33
- if (!FfiClient._client) FfiClient._client = new FfiClient();
34
-
35
- return FfiClient._client;
36
+ if (!globalThis._ffiClientInstance) {
37
+ globalThis._ffiClientInstance = new FfiClient();
38
+ }
39
+ return globalThis._ffiClientInstance;
36
40
  }
37
41
 
38
42
  constructor() {