@livekit/rtc-node 0.11.1 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/dist/audio_frame.cjs +94 -0
  2. package/dist/audio_frame.cjs.map +1 -0
  3. package/dist/audio_frame.js +64 -67
  4. package/dist/audio_frame.js.map +1 -1
  5. package/dist/audio_resampler.cjs +153 -0
  6. package/dist/audio_resampler.cjs.map +1 -0
  7. package/dist/audio_resampler.js +129 -134
  8. package/dist/audio_resampler.js.map +1 -1
  9. package/dist/audio_source.cjs +116 -0
  10. package/dist/audio_source.cjs.map +1 -0
  11. package/dist/audio_source.js +92 -85
  12. package/dist/audio_source.js.map +1 -1
  13. package/dist/audio_stream.cjs +104 -0
  14. package/dist/audio_stream.cjs.map +1 -0
  15. package/dist/audio_stream.js +77 -78
  16. package/dist/audio_stream.js.map +1 -1
  17. package/dist/e2ee.cjs +268 -0
  18. package/dist/e2ee.cjs.map +1 -0
  19. package/dist/e2ee.d.ts.map +1 -1
  20. package/dist/e2ee.js +244 -221
  21. package/dist/e2ee.js.map +1 -1
  22. package/dist/ffi_client.cjs +101 -0
  23. package/dist/ffi_client.cjs.map +1 -0
  24. package/dist/ffi_client.js +73 -48
  25. package/dist/ffi_client.js.map +1 -1
  26. package/dist/index.cjs +188 -0
  27. package/dist/index.cjs.map +1 -0
  28. package/dist/index.js +130 -48
  29. package/dist/index.js.map +1 -1
  30. package/dist/napi/native.d.cjs +17 -0
  31. package/dist/napi/native.d.cjs.map +1 -0
  32. package/dist/napi/native.d.js +1 -0
  33. package/dist/napi/native.d.js.map +1 -0
  34. package/dist/napi/native.d.ts +5 -5
  35. package/dist/native.cjs +301 -0
  36. package/dist/native.d.ts +19 -0
  37. package/dist/native.js +15 -0
  38. package/dist/participant.cjs +388 -0
  39. package/dist/participant.cjs.map +1 -0
  40. package/dist/participant.js +363 -339
  41. package/dist/participant.js.map +1 -1
  42. package/dist/proto/audio_frame_pb.cjs +193 -0
  43. package/dist/proto/audio_frame_pb.cjs.map +1 -0
  44. package/dist/proto/audio_frame_pb.js +120 -320
  45. package/dist/proto/audio_frame_pb.js.map +1 -1
  46. package/dist/proto/e2ee_pb.cjs +131 -0
  47. package/dist/proto/e2ee_pb.cjs.map +1 -0
  48. package/dist/proto/e2ee_pb.js +76 -202
  49. package/dist/proto/e2ee_pb.js.map +1 -1
  50. package/dist/proto/ffi_pb.cjs +76 -0
  51. package/dist/proto/ffi_pb.cjs.map +1 -0
  52. package/dist/proto/ffi_pb.js +33 -92
  53. package/dist/proto/ffi_pb.js.map +1 -1
  54. package/dist/proto/handle_pb.cjs +33 -0
  55. package/dist/proto/handle_pb.cjs.map +1 -0
  56. package/dist/proto/handle_pb.js +6 -22
  57. package/dist/proto/handle_pb.js.map +1 -1
  58. package/dist/proto/participant_pb.cjs +50 -0
  59. package/dist/proto/participant_pb.cjs.map +1 -0
  60. package/dist/proto/participant_pb.js +19 -57
  61. package/dist/proto/participant_pb.js.map +1 -1
  62. package/dist/proto/room_pb.cjs +370 -0
  63. package/dist/proto/room_pb.cjs.map +1 -0
  64. package/dist/proto/room_pb.js +239 -632
  65. package/dist/proto/room_pb.js.map +1 -1
  66. package/dist/proto/rpc_pb.cjs +63 -0
  67. package/dist/proto/rpc_pb.cjs.map +1 -0
  68. package/dist/proto/rpc_pb.js +26 -72
  69. package/dist/proto/rpc_pb.js.map +1 -1
  70. package/dist/proto/stats_pb.cjs +256 -0
  71. package/dist/proto/stats_pb.cjs.map +1 -0
  72. package/dist/proto/stats_pb.js +175 -456
  73. package/dist/proto/stats_pb.js.map +1 -1
  74. package/dist/proto/track_pb.cjs +116 -0
  75. package/dist/proto/track_pb.cjs.map +1 -0
  76. package/dist/proto/track_pb.js +65 -171
  77. package/dist/proto/track_pb.js.map +1 -1
  78. package/dist/proto/video_frame_pb.cjs +161 -0
  79. package/dist/proto/video_frame_pb.cjs.map +1 -0
  80. package/dist/proto/video_frame_pb.js +101 -269
  81. package/dist/proto/video_frame_pb.js.map +1 -1
  82. package/dist/room.cjs +440 -0
  83. package/dist/room.cjs.map +1 -0
  84. package/dist/room.js +384 -373
  85. package/dist/room.js.map +1 -1
  86. package/dist/rpc.cjs +89 -0
  87. package/dist/rpc.cjs.map +1 -0
  88. package/dist/rpc.js +59 -63
  89. package/dist/rpc.js.map +1 -1
  90. package/dist/track.cjs +100 -0
  91. package/dist/track.cjs.map +1 -0
  92. package/dist/track.js +66 -62
  93. package/dist/track.js.map +1 -1
  94. package/dist/track_publication.cjs +106 -0
  95. package/dist/track_publication.cjs.map +1 -0
  96. package/dist/track_publication.js +76 -74
  97. package/dist/track_publication.js.map +1 -1
  98. package/dist/transcription.cjs +17 -0
  99. package/dist/transcription.cjs.map +1 -0
  100. package/dist/transcription.js +0 -1
  101. package/dist/transcription.js.map +1 -1
  102. package/dist/types.cjs +17 -0
  103. package/dist/types.cjs.map +1 -0
  104. package/dist/types.js +0 -1
  105. package/dist/types.js.map +1 -1
  106. package/dist/version.cjs +29 -0
  107. package/dist/version.cjs.map +1 -0
  108. package/dist/version.d.ts +1 -1
  109. package/dist/version.js +4 -1
  110. package/dist/version.js.map +1 -1
  111. package/dist/video_frame.cjs +242 -0
  112. package/dist/video_frame.cjs.map +1 -0
  113. package/dist/video_frame.js +212 -201
  114. package/dist/video_frame.js.map +1 -1
  115. package/dist/video_source.cjs +63 -0
  116. package/dist/video_source.cjs.map +1 -0
  117. package/dist/video_source.d.ts.map +1 -1
  118. package/dist/video_source.js +42 -37
  119. package/dist/video_source.js.map +1 -1
  120. package/dist/video_stream.cjs +103 -0
  121. package/dist/video_stream.cjs.map +1 -0
  122. package/dist/video_stream.js +76 -77
  123. package/dist/video_stream.js.map +1 -1
  124. package/package.json +18 -9
  125. package/src/audio_frame.ts +2 -2
  126. package/src/audio_source.ts +2 -2
  127. package/src/e2ee.ts +2 -2
  128. package/src/napi/native.d.ts +5 -5
  129. package/src/version.ts +1 -1
  130. package/src/video_frame.ts +1 -1
  131. package/src/video_source.ts +5 -1
