@livekit/rtc-node 0.12.2 → 0.13.1

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 (217) hide show
  1. package/dist/audio_frame.cjs +2 -2
  2. package/dist/audio_frame.cjs.map +1 -1
  3. package/dist/audio_frame.d.cts +2 -3
  4. package/dist/audio_frame.d.ts +2 -3
  5. package/dist/audio_frame.d.ts.map +1 -1
  6. package/dist/audio_frame.js +3 -3
  7. package/dist/audio_frame.js.map +1 -1
  8. package/dist/audio_resampler.cjs +10 -7
  9. package/dist/audio_resampler.cjs.map +1 -1
  10. package/dist/audio_resampler.d.cts +2 -3
  11. package/dist/audio_resampler.d.ts +2 -3
  12. package/dist/audio_resampler.d.ts.map +1 -1
  13. package/dist/audio_resampler.js +13 -10
  14. package/dist/audio_resampler.js.map +1 -1
  15. package/dist/audio_source.cjs +6 -4
  16. package/dist/audio_source.cjs.map +1 -1
  17. package/dist/audio_source.d.cts +3 -3
  18. package/dist/audio_source.d.ts +3 -3
  19. package/dist/audio_source.d.ts.map +1 -1
  20. package/dist/audio_source.js +9 -7
  21. package/dist/audio_source.js.map +1 -1
  22. package/dist/audio_stream.cjs +1 -2
  23. package/dist/audio_stream.cjs.map +1 -1
  24. package/dist/audio_stream.d.cts +2 -3
  25. package/dist/audio_stream.d.ts +2 -3
  26. package/dist/audio_stream.d.ts.map +1 -1
  27. package/dist/audio_stream.js +2 -3
  28. package/dist/audio_stream.js.map +1 -1
  29. package/dist/e2ee.cjs +19 -20
  30. package/dist/e2ee.cjs.map +1 -1
  31. package/dist/e2ee.d.cts +5 -6
  32. package/dist/e2ee.d.ts +5 -6
  33. package/dist/e2ee.d.ts.map +1 -1
  34. package/dist/e2ee.js +29 -30
  35. package/dist/e2ee.js.map +1 -1
  36. package/dist/ffi_client.cjs +6 -5
  37. package/dist/ffi_client.cjs.map +1 -1
  38. package/dist/ffi_client.d.cts +10 -10
  39. package/dist/ffi_client.d.ts +10 -10
  40. package/dist/ffi_client.d.ts.map +1 -1
  41. package/dist/ffi_client.js +6 -10
  42. package/dist/ffi_client.js.map +1 -1
  43. package/dist/index.cjs +16 -49
  44. package/dist/index.cjs.map +1 -1
  45. package/dist/index.d.cts +6 -35
  46. package/dist/index.d.ts +6 -35
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +7 -46
  49. package/dist/index.js.map +1 -1
  50. package/dist/napi/native.d.cjs.map +1 -1
  51. package/dist/napi/native.d.ts +5 -5
  52. package/dist/native.d.ts +5 -5
  53. package/dist/participant.cjs +60 -36
  54. package/dist/participant.cjs.map +1 -1
  55. package/dist/participant.d.cts +11 -11
  56. package/dist/participant.d.ts +11 -11
  57. package/dist/participant.d.ts.map +1 -1
  58. package/dist/participant.js +78 -52
  59. package/dist/participant.js.map +1 -1
  60. package/dist/proto/audio_frame_pb.cjs +977 -125
  61. package/dist/proto/audio_frame_pb.cjs.map +1 -1
  62. package/dist/proto/audio_frame_pb.d.cts +502 -417
  63. package/dist/proto/audio_frame_pb.d.ts +502 -417
  64. package/dist/proto/audio_frame_pb.d.ts.map +1 -1
  65. package/dist/proto/audio_frame_pb.js +943 -85
  66. package/dist/proto/audio_frame_pb.js.map +1 -1
  67. package/dist/proto/e2ee_pb.cjs +700 -85
  68. package/dist/proto/e2ee_pb.cjs.map +1 -1
  69. package/dist/proto/e2ee_pb.d.cts +331 -263
  70. package/dist/proto/e2ee_pb.d.ts +331 -263
  71. package/dist/proto/e2ee_pb.d.ts.map +1 -1
  72. package/dist/proto/e2ee_pb.js +675 -57
  73. package/dist/proto/e2ee_pb.js.map +1 -1
  74. package/dist/proto/ffi_pb.cjs +369 -36
  75. package/dist/proto/ffi_pb.cjs.map +1 -1
  76. package/dist/proto/ffi_pb.d.cts +156 -109
  77. package/dist/proto/ffi_pb.d.ts +156 -109
  78. package/dist/proto/ffi_pb.d.ts.map +1 -1
  79. package/dist/proto/ffi_pb.js +364 -29
  80. package/dist/proto/ffi_pb.js.map +1 -1
  81. package/dist/proto/handle_pb.cjs +27 -7
  82. package/dist/proto/handle_pb.cjs.map +1 -1
  83. package/dist/proto/handle_pb.d.cts +13 -15
  84. package/dist/proto/handle_pb.d.ts +13 -15
  85. package/dist/proto/handle_pb.d.ts.map +1 -1
  86. package/dist/proto/handle_pb.js +26 -5
  87. package/dist/proto/handle_pb.js.map +1 -1
  88. package/dist/proto/participant_pb.cjs +112 -15
  89. package/dist/proto/participant_pb.cjs.map +1 -1
  90. package/dist/proto/participant_pb.d.cts +140 -52
  91. package/dist/proto/participant_pb.d.ts +140 -52
  92. package/dist/proto/participant_pb.d.ts.map +1 -1
  93. package/dist/proto/participant_pb.js +109 -11
  94. package/dist/proto/participant_pb.js.map +1 -1
  95. package/dist/proto/room_pb.cjs +2693 -302
  96. package/dist/proto/room_pb.cjs.map +1 -1
  97. package/dist/proto/room_pb.d.cts +1265 -862
  98. package/dist/proto/room_pb.d.ts +1265 -862
  99. package/dist/proto/room_pb.d.ts.map +1 -1
  100. package/dist/proto/room_pb.js +2603 -210
  101. package/dist/proto/room_pb.js.map +1 -1
  102. package/dist/proto/rpc_pb.cjs +302 -37
  103. package/dist/proto/rpc_pb.cjs.map +1 -1
  104. package/dist/proto/rpc_pb.d.cts +138 -108
  105. package/dist/proto/rpc_pb.d.ts +138 -108
  106. package/dist/proto/rpc_pb.d.ts.map +1 -1
  107. package/dist/proto/rpc_pb.js +291 -25
  108. package/dist/proto/rpc_pb.js.map +1 -1
  109. package/dist/proto/stats_pb.cjs +1253 -139
  110. package/dist/proto/stats_pb.cjs.map +1 -1
  111. package/dist/proto/stats_pb.d.cts +803 -692
  112. package/dist/proto/stats_pb.d.ts +803 -692
  113. package/dist/proto/stats_pb.d.ts.map +1 -1
  114. package/dist/proto/stats_pb.js +1216 -93
  115. package/dist/proto/stats_pb.js.map +1 -1
  116. package/dist/proto/track_pb.cjs +462 -64
  117. package/dist/proto/track_pb.cjs.map +1 -1
  118. package/dist/proto/track_pb.d.cts +250 -218
  119. package/dist/proto/track_pb.d.ts +250 -218
  120. package/dist/proto/track_pb.d.ts.map +1 -1
  121. package/dist/proto/track_pb.js +447 -45
  122. package/dist/proto/track_pb.js.map +1 -1
  123. package/dist/proto/track_publication_pb.cjs +130 -0
  124. package/dist/proto/track_publication_pb.cjs.map +1 -0
  125. package/dist/proto/track_publication_pb.d.cts +80 -0
  126. package/dist/proto/track_publication_pb.d.ts +80 -0
  127. package/dist/proto/track_publication_pb.d.ts.map +1 -0
  128. package/dist/proto/track_publication_pb.js +103 -0
  129. package/dist/proto/track_publication_pb.js.map +1 -0
  130. package/dist/proto/video_frame_pb.cjs +648 -88
  131. package/dist/proto/video_frame_pb.cjs.map +1 -1
  132. package/dist/proto/video_frame_pb.d.cts +371 -328
  133. package/dist/proto/video_frame_pb.d.ts +371 -328
  134. package/dist/proto/video_frame_pb.d.ts.map +1 -1
  135. package/dist/proto/video_frame_pb.js +626 -60
  136. package/dist/proto/video_frame_pb.js.map +1 -1
  137. package/dist/room.cjs +85 -125
  138. package/dist/room.cjs.map +1 -1
  139. package/dist/room.d.cts +6 -17
  140. package/dist/room.d.ts +6 -17
  141. package/dist/room.d.ts.map +1 -1
  142. package/dist/room.js +85 -123
  143. package/dist/room.js.map +1 -1
  144. package/dist/rpc.cjs.map +1 -1
  145. package/dist/rpc.d.cts +0 -1
  146. package/dist/rpc.d.ts +0 -1
  147. package/dist/rpc.js.map +1 -1
  148. package/dist/track.cjs +12 -8
  149. package/dist/track.cjs.map +1 -1
  150. package/dist/track.d.cts +8 -9
  151. package/dist/track.d.ts +8 -9
  152. package/dist/track.d.ts.map +1 -1
  153. package/dist/track.js +13 -9
  154. package/dist/track.js.map +1 -1
  155. package/dist/track_publication.cjs +21 -12
  156. package/dist/track_publication.cjs.map +1 -1
  157. package/dist/track_publication.d.cts +12 -13
  158. package/dist/track_publication.d.ts +12 -13
  159. package/dist/track_publication.d.ts.map +1 -1
  160. package/dist/track_publication.js +22 -13
  161. package/dist/track_publication.js.map +1 -1
  162. package/dist/version.cjs +1 -1
  163. package/dist/version.cjs.map +1 -1
  164. package/dist/version.d.cts +1 -1
  165. package/dist/version.d.ts +1 -1
  166. package/dist/version.js +1 -1
  167. package/dist/version.js.map +1 -1
  168. package/dist/video_frame.cjs +26 -45
  169. package/dist/video_frame.cjs.map +1 -1
  170. package/dist/video_frame.d.cts +2 -3
  171. package/dist/video_frame.d.ts +2 -3
  172. package/dist/video_frame.d.ts.map +1 -1
  173. package/dist/video_frame.js +29 -48
  174. package/dist/video_frame.js.map +1 -1
  175. package/dist/video_source.cjs +7 -4
  176. package/dist/video_source.cjs.map +1 -1
  177. package/dist/video_source.d.cts +4 -4
  178. package/dist/video_source.d.ts +4 -4
  179. package/dist/video_source.d.ts.map +1 -1
  180. package/dist/video_source.js +9 -6
  181. package/dist/video_source.js.map +1 -1
  182. package/dist/video_stream.cjs +16 -5
  183. package/dist/video_stream.cjs.map +1 -1
  184. package/dist/video_stream.d.cts +3 -4
  185. package/dist/video_stream.d.ts +3 -4
  186. package/dist/video_stream.d.ts.map +1 -1
  187. package/dist/video_stream.js +17 -6
  188. package/dist/video_stream.js.map +1 -1
  189. package/package.json +9 -9
  190. package/src/audio_frame.ts +10 -10
  191. package/src/audio_resampler.ts +15 -13
  192. package/src/audio_source.ts +11 -8
  193. package/src/audio_stream.ts +3 -4
  194. package/src/e2ee.ts +41 -42
  195. package/src/ffi_client.ts +8 -16
  196. package/src/index.ts +5 -68
  197. package/src/napi/native.d.ts +5 -5
  198. package/src/participant.ts +102 -73
  199. package/src/proto/audio_frame_pb.ts +1220 -496
  200. package/src/proto/e2ee_pb.ts +858 -337
  201. package/src/proto/ffi_pb.ts +442 -135
  202. package/src/proto/handle_pb.ts +33 -19
  203. package/src/proto/participant_pb.ts +225 -60
  204. package/src/proto/room_pb.ts +3149 -1013
  205. package/src/proto/rpc_pb.ts +358 -129
  206. package/src/proto/stats_pb.ts +1891 -877
  207. package/src/proto/track_pb.ts +587 -253
  208. package/src/proto/track_publication_pb.ts +180 -0
  209. package/src/proto/video_frame_pb.ts +861 -394
  210. package/src/room.ts +137 -189
  211. package/src/rpc.ts +1 -1
  212. package/src/track.ts +16 -17
  213. package/src/track_publication.ts +25 -26
  214. package/src/version.ts +1 -1
  215. package/src/video_frame.ts +48 -72
  216. package/src/video_source.ts +11 -8
  217. package/src/video_stream.ts +18 -8
