@livekit/rtc-node 0.13.21 → 0.13.23

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 (135) hide show
  1. package/dist/async_queue.cjs +80 -0
  2. package/dist/async_queue.cjs.map +1 -0
  3. package/dist/async_queue.d.cts +30 -0
  4. package/dist/async_queue.d.ts +30 -0
  5. package/dist/async_queue.d.ts.map +1 -0
  6. package/dist/async_queue.js +56 -0
  7. package/dist/async_queue.js.map +1 -0
  8. package/dist/audio_frame.cjs +5 -0
  9. package/dist/audio_frame.cjs.map +1 -1
  10. package/dist/audio_frame.d.cts +3 -0
  11. package/dist/audio_frame.d.ts +3 -0
  12. package/dist/audio_frame.d.ts.map +1 -1
  13. package/dist/audio_frame.js +5 -0
  14. package/dist/audio_frame.js.map +1 -1
  15. package/dist/audio_mixer.cjs +281 -0
  16. package/dist/audio_mixer.cjs.map +1 -0
  17. package/dist/audio_mixer.d.cts +121 -0
  18. package/dist/audio_mixer.d.ts +121 -0
  19. package/dist/audio_mixer.d.ts.map +1 -0
  20. package/dist/audio_mixer.js +256 -0
  21. package/dist/audio_mixer.js.map +1 -0
  22. package/dist/audio_stream.cjs +18 -5
  23. package/dist/audio_stream.cjs.map +1 -1
  24. package/dist/audio_stream.d.cts +4 -3
  25. package/dist/audio_stream.d.ts +4 -3
  26. package/dist/audio_stream.d.ts.map +1 -1
  27. package/dist/audio_stream.js +18 -5
  28. package/dist/audio_stream.js.map +1 -1
  29. package/dist/data_streams/stream_reader.cjs.map +1 -1
  30. package/dist/data_streams/stream_reader.js.map +1 -1
  31. package/dist/frame_processor.cjs +38 -0
  32. package/dist/frame_processor.cjs.map +1 -0
  33. package/dist/frame_processor.d.cts +29 -0
  34. package/dist/frame_processor.d.ts +29 -0
  35. package/dist/frame_processor.d.ts.map +1 -0
  36. package/dist/frame_processor.js +14 -0
  37. package/dist/frame_processor.js.map +1 -0
  38. package/dist/index.cjs +6 -0
  39. package/dist/index.cjs.map +1 -1
  40. package/dist/index.d.cts +3 -0
  41. package/dist/index.d.ts +3 -0
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +6 -0
  44. package/dist/index.js.map +1 -1
  45. package/dist/participant.cjs +4 -4
  46. package/dist/participant.cjs.map +1 -1
  47. package/dist/participant.d.cts +2 -2
  48. package/dist/participant.d.ts +2 -2
  49. package/dist/participant.d.ts.map +1 -1
  50. package/dist/participant.js +4 -4
  51. package/dist/participant.js.map +1 -1
  52. package/dist/proto/audio_frame_pb.cjs.map +1 -1
  53. package/dist/proto/audio_frame_pb.js.map +1 -1
  54. package/dist/proto/e2ee_pb.cjs.map +1 -1
  55. package/dist/proto/e2ee_pb.js.map +1 -1
  56. package/dist/proto/ffi_pb.cjs +4 -2
  57. package/dist/proto/ffi_pb.cjs.map +1 -1
  58. package/dist/proto/ffi_pb.d.cts +13 -1
  59. package/dist/proto/ffi_pb.d.ts +13 -1
  60. package/dist/proto/ffi_pb.d.ts.map +1 -1
  61. package/dist/proto/ffi_pb.js +5 -3
  62. package/dist/proto/ffi_pb.js.map +1 -1
  63. package/dist/proto/handle_pb.cjs.map +1 -1
  64. package/dist/proto/handle_pb.js.map +1 -1
  65. package/dist/proto/participant_pb.cjs +26 -4
  66. package/dist/proto/participant_pb.cjs.map +1 -1
  67. package/dist/proto/participant_pb.d.cts +31 -2
  68. package/dist/proto/participant_pb.d.ts +31 -2
  69. package/dist/proto/participant_pb.d.ts.map +1 -1
  70. package/dist/proto/participant_pb.js +24 -3
  71. package/dist/proto/participant_pb.js.map +1 -1
  72. package/dist/proto/room_pb.cjs +29 -2
  73. package/dist/proto/room_pb.cjs.map +1 -1
  74. package/dist/proto/room_pb.d.cts +30 -7
  75. package/dist/proto/room_pb.d.ts +30 -7
  76. package/dist/proto/room_pb.d.ts.map +1 -1
  77. package/dist/proto/room_pb.js +28 -2
  78. package/dist/proto/room_pb.js.map +1 -1
  79. package/dist/proto/rpc_pb.cjs.map +1 -1
  80. package/dist/proto/rpc_pb.js.map +1 -1
  81. package/dist/proto/stats_pb.cjs.map +1 -1
  82. package/dist/proto/stats_pb.js.map +1 -1
  83. package/dist/proto/track_pb.cjs.map +1 -1
  84. package/dist/proto/track_pb.js.map +1 -1
  85. package/dist/proto/track_publication_pb.cjs +66 -2
  86. package/dist/proto/track_publication_pb.cjs.map +1 -1
  87. package/dist/proto/track_publication_pb.d.cts +56 -1
  88. package/dist/proto/track_publication_pb.d.ts +56 -1
  89. package/dist/proto/track_publication_pb.d.ts.map +1 -1
  90. package/dist/proto/track_publication_pb.js +62 -1
  91. package/dist/proto/track_publication_pb.js.map +1 -1
  92. package/dist/proto/video_frame_pb.cjs +3 -1
  93. package/dist/proto/video_frame_pb.cjs.map +1 -1
  94. package/dist/proto/video_frame_pb.d.cts +5 -1
  95. package/dist/proto/video_frame_pb.d.ts +5 -1
  96. package/dist/proto/video_frame_pb.d.ts.map +1 -1
  97. package/dist/proto/video_frame_pb.js +3 -1
  98. package/dist/proto/video_frame_pb.js.map +1 -1
  99. package/dist/room.cjs +286 -288
  100. package/dist/room.cjs.map +1 -1
  101. package/dist/room.d.cts +11 -11
  102. package/dist/room.d.ts +11 -11
  103. package/dist/room.d.ts.map +1 -1
  104. package/dist/room.js +287 -289
  105. package/dist/room.js.map +1 -1
  106. package/dist/version.cjs +1 -1
  107. package/dist/version.cjs.map +1 -1
  108. package/dist/version.d.cts +1 -1
  109. package/dist/version.d.ts +1 -1
  110. package/dist/version.js +1 -1
  111. package/dist/version.js.map +1 -1
  112. package/package.json +9 -8
  113. package/src/async_queue.test.ts +250 -0
  114. package/src/async_queue.ts +80 -0
  115. package/src/audio_frame.ts +7 -0
  116. package/src/audio_mixer.test.ts +167 -0
  117. package/src/audio_mixer.ts +407 -0
  118. package/src/audio_stream.ts +22 -7
  119. package/src/data_streams/stream_reader.ts +4 -4
  120. package/src/frame_processor.ts +29 -0
  121. package/src/index.ts +6 -0
  122. package/src/participant.ts +5 -5
  123. package/src/proto/audio_frame_pb.ts +1 -1
  124. package/src/proto/e2ee_pb.ts +1 -1
  125. package/src/proto/ffi_pb.ts +16 -2
  126. package/src/proto/handle_pb.ts +1 -1
  127. package/src/proto/participant_pb.ts +45 -1
  128. package/src/proto/room_pb.ts +52 -8
  129. package/src/proto/rpc_pb.ts +1 -1
  130. package/src/proto/stats_pb.ts +1 -1
  131. package/src/proto/track_pb.ts +1 -1
  132. package/src/proto/track_publication_pb.ts +105 -1
  133. package/src/proto/video_frame_pb.ts +7 -1
  134. package/src/room.ts +297 -300
  135. package/src/version.ts +1 -1
@@ -1,4 +1,5 @@
1
1
  import { AudioFrame } from './audio_frame.cjs';
2
+ import { FrameProcessor } from './frame_processor.cjs';
2
3
  import { Track } from './track.cjs';
3
4
  import './proto/audio_frame_pb.cjs';
4
5
  import '@bufbuild/protobuf';
@@ -6,6 +7,8 @@ import './proto/track_pb.cjs';
6
7
  import './proto/stats_pb.cjs';
7
8
  import './proto/e2ee_pb.cjs';
8
9
  import './proto/handle_pb.cjs';
10
+ import './video_frame.cjs';
11
+ import './proto/video_frame_pb.cjs';
9
12
  import './audio_source.cjs';
10
13
  import './napi/native.d.cjs';
11
14
  import './ffi_client.cjs';
@@ -13,15 +16,13 @@ import '@livekit/typed-emitter';
13
16
  import './proto/ffi_pb.cjs';
14
17
  import './proto/room_pb.cjs';
15
18
  import './proto/participant_pb.cjs';
16
- import './proto/video_frame_pb.cjs';
17
19
  import './proto/data_stream_pb.cjs';
18
20
  import './proto/rpc_pb.cjs';
19
21
  import './proto/track_publication_pb.cjs';