@@ -1,211 +1,222 @@
1
- // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
- //
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 { VideoBufferInfoSchema, VideoBufferInfo_ComponentInfoSchema, VideoBufferType, } from './proto/video_frame_pb.js';
8
- export class VideoFrame {
9
- constructor(data, width, height, type) {
10
- this.data = data;
11
- this.width = width;
12
- this.height = height;
13
- this.type = type;
1
+ import { create } from "@bufbuild/protobuf";
2
+ import { FfiClient } from "./ffi_client.js";
3
+ import { FfiRequestSchema } from "./proto/ffi_pb.js";
4
+ import {
5
+ VideoBufferInfoSchema,
6
+ VideoBufferInfo_ComponentInfoSchema,
7
+ VideoBufferType
8
+ } from "./proto/video_frame_pb.js";
9
+ class VideoFrame {
10
+ constructor(data, width, height, type) {
11
+ this.data = data;
12
+ this.width = width;
13
+ this.height = height;
14
+ this.type = type;
15
+ }
16
+ /** @internal */
17
+ get dataPtr() {
18
+ return FfiClient.instance.retrievePtr(new Uint8Array(this.data.buffer));
19
+ }
20
+ /** @internal */
21
+ protoInfo() {
22
+ const info = create(VideoBufferInfoSchema, {
23
+ width: this.width,
24
+ height: this.height,
25
+ type: this.type,
26
+ dataPtr: this.dataPtr
27
+ });
28
+ switch (this.type) {
29
+ case VideoBufferType.ARGB:
30
+ case VideoBufferType.RGBA:
31
+ case VideoBufferType.ABGR:
32
+ case VideoBufferType.BGRA:
33
+ info.stride = this.width * 4;
34
+ break;
35
+ case VideoBufferType.RGB24:
36
+ info.stride = this.width * 3;
37
+ break;
14
38
  }
15
- /** @internal */
16
- get dataPtr() {
17
- return FfiClient.instance.retrievePtr(new Uint8Array(this.data.buffer));
18
- }
19
- /** @internal */
20
- protoInfo() {
21
- const info = create(VideoBufferInfoSchema, {
22
- width: this.width,
23
- height: this.height,
24
- type: this.type,
25
- dataPtr: this.dataPtr,
26
- });
27
- switch (this.type) {
28
- case VideoBufferType.ARGB:
29
- case VideoBufferType.RGBA:
30
- case VideoBufferType.ABGR:
31
- case VideoBufferType.BGRA:
32
- info.stride = this.width * 4;
33
- break;
34
- case VideoBufferType.RGB24:
35
- info.stride = this.width * 3;
36
- break;
37
- }
38
- info.components.push(...getPlaneInfos(this.dataPtr, this.type, this.width, this.height));
39
- return info;
40
- }
41
- /** @internal */
42
- static fromOwnedInfo(owned) {
43
- const info = owned.info;
44
- return new VideoFrame(FfiClient.instance.copyBuffer(info.dataPtr, getPlaneLength(info.type, info.width, info.height)), info.width, info.height, info.type);
45
- }
46
- getPlane(planeNth) {
47
- const planeInfos = getPlaneInfos(this.dataPtr, this.type, this.width, this.height);
48
- if (planeNth >= planeInfos.length)
49
- return;
50
- const planeInfo = planeInfos[planeNth];
51
- return FfiClient.instance.copyBuffer(planeInfo.dataPtr, planeInfo.size);
52
- }
53
- convert(dstType, flipY = false) {
54
- const req = create(FfiRequestSchema, {
55
- message: {
56
- case: 'videoConvert',
57
- value: {
58
- flipY,
59
- dstType,
60
- buffer: this.protoInfo(),
61
- },
62
- },
63
- });
64
- const resp = FfiClient.instance.request(req);
65
- if (resp.message.case !== 'buffer') {
66
- throw new Error(resp.message.value ?? 'Unknown Error');
39
+ info.components.push(...getPlaneInfos(this.dataPtr, this.type, this.width, this.height));
40
+ return info;
41
+ }
42
+ /** @internal */
43
+ static fromOwnedInfo(owned) {
44
+ const info = owned.info;
45
+ return new VideoFrame(
46
+ FfiClient.instance.copyBuffer(
47
+ info.dataPtr,
48
+ getPlaneLength(info.type, info.width, info.height)
49
+ ),
50
+ info.width,
51
+ info.height,
52
+ info.type
53
+ );
54
+ }
55
+ getPlane(planeNth) {
56
+ const planeInfos = getPlaneInfos(this.dataPtr, this.type, this.width, this.height);
57
+ if (planeNth >= planeInfos.length) return;
58
+ const planeInfo = planeInfos[planeNth];
59
+ return FfiClient.instance.copyBuffer(planeInfo.dataPtr, planeInfo.size);
60
+ }
61
+ convert(dstType, flipY = false) {
62
+ const req = create(FfiRequestSchema, {
63
+ message: {
64
+ case: "videoConvert",
65
+ value: {
66
+ flipY,
67
+ dstType,
68
+ buffer: this.protoInfo()
67
69
  }
68
- return VideoFrame.fromOwnedInfo(resp.message.value);
70
+ }
71
+ });
72
+ const resp = FfiClient.instance.request(req);
73
+ if (resp.message.case !== "buffer") {
74
+ throw new Error(resp.message.value ?? "Unknown Error");
69
75
  }
76
+ return VideoFrame.fromOwnedInfo(resp.message.value);
77
+ }
70
78
  }
71
79
  const getPlaneLength = (type, width, height) => {
72
- const chromaWidth = Math.trunc((width + 1) / 2);
73
- const chromaHeight = Math.trunc((height + 1) / 2);
74
- switch (type) {
75
- case VideoBufferType.ARGB:
76
- case VideoBufferType.RGBA:
77
- case VideoBufferType.ABGR:
78
- case VideoBufferType.BGRA:
79
- return width * height * 4;
80
- case VideoBufferType.RGB24:
81
- case VideoBufferType.I444:
82
- return width * height * 3;
83
- case VideoBufferType.I420:
84
- return width * height + chromaWidth * chromaHeight * 2;
85
- case VideoBufferType.I420A:
86
- return width * height * 2 + chromaWidth * chromaWidth * 2;
87
- case VideoBufferType.I422:
88
- return width * height + chromaWidth * height * 2;
89
- case VideoBufferType.I010:
90
- return width * height * 2 + chromaWidth * chromaHeight * 4;
91
- case VideoBufferType.NV12:
92
- return width * height + chromaWidth * chromaWidth * 2;
93
- }
80
+ const chromaWidth = Math.trunc((width + 1) / 2);
81
+ const chromaHeight = Math.trunc((height + 1) / 2);
82
+ switch (type) {
83
+ case VideoBufferType.ARGB:
84
+ case VideoBufferType.RGBA:
85
+ case VideoBufferType.ABGR:
86
+ case VideoBufferType.BGRA:
87
+ return width * height * 4;
88
+ case VideoBufferType.RGB24:
89
+ case VideoBufferType.I444:
90
+ return width * height * 3;
91
+ case VideoBufferType.I420:
92
+ return width * height + chromaWidth * chromaHeight * 2;
93
+ case VideoBufferType.I420A:
94
+ return width * height * 2 + chromaWidth * chromaWidth * 2;
95
+ case VideoBufferType.I422:
96
+ return width * height + chromaWidth * height * 2;
97
+ case VideoBufferType.I010:
98
+ return width * height * 2 + chromaWidth * chromaHeight * 4;
99
+ case VideoBufferType.NV12:
100
+ return width * height + chromaWidth * chromaWidth * 2;
101
+ }
94
102
  };
95
103
  const getPlaneInfos = (dataPtr, type, width, height) => {
96
- const chromaWidth = Math.trunc((width + 1) / 2);
97
- const chromaHeight = Math.trunc((height + 1) / 2);
98
- switch (type) {
99
- case VideoBufferType.I420: {
100
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
101
- dataPtr,
102
- stride: width,
103
- size: width * height,
104
- });
105
- const u = create(VideoBufferInfo_ComponentInfoSchema, {
106
- dataPtr: y.dataPtr + BigInt(y.size),
107
- stride: chromaWidth,
108
- size: chromaWidth * chromaHeight,
109
- });
110
- const v = create(VideoBufferInfo_ComponentInfoSchema, {
111
- dataPtr: u.dataPtr + BigInt(u.size),
112
- stride: chromaWidth,
113
- size: chromaWidth * chromaHeight,
114
- });
115
- return [y, u, v];
116
- }
117
- case VideoBufferType.I420A: {
118
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
119
- dataPtr,
120
- stride: width,
121
- size: width * height,
122
- });
123
- const u = create(VideoBufferInfo_ComponentInfoSchema, {
124
- dataPtr: y.dataPtr + BigInt(y.size),
125
- stride: chromaWidth,
126
- size: chromaWidth * chromaHeight,
127
- });
128
- const v = create(VideoBufferInfo_ComponentInfoSchema, {
129
- dataPtr: u.dataPtr + BigInt(u.size),
130
- stride: chromaWidth,
131
- size: chromaWidth * chromaHeight,
132
- });
133
- const a = create(VideoBufferInfo_ComponentInfoSchema, {
134
- dataPtr: v.dataPtr + BigInt(v.size),
135
- stride: width,
136
- size: width * height,
137
- });
138
- return [y, u, v, a];
139
- }
140
- case VideoBufferType.I422: {
141
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
142
- dataPtr,
143
- stride: width,
144
- size: width * height,
145
- });
146
- const u = create(VideoBufferInfo_ComponentInfoSchema, {
147
- dataPtr: y.dataPtr + BigInt(y.size),
148
- stride: chromaWidth,
149
- size: chromaWidth * height,
150
- });
151
- const v = create(VideoBufferInfo_ComponentInfoSchema, {
152
- dataPtr: u.dataPtr + BigInt(u.size),
153
- stride: chromaWidth,
154
- size: chromaWidth * height,
155
- });
156
- return [y, u, v];
157
- }
158
- case VideoBufferType.I444: {
159
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
160
- dataPtr,
161
- stride: width,
162
- size: width * height,
163
- });
164
- const u = create(VideoBufferInfo_ComponentInfoSchema, {
165
- dataPtr: y.dataPtr + BigInt(y.size),
166
- stride: width,
167
- size: width * height,
168
- });
169
- const v = create(VideoBufferInfo_ComponentInfoSchema, {
170
- dataPtr: u.dataPtr + BigInt(u.size),
171
- stride: width,
172
- size: width * height,
173
- });
174
- return [y, u, v];
175
- }
176
- case VideoBufferType.I010: {
177
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
178
- dataPtr,
179
- stride: width * 2,
180
- size: width * height * 2,
181
- });
182
- const u = create(VideoBufferInfo_ComponentInfoSchema, {
183
- dataPtr: y.dataPtr + BigInt(y.size),
184
- stride: chromaWidth * 2,
185
- size: chromaWidth * chromaHeight * 2,
186
- });
187
- const v = create(VideoBufferInfo_ComponentInfoSchema, {
188
- dataPtr: u.dataPtr + BigInt(u.size),
189
- stride: chromaWidth * 2,
190
- size: chromaWidth * chromaHeight * 2,
191
- });
192
- return [y, u, v];
193
- }
194
- case VideoBufferType.NV12: {
195
- const y = create(VideoBufferInfo_ComponentInfoSchema, {
196
- dataPtr,
197
- stride: width,
198
- size: width * height,
199
- });
200
- const uv = create(VideoBufferInfo_ComponentInfoSchema, {
201
- dataPtr: y.dataPtr + BigInt(y.size),
202
- stride: chromaWidth * 2,
203
- size: chromaWidth * chromaHeight * 2,
204
- });
205
- return [y, uv];
206
- }
207
- default:
208
- return [];
104
+ const chromaWidth = Math.trunc((width + 1) / 2);
105
+ const chromaHeight = Math.trunc((height + 1) / 2);
106
+ switch (type) {
107
+ case VideoBufferType.I420: {
108
+ const y = create(VideoBufferInfo_ComponentInfoSchema, {
109
+ dataPtr,
110
+ stride: width,
111
+ size: width * height
112
+ });
113
+ const u = create(VideoBufferInfo_ComponentInfoSchema, {
114
+ dataPtr: y.dataPtr + BigInt(y.size),
115
+ stride: chromaWidth,
116
+ size: chromaWidth * chromaHeight
117
+ });
118
+ const v = create(VideoBufferInfo_ComponentInfoSchema, {
119
+ dataPtr: u.dataPtr + BigInt(u.size),
120
+ stride: chromaWidth,
121
+ size: chromaWidth * chromaHeight
122
+ });
123
+ return [y, u, v];
124
+ }
125
+ case VideoBufferType.I420A: {
126
+ const y = create(VideoBufferInfo_ComponentInfoSchema, {
127
+ dataPtr,
128
+ stride: width,
129
+ size: width * height
130
+ });
131
+ const u = create(VideoBufferInfo_ComponentInfoSchema, {
132
+ dataPtr: y.dataPtr + BigInt(y.size),
133
+ stride: chromaWidth,
134
+ size: chromaWidth * chromaHeight
135
+ });
136
+ const v = create(VideoBufferInfo_ComponentInfoSchema, {
137
+ dataPtr: u.dataPtr + BigInt(u.size),
138
+ stride: chromaWidth,
139
+ size: chromaWidth * chromaHeight
140
+ });
141
+ const a = create(VideoBufferInfo_ComponentInfoSchema, {
142
+ dataPtr: v.dataPtr + BigInt(v.size),
143
+ stride: width,
144
+ size: width * height
145
+ });
146
+ return [y, u, v, a];
147
+ }
148
+ case VideoBufferType.I422: {
149
+ const y = create(VideoBufferInfo_ComponentInfoSchema, {
150
+ dataPtr,
151
+ stride: width,
152
+ size: width * height
153
+ });
154
+ const u = create(VideoBufferInfo_ComponentInfoSchema, {
155
+ dataPtr: y.dataPtr + BigInt(y.size),
156
+ stride: chromaWidth,
157
+ size: chromaWidth * height
158
+ });
159
+ const v = create(VideoBufferInfo_ComponentInfoSchema, {
160
+ dataPtr: u.dataPtr + BigInt(u.size),
161
+ stride: chromaWidth,
162
+ size: chromaWidth * height
163
+ });
164
+ return [y, u, v];
209
165
  }
166
+ case VideoBufferType.I444: {
167
+ const y = create(VideoBufferInfo_ComponentInfoSchema, {
168
+ dataPtr,
169
+ stride: width,
170
+ size: width * height
171
+ });
172
+ const u = create(VideoBufferInfo_ComponentInfoSchema, {
173
+ dataPtr: y.dataPtr + BigInt(y.size),
174
+ stride: width,
175
+ size: width * height
176
+ });
177
+ const v = create(VideoBufferInfo_ComponentInfoSchema, {
178
+ dataPtr: u.dataPtr + BigInt(u.size),
179
+ stride: width,
180
+ size: width * height
181
+ });
182
+ return [y, u, v];
183
+ }
184
+ case VideoBufferType.I010: {
185
+ const y = create(VideoBufferInfo_ComponentInfoSchema, {
186
+ dataPtr,
187
+ stride: width * 2,
188
+ size: width * height * 2
189
+ });
190
+ const u = create(VideoBufferInfo_ComponentInfoSchema, {
191
+ dataPtr: y.dataPtr + BigInt(y.size),
192
+ stride: chromaWidth * 2,
193
+ size: chromaWidth * chromaHeight * 2
194
+ });
195
+ const v = create(VideoBufferInfo_ComponentInfoSchema, {
196
+ dataPtr: u.dataPtr + BigInt(u.size),
197
+ stride: chromaWidth * 2,
198
+ size: chromaWidth * chromaHeight * 2
199
+ });
200
+ return [y, u, v];
201
+ }
202
+ case VideoBufferType.NV12: {
203
+ const y = create(VideoBufferInfo_ComponentInfoSchema, {
204
+ dataPtr,
205
+ stride: width,
206
+ size: width * height
207
+ });
208
+ const uv = create(VideoBufferInfo_ComponentInfoSchema, {
209
+ dataPtr: y.dataPtr + BigInt(y.size),
210
+ stride: chromaWidth * 2,
211
+ size: chromaWidth * chromaHeight * 2
212
+ });
213
+ return [y, uv];
214
+ }
215
+ default:
216
+ return [];
217
+ }
218
+ };
219
+ export {
220
+ VideoFrame
210
221
  };