@@ -1,12 +1,11 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { create } from '@bufbuild/protobuf';
5
4
  import { FfiClient } from './ffi_client.js';
6
5
  import { FfiHandle } from './napi/native.js';
7
6
  import type { EncryptionType } from './proto/e2ee_pb.js';
8
7
  import type { SetSubscribedResponse } from './proto/room_pb.js';
9
- import { SetSubscribedRequestSchema } from './proto/room_pb.js';
8
+ import { SetSubscribedRequest } from './proto/room_pb.js';
10
9
  import type {
11
10
  OwnedTrackPublication,
12
11
  TrackKind,
@@ -20,52 +19,52 @@ export abstract class TrackPublication {
20
19
  ffiHandle: FfiHandle;
21
20
 
22
21
  /** @internal */
23
- info: TrackPublicationInfo;
22
+ info?: TrackPublicationInfo;
24
23
  track?: Track;
25
24
 
26
25
  constructor(ownedInfo: OwnedTrackPublication) {
27
- this.info = ownedInfo.info!;
28
- this.ffiHandle = new FfiHandle(ownedInfo!.handle!.id);
26
+ this.info = ownedInfo.info;
27
+ this.ffiHandle = new FfiHandle(ownedInfo.handle!.id!);
29
28
  }
30
29
 
31
- get sid(): string {
32
- return this.info.sid;
30
+ get sid(): string | undefined {
31
+ return this.info?.sid;
33
32
  }
34
33
 
35
- get name(): string {
36
- return this.info.name;
34
+ get name(): string | undefined {
35
+ return this.info?.name;
37
36
  }
38
37
 
39
- get kind(): TrackKind {
40
- return this.info.kind;
38
+ get kind(): TrackKind | undefined {
39
+ return this.info?.kind;
41
40
  }
42
41
 
43
- get source(): TrackSource {
44
- return this.info.source;
42
+ get source(): TrackSource | undefined {
43
+ return this.info?.source;
45
44
  }
46
45
 
47
- get simulcasted(): boolean {
48
- return this.info.simulcasted;
46
+ get simulcasted(): boolean | undefined {
47
+ return this.info?.simulcasted;
49
48
  }
50
49
 
51
- get width(): number {
52
- return this.info.width;
50
+ get width(): number | undefined {
51
+ return this.info?.width;
53
52
  }
54
53
 
55
- get height(): number {
56
- return this.info.height;
54
+ get height(): number | undefined {
55
+ return this.info?.height;
57
56
  }
58
57
 
59
- get mimeType(): string {
60
- return this.info.mimeType;
58
+ get mimeType(): string | undefined {
59
+ return this.info?.mimeType;
61
60
  }
62
61
 
63
- get muted(): boolean {
64
- return this.info.muted;
62
+ get muted(): boolean | undefined {
63
+ return this.info?.muted;
65
64
  }
66
65
 
67
- get encryptionType(): EncryptionType {
68
- return this.info.encryptionType;
66
+ get encryptionType(): EncryptionType | undefined {
67
+ return this.info?.encryptionType;
69
68
  }
70
69
  }
71
70
 
@@ -101,7 +100,7 @@ export class RemoteTrackPublication extends TrackPublication {
101
100
  }
102
101
 
103
102
  setSubscribed(subscribed: boolean) {
104
- const req = create(SetSubscribedRequestSchema, {
103
+ const req = new SetSubscribedRequest({
105
104
  subscribe: subscribed,
106
105
  publicationHandle: this.ffiHandle.handle,
107
106
  });
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const SDK_VERSION = "0.12.2";
1
+ export const SDK_VERSION = "0.13.1";
@@ -1,18 +1,11 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { create } from '@bufbuild/protobuf';
5
- import { FfiClient } from './ffi_client.js';
6
- import { FfiRequestSchema } from './proto/ffi_pb.js';
7
- import type {
8
- OwnedVideoBuffer,
4
+ import { FfiClient, FfiRequest } from './ffi_client.js';
5
+ import type { OwnedVideoBuffer, VideoConvertResponse } from './proto/video_frame_pb.js';
6
+ import {
9
7
  VideoBufferInfo,
10
8
  VideoBufferInfo_ComponentInfo,
11
- VideoConvertResponse,
12
- } from './proto/video_frame_pb.js';
13
- import {
14
- VideoBufferInfoSchema,
15
- VideoBufferInfo_ComponentInfoSchema,
16
9
  VideoBufferType,
17
10
  } from './proto/video_frame_pb.js';
18
11
 
@@ -36,7 +29,7 @@ export class VideoFrame {
36
29
 
37
30
  /** @internal */
38
31
  protoInfo(): VideoBufferInfo {
39
- const info = create(VideoBufferInfoSchema, {
32
+ const info = new VideoBufferInfo({
40
33
  width: this.width,
41
34
  height: this.height,
42
35
  type: this.type,
@@ -65,12 +58,12 @@ export class VideoFrame {
65
58
  const info = owned.info!;
66
59
  return new VideoFrame(
67
60
  FfiClient.instance.copyBuffer(
68
- info.dataPtr,
69
- getPlaneLength(info.type, info.width, info.height),
61
+ info.dataPtr!,
62
+ getPlaneLength(info.type!, info.width!, info.height!),
70
63
  ),
71
- info.width,
72
- info.height,
73
- info.type,
64
+ info.width!,
65
+ info.height!,
66
+ info.type!,
74
67
  );
75
68
  }
76
69
 
@@ -79,11 +72,11 @@ export class VideoFrame {
79
72
  if (planeNth >= planeInfos.length) return;
80
73
 
81
74
  const planeInfo = planeInfos[planeNth]!;
82
- return FfiClient.instance.copyBuffer(planeInfo.dataPtr, planeInfo.size);
75
+ return FfiClient.instance.copyBuffer(planeInfo.dataPtr!, planeInfo.size!);
83
76
  }
84
77
 
85
78
  convert(dstType: VideoBufferType, flipY = false): VideoFrame {
86
- const req = create(FfiRequestSchema, {
79
+ const req = new FfiRequest({
87
80
  message: {
88
81
  case: 'videoConvert',
89
82
  value: {
@@ -94,11 +87,14 @@ export class VideoFrame {
94
87
  },
95
88
  });
96
89
  const resp = FfiClient.instance.request<VideoConvertResponse>(req);
97
- if (resp.message.case !== 'buffer') {
98
- throw new Error(resp.message.value ?? 'Unknown Error');
99
- }
100
90
 
101
- return VideoFrame.fromOwnedInfo(resp.message.value);
91
+ switch (resp.message.case) {
92
+ case 'buffer':
93
+ return VideoFrame.fromOwnedInfo(resp.message.value);
94
+ case 'error':
95
+ default:
96
+ throw resp.message.value;
97
+ }
102
98
  }
103
99
  }
104
100
 
@@ -137,108 +133,88 @@ const getPlaneInfos = (
137
133
  const chromaHeight = Math.trunc((height + 1) / 2);
138
134
  switch (type) {
139
135
  case VideoBufferType.I420: {
140
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
141
- dataPtr,
142
- stride: width,
143
- size: width * height,
144
- });
145
- const u = create(VideoBufferInfo_ComponentInfoSchema, {
146
- dataPtr: y.dataPtr + BigInt(y.size),
136
+ const y = new VideoBufferInfo_ComponentInfo({ dataPtr, stride: width, size: width * height });
137
+ const u = new VideoBufferInfo_ComponentInfo({
138
+ dataPtr: y.dataPtr! + BigInt(y.size!),
147
139
  stride: chromaWidth,
148
140
  size: chromaWidth * chromaHeight,
149
141
  });
150
- const v = create(VideoBufferInfo_ComponentInfoSchema, {
151
- dataPtr: u.dataPtr + BigInt(u.size),
142
+ const v = new VideoBufferInfo_ComponentInfo({
143
+ dataPtr: u.dataPtr! + BigInt(u.size!),
152
144
  stride: chromaWidth,
153
145
  size: chromaWidth * chromaHeight,
154
146
  });
155
147
  return [y, u, v];
156
148
  }
157
149
  case VideoBufferType.I420A: {
158
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
159
- dataPtr,
160
- stride: width,
161
- size: width * height,
162
- });
163
- const u = create(VideoBufferInfo_ComponentInfoSchema, {
164
- dataPtr: y.dataPtr + BigInt(y.size),
150
+ const y = new VideoBufferInfo_ComponentInfo({ dataPtr, stride: width, size: width * height });
151
+ const u = new VideoBufferInfo_ComponentInfo({
152
+ dataPtr: y.dataPtr! + BigInt(y.size!),
165
153
  stride: chromaWidth,
166
154
  size: chromaWidth * chromaHeight,
167
155
  });
168
- const v = create(VideoBufferInfo_ComponentInfoSchema, {
169
- dataPtr: u.dataPtr + BigInt(u.size),
156
+ const v = new VideoBufferInfo_ComponentInfo({
157
+ dataPtr: u.dataPtr! + BigInt(u.size!),
170
158
  stride: chromaWidth,
171
159
  size: chromaWidth * chromaHeight,
172
160
  });
173
- const a = create(VideoBufferInfo_ComponentInfoSchema, {
174
- dataPtr: v.dataPtr + BigInt(v.size),
161
+ const a = new VideoBufferInfo_ComponentInfo({
162
+ dataPtr: v.dataPtr! + BigInt(v.size!),
175
163
  stride: width,
176
164
  size: width * height,
177
165
  });
178
166
  return [y, u, v, a];
179
167
  }
180
168
  case VideoBufferType.I422: {
181
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
182
- dataPtr,
183
- stride: width,
184
- size: width * height,
185
- });
186
- const u = create(VideoBufferInfo_ComponentInfoSchema, {
187
- dataPtr: y.dataPtr + BigInt(y.size),
169
+ const y = new VideoBufferInfo_ComponentInfo({ dataPtr, stride: width, size: width * height });
170
+ const u = new VideoBufferInfo_ComponentInfo({
171
+ dataPtr: y.dataPtr! + BigInt(y.size!),
188
172
  stride: chromaWidth,
189
173
  size: chromaWidth * height,
190
174
  });
191
- const v = create(VideoBufferInfo_ComponentInfoSchema, {
192
- dataPtr: u.dataPtr + BigInt(u.size),
175
+ const v = new VideoBufferInfo_ComponentInfo({
176
+ dataPtr: u.dataPtr! + BigInt(u.size!),
193
177
  stride: chromaWidth,
194
178
  size: chromaWidth * height,
195
179
  });
196
180
  return [y, u, v];
197
181
  }
198
182
  case VideoBufferType.I444: {
199
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
200
- dataPtr,
201
- stride: width,
202
- size: width * height,
203
- });
204
- const u = create(VideoBufferInfo_ComponentInfoSchema, {
205
- dataPtr: y.dataPtr + BigInt(y.size),
183
+ const y = new VideoBufferInfo_ComponentInfo({ dataPtr, stride: width, size: width * height });
184
+ const u = new VideoBufferInfo_ComponentInfo({
185
+ dataPtr: y.dataPtr! + BigInt(y.size!),
206
186
  stride: width,
207
187
  size: width * height,
208
188
  });
209
- const v = create(VideoBufferInfo_ComponentInfoSchema, {
210
- dataPtr: u.dataPtr + BigInt(u.size),
189
+ const v = new VideoBufferInfo_ComponentInfo({
190
+ dataPtr: u.dataPtr! + BigInt(u.size!),
211
191
  stride: width,
212
192
  size: width * height,
213
193
  });
214
194
  return [y, u, v];
215
195
  }
216
196
  case VideoBufferType.I010: {
217
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
197
+ const y = new VideoBufferInfo_ComponentInfo({
218
198
  dataPtr,
219
199
  stride: width * 2,
220
200
  size: width * height * 2,
221
201
  });
222
- const u = create(VideoBufferInfo_ComponentInfoSchema, {
223
- dataPtr: y.dataPtr + BigInt(y.size),
202
+ const u = new VideoBufferInfo_ComponentInfo({
203
+ dataPtr: y.dataPtr! + BigInt(y.size!),
224
204
  stride: chromaWidth * 2,
225
205
  size: chromaWidth * chromaHeight * 2,
226
206
  });
227
- const v = create(VideoBufferInfo_ComponentInfoSchema, {
228
- dataPtr: u.dataPtr + BigInt(u.size),
207
+ const v = new VideoBufferInfo_ComponentInfo({
208
+ dataPtr: u.dataPtr! + BigInt(u.size!),
229
209
  stride: chromaWidth * 2,
230
210
  size: chromaWidth * chromaHeight * 2,
231
211
  });
232
212
  return [y, u, v];
233
213
  }
234
214
  case VideoBufferType.NV12: {
235
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
236
- dataPtr,
237
- stride: width,
238
- size: width * height,
239
- });
240
- const uv = create(VideoBufferInfo_ComponentInfoSchema, {
241
- dataPtr: y.dataPtr + BigInt(y.size),
215
+ const y = new VideoBufferInfo_ComponentInfo({ dataPtr, stride: width, size: width * height });
216
+ const uv = new VideoBufferInfo_ComponentInfo({
217
+ dataPtr: y.dataPtr! + BigInt(y.size!),
242
218
  stride: chromaWidth * 2,
243
219
  size: chromaWidth * chromaHeight * 2,
244
220
  });
@@ -1,7 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { create } from '@bufbuild/protobuf';
5
4
  import { FfiClient, FfiHandle } from './ffi_client.js';
6
5
  import type {
7
6
  CaptureVideoFrameResponse,
@@ -9,8 +8,8 @@ import type {
9
8
  VideoSourceInfo,
10
9
  } from './proto/video_frame_pb.js';
11
10
  import {
12
- CaptureVideoFrameRequestSchema,
13
- NewVideoSourceRequestSchema,
11
+ CaptureVideoFrameRequest,
12
+ NewVideoSourceRequest,
14
13
  VideoRotation,
15
14
  VideoSourceType,
16
15
  } from './proto/video_frame_pb.js';
@@ -18,7 +17,7 @@ import type { VideoFrame } from './video_frame.js';
18
17
 
19
18
  export class VideoSource {
20
19
  /** @internal */
21
- info: VideoSourceInfo;
20
+ info?: VideoSourceInfo;
22
21
  /** @internal */
23
22
  ffiHandle: FfiHandle;
24
23
 
@@ -29,7 +28,7 @@ export class VideoSource {
29
28
  this.width = width;
30
29
  this.height = height;
31
30
 
32
- const req = create(NewVideoSourceRequestSchema, {
31
+ const req = new NewVideoSourceRequest({
33
32
  type: VideoSourceType.VIDEO_SOURCE_NATIVE,
34
33
  resolution: {
35
34
  width: width,
@@ -44,8 +43,8 @@ export class VideoSource {
44
43
  },
45
44
  });
46
45
 
47
- this.info = res.source!.info!;
48
- this.ffiHandle = new FfiHandle(res.source!.handle!.id);
46
+ this.info = res.source?.info;
47
+ this.ffiHandle = new FfiHandle(res.source!.handle!.id!);
49
48
  }
50
49
 
51
50
  captureFrame(
@@ -53,7 +52,7 @@ export class VideoSource {
53
52
  timestampUs = BigInt(0),
54
53
  rotation = VideoRotation.VIDEO_ROTATION_0,
55
54
  ) {
56
- const req = create(CaptureVideoFrameRequestSchema, {
55
+ const req = new CaptureVideoFrameRequest({
57
56
  sourceHandle: this.ffiHandle.handle,
58
57
  buffer: frame.protoInfo(),
59
58
  rotation,
@@ -64,4 +63,8 @@ export class VideoSource {
64
63
  message: { case: 'captureVideoFrame', value: req },
65
64
  });
66
65
  }
66
+
67
+ async close() {
68
+ this.ffiHandle.dispose();
69
+ }
67
70
  }
@@ -1,7 +1,6 @@
1
1
  // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
2
  //
3
3
  // SPDX-License-Identifier: Apache-2.0
4
- import { create } from '@bufbuild/protobuf';
5
4
  import { Mutex } from '@livekit/mutex';
6
5
  import type { FfiEvent } from './ffi_client.js';
7
6
  import { FfiClient, FfiClientEvent, FfiHandle } from './ffi_client.js';
@@ -10,7 +9,7 @@ import type {
10
9
  VideoRotation,
11
10
  VideoStreamInfo,
12
11
  } from './proto/video_frame_pb.js';
13
- import { NewVideoStreamRequestSchema, VideoStreamType } from './proto/video_frame_pb.js';
12
+ import { NewVideoStreamRequest, VideoStreamType } from './proto/video_frame_pb.js';
14
13
  import type { Track } from './track.js';
15
14
  import { VideoFrame } from './video_frame.js';
16
15
 
@@ -22,7 +21,7 @@ export type VideoFrameEvent = {
22
21
 
23
22
  export class VideoStream implements AsyncIterableIterator<VideoFrameEvent> {
24
23
  /** @internal */
25
- info: VideoStreamInfo;
24
+ info?: VideoStreamInfo;
26
25
  /** @internal */
27
26
  ffiHandle: FfiHandle;
28
27
  /** @internal */
@@ -37,7 +36,7 @@ export class VideoStream implements AsyncIterableIterator<VideoFrameEvent> {
37
36
  constructor(track: Track) {
38
37
  this.track = track;
39
38
 
40
- const req = create(NewVideoStreamRequestSchema, {
39
+ const req = new NewVideoStreamRequest({
41
40
  type: VideoStreamType.VIDEO_STREAM_NATIVE,
42
41
  trackHandle: track.ffi_handle.handle,
43
42
  });
@@ -49,8 +48,8 @@ export class VideoStream implements AsyncIterableIterator<VideoFrameEvent> {
49
48
  },
50
49
  });
51
50
 
52
- this.info = res.stream!.info!;
53
- this.ffiHandle = new FfiHandle(res.stream!.handle!.id);
51
+ this.info = res.stream?.info;
52
+ this.ffiHandle = new FfiHandle(res.stream!.handle!.id!);
54
53
 
55
54
  FfiClient.instance.on(FfiClientEvent.FfiEvent, this.onEvent);
56
55
  }
@@ -71,9 +70,20 @@ export class VideoStream implements AsyncIterableIterator<VideoFrameEvent> {
71
70
  const frame = VideoFrame.fromOwnedInfo(streamEvent.value.buffer!);
72
71
  const value = { rotation, timestampUs, frame };
73
72
  if (this.queueResolve) {
74
- this.queueResolve({ done: false, value });
73
+ this.queueResolve({
74
+ done: false,
75
+ value: {
76
+ frame: value.frame,
77
+ timestampUs: value.timestampUs!,
78
+ rotation: value.rotation!,
79
+ },
80
+ });
75
81
  } else {
76
- this.eventQueue.push(value);
82
+ this.eventQueue.push({
83
+ frame: value.frame,
84
+ timestampUs: value.timestampUs!,
85
+ rotation: value.rotation!,
86
+ });
77
87
  }
78
88
  break;
79
89
  case 'eos':