20
22
  import './video_source.cjs';
21
- import './video_frame.cjs';
22
23
 
23
24
  interface AudioStreamOptions {
24
- noiseCancellation?: NoiseCancellationOptions;
25
+ noiseCancellation?: NoiseCancellationOptions | FrameProcessor<AudioFrame>;
25
26
  sampleRate?: number;
26
27
  numChannels?: number;
27
28
  frameSizeMs?: number;
@@ -1,4 +1,5 @@
1
1
  import { AudioFrame } from './audio_frame.js';
2
+ import { FrameProcessor } from './frame_processor.js';
2
3
  import { Track } from './track.js';
3
4
  import './proto/audio_frame_pb.js';
4
5
  import '@bufbuild/protobuf';
@@ -6,6 +7,8 @@ import './proto/track_pb.js';
6
7
  import './proto/stats_pb.js';
7
8
  import './proto/e2ee_pb.js';
8
9
  import './proto/handle_pb.js';
10
+ import './video_frame.js';
11
+ import './proto/video_frame_pb.js';
9
12
  import './audio_source.js';
10
13
  import './napi/native.d.js';
11
14
  import './ffi_client.js';
@@ -13,15 +16,13 @@ import '@livekit/typed-emitter';
13
16
  import './proto/ffi_pb.js';
14
17
  import './proto/room_pb.js';
15
18
  import './proto/participant_pb.js';
16
- import './proto/video_frame_pb.js';
17
19
  import './proto/data_stream_pb.js';
18
20
  import './proto/rpc_pb.js';
19
21
  import './proto/track_publication_pb.js';
20
22
  import './video_source.js';
21
- import './video_frame.js';
22
23
 
23
24
  interface AudioStreamOptions {
24
- noiseCancellation?: NoiseCancellationOptions;
25
+ noiseCancellation?: NoiseCancellationOptions | FrameProcessor<AudioFrame>;
25
26
  sampleRate?: number;
26
27
  numChannels?: number;
27
28
  frameSizeMs?: number;
@@ -1 +1 @@
1
- {"version":3,"file":"audio_stream.d.ts","sourceRoot":"","sources":["../src/audio_stream.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAK9C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,kBAAkB;IACjC,iBAAiB,CAAC,EAAE,wBAAwB,CAAC;IAC7C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B;AAsFD,qBAAa,WAAY,SAAQ,cAAc,CAAC,UAAU,CAAC;gBAC7C,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM;gBAChC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;gBACrD,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB;CAQtD"}
1
+ {"version":3,"file":"audio_stream.d.ts","sourceRoot":"","sources":["../src/audio_stream.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExC,MAAM,WAAW,kBAAkB;IACjC,iBAAiB,CAAC,EAAE,wBAAwB,GAAG,cAAc,CAAC,UAAU,CAAC,CAAC;IAC1E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,MAAM,CAAC;IAEjB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B;AAkGD,qBAAa,WAAY,SAAQ,cAAc,CAAC,UAAU,CAAC;gBAC7C,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM;gBAChC,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;gBACrD,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,kBAAkB;CAQtD"}
@@ -1,5 +1,7 @@
1
1
  import { AudioFrame } from "./audio_frame.js";
2
2
  import { FfiClient, FfiClientEvent, FfiHandle } from "./ffi_client.js";
3
+ import { FrameProcessor } from "./frame_processor.js";
4
+ import { log } from "./log.js";
3
5
  import { AudioStreamType, NewAudioStreamRequest } from "./proto/audio_frame_pb.js";
4
6
  class AudioStreamSource {
5
7
  constructor(track, sampleRateOrOptions, numChannels) {
@@ -13,7 +15,14 @@ class AudioStreamSource {
13
15
  const streamEvent = ev.message.value.message;
14
16
  switch (streamEvent.case) {
15
17
  case "frameReceived":
16
- const frame = AudioFrame.fromOwnedInfo(streamEvent.value.frame);
18
+ let frame = AudioFrame.fromOwnedInfo(streamEvent.value.frame);
19
+ if (this.frameProcessor && this.frameProcessor.isEnabled()) {
20
+ try {
21
+ frame = this.frameProcessor.process(frame);
22
+ } catch (err) {
23
+ log.warn(`Frame processing failed, passing through original frame: ${err}`);
24
+ }
25
+ }
17
26
  this.controller.enqueue(frame);
18
27
  break;
19
28
  case "eos":
@@ -25,7 +34,11 @@ class AudioStreamSource {
25
34
  if (sampleRateOrOptions !== void 0 && typeof sampleRateOrOptions !== "number") {
26
35
  this.sampleRate = sampleRateOrOptions.sampleRate ?? 48e3;
27
36
  this.numChannels = sampleRateOrOptions.numChannels ?? 1;
28
- this.ncOptions = sampleRateOrOptions.noiseCancellation;
37
+ if (sampleRateOrOptions.noiseCancellation instanceof FrameProcessor) {
38
+ this.frameProcessor = sampleRateOrOptions.noiseCancellation;
39
+ } else {
40
+ this.legacyNcOptions = sampleRateOrOptions.noiseCancellation;
41
+ }
29
42
  this.frameSizeMs = sampleRateOrOptions.frameSizeMs;
30
43
  } else {
31
44
  this.sampleRate = sampleRateOrOptions ?? 48e3;
@@ -37,9 +50,9 @@ class AudioStreamSource {
37
50
  sampleRate: this.sampleRate,
38
51
  numChannels: this.numChannels,
39
52
  frameSizeMs: this.frameSizeMs,
40
- ...this.ncOptions ? {
41
- audioFilterModuleId: this.ncOptions.moduleId,
42
- audioFilterOptions: JSON.stringify(this.ncOptions.options)
53
+ ...this.legacyNcOptions ? {
54
+ audioFilterModuleId: this.legacyNcOptions.moduleId,
55
+ audioFilterOptions: JSON.stringify(this.legacyNcOptions.options)
43
56
  } : {}
44
57
  });
45
58
  const res = FfiClient.instance.request({
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/audio_stream.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { UnderlyingSource } from 'node:stream/web';\nimport { AudioFrame } from './audio_frame.js';\nimport type { FfiEvent } from './ffi_client.js';\nimport { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';\nimport type { NewAudioStreamResponse } from './proto/audio_frame_pb.js';\nimport { AudioStreamType, NewAudioStreamRequest } from './proto/audio_frame_pb.js';\nimport type { Track } from './track.js';\n\nexport interface AudioStreamOptions {\n noiseCancellation?: NoiseCancellationOptions;\n sampleRate?: number;\n numChannels?: number;\n frameSizeMs?: number;\n}\n\nexport interface NoiseCancellationOptions {\n moduleId: string;\n options: Record<string, any>;\n}\n\nclass AudioStreamSource implements UnderlyingSource<AudioFrame> {\n private controller?: ReadableStreamDefaultController<AudioFrame>;\n private ffiHandle: FfiHandle;\n private sampleRate: number;\n private numChannels: number;\n private ncOptions?: NoiseCancellationOptions;\n private frameSizeMs?: number;\n\n constructor(\n track: Track,\n sampleRateOrOptions?: number | AudioStreamOptions,\n numChannels?: number,\n ) {\n if (sampleRateOrOptions !== undefined && typeof sampleRateOrOptions !== 'number') {\n this.sampleRate = sampleRateOrOptions.sampleRate ?? 48000;\n this.numChannels = sampleRateOrOptions.numChannels ?? 1;\n this.ncOptions = sampleRateOrOptions.noiseCancellation;\n this.frameSizeMs = sampleRateOrOptions.frameSizeMs;\n } else {\n this.sampleRate = (sampleRateOrOptions as number) ?? 48000;\n this.numChannels = numChannels ?? 1;\n }\n\n const req = new NewAudioStreamRequest({\n type: AudioStreamType.AUDIO_STREAM_NATIVE,\n trackHandle: track.ffi_handle.handle,\n sampleRate: this.sampleRate,\n numChannels: this.numChannels,\n frameSizeMs: this.frameSizeMs,\n ...(this.ncOptions\n ? {\n audioFilterModuleId: this.ncOptions.moduleId,\n audioFilterOptions: JSON.stringify(this.ncOptions.options),\n }\n : {}),\n });\n\n const res = FfiClient.instance.request<NewAudioStreamResponse>({\n message: {\n case: 'newAudioStream',\n value: req,\n },\n });\n\n this.ffiHandle = new FfiHandle(res.stream!.handle!.id!);\n\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 != 'audioStreamEvent' ||\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 frame = AudioFrame.fromOwnedInfo(streamEvent.value.frame!);\n this.controller.enqueue(frame);\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<AudioFrame>) {\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 AudioStream extends ReadableStream<AudioFrame> {\n constructor(track: Track);\n constructor(track: Track, sampleRate: number);\n constructor(track: Track, sampleRate: number, numChannels: number);\n constructor(track: Track, options: AudioStreamOptions);\n constructor(\n track: Track,\n sampleRateOrOptions?: number | AudioStreamOptions,\n numChannels?: number,\n ) {\n super(new AudioStreamSource(track, sampleRateOrOptions, numChannels));\n }\n}\n"],"mappings":"AAIA,SAAS,kBAAkB;AAE3B,SAAS,WAAW,gBAAgB,iBAAiB;AAErD,SAAS,iBAAiB,6BAA6B;AAevD,MAAM,kBAA0D;AAAA,EAQ9D,YACE,OACA,qBACA,aACA;AAqCF,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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AK,UAAU,QAAQ;AAAA,EACzB;AACF;AAEO,MAAM,oBAAoB,eAA2B;AAAA,EAK1D,YACE,OACA,qBACA,aACA;AACA,UAAM,IAAI,kBAAkB,OAAO,qBAAqB,WAAW,CAAC;AAAA,EACtE;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/audio_stream.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport type { UnderlyingSource } from 'node:stream/web';\nimport { AudioFrame } from './audio_frame.js';\nimport type { FfiEvent } from './ffi_client.js';\nimport { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';\nimport { FrameProcessor } from './frame_processor.js';\nimport { log } from './log.js';\nimport type { NewAudioStreamResponse } from './proto/audio_frame_pb.js';\nimport { AudioStreamType, NewAudioStreamRequest } from './proto/audio_frame_pb.js';\nimport type { Track } from './track.js';\n\nexport interface AudioStreamOptions {\n noiseCancellation?: NoiseCancellationOptions | FrameProcessor<AudioFrame>;\n sampleRate?: number;\n numChannels?: number;\n frameSizeMs?: number;\n}\n\nexport interface NoiseCancellationOptions {\n moduleId: string;\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n options: Record<string, any>;\n}\n\nclass AudioStreamSource implements UnderlyingSource<AudioFrame> {\n private controller?: ReadableStreamDefaultController<AudioFrame>;\n private ffiHandle: FfiHandle;\n private sampleRate: number;\n private numChannels: number;\n private legacyNcOptions?: NoiseCancellationOptions;\n private frameProcessor?: FrameProcessor<AudioFrame>;\n private frameSizeMs?: number;\n\n constructor(\n track: Track,\n sampleRateOrOptions?: number | AudioStreamOptions,\n numChannels?: number,\n ) {\n if (sampleRateOrOptions !== undefined && typeof sampleRateOrOptions !== 'number') {\n this.sampleRate = sampleRateOrOptions.sampleRate ?? 48000;\n this.numChannels = sampleRateOrOptions.numChannels ?? 1;\n if (sampleRateOrOptions.noiseCancellation instanceof FrameProcessor) {\n this.frameProcessor = sampleRateOrOptions.noiseCancellation;\n } else {\n this.legacyNcOptions = sampleRateOrOptions.noiseCancellation;\n }\n this.frameSizeMs = sampleRateOrOptions.frameSizeMs;\n } else {\n this.sampleRate = (sampleRateOrOptions as number) ?? 48000;\n this.numChannels = numChannels ?? 1;\n }\n\n const req = new NewAudioStreamRequest({\n type: AudioStreamType.AUDIO_STREAM_NATIVE,\n trackHandle: track.ffi_handle.handle,\n sampleRate: this.sampleRate,\n numChannels: this.numChannels,\n frameSizeMs: this.frameSizeMs,\n ...(this.legacyNcOptions\n ? {\n audioFilterModuleId: this.legacyNcOptions.moduleId,\n audioFilterOptions: JSON.stringify(this.legacyNcOptions.options),\n }\n : {}),\n });\n\n const res = FfiClient.instance.request<NewAudioStreamResponse>({\n message: {\n case: 'newAudioStream',\n value: req,\n },\n });\n\n this.ffiHandle = new FfiHandle(res.stream!.handle!.id!);\n\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 != 'audioStreamEvent' ||\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 let frame = AudioFrame.fromOwnedInfo(streamEvent.value.frame!);\n if (this.frameProcessor && this.frameProcessor.isEnabled()) {\n try {\n frame = this.frameProcessor.process(frame);\n } catch (err: unknown) {\n log.warn(`Frame processing failed, passing through original frame: ${err}`);\n }\n }\n this.controller.enqueue(frame);\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<AudioFrame>) {\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 AudioStream extends ReadableStream<AudioFrame> {\n constructor(track: Track);\n constructor(track: Track, sampleRate: number);\n constructor(track: Track, sampleRate: number, numChannels: number);\n constructor(track: Track, options: AudioStreamOptions);\n constructor(\n track: Track,\n sampleRateOrOptions?: number | AudioStreamOptions,\n numChannels?: number,\n ) {\n super(new AudioStreamSource(track, sampleRateOrOptions, numChannels));\n }\n}\n"],"mappings":"AAIA,SAAS,kBAAkB;AAE3B,SAAS,WAAW,gBAAgB,iBAAiB;AACrD,SAAS,sBAAsB;AAC/B,SAAS,WAAW;AAEpB,SAAS,iBAAiB,6BAA6B;AAgBvD,MAAM,kBAA0D;AAAA,EAS9D,YACE,OACA,qBACA,aACA;AAyCF,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,cAAI,QAAQ,WAAW,cAAc,YAAY,MAAM,KAAM;AAC7D,cAAI,KAAK,kBAAkB,KAAK,eAAe,UAAU,GAAG;AAC1D,gBAAI;AACF,sBAAQ,KAAK,eAAe,QAAQ,KAAK;AAAA,YAC3C,SAAS,KAAc;AACrB,kBAAI,KAAK,4DAA4D,GAAG,EAAE;AAAA,YAC5E;AAAA,UACF;AACA,eAAK,WAAW,QAAQ,KAAK;AAC7B;AAAA,QACF,KAAK;AACH,oBAAU,SAAS,IAAI,eAAe,UAAU,KAAK,OAAO;AAC5D,eAAK,WAAW,MAAM;AACtB;AAAA,MACJ;AAAA,IACF;AAtEE,QAAI,wBAAwB,UAAa,OAAO,wBAAwB,UAAU;AAChF,WAAK,aAAa,oBAAoB,cAAc;AACpD,WAAK,cAAc,oBAAoB,eAAe;AACtD,UAAI,oBAAoB,6BAA6B,gBAAgB;AACnE,aAAK,iBAAiB,oBAAoB;AAAA,MAC5C,OAAO;AACL,aAAK,kBAAkB,oBAAoB;AAAA,MAC7C;AACA,WAAK,cAAc,oBAAoB;AAAA,IACzC,OAAO;AACL,WAAK,aAAc,uBAAkC;AACrD,WAAK,cAAc,eAAe;AAAA,IACpC;AAEA,UAAM,MAAM,IAAI,sBAAsB;AAAA,MACpC,MAAM,gBAAgB;AAAA,MACtB,aAAa,MAAM,WAAW;AAAA,MAC9B,YAAY,KAAK;AAAA,MACjB,aAAa,KAAK;AAAA,MAClB,aAAa,KAAK;AAAA,MAClB,GAAI,KAAK,kBACL;AAAA,QACE,qBAAqB,KAAK,gBAAgB;AAAA,QAC1C,oBAAoB,KAAK,UAAU,KAAK,gBAAgB,OAAO;AAAA,MACjE,IACA,CAAC;AAAA,IACP,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;AAEtD,cAAU,SAAS,GAAG,eAAe,UAAU,KAAK,OAAO;AAAA,EAC7D;AAAA,EAkCA,MAAM,YAAyD;AAC7D,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,eAA2B;AAAA,EAK1D,YACE,OACA,qBACA,aACA;AACA,UAAM,IAAI,kBAAkB,OAAO,qBAAqB,WAAW,CAAC;AAAA,EACtE;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/data_streams/stream_reader.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log } from '../log.js';\nimport type { DataStream_Chunk } from '../proto/room_pb.js';\nimport { bigIntToNumber } from '../utils.js';\nimport type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types.js';\n\nabstract class BaseStreamReader<T extends BaseStreamInfo> {\n protected reader: ReadableStream<DataStream_Chunk>;\n\n protected totalByteSize?: number;\n\n protected _info: T;\n\n protected bytesReceived: number;\n\n get info() {\n return this._info;\n }\n\n constructor(info: T, stream: ReadableStream<DataStream_Chunk>, totalByteSize?: number) {\n this.reader = stream;\n this.totalByteSize = totalByteSize;\n this._info = info;\n this.bytesReceived = 0;\n }\n\n protected abstract handleChunkReceived(chunk: DataStream_Chunk): void;\n\n onProgress?: (progress: number | undefined) => void;\n\n abstract readAll(): Promise<string | Array<Uint8Array>>;\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class ByteStreamReader extends BaseStreamReader<ByteStreamInfo> {\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n this.bytesReceived += chunk.content!.byteLength;\n const currentProgress = this.totalByteSize\n ? this.bytesReceived / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n\n return {\n next: async (): Promise<IteratorResult<Uint8Array>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined as any };\n } else {\n this.handleChunkReceived(value);\n return { done: false, value: value.content! };\n }\n } catch (error: any) {\n log.error('error processing stream update: %s', error);\n return { done: true, value: undefined };\n }\n },\n\n return(): IteratorResult<Uint8Array> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<Array<Uint8Array>> {\n const chunks: Set<Uint8Array> = new Set();\n for await (const chunk of this) {\n chunks.add(chunk);\n }\n return Array.from(chunks);\n }\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class TextStreamReader extends BaseStreamReader<TextStreamInfo> {\n private receivedChunks: Map<number, DataStream_Chunk>;\n\n /**\n * A TextStreamReader instance can be used as an AsyncIterator that returns the entire string\n * that has been received up to the current point in time.\n */\n constructor(\n info: TextStreamInfo,\n stream: ReadableStream<DataStream_Chunk>,\n totalChunkCount?: number,\n ) {\n super(info, stream, totalChunkCount);\n this.receivedChunks = new Map();\n }\n\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n const index = bigIntToNumber(chunk.chunkIndex!);\n const previousChunkAtIndex = this.receivedChunks.get(index!);\n if (previousChunkAtIndex && previousChunkAtIndex.version! > chunk.version!) {\n // we have a newer version already, dropping the old one\n return;\n }\n this.receivedChunks.set(index, chunk);\n const currentProgress = this.totalByteSize\n ? this.receivedChunks.size / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n /**\n * Async iterator implementation to allow usage of `for await...of` syntax.\n * Yields structured chunks from the stream.\n *\n */\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n const decoder = new TextDecoder();\n\n return {\n next: async (): Promise<IteratorResult<string>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined };\n } else {\n this.handleChunkReceived(value);\n return {\n done: false,\n value: decoder.decode(value.content!),\n };\n }\n } catch (error: any) {\n log.error('error processing stream update: %s', error);\n return { done: true, value: undefined };\n }\n },\n\n return(): IteratorResult<string> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<string> {\n let finalString: string = '';\n for await (const chunk of this) {\n finalString += chunk;\n }\n return finalString;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAoB;AAEpB,mBAA+B;AAG/B,MAAe,iBAA2C;AAAA,EASxD,IAAI,OAAO;AACT,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAY,MAAS,QAA0C,eAAwB;AACrF,SAAK,SAAS;AACd,SAAK,gBAAgB;AACrB,SAAK,QAAQ;AACb,SAAK,gBAAgB;AAAA,EACvB;AAOF;AAKO,MAAM,yBAAyB,iBAAiC;AAAA,EAC3D,oBAAoB,OAA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E1E;AAAA,IACF;AACA,SAAK,eAAe,IAAI,OAAO,KAAK;AACpC,UAAM,kBAAkB,KAAK,gBACzB,KAAK,eAAe,OAAO,KAAK,gBAChC;AACJ,eAAK,eAAL,8BAAkB;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,CAAC,OAAO,aAAa,IAAI;AACvB,UAAM,SAAS,KAAK,OAAO,UAAU;AACrC,UAAM,UAAU,IAAI,YAAY;AAEhC,WAAO;AAAA,MACL,MAAM,YAA6C;AACjD,YAAI;AACF,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,cAAI,MAAM;AACR,mBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,UACxC,OAAO;AACL,iBAAK,oBAAoB,KAAK;AAC9B,mBAAO;AAAA,cACL,MAAM;AAAA,cACN,OAAO,QAAQ,OAAO,MAAM,OAAQ;AAAA,YACtC;AAAA,UACF;AAAA,QACF,SAAS,OAAY;AACnB,yBAAI,MAAM,sCAAsC,KAAK;AACrD,iBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,QACxC;AAAA,MACF;AAAA,MAEA,SAAiC;AAC/B,eAAO,YAAY;AACnB,eAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,UAA2B;AAC/B,QAAI,cAAsB;AAC1B,qBAAiB,SAAS,MAAM;AAC9B,qBAAe;AAAA,IACjB;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/data_streams/stream_reader.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log } from '../log.js';\nimport type { DataStream_Chunk } from '../proto/room_pb.js';\nimport { bigIntToNumber } from '../utils.js';\nimport type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types.js';\n\nabstract class BaseStreamReader<T extends BaseStreamInfo> {\n protected reader: ReadableStream<DataStream_Chunk>;\n\n protected totalByteSize?: number;\n\n protected _info: T;\n\n protected bytesReceived: number;\n\n get info() {\n return this._info;\n }\n\n constructor(info: T, stream: ReadableStream<DataStream_Chunk>, totalByteSize?: number) {\n this.reader = stream;\n this.totalByteSize = totalByteSize;\n this._info = info;\n this.bytesReceived = 0;\n }\n\n protected abstract handleChunkReceived(chunk: DataStream_Chunk): void;\n\n onProgress?: (progress: number | undefined) => void;\n\n abstract readAll(): Promise<string | Array<Uint8Array>>;\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class ByteStreamReader extends BaseStreamReader<ByteStreamInfo> {\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n this.bytesReceived += chunk.content!.byteLength;\n const currentProgress = this.totalByteSize\n ? this.bytesReceived / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n\n return {\n next: async (): Promise<IteratorResult<Uint8Array>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined as unknown };\n } else {\n this.handleChunkReceived(value);\n return { done: false, value: value.content! };\n }\n } catch (error: unknown) {\n log.error('error processing stream update: %s', error);\n return { done: true, value: undefined as unknown };\n }\n },\n\n return(): IteratorResult<Uint8Array> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<Array<Uint8Array>> {\n const chunks: Set<Uint8Array> = new Set();\n for await (const chunk of this) {\n chunks.add(chunk);\n }\n return Array.from(chunks);\n }\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class TextStreamReader extends BaseStreamReader<TextStreamInfo> {\n private receivedChunks: Map<number, DataStream_Chunk>;\n\n /**\n * A TextStreamReader instance can be used as an AsyncIterator that returns the entire string\n * that has been received up to the current point in time.\n */\n constructor(\n info: TextStreamInfo,\n stream: ReadableStream<DataStream_Chunk>,\n totalChunkCount?: number,\n ) {\n super(info, stream, totalChunkCount);\n this.receivedChunks = new Map();\n }\n\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n const index = bigIntToNumber(chunk.chunkIndex!);\n const previousChunkAtIndex = this.receivedChunks.get(index!);\n if (previousChunkAtIndex && previousChunkAtIndex.version! > chunk.version!) {\n // we have a newer version already, dropping the old one\n return;\n }\n this.receivedChunks.set(index, chunk);\n const currentProgress = this.totalByteSize\n ? this.receivedChunks.size / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n /**\n * Async iterator implementation to allow usage of `for await...of` syntax.\n * Yields structured chunks from the stream.\n *\n */\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n const decoder = new TextDecoder();\n\n return {\n next: async (): Promise<IteratorResult<string>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined };\n } else {\n this.handleChunkReceived(value);\n return {\n done: false,\n value: decoder.decode(value.content!),\n };\n }\n } catch (error: unknown) {\n log.error('error processing stream update: %s', error);\n return { done: true, value: undefined };\n }\n },\n\n return(): IteratorResult<string> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<string> {\n let finalString: string = '';\n for await (const chunk of this) {\n finalString += chunk;\n }\n return finalString;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,iBAAoB;AAEpB,mBAA+B;AAG/B,MAAe,iBAA2C;AAAA,EASxD,IAAI,OAAO;AACT,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAY,MAAS,QAA0C,eAAwB;AACrF,SAAK,SAAS;AACd,SAAK,gBAAgB;AACrB,SAAK,QAAQ;AACb,SAAK,gBAAgB;AAAA,EACvB;AAOF;AAKO,MAAM,yBAAyB,iBAAiC;AAAA,EAC3D,oBAAoB,OAAyB;AAvCzD;AAwCI,SAAK,iBAAiB,MAAM,QAAS;AACrC,UAAM,kBAAk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kBAAkB,KAAK,gBACzB,KAAK,eAAe,OAAO,KAAK,gBAChC;AACJ,eAAK,eAAL,8BAAkB;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,CAAC,OAAO,aAAa,IAAI;AACvB,UAAM,SAAS,KAAK,OAAO,UAAU;AACrC,UAAM,UAAU,IAAI,YAAY;AAEhC,WAAO;AAAA,MACL,MAAM,YAA6C;AACjD,YAAI;AACF,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,cAAI,MAAM;AACR,mBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,UACxC,OAAO;AACL,iBAAK,oBAAoB,KAAK;AAC9B,mBAAO;AAAA,cACL,MAAM;AAAA,cACN,OAAO,QAAQ,OAAO,MAAM,OAAQ;AAAA,YACtC;AAAA,UACF;AAAA,QACF,SAAS,OAAgB;AACvB,yBAAI,MAAM,sCAAsC,KAAK;AACrD,iBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,QACxC;AAAA,MACF;AAAA,MAEA,SAAiC;AAC/B,eAAO,YAAY;AACnB,eAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,UAA2B;AAC/B,QAAI,cAAsB;AAC1B,qBAAiB,SAAS,MAAM;AAC9B,qBAAe;AAAA,IACjB;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/data_streams/stream_reader.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log } from '../log.js';\nimport type { DataStream_Chunk } from '../proto/room_pb.js';\nimport { bigIntToNumber } from '../utils.js';\nimport type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types.js';\n\nabstract class BaseStreamReader<T extends BaseStreamInfo> {\n protected reader: ReadableStream<DataStream_Chunk>;\n\n protected totalByteSize?: number;\n\n protected _info: T;\n\n protected bytesReceived: number;\n\n get info() {\n return this._info;\n }\n\n constructor(info: T, stream: ReadableStream<DataStream_Chunk>, totalByteSize?: number) {\n this.reader = stream;\n this.totalByteSize = totalByteSize;\n this._info = info;\n this.bytesReceived = 0;\n }\n\n protected abstract handleChunkReceived(chunk: DataStream_Chunk): void;\n\n onProgress?: (progress: number | undefined) => void;\n\n abstract readAll(): Promise<string | Array<Uint8Array>>;\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class ByteStreamReader extends BaseStreamReader<ByteStreamInfo> {\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n this.bytesReceived += chunk.content!.byteLength;\n const currentProgress = this.totalByteSize\n ? this.bytesReceived / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n\n return {\n next: async (): Promise<IteratorResult<Uint8Array>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined as any };\n } else {\n this.handleChunkReceived(value);\n return { done: false, value: value.content! };\n }\n } catch (error: any) {\n log.error('error processing stream update: %s', error);\n return { done: true, value: undefined };\n }\n },\n\n return(): IteratorResult<Uint8Array> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<Array<Uint8Array>> {\n const chunks: Set<Uint8Array> = new Set();\n for await (const chunk of this) {\n chunks.add(chunk);\n }\n return Array.from(chunks);\n }\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class TextStreamReader extends BaseStreamReader<TextStreamInfo> {\n private receivedChunks: Map<number, DataStream_Chunk>;\n\n /**\n * A TextStreamReader instance can be used as an AsyncIterator that returns the entire string\n * that has been received up to the current point in time.\n */\n constructor(\n info: TextStreamInfo,\n stream: ReadableStream<DataStream_Chunk>,\n totalChunkCount?: number,\n ) {\n super(info, stream, totalChunkCount);\n this.receivedChunks = new Map();\n }\n\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n const index = bigIntToNumber(chunk.chunkIndex!);\n const previousChunkAtIndex = this.receivedChunks.get(index!);\n if (previousChunkAtIndex && previousChunkAtIndex.version! > chunk.version!) {\n // we have a newer version already, dropping the old one\n return;\n }\n this.receivedChunks.set(index, chunk);\n const currentProgress = this.totalByteSize\n ? this.receivedChunks.size / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n /**\n * Async iterator implementation to allow usage of `for await...of` syntax.\n * Yields structured chunks from the stream.\n *\n */\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n const decoder = new TextDecoder();\n\n return {\n next: async (): Promise<IteratorResult<string>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined };\n } else {\n this.handleChunkReceived(value);\n return {\n done: false,\n value: decoder.decode(value.content!),\n };\n }\n } catch (error: any) {\n log.error('error processing stream update: %s', error);\n return { done: true, value: undefined };\n }\n },\n\n return(): IteratorResult<string> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<string> {\n let finalString: string = '';\n for await (const chunk of this) {\n finalString += chunk;\n }\n return finalString;\n }\n}\n"],"mappings":"AAGA,SAAS,WAAW;AAEpB,SAAS,sBAAsB;AAG/B,MAAe,iBAA2C;AAAA,EASxD,IAAI,OAAO;AACT,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAY,MAAS,QAA0C,eAAwB;AACrF,SAAK,SAAS;AACd,SAAK,gBAAgB;AACrB,SAAK,QAAQ;AACb,SAAK,gBAAgB;AAAA,EACvB;AAOF;AAKO,MAAM,yBAAyB,iBAAiC;AAAA,EAC3D,oBAAoB,OAAyB;AAvCzD;AAwCI,SAAK,iBAAiB,MAAM,QAAS;AACrC,UAAM,kBAAkB,KAAK,gBACzB,KAAK,gBAAgB,KAAK,gBAC1B;AACJ,eAAK,eAAL,8BAAkB;AAAA,EACpB;AAAA,EAEA,CAAC,OAAO,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AAA;AAAA;AAAA,EAOA,CAAC,OAAO,aAAa,IAAI;AACvB,UAAM,SAAS,KAAK,OAAO,UAAU;AACrC,UAAM,UAAU,IAAI,YAAY;AAEhC,WAAO;AAAA,MACL,MAAM,YAA6C;AACjD,YAAI;AACF,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,cAAI,MAAM;AACR,mBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,UACxC,OAAO;AACL,iBAAK,oBAAoB,KAAK;AAC9B,mBAAO;AAAA,cACL,MAAM;AAAA,cACN,OAAO,QAAQ,OAAO,MAAM,OAAQ;AAAA,YACtC;AAAA,UACF;AAAA,QACF,SAAS,OAAY;AACnB,cAAI,MAAM,sCAAsC,KAAK;AACrD,iBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,QACxC;AAAA,MACF;AAAA,MAEA,SAAiC;AAC/B,eAAO,YAAY;AACnB,eAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,UAA2B;AAC/B,QAAI,cAAsB;AAC1B,qBAAiB,SAAS,MAAM;AAC9B,qBAAe;AAAA,IACjB;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
1
+ {"version":3,"sources":["../../src/data_streams/stream_reader.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { log } from '../log.js';\nimport type { DataStream_Chunk } from '../proto/room_pb.js';\nimport { bigIntToNumber } from '../utils.js';\nimport type { BaseStreamInfo, ByteStreamInfo, TextStreamInfo } from './types.js';\n\nabstract class BaseStreamReader<T extends BaseStreamInfo> {\n protected reader: ReadableStream<DataStream_Chunk>;\n\n protected totalByteSize?: number;\n\n protected _info: T;\n\n protected bytesReceived: number;\n\n get info() {\n return this._info;\n }\n\n constructor(info: T, stream: ReadableStream<DataStream_Chunk>, totalByteSize?: number) {\n this.reader = stream;\n this.totalByteSize = totalByteSize;\n this._info = info;\n this.bytesReceived = 0;\n }\n\n protected abstract handleChunkReceived(chunk: DataStream_Chunk): void;\n\n onProgress?: (progress: number | undefined) => void;\n\n abstract readAll(): Promise<string | Array<Uint8Array>>;\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class ByteStreamReader extends BaseStreamReader<ByteStreamInfo> {\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n this.bytesReceived += chunk.content!.byteLength;\n const currentProgress = this.totalByteSize\n ? this.bytesReceived / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n\n return {\n next: async (): Promise<IteratorResult<Uint8Array>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined as unknown };\n } else {\n this.handleChunkReceived(value);\n return { done: false, value: value.content! };\n }\n } catch (error: unknown) {\n log.error('error processing stream update: %s', error);\n return { done: true, value: undefined as unknown };\n }\n },\n\n return(): IteratorResult<Uint8Array> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<Array<Uint8Array>> {\n const chunks: Set<Uint8Array> = new Set();\n for await (const chunk of this) {\n chunks.add(chunk);\n }\n return Array.from(chunks);\n }\n}\n\n/**\n * A class to read chunks from a ReadableStream and provide them in a structured format.\n */\nexport class TextStreamReader extends BaseStreamReader<TextStreamInfo> {\n private receivedChunks: Map<number, DataStream_Chunk>;\n\n /**\n * A TextStreamReader instance can be used as an AsyncIterator that returns the entire string\n * that has been received up to the current point in time.\n */\n constructor(\n info: TextStreamInfo,\n stream: ReadableStream<DataStream_Chunk>,\n totalChunkCount?: number,\n ) {\n super(info, stream, totalChunkCount);\n this.receivedChunks = new Map();\n }\n\n protected handleChunkReceived(chunk: DataStream_Chunk) {\n const index = bigIntToNumber(chunk.chunkIndex!);\n const previousChunkAtIndex = this.receivedChunks.get(index!);\n if (previousChunkAtIndex && previousChunkAtIndex.version! > chunk.version!) {\n // we have a newer version already, dropping the old one\n return;\n }\n this.receivedChunks.set(index, chunk);\n const currentProgress = this.totalByteSize\n ? this.receivedChunks.size / this.totalByteSize\n : undefined;\n this.onProgress?.(currentProgress);\n }\n\n /**\n * Async iterator implementation to allow usage of `for await...of` syntax.\n * Yields structured chunks from the stream.\n *\n */\n [Symbol.asyncIterator]() {\n const reader = this.reader.getReader();\n const decoder = new TextDecoder();\n\n return {\n next: async (): Promise<IteratorResult<string>> => {\n try {\n const { done, value } = await reader.read();\n if (done) {\n return { done: true, value: undefined };\n } else {\n this.handleChunkReceived(value);\n return {\n done: false,\n value: decoder.decode(value.content!),\n };\n }\n } catch (error: unknown) {\n log.error('error processing stream update: %s', error);\n return { done: true, value: undefined };\n }\n },\n\n return(): IteratorResult<string> {\n reader.releaseLock();\n return { done: true, value: undefined };\n },\n };\n }\n\n async readAll(): Promise<string> {\n let finalString: string = '';\n for await (const chunk of this) {\n finalString += chunk;\n }\n return finalString;\n }\n}\n"],"mappings":"AAGA,SAAS,WAAW;AAEpB,SAAS,sBAAsB;AAG/B,MAAe,iBAA2C;AAAA,EASxD,IAAI,OAAO;AACT,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,YAAY,MAAS,QAA0C,eAAwB;AACrF,SAAK,SAAS;AACd,SAAK,gBAAgB;AACrB,SAAK,QAAQ;AACb,SAAK,gBAAgB;AAAA,EACvB;AAOF;AAKO,MAAM,yBAAyB,iBAAiC;AAAA,EAC3D,oBAAoB,OAAyB;AAvCzD;AAwCI,SAAK,iBAAiB,MAAM,QAAS;AACrC,UAAM,kBAAkB,KAAK,gBACzB,KAAK,gBAAgB,KAAK,gBAC1B;AACJ,eAAK,eAAL,8BAAkB;AAAA,EACpB;AAAA,EAEA,CAAC,OAAO,aAAa,IAAI;AACvB,UAAM,SAAS,KAAK,OAAO,UAAU;AAErC,WAAO;AAAA,MACL,MAAM,YAAiD;AACrD,YAAI;AACF,gBAAM,EAAE,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AAEhC,WAAO;AAAA,MACL,MAAM,YAA6C;AACjD,YAAI;AACF,gBAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAC1C,cAAI,MAAM;AACR,mBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,UACxC,OAAO;AACL,iBAAK,oBAAoB,KAAK;AAC9B,mBAAO;AAAA,cACL,MAAM;AAAA,cACN,OAAO,QAAQ,OAAO,MAAM,OAAQ;AAAA,YACtC;AAAA,UACF;AAAA,QACF,SAAS,OAAgB;AACvB,cAAI,MAAM,sCAAsC,KAAK;AACrD,iBAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,QACxC;AAAA,MACF;AAAA,MAEA,SAAiC;AAC/B,eAAO,YAAY;AACnB,eAAO,EAAE,MAAM,MAAM,OAAO,OAAU;AAAA,MACxC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,MAAM,UAA2B;AAC/B,QAAI,cAAsB;AAC1B,qBAAiB,SAAS,MAAM;AAC9B,qBAAe;AAAA,IACjB;AACA,WAAO;AAAA,EACT;AACF;","names":[]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var frame_processor_exports = {};
20
+ __export(frame_processor_exports, {
21
+ FrameProcessor: () => FrameProcessor
22
+ });
23
+ module.exports = __toCommonJS(frame_processor_exports);
24
+ var import_audio_frame = require("./audio_frame.cjs");
25
+ var import_video_frame = require("./video_frame.cjs");
26
+ class FrameProcessor {
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ onStreamInfoUpdated(_info) {
29
+ }
30
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
31
+ onCredentialsUpdated(_credentials) {
32
+ }
33
+ }
34
+ // Annotate the CommonJS export names for ESM import in node:
35
+ 0 && (module.exports = {
36
+ FrameProcessor
37
+ });
38
+ //# sourceMappingURL=frame_processor.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/frame_processor.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { type AudioFrame } from './audio_frame.js';\nimport { type VideoFrame } from './video_frame.js';\n\nexport type FrameProcessorStreamInfo = {\n roomName: string;\n participantIdentity: string;\n publicationSid: string;\n};\n\nexport type FrameProcessorCredentials = {\n token: string;\n url: string;\n};\n\nexport abstract class FrameProcessor<Frame extends VideoFrame | AudioFrame> {\n abstract isEnabled(): boolean;\n abstract setEnabled(enabled: boolean): void;\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onStreamInfoUpdated(_info: FrameProcessorStreamInfo): void {}\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onCredentialsUpdated(_credentials: FrameProcessorCredentials): void {}\n\n abstract process(frame: Frame): Frame;\n abstract close(): void;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAgC;AAChC,yBAAgC;AAazB,MAAe,eAAsD;AAAA;AAAA,EAK1E,oBAAoB,OAAuC;AAAA,EAAC;AAAA;AAAA,EAE5D,qBAAqB,cAA+C;AAAA,EAAC;AAIvE;","names":[]}
@@ -0,0 +1,29 @@
1
+ import { AudioFrame } from './audio_frame.cjs';
2
+ import { VideoFrame } from './video_frame.cjs';
3
+ import './proto/audio_frame_pb.cjs';
4
+ import '@bufbuild/protobuf';
5
+ import './proto/track_pb.cjs';
6
+ import './proto/stats_pb.cjs';
7
+ import './proto/e2ee_pb.cjs';
8
+ import './proto/handle_pb.cjs';
9
+ import './proto/video_frame_pb.cjs';
10
+
11
+ type FrameProcessorStreamInfo = {
12
+ roomName: string;
13
+ participantIdentity: string;
14
+ publicationSid: string;
15
+ };
16
+ type FrameProcessorCredentials = {
17
+ token: string;
18
+ url: string;
19
+ };
20
+ declare abstract class FrameProcessor<Frame extends VideoFrame | AudioFrame> {
21
+ abstract isEnabled(): boolean;
22
+ abstract setEnabled(enabled: boolean): void;
23
+ onStreamInfoUpdated(_info: FrameProcessorStreamInfo): void;
24
+ onCredentialsUpdated(_credentials: FrameProcessorCredentials): void;
25
+ abstract process(frame: Frame): Frame;
26
+ abstract close(): void;
27
+ }
28
+
29
+ export { FrameProcessor, type FrameProcessorCredentials, type FrameProcessorStreamInfo };
@@ -0,0 +1,29 @@
1
+ import { AudioFrame } from './audio_frame.js';
2
+ import { VideoFrame } from './video_frame.js';
3
+ import './proto/audio_frame_pb.js';
4
+ import '@bufbuild/protobuf';
5
+ import './proto/track_pb.js';
6
+ import './proto/stats_pb.js';
7
+ import './proto/e2ee_pb.js';
8
+ import './proto/handle_pb.js';
9
+ import './proto/video_frame_pb.js';
10
+
11
+ type FrameProcessorStreamInfo = {
12
+ roomName: string;
13
+ participantIdentity: string;
14
+ publicationSid: string;
15
+ };
16
+ type FrameProcessorCredentials = {
17
+ token: string;
18
+ url: string;
19
+ };
20
+ declare abstract class FrameProcessor<Frame extends VideoFrame | AudioFrame> {
21
+ abstract isEnabled(): boolean;
22
+ abstract setEnabled(enabled: boolean): void;
23
+ onStreamInfoUpdated(_info: FrameProcessorStreamInfo): void;
24
+ onCredentialsUpdated(_credentials: FrameProcessorCredentials): void;
25
+ abstract process(frame: Frame): Frame;
26
+ abstract close(): void;
27
+ }
28
+
29
+ export { FrameProcessor, type FrameProcessorCredentials, type FrameProcessorStreamInfo };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame_processor.d.ts","sourceRoot":"","sources":["../src/frame_processor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,MAAM,MAAM,wBAAwB,GAAG;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,yBAAyB,GAAG;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;CACb,CAAC;AAEF,8BAAsB,cAAc,CAAC,KAAK,SAAS,UAAU,GAAG,UAAU;IACxE,QAAQ,CAAC,SAAS,IAAI,OAAO;IAC7B,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAG3C,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,GAAG,IAAI;IAE1D,oBAAoB,CAAC,YAAY,EAAE,yBAAyB,GAAG,IAAI;IAEnE,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK;IACrC,QAAQ,CAAC,KAAK,IAAI,IAAI;CACvB"}
@@ -0,0 +1,14 @@
1
+ import {} from "./audio_frame.js";
2
+ import {} from "./video_frame.js";
3
+ class FrameProcessor {
4
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
+ onStreamInfoUpdated(_info) {
6
+ }
7
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
+ onCredentialsUpdated(_credentials) {
9
+ }
10
+ }
11
+ export {
12
+ FrameProcessor
13
+ };
14
+ //# sourceMappingURL=frame_processor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/frame_processor.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2025 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { type AudioFrame } from './audio_frame.js';\nimport { type VideoFrame } from './video_frame.js';\n\nexport type FrameProcessorStreamInfo = {\n roomName: string;\n participantIdentity: string;\n publicationSid: string;\n};\n\nexport type FrameProcessorCredentials = {\n token: string;\n url: string;\n};\n\nexport abstract class FrameProcessor<Frame extends VideoFrame | AudioFrame> {\n abstract isEnabled(): boolean;\n abstract setEnabled(enabled: boolean): void;\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onStreamInfoUpdated(_info: FrameProcessorStreamInfo): void {}\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onCredentialsUpdated(_credentials: FrameProcessorCredentials): void {}\n\n abstract process(frame: Frame): Frame;\n abstract close(): void;\n}\n"],"mappings":"AAGA,eAAgC;AAChC,eAAgC;AAazB,MAAe,eAAsD;AAAA;AAAA,EAK1E,oBAAoB,OAAuC;AAAA,EAAC;AAAA;AAAA,EAE5D,qBAAqB,cAA+C;AAAA,EAAC;AAIvE;","names":[]}
package/dist/index.cjs CHANGED
@@ -21,6 +21,7 @@ var index_exports = {};
21
21
  __export(index_exports, {
22
22
  AudioFilter: () => import_audio_filter.AudioFilter,
23
23
  AudioFrame: () => import_audio_frame.AudioFrame,
24
+ AudioMixer: () => import_audio_mixer.AudioMixer,
24
25
  AudioResampler: () => import_audio_resampler.AudioResampler,
25
26
  AudioResamplerQuality: () => import_audio_resampler.AudioResamplerQuality,
26
27
  AudioSource: () => import_audio_source.AudioSource,
@@ -35,6 +36,7 @@ __export(index_exports, {
35
36
  EncryptionState: () => import_e2ee_pb.EncryptionState,
36
37
  EncryptionType: () => import_e2ee_pb.EncryptionType,
37
38
  FrameCryptor: () => import_e2ee.FrameCryptor,
39
+ FrameProcessor: () => import_frame_processor.FrameProcessor,
38
40
  IceServer: () => import_room_pb.IceServer,
39
41
  IceTransportType: () => import_room_pb.IceTransportType,
40
42
  KeyProvider: () => import_e2ee.KeyProvider,
@@ -72,6 +74,7 @@ var import_audio_resampler = require("./audio_resampler.cjs");
72
74
  var import_audio_source = require("./audio_source.cjs");
73
75
  var import_audio_stream = require("./audio_stream.cjs");
74
76
  var import_audio_filter = require("./audio_filter.cjs");
77
+ var import_audio_mixer = require("./audio_mixer.cjs");
75
78
  __reExport(index_exports, require("./data_streams/index.cjs"), module.exports);
76
79
  var import_e2ee = require("./e2ee.cjs");
77
80
  var import_ffi_client = require("./ffi_client.cjs");
@@ -88,10 +91,12 @@ var import_track_publication = require("./track_publication.cjs");
88
91
  var import_video_frame = require("./video_frame.cjs");
89
92
  var import_video_source = require("./video_source.cjs");
90
93
  var import_video_stream = require("./video_stream.cjs");
94
+ var import_frame_processor = require("./frame_processor.cjs");
91
95
  // Annotate the CommonJS export names for ESM import in node:
92
96
  0 && (module.exports = {
93
97
  AudioFilter,
94
98
  AudioFrame,
99
+ AudioMixer,
95
100
  AudioResampler,
96
101
  AudioResamplerQuality,
97
102
  AudioSource,
@@ -106,6 +111,7 @@ var import_video_stream = require("./video_stream.cjs");
106
111
  EncryptionState,
107
112
  EncryptionType,
108
113
  FrameCryptor,
114
+ FrameProcessor,
109
115
  IceServer,
110
116
  IceTransportType,
111
117
  KeyProvider,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { AudioSource } from './audio_source.js';\nexport { AudioStream } from './audio_stream.js';\nexport type { NoiseCancellationOptions } from './audio_stream.js';\nexport { AudioFilter } from './audio_filter.js';\nexport * from './data_streams/index.js';\nexport { E2EEManager, FrameCryptor, KeyProvider } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport { dispose } from './ffi_client.js';\nexport { LocalParticipant, Participant, RemoteParticipant } from './participant.js';\nexport { EncryptionState, EncryptionType } from './proto/e2ee_pb.js';\nexport { DisconnectReason, ParticipantKind } from './proto/participant_pb.js';\nexport {\n ConnectionQuality,\n ConnectionState,\n ContinualGatheringPolicy,\n DataPacketKind,\n IceServer,\n IceTransportType,\n TrackPublishOptions,\n} from './proto/room_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoCodec, VideoRotation } from './proto/video_frame_pb.js';\nexport { ConnectError, Room, RoomEvent, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { RpcError, type PerformRpcParams, type RpcInvocationData } from './rpc.js';\nexport {\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n Track,\n type AudioTrack,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n} from './track.js';\nexport {\n LocalTrackPublication,\n RemoteTrackPublication,\n TrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport type { ChatMessage } from './types.js';\nexport { VideoFrame } from './video_frame.js';\nexport { VideoSource } from './video_source.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,yBAA+C;AAC/C,6BAAsD;AACtD,0BAA4B;AAC5B,0BAA4B;AAE5B,0BAA4B;AAC5B,0BAAc,oCAVd;AAWA,kBAAuD;AAEvD,wBAAwB;AACxB,yBAAiE;AACjE,qBAAgD;AAChD,4BAAkD;AAClD,qBAQO;AACP,sBAAoD;AACpD,4BAA2D;AAC3D,kBAAuF;AACvF,iBAAwE;AACxE,mBAUO;AACP,+BAIO;AAGP,yBAA2B;AAC3B,0BAA4B;AAC5B,0BAAkD;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { AudioSource } from './audio_source.js';\nexport { AudioStream } from './audio_stream.js';\nexport type { NoiseCancellationOptions } from './audio_stream.js';\nexport { AudioFilter } from './audio_filter.js';\nexport { AudioMixer, type AudioMixerOptions } from './audio_mixer.js';\nexport * from './data_streams/index.js';\nexport { E2EEManager, FrameCryptor, KeyProvider } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport { dispose } from './ffi_client.js';\nexport { LocalParticipant, Participant, RemoteParticipant } from './participant.js';\nexport { EncryptionState, EncryptionType } from './proto/e2ee_pb.js';\nexport { DisconnectReason, ParticipantKind } from './proto/participant_pb.js';\nexport {\n ConnectionQuality,\n ConnectionState,\n ContinualGatheringPolicy,\n DataPacketKind,\n IceServer,\n IceTransportType,\n TrackPublishOptions,\n} from './proto/room_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoCodec, VideoRotation } from './proto/video_frame_pb.js';\nexport { ConnectError, Room, RoomEvent, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { RpcError, type PerformRpcParams, type RpcInvocationData } from './rpc.js';\nexport {\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n Track,\n type AudioTrack,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n} from './track.js';\nexport {\n LocalTrackPublication,\n RemoteTrackPublication,\n TrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport type { ChatMessage } from './types.js';\nexport { VideoFrame } from './video_frame.js';\nexport { VideoSource } from './video_source.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\nexport {\n FrameProcessor,\n type FrameProcessorStreamInfo,\n type FrameProcessorCredentials,\n} from './frame_processor.js';\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,yBAA+C;AAC/C,6BAAsD;AACtD,0BAA4B;AAC5B,0BAA4B;AAE5B,0BAA4B;AAC5B,yBAAmD;AACnD,0BAAc,oCAXd;AAYA,kBAAuD;AAEvD,wBAAwB;AACxB,yBAAiE;AACjE,qBAAgD;AAChD,4BAAkD;AAClD,qBAQO;AACP,sBAAoD;AACpD,4BAA2D;AAC3D,kBAAuF;AACvF,iBAAwE;AACxE,mBAUO;AACP,+BAIO;AAGP,yBAA2B;AAC3B,0BAA4B;AAC5B,0BAAkD;AAClD,6BAIO;","names":[]}
package/dist/index.d.cts CHANGED
@@ -3,6 +3,7 @@ export { AudioResampler, AudioResamplerQuality } from './audio_resampler.cjs';
3
3
  export { AudioSource } from './audio_source.cjs';
4
4
  export { AudioStream, NoiseCancellationOptions } from './audio_stream.cjs';
5
5
  export { AudioFilter } from './audio_filter.cjs';
6
+ export { AudioMixer, AudioMixerOptions } from './audio_mixer.cjs';
6
7
  export { a as BaseStreamInfo, f as ByteStreamHandler, b as ByteStreamInfo, e as ByteStreamOptions, B as ByteStreamReader, D as DataStreamOptions, S as StreamController, g as TextStreamHandler, c as TextStreamInfo, d as TextStreamOptions, T as TextStreamReader } from './stream_reader-Ch2zvjU3.cjs';
7
8
  export { ByteStreamWriter, TextStreamWriter } from './data_streams/stream_writer.cjs';
8
9
  export { E2EEManager, E2EEOptions, FrameCryptor, KeyProvider, KeyProviderOptions } from './e2ee.cjs';
@@ -22,10 +23,12 @@ export { ChatMessage } from './types.cjs';
22
23
  export { VideoFrame } from './video_frame.cjs';
23
24
  export { VideoSource } from './video_source.cjs';
24
25
  export { VideoFrameEvent, VideoStream } from './video_stream.cjs';
26
+ export { FrameProcessor, FrameProcessorCredentials, FrameProcessorStreamInfo } from './frame_processor.cjs';
25
27
  export { livekitDispose as dispose } from './napi/native.d.cjs';
26
28
  import './proto/audio_frame_pb.cjs';
27
29
  import '@bufbuild/protobuf';
28
30
  import './proto/handle_pb.cjs';
31
+ import './async_queue.cjs';
29
32
  import '@livekit/typed-emitter';
30
33
  import './proto/ffi_pb.cjs';
31
34
  import './proto/rpc_pb.cjs';
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ export { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';
3
3
  export { AudioSource } from './audio_source.js';
4
4
  export { AudioStream, NoiseCancellationOptions } from './audio_stream.js';
5
5
  export { AudioFilter } from './audio_filter.js';
6
+ export { AudioMixer, AudioMixerOptions } from './audio_mixer.js';
6
7
  export { a as BaseStreamInfo, f as ByteStreamHandler, b as ByteStreamInfo, e as ByteStreamOptions, B as ByteStreamReader, D as DataStreamOptions, S as StreamController, g as TextStreamHandler, c as TextStreamInfo, d as TextStreamOptions, T as TextStreamReader } from './stream_reader-DRyR29vo.js';
7
8
  export { ByteStreamWriter, TextStreamWriter } from './data_streams/stream_writer.js';
8
9
  export { E2EEManager, E2EEOptions, FrameCryptor, KeyProvider, KeyProviderOptions } from './e2ee.js';
@@ -22,10 +23,12 @@ export { ChatMessage } from './types.js';
22
23
  export { VideoFrame } from './video_frame.js';
23
24
  export { VideoSource } from './video_source.js';
24
25
  export { VideoFrameEvent, VideoStream } from './video_stream.js';
26
+ export { FrameProcessor, FrameProcessorCredentials, FrameProcessorStreamInfo } from './frame_processor.js';
25
27
  export { livekitDispose as dispose } from './napi/native.d.js';
26
28
  import './proto/audio_frame_pb.js';
27
29
  import '@bufbuild/protobuf';
28
30
  import './proto/handle_pb.js';
31
+ import './async_queue.js';
29
32
  import '@livekit/typed-emitter';
30
33
  import './proto/ffi_pb.js';
31
34
  import './proto/rpc_pb.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACnE,YAAY,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC9E,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,wBAAwB,EACxB,c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K,UAAU,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC9E,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EACL,cAAc,EACd,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,GAC/B,MAAM,sBAAsB,CAAC"}
package/dist/index.js CHANGED
@@ -3,6 +3,7 @@ import { AudioResampler, AudioResamplerQuality } from "./audio_resampler.js";
3
3
  import { AudioSource } from "./audio_source.js";
4
4
  import { AudioStream } from "./audio_stream.js";
5
5
  import { AudioFilter } from "./audio_filter.js";
6
+ import { AudioMixer } from "./audio_mixer.js";
6
7
  export * from "./data_streams/index.js";
7
8
  import { E2EEManager, FrameCryptor, KeyProvider } from "./e2ee.js";
8
9
  import { dispose } from "./ffi_client.js";
@@ -37,9 +38,13 @@ import {
37
38
  import { VideoFrame } from "./video_frame.js";
38
39
  import { VideoSource } from "./video_source.js";
39
40
  import { VideoStream } from "./video_stream.js";
41
+ import {
42
+ FrameProcessor
43
+ } from "./frame_processor.js";
40
44
  export {
41
45
  AudioFilter,
42
46
  AudioFrame,
47
+ AudioMixer,
43
48
  AudioResampler,
44
49
  AudioResamplerQuality,
45
50
  AudioSource,
@@ -54,6 +59,7 @@ export {
54
59
  EncryptionState,
55
60
  EncryptionType,
56
61
  FrameCryptor,
62
+ FrameProcessor,
57
63
  IceServer,
58
64
  IceTransportType,
59
65
  KeyProvider,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { AudioSource } from './audio_source.js';\nexport { AudioStream } from './audio_stream.js';\nexport type { NoiseCancellationOptions } from './audio_stream.js';\nexport { AudioFilter } from './audio_filter.js';\nexport * from './data_streams/index.js';\nexport { E2EEManager, FrameCryptor, KeyProvider } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport { dispose } from './ffi_client.js';\nexport { LocalParticipant, Participant, RemoteParticipant } from './participant.js';\nexport { EncryptionState, EncryptionType } from './proto/e2ee_pb.js';\nexport { DisconnectReason, ParticipantKind } from './proto/participant_pb.js';\nexport {\n ConnectionQuality,\n ConnectionState,\n ContinualGatheringPolicy,\n DataPacketKind,\n IceServer,\n IceTransportType,\n TrackPublishOptions,\n} from './proto/room_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoCodec, VideoRotation } from './proto/video_frame_pb.js';\nexport { ConnectError, Room, RoomEvent, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { RpcError, type PerformRpcParams, type RpcInvocationData } from './rpc.js';\nexport {\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n Track,\n type AudioTrack,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n} from './track.js';\nexport {\n LocalTrackPublication,\n RemoteTrackPublication,\n TrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport type { ChatMessage } from './types.js';\nexport { VideoFrame } from './video_frame.js';\nexport { VideoSource } from './video_source.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\n"],"mappings":"AAIA,SAAS,YAAY,0BAA0B;AAC/C,SAAS,gBAAgB,6BAA6B;AACtD,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAE5B,SAAS,mBAAmB;AAC5B,cAAc;AACd,SAAS,aAAa,cAAc,mBAAmB;AAEvD,SAAS,eAAe;AACxB,SAAS,kBAAkB,aAAa,yBAAyB;AACjE,SAAS,iBAAiB,sBAAsB;AAChD,SAAS,kBAAkB,uBAAuB;AAClD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,WAAW,mBAAmB;AACpD,SAAS,iBAAiB,YAAY,qBAAqB;AAC3D,SAAS,cAAc,MAAM,iBAA0D;AACvF,SAAS,gBAA+D;AACxE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,mBAAyC;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\n\nexport { AudioFrame, combineAudioFrames } from './audio_frame.js';\nexport { AudioResampler, AudioResamplerQuality } from './audio_resampler.js';\nexport { AudioSource } from './audio_source.js';\nexport { AudioStream } from './audio_stream.js';\nexport type { NoiseCancellationOptions } from './audio_stream.js';\nexport { AudioFilter } from './audio_filter.js';\nexport { AudioMixer, type AudioMixerOptions } from './audio_mixer.js';\nexport * from './data_streams/index.js';\nexport { E2EEManager, FrameCryptor, KeyProvider } from './e2ee.js';\nexport type { E2EEOptions, KeyProviderOptions } from './e2ee.js';\nexport { dispose } from './ffi_client.js';\nexport { LocalParticipant, Participant, RemoteParticipant } from './participant.js';\nexport { EncryptionState, EncryptionType } from './proto/e2ee_pb.js';\nexport { DisconnectReason, ParticipantKind } from './proto/participant_pb.js';\nexport {\n ConnectionQuality,\n ConnectionState,\n ContinualGatheringPolicy,\n DataPacketKind,\n IceServer,\n IceTransportType,\n TrackPublishOptions,\n} from './proto/room_pb.js';\nexport { StreamState, TrackKind, TrackSource } from './proto/track_pb.js';\nexport { VideoBufferType, VideoCodec, VideoRotation } from './proto/video_frame_pb.js';\nexport { ConnectError, Room, RoomEvent, type RoomOptions, type RtcConfiguration } from './room.js';\nexport { RpcError, type PerformRpcParams, type RpcInvocationData } from './rpc.js';\nexport {\n LocalAudioTrack,\n LocalVideoTrack,\n RemoteAudioTrack,\n RemoteVideoTrack,\n Track,\n type AudioTrack,\n type LocalTrack,\n type RemoteTrack,\n type VideoTrack,\n} from './track.js';\nexport {\n LocalTrackPublication,\n RemoteTrackPublication,\n TrackPublication,\n} from './track_publication.js';\nexport type { Transcription, TranscriptionSegment } from './transcription.js';\nexport type { ChatMessage } from './types.js';\nexport { VideoFrame } from './video_frame.js';\nexport { VideoSource } from './video_source.js';\nexport { VideoStream, type VideoFrameEvent } from './video_stream.js';\nexport {\n FrameProcessor,\n type FrameProcessorStreamInfo,\n type FrameProcessorCredentials,\n} from './frame_processor.js';\n"],"mappings":"AAIA,SAAS,YAAY,0BAA0B;AAC/C,SAAS,gBAAgB,6BAA6B;AACtD,SAAS,mBAAmB;AAC5B,SAAS,mBAAmB;AAE5B,SAAS,mBAAmB;AAC5B,SAAS,kBAA0C;AACnD,cAAc;AACd,SAAS,aAAa,cAAc,mBAAmB;AAEvD,SAAS,eAAe;AACxB,SAAS,kBAAkB,aAAa,yBAAyB;AACjE,SAAS,iBAAiB,sBAAsB;AAChD,SAAS,kBAAkB,uBAAuB;AAClD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,aAAa,WAAW,mBAAmB;AACpD,SAAS,iBAAiB,YAAY,qBAAqB;AAC3D,SAAS,cAAc,MAAM,iBAA0D;AACvF,SAAS,gBAA+D;AACxE;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAKK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,kBAAkB;AAC3B,SAAS,mBAAmB;AAC5B,SAAS,mBAAyC;AAClD;AAAA,EACE;AAAA,OAGK;","names":[]}
@@ -67,11 +67,11 @@ class Participant {
67
67
  }
68
68
  }
69
69
  class LocalParticipant extends Participant {
70
- constructor(info, roomEventLock) {
70
+ constructor(info, ffiEventLock) {
71
71
  super(info);
72
72
  this.rpcHandlers = /* @__PURE__ */ new Map();
73
73
  this.trackPublications = /* @__PURE__ */ new Map();
74
- this.roomEventLock = roomEventLock;
74
+ this.ffiEventLock = ffiEventLock;
75
75
  }
76
76
  async publishData(data, options) {
77
77
  const req = new import_room_pb.PublishDataRequest({
@@ -472,7 +472,7 @@ class LocalParticipant extends Participant {
472
472
  trackHandle: track.ffi_handle.handle,
473
473
  options
474
474
  });
475
- const unlock = await this.roomEventLock.lock();
475
+ const unlock = await this.ffiEventLock.lock();
476
476
  const res = import_ffi_client.FfiClient.instance.request({
477
477
  message: { case: "publishTrack", value: req }
478
478
  });
@@ -495,7 +495,7 @@ class LocalParticipant extends Participant {
495
495
  }
496
496
  }
497
497
  async unpublishTrack(trackSid, stopOnUnpublish) {
498
- const unlock = await this.roomEventLock.lock();
498
+ const unlock = await this.ffiEventLock.lock();
499
499
  try {
500
500
  const req = new import_room_pb.UnpublishTrackRequest({
501
501
  localParticipantHandle: this.ffi_handle.handle,