211
222
  //# sourceMappingURL=video_frame.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"video_frame.js","sourceRoot":"","sources":["../src/video_frame.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,sCAAsC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM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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":"AAGA,SAAS,cAAc;AACvB,SAAS,iBAAiB;AAC1B,SAAS,wBAAwB;AAOjC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;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,UAAU,SAAS,YAAY,IAAI,WAAW,KAAK,KAAK,MAAM,CAAC;AAAA,EACxE;AAAA;AAAA,EAGA,YAA6B;AAC3B,UAAM,OAAO,OAAO,uBAAuB;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,gBAAgB;AAAA,MACrB,KAAK,gBAAgB;AAAA,MACrB,KAAK,gBAAgB;AAAA,MACrB,KAAK,gBAAgB;AACnB,aAAK,SAAS,KAAK,QAAQ;AAC3B;AAAA,MACF,KAAK,gBAAgB;AACnB,aAAK,SAAS,KAAK,QAAQ;AAC3B;AAAA,IACJ;AAEA,SAAK,WAAW,KAAK,GAAG,cAAc,KAAK,SAAS,KAAK,MAAM,KAAK,OAAO,KAAK,MAAM,CAAC;AAEvF,WAAO;AAAA,EACT;AAAA;AAAA,EAGA,OAAO,cAAc,OAAqC;AACxD,UAAM,OAA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AACD,aAAO,CAAC,GAAG,GAAG,CAAC;AAAA,IACjB;AAAA,IACA,KAAK,gBAAgB,MAAM;AACzB,YAAM,IAAI,OAAO,qCAAqC;AAAA,QACpD;AAAA,QACA,QAAQ,QAAQ;AAAA,QAChB,MAAM,QAAQ,SAAS;AAAA,MACzB,CAAC;AACD,YAAM,IAAI,OAAO,qCAAqC;AAAA,QACpD,SAAS,EAAE,UAAU,OAAO,EAAE,IAAI;AAAA,QAClC,QAAQ,cAAc;AAAA,QACtB,MAAM,cAAc,eAAe;AAAA,MACrC,CAAC;AACD,YAAM,IAAI,OAAO,qCAAqC;AAAA,QACpD,SAAS,EAAE,UAAU,OAAO,EAAE,IAAI;AAAA,QAClC,QAAQ,cAAc;AAAA,QACtB,MAAM,cAAc,eAAe;AAAA,MACrC,CAAC;AACD,aAAO,CAAC,GAAG,GAAG,CAAC;AAAA,IACjB;AAAA,IACA,KAAK,gBAAgB,MAAM;AACzB,YAAM,IAAI,OAAO,qCAAqC;AAAA,QACpD;AAAA,QACA,QAAQ;AAAA,QACR,MAAM,QAAQ;AAAA,MAChB,CAAC;AACD,YAAM,KAAK,OAAO,qCAAqC;AAAA,QACrD,SAAS,EAAE,UAAU,OAAO,EAAE,IAAI;AAAA,QAClC,QAAQ,cAAc;AAAA,QACtB,MAAM,cAAc,eAAe;AAAA,MACrC,CAAC;AACD,aAAO,CAAC,GAAG,EAAE;AAAA,IACf;AAAA,IACA;AACE,aAAO,CAAC;AAAA,EACZ;AACF;","names":[]}
