@livekit/rtc-node 0.11.1 → 0.12.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.
- package/dist/audio_frame.cjs +94 -0
- package/dist/audio_frame.cjs.map +1 -0
- package/dist/audio_frame.js +64 -67
- package/dist/audio_frame.js.map +1 -1
- package/dist/audio_resampler.cjs +153 -0
- package/dist/audio_resampler.cjs.map +1 -0
- package/dist/audio_resampler.js +129 -134
- package/dist/audio_resampler.js.map +1 -1
- package/dist/audio_source.cjs +116 -0
- package/dist/audio_source.cjs.map +1 -0
- package/dist/audio_source.js +92 -85
- package/dist/audio_source.js.map +1 -1
- package/dist/audio_stream.cjs +104 -0
- package/dist/audio_stream.cjs.map +1 -0
- package/dist/audio_stream.js +77 -78
- package/dist/audio_stream.js.map +1 -1
- package/dist/e2ee.cjs +268 -0
- package/dist/e2ee.cjs.map +1 -0
- package/dist/e2ee.d.ts.map +1 -1
- package/dist/e2ee.js +244 -221
- package/dist/e2ee.js.map +1 -1
- package/dist/ffi_client.cjs +95 -0
- package/dist/ffi_client.cjs.map +1 -0
- package/dist/ffi_client.d.ts +2 -2
- package/dist/ffi_client.d.ts.map +1 -1
- package/dist/ffi_client.js +67 -48
- package/dist/ffi_client.js.map +1 -1
- package/dist/index.cjs +166 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +119 -48
- package/dist/index.js.map +1 -1
- package/dist/napi/native.d.cjs +17 -0
- package/dist/napi/native.d.cjs.map +1 -0
- package/dist/napi/native.d.js +1 -0
- package/dist/napi/native.d.js.map +1 -0
- package/dist/native.cjs +301 -0
- package/dist/native.d.ts +19 -0
- package/dist/native.js +15 -0
- package/dist/participant.cjs +388 -0
- package/dist/participant.cjs.map +1 -0
- package/dist/participant.js +363 -339
- package/dist/participant.js.map +1 -1
- package/dist/proto/audio_frame_pb.cjs +193 -0
- package/dist/proto/audio_frame_pb.cjs.map +1 -0
- package/dist/proto/audio_frame_pb.js +120 -320
- package/dist/proto/audio_frame_pb.js.map +1 -1
- package/dist/proto/e2ee_pb.cjs +131 -0
- package/dist/proto/e2ee_pb.cjs.map +1 -0
- package/dist/proto/e2ee_pb.js +76 -202
- package/dist/proto/e2ee_pb.js.map +1 -1
- package/dist/proto/ffi_pb.cjs +76 -0
- package/dist/proto/ffi_pb.cjs.map +1 -0
- package/dist/proto/ffi_pb.js +33 -92
- package/dist/proto/ffi_pb.js.map +1 -1
- package/dist/proto/handle_pb.cjs +33 -0
- package/dist/proto/handle_pb.cjs.map +1 -0
- package/dist/proto/handle_pb.js +6 -22
- package/dist/proto/handle_pb.js.map +1 -1
- package/dist/proto/participant_pb.cjs +50 -0
- package/dist/proto/participant_pb.cjs.map +1 -0
- package/dist/proto/participant_pb.js +19 -57
- package/dist/proto/participant_pb.js.map +1 -1
- package/dist/proto/room_pb.cjs +370 -0
- package/dist/proto/room_pb.cjs.map +1 -0
- package/dist/proto/room_pb.js +239 -632
- package/dist/proto/room_pb.js.map +1 -1
- package/dist/proto/rpc_pb.cjs +63 -0
- package/dist/proto/rpc_pb.cjs.map +1 -0
- package/dist/proto/rpc_pb.js +26 -72
- package/dist/proto/rpc_pb.js.map +1 -1
- package/dist/proto/stats_pb.cjs +256 -0
- package/dist/proto/stats_pb.cjs.map +1 -0
- package/dist/proto/stats_pb.js +175 -456
- package/dist/proto/stats_pb.js.map +1 -1
- package/dist/proto/track_pb.cjs +116 -0
- package/dist/proto/track_pb.cjs.map +1 -0
- package/dist/proto/track_pb.js +65 -171
- package/dist/proto/track_pb.js.map +1 -1
- package/dist/proto/video_frame_pb.cjs +161 -0
- package/dist/proto/video_frame_pb.cjs.map +1 -0
- package/dist/proto/video_frame_pb.js +101 -269
- package/dist/proto/video_frame_pb.js.map +1 -1
- package/dist/room.cjs +440 -0
- package/dist/room.cjs.map +1 -0
- package/dist/room.js +384 -373
- package/dist/room.js.map +1 -1
- package/dist/rpc.cjs +89 -0
- package/dist/rpc.cjs.map +1 -0
- package/dist/rpc.js +59 -63
- package/dist/rpc.js.map +1 -1
- package/dist/track.cjs +100 -0
- package/dist/track.cjs.map +1 -0
- package/dist/track.js +66 -62
- package/dist/track.js.map +1 -1
- package/dist/track_publication.cjs +106 -0
- package/dist/track_publication.cjs.map +1 -0
- package/dist/track_publication.js +76 -74
- package/dist/track_publication.js.map +1 -1
- package/dist/transcription.cjs +17 -0
- package/dist/transcription.cjs.map +1 -0
- package/dist/transcription.js +0 -1
- package/dist/transcription.js.map +1 -1
- package/dist/types.cjs +17 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/dist/version.cjs +29 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +4 -1
- package/dist/version.js.map +1 -1
- package/dist/video_frame.cjs +242 -0
- package/dist/video_frame.cjs.map +1 -0
- package/dist/video_frame.js +212 -201
- package/dist/video_frame.js.map +1 -1
- package/dist/video_source.cjs +63 -0
- package/dist/video_source.cjs.map +1 -0
- package/dist/video_source.d.ts.map +1 -1
- package/dist/video_source.js +42 -37
- package/dist/video_source.js.map +1 -1
- package/dist/video_stream.cjs +103 -0
- package/dist/video_stream.cjs.map +1 -0
- package/dist/video_stream.js +76 -77
- package/dist/video_stream.js.map +1 -1
- package/package.json +18 -9
- package/src/audio_frame.ts +2 -2
- package/src/audio_source.ts +2 -2
- package/src/e2ee.ts +2 -2
- package/src/ffi_client.ts +4 -4
- package/src/index.ts +14 -8
- package/src/version.ts +1 -1
- package/src/video_frame.ts +1 -1
- package/src/video_source.ts +5 -1
|
@@ -0,0 +1,242 @@
|
|
|
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 video_frame_exports = {};
|
|
20
|
+
__export(video_frame_exports, {
|
|
21
|
+
VideoFrame: () => VideoFrame
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(video_frame_exports);
|
|
24
|
+
var import_protobuf = require("@bufbuild/protobuf");
|
|
25
|
+
var import_ffi_client = require("./ffi_client.cjs");
|
|
26
|
+
var import_ffi_pb = require("./proto/ffi_pb.cjs");
|
|
27
|
+
var import_video_frame_pb = require("./proto/video_frame_pb.cjs");
|
|
28
|
+
class VideoFrame {
|
|
29
|
+
constructor(data, width, height, type) {
|
|
30
|
+
this.data = data;
|
|
31
|
+
this.width = width;
|
|
32
|
+
this.height = height;
|
|
33
|
+
this.type = type;
|
|
34
|
+
}
|
|
35
|
+
/** @internal */
|
|
36
|
+
get dataPtr() {
|
|
37
|
+
return import_ffi_client.FfiClient.instance.retrievePtr(new Uint8Array(this.data.buffer));
|
|
38
|
+
}
|
|
39
|
+
/** @internal */
|
|
40
|
+
protoInfo() {
|
|
41
|
+
const info = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfoSchema, {
|
|
42
|
+
width: this.width,
|
|
43
|
+
height: this.height,
|
|
44
|
+
type: this.type,
|
|
45
|
+
dataPtr: this.dataPtr
|
|
46
|
+
});
|
|
47
|
+
switch (this.type) {
|
|
48
|
+
case import_video_frame_pb.VideoBufferType.ARGB:
|
|
49
|
+
case import_video_frame_pb.VideoBufferType.RGBA:
|
|
50
|
+
case import_video_frame_pb.VideoBufferType.ABGR:
|
|
51
|
+
case import_video_frame_pb.VideoBufferType.BGRA:
|
|
52
|
+
info.stride = this.width * 4;
|
|
53
|
+
break;
|
|
54
|
+
case import_video_frame_pb.VideoBufferType.RGB24:
|
|
55
|
+
info.stride = this.width * 3;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
info.components.push(...getPlaneInfos(this.dataPtr, this.type, this.width, this.height));
|
|
59
|
+
return info;
|
|
60
|
+
}
|
|
61
|
+
/** @internal */
|
|
62
|
+
static fromOwnedInfo(owned) {
|
|
63
|
+
const info = owned.info;
|
|
64
|
+
return new VideoFrame(
|
|
65
|
+
import_ffi_client.FfiClient.instance.copyBuffer(
|
|
66
|
+
info.dataPtr,
|
|
67
|
+
getPlaneLength(info.type, info.width, info.height)
|
|
68
|
+
),
|
|
69
|
+
info.width,
|
|
70
|
+
info.height,
|
|
71
|
+
info.type
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
getPlane(planeNth) {
|
|
75
|
+
const planeInfos = getPlaneInfos(this.dataPtr, this.type, this.width, this.height);
|
|
76
|
+
if (planeNth >= planeInfos.length) return;
|
|
77
|
+
const planeInfo = planeInfos[planeNth];
|
|
78
|
+
return import_ffi_client.FfiClient.instance.copyBuffer(planeInfo.dataPtr, planeInfo.size);
|
|
79
|
+
}
|
|
80
|
+
convert(dstType, flipY = false) {
|
|
81
|
+
const req = (0, import_protobuf.create)(import_ffi_pb.FfiRequestSchema, {
|
|
82
|
+
message: {
|
|
83
|
+
case: "videoConvert",
|
|
84
|
+
value: {
|
|
85
|
+
flipY,
|
|
86
|
+
dstType,
|
|
87
|
+
buffer: this.protoInfo()
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const resp = import_ffi_client.FfiClient.instance.request(req);
|
|
92
|
+
if (resp.message.case !== "buffer") {
|
|
93
|
+
throw new Error(resp.message.value ?? "Unknown Error");
|
|
94
|
+
}
|
|
95
|
+
return VideoFrame.fromOwnedInfo(resp.message.value);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const getPlaneLength = (type, width, height) => {
|
|
99
|
+
const chromaWidth = Math.trunc((width + 1) / 2);
|
|
100
|
+
const chromaHeight = Math.trunc((height + 1) / 2);
|
|
101
|
+
switch (type) {
|
|
102
|
+
case import_video_frame_pb.VideoBufferType.ARGB:
|
|
103
|
+
case import_video_frame_pb.VideoBufferType.RGBA:
|
|
104
|
+
case import_video_frame_pb.VideoBufferType.ABGR:
|
|
105
|
+
case import_video_frame_pb.VideoBufferType.BGRA:
|
|
106
|
+
return width * height * 4;
|
|
107
|
+
case import_video_frame_pb.VideoBufferType.RGB24:
|
|
108
|
+
case import_video_frame_pb.VideoBufferType.I444:
|
|
109
|
+
return width * height * 3;
|
|
110
|
+
case import_video_frame_pb.VideoBufferType.I420:
|
|
111
|
+
return width * height + chromaWidth * chromaHeight * 2;
|
|
112
|
+
case import_video_frame_pb.VideoBufferType.I420A:
|
|
113
|
+
return width * height * 2 + chromaWidth * chromaWidth * 2;
|
|
114
|
+
case import_video_frame_pb.VideoBufferType.I422:
|
|
115
|
+
return width * height + chromaWidth * height * 2;
|
|
116
|
+
case import_video_frame_pb.VideoBufferType.I010:
|
|
117
|
+
return width * height * 2 + chromaWidth * chromaHeight * 4;
|
|
118
|
+
case import_video_frame_pb.VideoBufferType.NV12:
|
|
119
|
+
return width * height + chromaWidth * chromaWidth * 2;
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
const getPlaneInfos = (dataPtr, type, width, height) => {
|
|
123
|
+
const chromaWidth = Math.trunc((width + 1) / 2);
|
|
124
|
+
const chromaHeight = Math.trunc((height + 1) / 2);
|
|
125
|
+
switch (type) {
|
|
126
|
+
case import_video_frame_pb.VideoBufferType.I420: {
|
|
127
|
+
const y = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
128
|
+
dataPtr,
|
|
129
|
+
stride: width,
|
|
130
|
+
size: width * height
|
|
131
|
+
});
|
|
132
|
+
const u = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
133
|
+
dataPtr: y.dataPtr + BigInt(y.size),
|
|
134
|
+
stride: chromaWidth,
|
|
135
|
+
size: chromaWidth * chromaHeight
|
|
136
|
+
});
|
|
137
|
+
const v = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
138
|
+
dataPtr: u.dataPtr + BigInt(u.size),
|
|
139
|
+
stride: chromaWidth,
|
|
140
|
+
size: chromaWidth * chromaHeight
|
|
141
|
+
});
|
|
142
|
+
return [y, u, v];
|
|
143
|
+
}
|
|
144
|
+
case import_video_frame_pb.VideoBufferType.I420A: {
|
|
145
|
+
const y = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
146
|
+
dataPtr,
|
|
147
|
+
stride: width,
|
|
148
|
+
size: width * height
|
|
149
|
+
});
|
|
150
|
+
const u = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
151
|
+
dataPtr: y.dataPtr + BigInt(y.size),
|
|
152
|
+
stride: chromaWidth,
|
|
153
|
+
size: chromaWidth * chromaHeight
|
|
154
|
+
});
|
|
155
|
+
const v = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
156
|
+
dataPtr: u.dataPtr + BigInt(u.size),
|
|
157
|
+
stride: chromaWidth,
|
|
158
|
+
size: chromaWidth * chromaHeight
|
|
159
|
+
});
|
|
160
|
+
const a = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
161
|
+
dataPtr: v.dataPtr + BigInt(v.size),
|
|
162
|
+
stride: width,
|
|
163
|
+
size: width * height
|
|
164
|
+
});
|
|
165
|
+
return [y, u, v, a];
|
|
166
|
+
}
|
|
167
|
+
case import_video_frame_pb.VideoBufferType.I422: {
|
|
168
|
+
const y = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
169
|
+
dataPtr,
|
|
170
|
+
stride: width,
|
|
171
|
+
size: width * height
|
|
172
|
+
});
|
|
173
|
+
const u = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
174
|
+
dataPtr: y.dataPtr + BigInt(y.size),
|
|
175
|
+
stride: chromaWidth,
|
|
176
|
+
size: chromaWidth * height
|
|
177
|
+
});
|
|
178
|
+
const v = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
179
|
+
dataPtr: u.dataPtr + BigInt(u.size),
|
|
180
|
+
stride: chromaWidth,
|
|
181
|
+
size: chromaWidth * height
|
|
182
|
+
});
|
|
183
|
+
return [y, u, v];
|
|
184
|
+
}
|
|
185
|
+
case import_video_frame_pb.VideoBufferType.I444: {
|
|
186
|
+
const y = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
187
|
+
dataPtr,
|
|
188
|
+
stride: width,
|
|
189
|
+
size: width * height
|
|
190
|
+
});
|
|
191
|
+
const u = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
192
|
+
dataPtr: y.dataPtr + BigInt(y.size),
|
|
193
|
+
stride: width,
|
|
194
|
+
size: width * height
|
|
195
|
+
});
|
|
196
|
+
const v = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
197
|
+
dataPtr: u.dataPtr + BigInt(u.size),
|
|
198
|
+
stride: width,
|
|
199
|
+
size: width * height
|
|
200
|
+
});
|
|
201
|
+
return [y, u, v];
|
|
202
|
+
}
|
|
203
|
+
case import_video_frame_pb.VideoBufferType.I010: {
|
|
204
|
+
const y = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
205
|
+
dataPtr,
|
|
206
|
+
stride: width * 2,
|
|
207
|
+
size: width * height * 2
|
|
208
|
+
});
|
|
209
|
+
const u = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
210
|
+
dataPtr: y.dataPtr + BigInt(y.size),
|
|
211
|
+
stride: chromaWidth * 2,
|
|
212
|
+
size: chromaWidth * chromaHeight * 2
|
|
213
|
+
});
|
|
214
|
+
const v = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
215
|
+
dataPtr: u.dataPtr + BigInt(u.size),
|
|
216
|
+
stride: chromaWidth * 2,
|
|
217
|
+
size: chromaWidth * chromaHeight * 2
|
|
218
|
+
});
|
|
219
|
+
return [y, u, v];
|
|
220
|
+
}
|
|
221
|
+
case import_video_frame_pb.VideoBufferType.NV12: {
|
|
222
|
+
const y = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
223
|
+
dataPtr,
|
|
224
|
+
stride: width,
|
|
225
|
+
size: width * height
|
|
226
|
+
});
|
|
227
|
+
const uv = (0, import_protobuf.create)(import_video_frame_pb.VideoBufferInfo_ComponentInfoSchema, {
|
|
228
|
+
dataPtr: y.dataPtr + BigInt(y.size),
|
|
229
|
+
stride: chromaWidth * 2,
|
|
230
|
+
size: chromaWidth * chromaHeight * 2
|
|
231
|
+
});
|
|
232
|
+
return [y, uv];
|
|
233
|
+
}
|
|
234
|
+
default:
|
|
235
|
+
return [];
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
239
|
+
0 && (module.exports = {
|
|
240
|
+
VideoFrame
|
|
241
|
+
});
|
|
242
|
+
//# sourceMappingURL=video_frame.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/video_frame.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { create } from '@bufbuild/protobuf';\nimport { FfiClient } from './ffi_client.js';\nimport { FfiRequestSchema } from './proto/ffi_pb.js';\nimport type {\n OwnedVideoBuffer,\n VideoBufferInfo,\n VideoBufferInfo_ComponentInfo,\n VideoConvertResponse,\n} from './proto/video_frame_pb.js';\nimport {\n VideoBufferInfoSchema,\n VideoBufferInfo_ComponentInfoSchema,\n VideoBufferType,\n} from './proto/video_frame_pb.js';\n\nexport class VideoFrame {\n data: Uint8Array;\n width: number;\n height: number;\n type: VideoBufferType;\n\n constructor(data: Uint8Array, width: number, height: number, type: VideoBufferType) {\n this.data = data;\n this.width = width;\n this.height = height;\n this.type = type;\n }\n\n /** @internal */\n get dataPtr(): bigint {\n return FfiClient.instance.retrievePtr(new Uint8Array(this.data.buffer));\n }\n\n /** @internal */\n protoInfo(): VideoBufferInfo {\n const info = create(VideoBufferInfoSchema, {\n width: this.width,\n height: this.height,\n type: this.type,\n dataPtr: this.dataPtr,\n });\n\n switch (this.type) {\n case VideoBufferType.ARGB:\n case VideoBufferType.RGBA:\n case VideoBufferType.ABGR:\n case VideoBufferType.BGRA:\n info.stride = this.width * 4;\n break;\n case VideoBufferType.RGB24:\n info.stride = this.width * 3;\n break;\n }\n\n info.components.push(...getPlaneInfos(this.dataPtr, this.type, this.width, this.height));\n\n return info;\n }\n\n /** @internal */\n static fromOwnedInfo(owned: OwnedVideoBuffer): VideoFrame {\n const info = owned.info!;\n return new VideoFrame(\n FfiClient.instance.copyBuffer(\n info.dataPtr,\n getPlaneLength(info.type, info.width, info.height),\n ),\n info.width,\n info.height,\n info.type,\n );\n }\n\n getPlane(planeNth: number): Uint8Array | void {\n const planeInfos = getPlaneInfos(this.dataPtr, this.type, this.width, this.height);\n if (planeNth >= planeInfos.length) return;\n\n const planeInfo = planeInfos[planeNth]!;\n return FfiClient.instance.copyBuffer(planeInfo.dataPtr, planeInfo.size);\n }\n\n convert(dstType: VideoBufferType, flipY = false): VideoFrame {\n const req = create(FfiRequestSchema, {\n message: {\n case: 'videoConvert',\n value: {\n flipY,\n dstType,\n buffer: this.protoInfo(),\n },\n },\n });\n const resp = FfiClient.instance.request<VideoConvertResponse>(req);\n if (resp.message.case !== 'buffer') {\n throw new Error(resp.message.value ?? 'Unknown Error');\n }\n\n return VideoFrame.fromOwnedInfo(resp.message.value);\n }\n}\n\nconst getPlaneLength = (type: VideoBufferType, width: number, height: number): number => {\n const chromaWidth = Math.trunc((width + 1) / 2);\n const chromaHeight = Math.trunc((height + 1) / 2);\n switch (type) {\n case VideoBufferType.ARGB:\n case VideoBufferType.RGBA:\n case VideoBufferType.ABGR:\n case VideoBufferType.BGRA:\n return width * height * 4;\n case VideoBufferType.RGB24:\n case VideoBufferType.I444:\n return width * height * 3;\n case VideoBufferType.I420:\n return width * height + chromaWidth * chromaHeight * 2;\n case VideoBufferType.I420A:\n return width * height * 2 + chromaWidth * chromaWidth * 2;\n case VideoBufferType.I422:\n return width * height + chromaWidth * height * 2;\n case VideoBufferType.I010:\n return width * height * 2 + chromaWidth * chromaHeight * 4;\n case VideoBufferType.NV12:\n return width * height + chromaWidth * chromaWidth * 2;\n }\n};\n\nconst getPlaneInfos = (\n dataPtr: bigint,\n type: VideoBufferType,\n width: number,\n height: number,\n): VideoBufferInfo_ComponentInfo[] => {\n const chromaWidth = Math.trunc((width + 1) / 2);\n const chromaHeight = Math.trunc((height + 1) / 2);\n switch (type) {\n case VideoBufferType.I420: {\n const y = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr,\n stride: width,\n size: width * height,\n });\n const u = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: y.dataPtr + BigInt(y.size),\n stride: chromaWidth,\n size: chromaWidth * chromaHeight,\n });\n const v = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: u.dataPtr + BigInt(u.size),\n stride: chromaWidth,\n size: chromaWidth * chromaHeight,\n });\n return [y, u, v];\n }\n case VideoBufferType.I420A: {\n const y = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr,\n stride: width,\n size: width * height,\n });\n const u = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: y.dataPtr + BigInt(y.size),\n stride: chromaWidth,\n size: chromaWidth * chromaHeight,\n });\n const v = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: u.dataPtr + BigInt(u.size),\n stride: chromaWidth,\n size: chromaWidth * chromaHeight,\n });\n const a = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: v.dataPtr + BigInt(v.size),\n stride: width,\n size: width * height,\n });\n return [y, u, v, a];\n }\n case VideoBufferType.I422: {\n const y = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr,\n stride: width,\n size: width * height,\n });\n const u = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: y.dataPtr + BigInt(y.size),\n stride: chromaWidth,\n size: chromaWidth * height,\n });\n const v = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: u.dataPtr + BigInt(u.size),\n stride: chromaWidth,\n size: chromaWidth * height,\n });\n return [y, u, v];\n }\n case VideoBufferType.I444: {\n const y = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr,\n stride: width,\n size: width * height,\n });\n const u = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: y.dataPtr + BigInt(y.size),\n stride: width,\n size: width * height,\n });\n const v = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: u.dataPtr + BigInt(u.size),\n stride: width,\n size: width * height,\n });\n return [y, u, v];\n }\n case VideoBufferType.I010: {\n const y = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr,\n stride: width * 2,\n size: width * height * 2,\n });\n const u = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: y.dataPtr + BigInt(y.size),\n stride: chromaWidth * 2,\n size: chromaWidth * chromaHeight * 2,\n });\n const v = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: u.dataPtr + BigInt(u.size),\n stride: chromaWidth * 2,\n size: chromaWidth * chromaHeight * 2,\n });\n return [y, u, v];\n }\n case VideoBufferType.NV12: {\n const y = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr,\n stride: width,\n size: width * height,\n });\n const uv = create(VideoBufferInfo_ComponentInfoSchema, {\n dataPtr: y.dataPtr + BigInt(y.size),\n stride: chromaWidth * 2,\n size: chromaWidth * chromaHeight * 2,\n });\n return [y, uv];\n }\n default:\n return [];\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAuB;AACvB,wBAA0B;AAC1B,oBAAiC;AAOjC,4BAIO;AAEA,MAAM,WAAW;AAAA,EAMtB,YAAY,MAAkB,OAAe,QAAgB,MAAuB;AAClF,SAAK,OAAO;AACZ,SAAK,QAAQ;AACb,SAAK,SAAS;AACd,SAAK,OAAO;AAAA,EACd;AAAA;AAAA,EAGA,IAAI,UAAkB;AACpB,WAAO,4BAAU,SAAS,YAAY,IAAI,WAAW,KAAK,KAAK,MAAM,CAAC;AAAA,EACxE;AAAA;AAAA,EAGA,YAA6B;AAC3B,UAAM,WAAO,wBAAO,6CAAuB;AAAA,MACzC,OAAO,KAAK;AAAA,MACZ,QAAQ,KAAK;AAAA,MACb,MAAM,KAAK;AAAA,MACX,SAAS,KAAK;AAAA,IAChB,CAAC;AAED,YAAQ,KAAK,MAAM;AAAA,MACjB,KAAK,sCAAgB;AAAA,MACrB,KAAK,sCAAgB;AAAA,MACrB,KAAK,sCAAgB;AAAA,MACrB,KAAK,sCAAgB;AACnB,aAAK,SAAS,KAAK,QAAQ;AAC3B;AAAA,MACF,KAAK,sCAAgB;AACnB,aAAK,SAAS,KAAK,QAAQ;AAC3B;AAAA,IACJ;AAEA,SAAK,WAAW,KAAK,GAAG,cAAc,KAAK,SAAS,KAAK,MAAM,KAAK,OAAO,KAAK,MAAM,CAAC;AAEvF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