@@ -0,0 +1,63 @@
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_source_exports = {};
20
+ __export(video_source_exports, {
21
+ VideoSource: () => VideoSource
22
+ });
23
+ module.exports = __toCommonJS(video_source_exports);
24
+ var import_protobuf = require("@bufbuild/protobuf");
25
+ var import_ffi_client = require("./ffi_client.cjs");
26
+ var import_video_frame_pb = require("./proto/video_frame_pb.cjs");
27
+ class VideoSource {
28
+ constructor(width, height) {
29
+ this.width = width;
30
+ this.height = height;
31
+ const req = (0, import_protobuf.create)(import_video_frame_pb.NewVideoSourceRequestSchema, {
32
+ type: import_video_frame_pb.VideoSourceType.VIDEO_SOURCE_NATIVE,
33
+ resolution: {
34
+ width,
35
+ height
36
+ }
37
+ });
38
+ const res = import_ffi_client.FfiClient.instance.request({
39
+ message: {
40
+ case: "newVideoSource",
41
+ value: req
42
+ }
43
+ });
44
+ this.info = res.source.info;
45
+ this.ffiHandle = new import_ffi_client.FfiHandle(res.source.handle.id);
46
+ }
47
+ captureFrame(frame, timestampUs = BigInt(0), rotation = import_video_frame_pb.VideoRotation.VIDEO_ROTATION_0) {
48
+ const req = (0, import_protobuf.create)(import_video_frame_pb.CaptureVideoFrameRequestSchema, {
49
+ sourceHandle: this.ffiHandle.handle,
50
+ buffer: frame.protoInfo(),
51
+ rotation,
52
+ timestampUs
53
+ });
54
+ import_ffi_client.FfiClient.instance.request({
55
+ message: { case: "captureVideoFrame", value: req }
56
+ });
57
+ }
58
+ }
59
+ // Annotate the CommonJS export names for ESM import in node:
60
+ 0 && (module.exports = {
61
+ VideoSource
62
+ });
63
+ //# sourceMappingURL=video_source.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/video_source.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { create } from '@bufbuild/protobuf';\nimport { FfiClient, FfiHandle } from './ffi_client.js';\nimport type {\n CaptureVideoFrameResponse,\n NewVideoSourceResponse,\n VideoSourceInfo,\n} from './proto/video_frame_pb.js';\nimport {\n CaptureVideoFrameRequestSchema,\n NewVideoSourceRequestSchema,\n VideoRotation,\n VideoSourceType,\n} from './proto/video_frame_pb.js';\nimport type { VideoFrame } from './video_frame.js';\n\nexport class VideoSource {\n /** @internal */\n info: VideoSourceInfo;\n /** @internal */\n ffiHandle: FfiHandle;\n\n width: number;\n height: number;\n\n constructor(width: number, height: number) {\n this.width = width;\n this.height = height;\n\n const req = create(NewVideoSourceRequestSchema, {\n type: VideoSourceType.VIDEO_SOURCE_NATIVE,\n resolution: {\n width: width,\n height: height,\n },\n });\n\n const res = FfiClient.instance.request<NewVideoSourceResponse>({\n message: {\n case: 'newVideoSource',\n value: req,\n },\n });\n\n this.info = res.source!.info!;\n this.ffiHandle = new FfiHandle(res.source!.handle!.id);\n }\n\n captureFrame(\n frame: VideoFrame,\n timestampUs = BigInt(0),\n rotation = VideoRotation.VIDEO_ROTATION_0,\n ) {\n const req = create(CaptureVideoFrameRequestSchema, {\n sourceHandle: this.ffiHandle.handle,\n buffer: frame.protoInfo(),\n rotation,\n timestampUs,\n });\n\n FfiClient.instance.request<CaptureVideoFrameResponse>({\n message: { case: 'captureVideoFrame', value: req },\n });\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,sBAAuB;AACvB,wBAAqC;AAMrC,4BAKO;AAGA,MAAM,YAAY;AAAA,EASvB,YAAY,OAAe,QAAgB;AACzC,SAAK,QAAQ;AACb,SAAK,SAAS;AAEd,UAAM,UAAM,wBAAO,mDAA6B;AAAA,MAC9C,MAAM,sCAAgB;AAAA,MACtB,YAAY;AAAA,QACV;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAED,UAAM,MAAM,4BAAU,SAAS,QAAgC;AAAA,MAC7D,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,SAAK,OAAO,IAAI,OAAQ;AACxB,SAAK,YAAY,IAAI,4BAAU,IAAI,OAAQ,OAAQ,EAAE;AAAA,EACvD;AAAA,EAEA,aACE,OACA,cAAc,OAAO,CAAC,GACtB,WAAW,oCAAc,kBACzB;AACA,UAAM,UAAM,wBAAO,sDAAgC;AAAA,MACjD,cAAc,KAAK,UAAU;AAAA,MAC7B,QAAQ,MAAM,UAAU;AAAA,MACxB;AAAA,MACA;AAAA,IACF,CAAC;AAED,gCAAU,SAAS,QAAmC;AAAA,MACpD,SAAS,EAAE,MAAM,qBAAqB,OAAO,IAAI;AAAA,IACnD,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"video_source.d.ts","sourceRoot":"","sources":["../src/video_source.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,aAAa,EAEd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,qBAAa,WAAW;IACtB,gBAAgB;IAChB,IAAI,EAAE,eAAe,CAAC;IACtB,gBAAgB;IAChB,SAAS,EAAE,SAAS,CAAC;IAErB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;gBAEH,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAuBzC,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,SAAK,EAAE,QAAQ,gBAAiC;CAY5F"}
1
+ {"version":3,"file":"video_source.d.ts","sourceRoot":"","sources":["../src/video_source.ts"],"names":[],"mappings":"AAIA,OAAO,EAAa,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAGV,eAAe,EAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAGL,aAAa,EAEd,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD,qBAAa,WAAW;IACtB,gBAAgB;IAChB,IAAI,EAAE,eAAe,CAAC;IACtB,gBAAgB;IAChB,SAAS,EAAE,SAAS,CAAC;IAErB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;gBAEH,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAuBzC,YAAY,CACV,KAAK,EAAE,UAAU,EACjB,WAAW,SAAY,EACvB,QAAQ,gBAAiC;CAa5C"}
@@ -1,39 +1,44 @@
1
- // SPDX-FileCopyrightText: 2024 LiveKit, Inc.
2
- //
3
- // SPDX-License-Identifier: Apache-2.0
4
- import { create } from '@bufbuild/protobuf';
5
- import { FfiClient, FfiHandle } from './ffi_client.js';
6
- import { CaptureVideoFrameRequestSchema, NewVideoSourceRequestSchema, VideoRotation, VideoSourceType, } from './proto/video_frame_pb.js';
7
- export class VideoSource {
8
- constructor(width, height) {
9
- this.width = width;
10
- this.height = height;
11
- const req = create(NewVideoSourceRequestSchema, {
12
- type: VideoSourceType.VIDEO_SOURCE_NATIVE,
13
- resolution: {
14
- width: width,
15
- height: height,
16
- },
17
- });
18
- const res = FfiClient.instance.request({
19
- message: {
20
- case: 'newVideoSource',
21
- value: req,
22
- },
23
- });
24
- this.info = res.source.info;
25
- this.ffiHandle = new FfiHandle(res.source.handle.id);
26
- }
27
- captureFrame(frame, timestampUs = 0n, rotation = VideoRotation.VIDEO_ROTATION_0) {
28
- const req = create(CaptureVideoFrameRequestSchema, {
29
- sourceHandle: this.ffiHandle.handle,
30
- buffer: frame.protoInfo(),
31
- rotation,
32
- timestampUs,
33
- });
34
- FfiClient.instance.request({
35
- message: { case: 'captureVideoFrame', value: req },
36
- });
37
- }
1
+ import { create } from "@bufbuild/protobuf";
2
+ import { FfiClient, FfiHandle } from "./ffi_client.js";
3
+ import {
4
+ CaptureVideoFrameRequestSchema,
5
+ NewVideoSourceRequestSchema,
6
+ VideoRotation,
7
+ VideoSourceType
8
+ } from "./proto/video_frame_pb.js";
9
+ class VideoSource {
10
+ constructor(width, height) {
11
+ this.width = width;
12
+ this.height = height;
13
+ const req = create(NewVideoSourceRequestSchema, {
14
+ type: VideoSourceType.VIDEO_SOURCE_NATIVE,
15
+ resolution: {
16
+ width,
17
+ height
18
+ }
19
+ });
20
+ const res = FfiClient.instance.request({
21
+ message: {
22
+ case: "newVideoSource",
23
+ value: req
24
+ }
25
+ });
26
+ this.info = res.source.info;
27
+ this.ffiHandle = new FfiHandle(res.source.handle.id);
28
+ }
29
+ captureFrame(frame, timestampUs = BigInt(0), rotation = VideoRotation.VIDEO_ROTATION_0) {
30
+ const req = create(CaptureVideoFrameRequestSchema, {
31
+ sourceHandle: this.ffiHandle.handle,
32
+ buffer: frame.protoInfo(),
33
+ rotation,
34
+ timestampUs
35
+ });
36
+ FfiClient.instance.request({
37
+ message: { case: "captureVideoFrame", value: req }
38
+ });
39
+ }
38
40
  }
41
+ export {
42
+ VideoSource
43
+ };
39
44
  //# sourceMappingURL=video_source.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"video_source.js","sourceRoot":"","sources":["../src/video_source.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,EAAE;AACF,sCAAsC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAMvD,OAAO,EACL,8BAA8B,EAC9B,2BAA2B,EAC3B,aAAa,EACb,eAAe,GAChB,MAAM,2BAA2B,CAAC;AAGnC,MAAM,OAAO,WAAW;IAStB,YAAY,KAAa,EAAE,MAAc;QACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,MAAM,GAAG,GAAG,MAAM,CAAC,2BAA2B,EAAE;YAC9C,IAAI,EAAE,eAAe,CAAC,mBAAmB;YACzC,UAAU,EAAE;gBACV,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,MAAM;aACf;SACF,CAAC,CAAC;QAEH,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAyB;YAC7D,OAAO,EAAE;gBACP,IAAI,EAAE,gBAAgB;gBACtB,KAAK,EAAE,GAAG;aACX;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,MAAO,CAAC,IAAK,CAAC;QAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,GAAG,CAAC,MAAO,CAAC,MAAO,CAAC,EAAE,CAAC,CAAC;IACzD,CAAC;IAED,YAAY,CAAC,KAAiB,EAAE,WAAW,GAAG,EAAE,EAAE,QAAQ,GAAG,aAAa,CAAC,gBAAgB;QACzF,MAAM,GAAG,GAAG,MAAM,CAAC,8BAA8B,EAAE;YACjD,YAAY,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM;YACnC,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE;YACzB,QAAQ;YACR,WAAW;SACZ,CAAC,CAAC;QAEH,SAAS,CAAC,QAAQ,CAAC,OAAO,CAA4B;YACpD,OAAO,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE,KAAK,EAAE,GAAG,EAAE;SACnD,CAAC,CAAC;IACL,CAAC;CACF"}
1
+ {"version":3,"sources":["../src/video_source.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2024 LiveKit, Inc.\n//\n// SPDX-License-Identifier: Apache-2.0\nimport { create } from '@bufbuild/protobuf';\nimport { FfiClient, FfiHandle } from './ffi_client.js';\nimport type {\n CaptureVideoFrameResponse,\n NewVideoSourceResponse,\n VideoSourceInfo,\n} from './proto/video_frame_pb.js';\nimport {\n CaptureVideoFrameRequestSchema,\n NewVideoSourceRequestSchema,\n VideoRotation,\n VideoSourceType,\n} from './proto/video_frame_pb.js';\nimport type { VideoFrame } from './video_frame.js';\n\nexport class VideoSource {\n /** @internal */\n info: VideoSourceInfo;\n /** @internal */\n ffiHandle: FfiHandle;\n\n width: number;\n height: number;\n\n constructor(width: number, height: number) {\n this.width = width;\n this.height = height;\n\n const req = create(NewVideoSourceRequestSchema, {\n type: VideoSourceType.VIDEO_SOURCE_NATIVE,\n resolution: {\n width: width,\n height: height,\n },\n });\n\n const res = FfiClient.instance.request<NewVideoSourceResponse>({\n message: {\n case: 'newVideoSource',\n value: req,\n },\n });\n\n this.info = res.source!.info!;\n this.ffiHandle = new FfiHandle(res.source!.handle!.id);\n }\n\n captureFrame(\n frame: VideoFrame,\n timestampUs = BigInt(0),\n rotation = VideoRotation.VIDEO_ROTATION_0,\n ) {\n const req = create(CaptureVideoFrameRequestSchema, {\n sourceHandle: this.ffiHandle.handle,\n buffer: frame.protoInfo(),\n rotation,\n timestampUs,\n });\n\n FfiClient.instance.request<CaptureVideoFrameResponse>({\n message: { case: 'captureVideoFrame', value: req },\n });\n }\n}\n"],"mappings":"AAGA,SAAS,cAAc;AACvB,SAAS,WAAW,iBAAiB;AAMrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGA,MAAM,YAAY;AAAA,EASvB,YAAY,OAAe,QAAgB;AACzC,SAAK,QAAQ;AACb,SAAK,SAAS;AAEd,UAAM,MAAM,OAAO,6BAA6B;AAAA,MAC9C,MAAM,gBAAgB;AAAA,MACtB,YAAY;AAAA,QACV;AAAA,QACA;AAAA,MACF;AAAA,IACF,CAAC;AAED,UAAM,MAAM,UAAU,SAAS,QAAgC;AAAA,MAC7D,SAAS;AAAA,QACP,MAAM;AAAA,QACN,OAAO;AAAA,MACT;AAAA,IACF,CAAC;AAED,SAAK,OAAO,IAAI,OAAQ;AACxB,SAAK,YAAY,IAAI,UAAU,IAAI,OAAQ,OAAQ,EAAE;AAAA,EACvD;AAAA,EAEA,aACE,OACA,cAAc,OAAO,CAAC,GACtB,WAAW,cAAc,kBACzB;AACA,UAAM,MAAM,OAAO,gCAAgC;AAAA,MACjD,cAAc,KAAK,UAAU;AAAA,MAC7B,QAAQ,MAAM,UAAU;AAAA,MACxB;AAAA,MACA;AAAA,IACF,CAAC;AAED,cAAU,SAAS,QAAmC;AAAA,MACpD,SAAS,EAAE,MAAM,qBAAqB,OAAO,IAAI;AAAA,IACnD,CAAC;AAAA,EACH;AACF;","names":[]}