@fishjam-cloud/react-native-custom-video-source 0.29.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.
- package/README.md +70 -0
- package/dist/module/index.js +22 -0
- package/dist/module/index.js.map +1 -0
- package/dist/module/internal/stopStreamTracks.js +9 -0
- package/dist/module/internal/stopStreamTracks.js.map +1 -0
- package/dist/module/internal/toError.js +5 -0
- package/dist/module/internal/toError.js.map +1 -0
- package/dist/module/internal/useManagedForwardTrack.js +63 -0
- package/dist/module/internal/useManagedForwardTrack.js.map +1 -0
- package/dist/module/internal/useManagedPooledTrack.js +120 -0
- package/dist/module/internal/useManagedPooledTrack.js.map +1 -0
- package/dist/module/webgpu/cameraPassthroughPipeline.js +237 -0
- package/dist/module/webgpu/cameraPassthroughPipeline.js.map +1 -0
- package/dist/module/webgpu/cameraShaderBindings.js +126 -0
- package/dist/module/webgpu/cameraShaderBindings.js.map +1 -0
- package/dist/module/webgpu/cameraTextureResolver.js +52 -0
- package/dist/module/webgpu/cameraTextureResolver.js.map +1 -0
- package/dist/module/webgpu/cropUtilities.js +121 -0
- package/dist/module/webgpu/cropUtilities.js.map +1 -0
- package/dist/module/webgpu/frameRenderContext.js +2 -0
- package/dist/module/webgpu/frameRenderContext.js.map +1 -0
- package/dist/module/webgpu/requiredFeatures.js +46 -0
- package/dist/module/webgpu/requiredFeatures.js.map +1 -0
- package/dist/module/webgpu/useCameraWebGpuDevice.js +114 -0
- package/dist/module/webgpu/useCameraWebGpuDevice.js.map +1 -0
- package/dist/module/webgpu/webGpuRuntime.js +25 -0
- package/dist/module/webgpu/webGpuRuntime.js.map +1 -0
- package/dist/module/webgpu.js +25 -0
- package/dist/module/webgpu.js.map +1 -0
- package/dist/typescript/index.d.ts +21 -0
- package/dist/typescript/index.d.ts.map +1 -0
- package/dist/typescript/internal/stopStreamTracks.d.ts +4 -0
- package/dist/typescript/internal/stopStreamTracks.d.ts.map +1 -0
- package/dist/typescript/internal/toError.d.ts +3 -0
- package/dist/typescript/internal/toError.d.ts.map +1 -0
- package/dist/typescript/internal/useManagedForwardTrack.d.ts +17 -0
- package/dist/typescript/internal/useManagedForwardTrack.d.ts.map +1 -0
- package/dist/typescript/internal/useManagedPooledTrack.d.ts +26 -0
- package/dist/typescript/internal/useManagedPooledTrack.d.ts.map +1 -0
- package/dist/typescript/webgpu/cameraPassthroughPipeline.d.ts +46 -0
- package/dist/typescript/webgpu/cameraPassthroughPipeline.d.ts.map +1 -0
- package/dist/typescript/webgpu/cameraShaderBindings.d.ts +69 -0
- package/dist/typescript/webgpu/cameraShaderBindings.d.ts.map +1 -0
- package/dist/typescript/webgpu/cameraTextureResolver.d.ts +39 -0
- package/dist/typescript/webgpu/cameraTextureResolver.d.ts.map +1 -0
- package/dist/typescript/webgpu/cropUtilities.d.ts +67 -0
- package/dist/typescript/webgpu/cropUtilities.d.ts.map +1 -0
- package/dist/typescript/webgpu/frameRenderContext.d.ts +61 -0
- package/dist/typescript/webgpu/frameRenderContext.d.ts.map +1 -0
- package/dist/typescript/webgpu/requiredFeatures.d.ts +25 -0
- package/dist/typescript/webgpu/requiredFeatures.d.ts.map +1 -0
- package/dist/typescript/webgpu/useCameraWebGpuDevice.d.ts +27 -0
- package/dist/typescript/webgpu/useCameraWebGpuDevice.d.ts.map +1 -0
- package/dist/typescript/webgpu/webGpuRuntime.d.ts +14 -0
- package/dist/typescript/webgpu/webGpuRuntime.d.ts.map +1 -0
- package/dist/typescript/webgpu.d.ts +24 -0
- package/dist/typescript/webgpu.d.ts.map +1 -0
- package/package.json +109 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Publish your own video frames to Fishjam.
|
|
3
|
+
*
|
|
4
|
+
* Source-lifecycle hooks that create a custom video track, publish it, and clean it up — you
|
|
5
|
+
* supply the frames from any source. Two modes, picked by how you produce frames:
|
|
6
|
+
*
|
|
7
|
+
* - {@link useManagedForwardTrack} — you already have finished native buffers (a camera, a native
|
|
8
|
+
* ML pipeline, a compositor); forward each buffer pointer with `forwardFrame` from
|
|
9
|
+
* `@fishjam-cloud/react-native-webrtc`.
|
|
10
|
+
* - {@link useManagedPooledTrack} — you render the frames yourself; allocate a surface pool, draw
|
|
11
|
+
* into it, and hand each frame back with `pushFrame`. The `@fishjam-cloud/react-native-custom-video-source/webgpu`
|
|
12
|
+
* entry point provides a WebGPU camera-rendering toolkit for this mode.
|
|
13
|
+
*
|
|
14
|
+
* For a ready-made VisionCamera integration on top of this, use
|
|
15
|
+
* `@fishjam-cloud/react-native-vision-camera-source`.
|
|
16
|
+
*
|
|
17
|
+
* @packageDocumentation
|
|
18
|
+
*/
|
|
19
|
+
export { type ManagedForwardTrack, useManagedForwardTrack } from './internal/useManagedForwardTrack';
|
|
20
|
+
export { type ManagedPooledTrack, useManagedPooledTrack, type WorkletBufferDescriptor, } from './internal/useManagedPooledTrack';
|
|
21
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,KAAK,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AACrG,OAAO,EACL,KAAK,kBAAkB,EACvB,qBAAqB,EACrB,KAAK,uBAAuB,GAC7B,MAAM,kCAAkC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { MediaStream } from '@fishjam-cloud/react-native-webrtc';
|
|
2
|
+
/** Stops every track of `stream`, downgrading failures to a warning tagged with `ownerLabel`. */
|
|
3
|
+
export declare function stopStreamTracks(stream: MediaStream, ownerLabel: string): void;
|
|
4
|
+
//# sourceMappingURL=stopStreamTracks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stopStreamTracks.d.ts","sourceRoot":"","sources":["../../../src/internal/stopStreamTracks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AAEtE,iGAAiG;AACjG,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAM9E"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toError.d.ts","sourceRoot":"","sources":["../../../src/internal/toError.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,CAE7C"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ForwardTrack, type MediaStream } from '@fishjam-cloud/react-native-webrtc';
|
|
2
|
+
/**
|
|
3
|
+
* State of a forwarding custom video track managed by {@link useManagedForwardTrack}.
|
|
4
|
+
* While the track is being created (or after an error) `track` and `stream` are `null`.
|
|
5
|
+
*/
|
|
6
|
+
export interface ManagedForwardTrack {
|
|
7
|
+
track: ForwardTrack | null;
|
|
8
|
+
stream: MediaStream | null;
|
|
9
|
+
error: Error | null;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Owns the async lifecycle of a forwarding custom video track: creates it while `enabled`,
|
|
13
|
+
* exposes the handle + stream once ready, and stops the tracks on disable/unmount (also when
|
|
14
|
+
* creation resolves after the owner already unmounted).
|
|
15
|
+
*/
|
|
16
|
+
export declare function useManagedForwardTrack(enabled: boolean): ManagedForwardTrack;
|
|
17
|
+
//# sourceMappingURL=useManagedForwardTrack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useManagedForwardTrack.d.ts","sourceRoot":"","sources":["../../../src/internal/useManagedForwardTrack.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,WAAW,EACjB,MAAM,oCAAoC,CAAC;AAM5C;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAID;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CAuC5E"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type MediaStream, type PooledTrack } from '@fishjam-cloud/react-native-webrtc';
|
|
2
|
+
/** One pooled output surface as plain values the frame worklet can capture and import itself. */
|
|
3
|
+
export interface WorkletBufferDescriptor {
|
|
4
|
+
index: number;
|
|
5
|
+
surfaceHandle: bigint;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* State of a pooled custom video track managed by {@link useManagedPooledTrack}.
|
|
11
|
+
* While the pool and track are being created (or after an error) all fields are `null`.
|
|
12
|
+
*/
|
|
13
|
+
export interface ManagedPooledTrack {
|
|
14
|
+
track: PooledTrack | null;
|
|
15
|
+
stream: MediaStream | null;
|
|
16
|
+
/** Plain per-surface descriptors (the pool object itself is not worklet-serializable). */
|
|
17
|
+
bufferDescriptors: WorkletBufferDescriptor[] | null;
|
|
18
|
+
error: Error | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Owns the async lifecycle of a surface pool + pooled custom video track: allocates both while
|
|
22
|
+
* `enabled` (re-allocates when the dimensions change), exposes worklet-ready descriptors, and
|
|
23
|
+
* tears down in the correct order (stop tracks, then dispose the pool) on disable/unmount.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useManagedPooledTrack(enabled: boolean, width: number, height: number, poolSize: number): ManagedPooledTrack;
|
|
26
|
+
//# sourceMappingURL=useManagedPooledTrack.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useManagedPooledTrack.d.ts","sourceRoot":"","sources":["../../../src/internal/useManagedPooledTrack.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,WAAW,EACjB,MAAM,oCAAoC,CAAC;AAM5C,iGAAiG;AACjG,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAC3B,0FAA0F;IAC1F,iBAAiB,EAAE,uBAAuB,EAAE,GAAG,IAAI,CAAC;IACpD,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAwCD;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,GACf,kBAAkB,CA8CpB"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type CameraShaderBindings } from './cameraShaderBindings';
|
|
2
|
+
import { type FrameCrop } from './cropUtilities';
|
|
3
|
+
/** Options for {@link createCameraPassthroughPipeline}. */
|
|
4
|
+
export interface CameraPassthroughPipelineOptions {
|
|
5
|
+
/** Render-target format. Defaults to {@link getOutputSurfaceFormat} (the Fishjam output surface). */
|
|
6
|
+
outputFormat?: GPUTextureFormat;
|
|
7
|
+
/** Mirror the camera horizontally (the usual selfie self-view convention). Defaults to `false`. */
|
|
8
|
+
mirror?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A ready-made full-screen camera→target render pipeline. Build once at setup with
|
|
12
|
+
* {@link createCameraPassthroughPipeline}; every field is safe to capture into the frame worklet.
|
|
13
|
+
*
|
|
14
|
+
* @group WebGPU
|
|
15
|
+
*/
|
|
16
|
+
export interface CameraPassthroughPipeline {
|
|
17
|
+
readonly pipeline: GPURenderPipeline;
|
|
18
|
+
/** The camera shader bindings the pipeline samples through. */
|
|
19
|
+
readonly cameraShaderBindings: CameraShaderBindings;
|
|
20
|
+
/** Uniform buffer holding the packed FrameCropParams; written by {@link encodeCameraPassthrough}. */
|
|
21
|
+
readonly cropParamsBuffer: GPUBuffer;
|
|
22
|
+
/** Static bind group with the crop uniform. */
|
|
23
|
+
readonly cropBindGroup: GPUBindGroup;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Builds the full-screen camera passthrough pipeline: crop/orientation via {@link FrameCrop},
|
|
27
|
+
* platform-correct camera sampling, one triangle. Use it to publish the camera through the WebGPU
|
|
28
|
+
* tier with zero WGSL of your own, or as the base pass under your overlay passes.
|
|
29
|
+
*
|
|
30
|
+
* @group WebGPU
|
|
31
|
+
*/
|
|
32
|
+
export declare function createCameraPassthroughPipeline(device: GPUDevice, options?: CameraPassthroughPipelineOptions): CameraPassthroughPipeline;
|
|
33
|
+
/**
|
|
34
|
+
* Encodes one full-screen pass drawing the camera into `outputView`, cropped per `crop`.
|
|
35
|
+
* Worklet-safe; call it inside your render callback, and encode any overlay passes after it on
|
|
36
|
+
* the same command encoder (with `loadOp: 'load'` so they draw on top).
|
|
37
|
+
*
|
|
38
|
+
* At most one call per pipeline instance per frame: the crop lives in a single uniform buffer
|
|
39
|
+
* written via `queue.writeBuffer`, which lands before the submitted command buffer executes — a
|
|
40
|
+
* second call in the same frame makes both draws use the second crop. Encode to multiple targets
|
|
41
|
+
* with different crops by building one pipeline per target.
|
|
42
|
+
*
|
|
43
|
+
* @group WebGPU
|
|
44
|
+
*/
|
|
45
|
+
export declare function encodeCameraPassthrough(device: GPUDevice, passthrough: CameraPassthroughPipeline, cameraTexture: GPUExternalTexture, outputView: GPUTextureView, commandEncoder: GPUCommandEncoder, crop: FrameCrop): void;
|
|
46
|
+
//# sourceMappingURL=cameraPassthroughPipeline.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraPassthroughPipeline.d.ts","sourceRoot":"","sources":["../../../src/webgpu/cameraPassthroughPipeline.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,oBAAoB,EAI1B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,KAAK,SAAS,EAAwC,MAAM,iBAAiB,CAAC;AAoDvF,2DAA2D;AAC3D,MAAM,WAAW,gCAAgC;IAC/C,qGAAqG;IACrG,YAAY,CAAC,EAAE,gBAAgB,CAAC;IAChC,mGAAmG;IACnG,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,+DAA+D;IAC/D,QAAQ,CAAC,oBAAoB,EAAE,oBAAoB,CAAC;IACpD,qGAAqG;IACrG,QAAQ,CAAC,gBAAgB,EAAE,SAAS,CAAC;IACrC,+CAA+C;IAC/C,QAAQ,CAAC,aAAa,EAAE,YAAY,CAAC;CACtC;AAeD;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,MAAM,EAAE,SAAS,EACjB,OAAO,GAAE,gCAAqC,GAC7C,yBAAyB,CAsC3B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,yBAAyB,EACtC,aAAa,EAAE,kBAAkB,EACjC,UAAU,EAAE,cAAc,EAC1B,cAAc,EAAE,iBAAiB,EACjC,IAAI,EAAE,SAAS,GACd,IAAI,CAYN"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { type TgpuFn } from 'typegpu';
|
|
2
|
+
import * as d from 'typegpu/data';
|
|
3
|
+
/**
|
|
4
|
+
* Samples the live camera and returns upright RGB on both platforms (the Android in-shader BT.709
|
|
5
|
+
* YUV decode is included automatically). A TypeGPU function you can call from your own TGSL
|
|
6
|
+
* fragment shaders. It reads the camera texture + sampler declared by
|
|
7
|
+
* {@link CameraShaderBindings.bindingDeclarations}, which you must prepend to the resolved shader.
|
|
8
|
+
*
|
|
9
|
+
* @group WebGPU
|
|
10
|
+
*/
|
|
11
|
+
export declare const sampleCamera: TgpuFn<(uv: d.Vec2f) => d.Vec4f>;
|
|
12
|
+
/** Options for {@link createCameraShaderBindings}. */
|
|
13
|
+
export interface CreateCameraShaderBindingsOptions {
|
|
14
|
+
/** Bind group index the camera texture + sampler are declared at. Defaults to `0`. */
|
|
15
|
+
bindGroupIndex?: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Everything a fragment shader needs to sample the live camera. Build once at setup with
|
|
19
|
+
* {@link createCameraShaderBindings}; the fields are safe to capture into the frame worklet.
|
|
20
|
+
*
|
|
21
|
+
* @group WebGPU
|
|
22
|
+
*/
|
|
23
|
+
export interface CameraShaderBindings {
|
|
24
|
+
/**
|
|
25
|
+
* The camera sampler as a TypeGPU function — call `sampleCamera(uv)` from your TGSL fragment
|
|
26
|
+
* shader. Same value as the exported {@link sampleCamera}.
|
|
27
|
+
*/
|
|
28
|
+
readonly sampleCamera: typeof sampleCamera;
|
|
29
|
+
/**
|
|
30
|
+
* WGSL declaring the camera `texture_external` and `sampler` at {@link bindGroupIndex}. TypeGPU
|
|
31
|
+
* cannot emit an external-texture binding, so prepend this to the WGSL your shader resolves to.
|
|
32
|
+
*/
|
|
33
|
+
readonly bindingDeclarations: string;
|
|
34
|
+
/** Layout of the camera bind group; place it at {@link bindGroupIndex} in your pipeline layout. */
|
|
35
|
+
readonly bindGroupLayout: GPUBindGroupLayout;
|
|
36
|
+
/** The linear-filtering sampler bound at binding 1. */
|
|
37
|
+
readonly sampler: GPUSampler;
|
|
38
|
+
/** The group index the bindings are declared at. */
|
|
39
|
+
readonly bindGroupIndex: number;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Builds the camera-sampling bindings against the device your pipelines use. Pass the result to
|
|
43
|
+
* the source hook's `cameraShaderBindings` option and the render context delivers a ready-made
|
|
44
|
+
* `cameraBindGroup` every frame — set it at {@link CameraShaderBindings.bindGroupIndex} and call
|
|
45
|
+
* `sampleCamera(uv)` in your fragment shader.
|
|
46
|
+
*
|
|
47
|
+
* ```ts
|
|
48
|
+
* const cam = createCameraShaderBindings(device);
|
|
49
|
+
* const fragment = tgpu.fragmentFn({ in: { uv: d.location(0, d.vec2f) }, out: d.vec4f })((input) => {
|
|
50
|
+
* return cam.sampleCamera(input.uv);
|
|
51
|
+
* });
|
|
52
|
+
* const wgsl = cam.bindingDeclarations + tgpu.resolve({ externals: { fragment } });
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* @group WebGPU
|
|
56
|
+
*/
|
|
57
|
+
export declare function createCameraShaderBindings(device: GPUDevice, options?: CreateCameraShaderBindingsOptions): CameraShaderBindings;
|
|
58
|
+
/**
|
|
59
|
+
* Builds the per-frame bind group for the live camera texture. The source hook already does this
|
|
60
|
+
* for you when you pass `cameraShaderBindings` in its options (see the render context's
|
|
61
|
+
* `cameraBindGroup`); call it yourself only for advanced multi-layout setups. Worklet-safe.
|
|
62
|
+
*
|
|
63
|
+
* A camera texture expires when the frame ends, so a bind group referencing it must be rebuilt
|
|
64
|
+
* every frame — never cache the result.
|
|
65
|
+
*
|
|
66
|
+
* @group WebGPU
|
|
67
|
+
*/
|
|
68
|
+
export declare function createCameraBindGroup(device: GPUDevice, cameraShaderBindings: CameraShaderBindings, cameraTexture: GPUExternalTexture): GPUBindGroup;
|
|
69
|
+
//# sourceMappingURL=cameraShaderBindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraShaderBindings.d.ts","sourceRoot":"","sources":["../../../src/webgpu/cameraShaderBindings.ts"],"names":[],"mappings":"AAEA,OAAa,EAAE,KAAK,MAAM,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AA8BlC;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK,CAKlC,CAAC;AAEzB,sDAAsD;AACtD,MAAM,WAAW,iCAAiC;IAChD,sFAAsF;IACtF,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;OAGG;IACH,QAAQ,CAAC,YAAY,EAAE,OAAO,YAAY,CAAC;IAC3C;;;OAGG;IACH,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,mGAAmG;IACnG,QAAQ,CAAC,eAAe,EAAE,kBAAkB,CAAC;IAC7C,uDAAuD;IACvD,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,oDAAoD;IACpD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;CACjC;AAQD;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CACxC,MAAM,EAAE,SAAS,EACjB,OAAO,GAAE,iCAAsC,GAC9C,oBAAoB,CAiBtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,SAAS,EACjB,oBAAoB,EAAE,oBAAoB,EAC1C,aAAa,EAAE,kBAAkB,GAChC,YAAY,CAUd"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { createCameraPassthroughPipeline } from './cameraPassthroughPipeline';
|
|
2
|
+
/**
|
|
3
|
+
* An owned `rgba8unorm` texture the camera frame is resolved into each frame — for pipelines that
|
|
4
|
+
* want a plain `texture_2d` camera instead of `texture_external`. Build once at setup with
|
|
5
|
+
* {@link createCameraTextureResolver}; every field is safe to capture into the frame worklet.
|
|
6
|
+
*
|
|
7
|
+
* Prefer sampling the camera directly via {@link createCameraShaderBindings} when you can: the
|
|
8
|
+
* resolver costs one extra render pass per frame.
|
|
9
|
+
*
|
|
10
|
+
* @group WebGPU
|
|
11
|
+
*/
|
|
12
|
+
export interface CameraTextureResolver {
|
|
13
|
+
/** The resolved camera texture (`rgba8unorm`, sampled + render-attachment usage). */
|
|
14
|
+
readonly texture: GPUTexture;
|
|
15
|
+
/** A reusable default view of {@link texture}. */
|
|
16
|
+
readonly view: GPUTextureView;
|
|
17
|
+
readonly width: number;
|
|
18
|
+
readonly height: number;
|
|
19
|
+
/** @internal The pass used to resolve into {@link texture}. */
|
|
20
|
+
readonly resolvePass: ReturnType<typeof createCameraPassthroughPipeline>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a {@link CameraTextureResolver} with an owned `rgba8unorm` texture of the given size.
|
|
24
|
+
*
|
|
25
|
+
* @group WebGPU
|
|
26
|
+
*/
|
|
27
|
+
export declare function createCameraTextureResolver(device: GPUDevice, size: {
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}): CameraTextureResolver;
|
|
31
|
+
/**
|
|
32
|
+
* Encodes one pass resolving the live camera texture into `resolver.texture`, aspect-filled to
|
|
33
|
+
* the resolver's size (platform YUV decode included). Worklet-safe; call it inside your render
|
|
34
|
+
* callback before the passes that sample `resolver.texture`.
|
|
35
|
+
*
|
|
36
|
+
* @group WebGPU
|
|
37
|
+
*/
|
|
38
|
+
export declare function resolveCameraTexture(device: GPUDevice, resolver: CameraTextureResolver, cameraTexture: GPUExternalTexture, cameraWidth: number, cameraHeight: number, commandEncoder: GPUCommandEncoder): void;
|
|
39
|
+
//# sourceMappingURL=cameraTextureResolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cameraTextureResolver.d.ts","sourceRoot":"","sources":["../../../src/webgpu/cameraTextureResolver.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,+BAA+B,EAA2B,MAAM,6BAA6B,CAAC;AAGvG;;;;;;;;;GASG;AACH,MAAM,WAAW,qBAAqB;IACpC,qFAAqF;IACrF,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,+DAA+D;IAC/D,QAAQ,CAAC,WAAW,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC;CAC1E;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,SAAS,EACjB,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACtC,qBAAqB,CAcvB;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,qBAAqB,EAC/B,aAAa,EAAE,kBAAkB,EACjC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,cAAc,EAAE,iBAAiB,GAChC,IAAI,CAIN"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Crop math + a worklet-safe byte packer for the {@link FrameCropParams} uniform used by
|
|
3
|
+
* {@link createCameraPassthroughPipeline} (and reusable by your own shaders).
|
|
4
|
+
*/
|
|
5
|
+
import * as d from 'typegpu/data';
|
|
6
|
+
/**
|
|
7
|
+
* The TypeGPU schema for the crop uniform. This is the single source of truth for both the WGSL
|
|
8
|
+
* `struct FrameCropParams` (emitted when the passthrough shader is resolved) and the byte layout
|
|
9
|
+
* {@link packFrameCropParams} writes. Its std140 layout is 40 bytes:
|
|
10
|
+
*
|
|
11
|
+
* sourceSize: vec2u @0 cropOrigin: vec2f @8 cropSize: vec2f @16 uvTransform: mat2x2f @24
|
|
12
|
+
*
|
|
13
|
+
* @group WebGPU
|
|
14
|
+
*/
|
|
15
|
+
export declare const FrameCropParams: d.WgslStruct<{
|
|
16
|
+
sourceSize: d.Vec2u;
|
|
17
|
+
cropOrigin: d.Vec2f;
|
|
18
|
+
cropSize: d.Vec2f;
|
|
19
|
+
uvTransform: d.Mat2x2f;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* A center-crop of a source frame plus a UV-space orientation transform, in source pixels.
|
|
23
|
+
* Produce one with {@link computeAspectFillCrop} or {@link computeSquareCrop}.
|
|
24
|
+
*
|
|
25
|
+
* @group WebGPU
|
|
26
|
+
*/
|
|
27
|
+
export interface FrameCrop {
|
|
28
|
+
sourceWidth: number;
|
|
29
|
+
sourceHeight: number;
|
|
30
|
+
cropOriginX: number;
|
|
31
|
+
cropOriginY: number;
|
|
32
|
+
cropSizeX: number;
|
|
33
|
+
cropSizeY: number;
|
|
34
|
+
/** uvTransform matrix scalars in (m00, m01, m10, m11) order; identity when omitted at compute time. */
|
|
35
|
+
uv00: number;
|
|
36
|
+
uv01: number;
|
|
37
|
+
uv10: number;
|
|
38
|
+
uv11: number;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Packs a {@link FrameCrop} into the {@link FrameCropParams} uniform byte layout.
|
|
42
|
+
* Worklet-safe; upload the result with `device.queue.writeBuffer(buffer, 0, bytes)`.
|
|
43
|
+
*
|
|
44
|
+
* @group WebGPU
|
|
45
|
+
*/
|
|
46
|
+
export declare function packFrameCropParams(crop: FrameCrop): ArrayBuffer;
|
|
47
|
+
/**
|
|
48
|
+
* Center-crop of a (sourceWidth × sourceHeight) frame to the target aspect ratio (width/height).
|
|
49
|
+
* A no-op full-frame crop when the source already has the target aspect. Worklet-safe.
|
|
50
|
+
*
|
|
51
|
+
* Feed it the upright camera size from the render context:
|
|
52
|
+
* `computeAspectFillCrop(context.cameraWidth, context.cameraHeight, context.outputWidth / context.outputHeight)`.
|
|
53
|
+
*
|
|
54
|
+
* The optional `uv00..uv11` scalars form a UV-space transform applied around the frame center
|
|
55
|
+
* (identity by default).
|
|
56
|
+
*
|
|
57
|
+
* @group WebGPU
|
|
58
|
+
*/
|
|
59
|
+
export declare function computeAspectFillCrop(sourceWidth: number, sourceHeight: number, targetAspect: number, uv00?: number, uv01?: number, uv10?: number, uv11?: number): FrameCrop;
|
|
60
|
+
/**
|
|
61
|
+
* Square center-crop of a (sourceWidth × sourceHeight) frame — the usual shape for square model
|
|
62
|
+
* inputs. Worklet-safe. The optional `uv00..uv11` scalars are as in {@link computeAspectFillCrop}.
|
|
63
|
+
*
|
|
64
|
+
* @group WebGPU
|
|
65
|
+
*/
|
|
66
|
+
export declare function computeSquareCrop(sourceWidth: number, sourceHeight: number, uv00?: number, uv01?: number, uv10?: number, uv11?: number): FrameCrop;
|
|
67
|
+
//# sourceMappingURL=cropUtilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cropUtilities.d.ts","sourceRoot":"","sources":["../../../src/webgpu/cropUtilities.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAElC;;;;;;;;GAQG;AACH,eAAO,MAAM,eAAe;;;;;EAK1B,CAAC;AAEH;;;;;GAKG;AACH,MAAM,WAAW,SAAS;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,uGAAuG;IACvG,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAQD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,GAAG,WAAW,CAgBhE;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,YAAY,EAAE,MAAM,EACpB,IAAI,GAAE,MAAU,EAChB,IAAI,GAAE,MAAU,EAChB,IAAI,GAAE,MAAU,EAChB,IAAI,GAAE,MAAU,GACf,SAAS,CAqBX;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,IAAI,GAAE,MAAU,EAChB,IAAI,GAAE,MAAU,EAChB,IAAI,GAAE,MAAU,EAChB,IAAI,GAAE,MAAU,GACf,SAAS,CAeX"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Everything your render callback needs for one frame. Handed to the function you pass to
|
|
3
|
+
* `render(...)` inside the source hook's `onFrame` worklet; every field is valid only until that
|
|
4
|
+
* function returns.
|
|
5
|
+
*
|
|
6
|
+
* @group WebGPU
|
|
7
|
+
*/
|
|
8
|
+
export interface WebGpuFrameRenderContext {
|
|
9
|
+
/** The device in use (the shared device, or your override). */
|
|
10
|
+
device: GPUDevice;
|
|
11
|
+
/** Shortcut for `device.queue`. */
|
|
12
|
+
queue: GPUQueue;
|
|
13
|
+
/**
|
|
14
|
+
* The command encoder for this frame. Encode your render/compute passes into it — the hook
|
|
15
|
+
* submits it (a single submit) and delivers the frame after your callback returns. Do not call
|
|
16
|
+
* `queue.submit` yourself for work targeting {@link outputTexture}.
|
|
17
|
+
*/
|
|
18
|
+
commandEncoder: GPUCommandEncoder;
|
|
19
|
+
/**
|
|
20
|
+
* The live camera frame as a `texture_external`, already rotated upright (and mirrored per the
|
|
21
|
+
* camera's mirroring). On Android it samples as raw YCbCr — sample it through
|
|
22
|
+
* `createCameraShaderBindings` (or the ready-made {@link cameraBindGroup}) for
|
|
23
|
+
* platform-correct RGB.
|
|
24
|
+
*/
|
|
25
|
+
cameraTexture: GPUExternalTexture;
|
|
26
|
+
/**
|
|
27
|
+
* Ready-made bind group for {@link cameraTexture}, present when the hook's
|
|
28
|
+
* `cameraShaderBindings` option was provided: set it at the bindings' group index and
|
|
29
|
+
* `sampleCamera(uv)` works.
|
|
30
|
+
*/
|
|
31
|
+
cameraBindGroup?: GPUBindGroup;
|
|
32
|
+
/** The output texture your passes draw into; its content becomes the published video frame. */
|
|
33
|
+
outputTexture: GPUTexture;
|
|
34
|
+
/**
|
|
35
|
+
* A cached, reusable default `createView()` of {@link outputTexture}. Prefer this over calling
|
|
36
|
+
* `outputTexture.createView()` yourself every frame: `GPUTextureView` has no `destroy()`/`release()`
|
|
37
|
+
* in react-native-webgpu, so a per-frame view accumulates native (malloc) wrappers on the frame
|
|
38
|
+
* runtime until GC — a steady leak in a render loop. The output textures are a small fixed pool, so
|
|
39
|
+
* the hook builds one view per slot and reuses it.
|
|
40
|
+
*/
|
|
41
|
+
outputView: GPUTextureView;
|
|
42
|
+
/** Size of {@link outputTexture}, in pixels. */
|
|
43
|
+
outputWidth: number;
|
|
44
|
+
outputHeight: number;
|
|
45
|
+
/**
|
|
46
|
+
* Upright (post-rotation) camera frame size, in pixels — feed it to `computeAspectFillCrop`
|
|
47
|
+
* together with the output aspect.
|
|
48
|
+
*/
|
|
49
|
+
cameraWidth: number;
|
|
50
|
+
cameraHeight: number;
|
|
51
|
+
/** Whether the camera feed is mirrored (front cameras usually are). */
|
|
52
|
+
cameraIsMirrored: boolean;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The `render` function handed to the source hook's `onFrame` worklet. Call it at most once per
|
|
56
|
+
* frame with your encode function; skipping it drops the frame (nothing is published for it).
|
|
57
|
+
*
|
|
58
|
+
* @group WebGPU
|
|
59
|
+
*/
|
|
60
|
+
export type WebGpuFrameRenderFunction = (encode: (context: WebGpuFrameRenderContext) => void) => void;
|
|
61
|
+
//# sourceMappingURL=frameRenderContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"frameRenderContext.d.ts","sourceRoot":"","sources":["../../../src/webgpu/frameRenderContext.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,WAAW,wBAAwB;IACvC,+DAA+D;IAC/D,MAAM,EAAE,SAAS,CAAC;IAClB,mCAAmC;IACnC,KAAK,EAAE,QAAQ,CAAC;IAChB;;;;OAIG;IACH,cAAc,EAAE,iBAAiB,CAAC;IAClC;;;;;OAKG;IACH,aAAa,EAAE,kBAAkB,CAAC;IAClC;;;;OAIG;IACH,eAAe,CAAC,EAAE,YAAY,CAAC;IAC/B,+FAA+F;IAC/F,aAAa,EAAE,UAAU,CAAC;IAC1B;;;;;;OAMG;IACH,UAAU,EAAE,cAAc,CAAC;IAC3B,gDAAgD;IAChD,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,uEAAuE;IACvE,gBAAgB,EAAE,OAAO,CAAC;CAC3B;AAED;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GAAG,CAAC,MAAM,EAAE,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,KAAK,IAAI,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The GPU features a device must have to import camera frames and Fishjam output surfaces on this
|
|
3
|
+
* platform. {@link useCameraWebGpuDevice} requests them for you; pass them yourself as
|
|
4
|
+
* `requiredFeatures` in `GPUDeviceDescriptor` when you bring your own device.
|
|
5
|
+
*
|
|
6
|
+
* @group WebGPU
|
|
7
|
+
*/
|
|
8
|
+
export declare function getRequiredWebGpuCameraFeatures(): GPUFeatureName[];
|
|
9
|
+
/**
|
|
10
|
+
* Throws a descriptive error when `device` is missing any feature required to import camera
|
|
11
|
+
* frames or Fishjam output surfaces on this platform. Called automatically on devices passed as
|
|
12
|
+
* an override; call it yourself to validate a device early.
|
|
13
|
+
*
|
|
14
|
+
* @group WebGPU
|
|
15
|
+
*/
|
|
16
|
+
export declare function assertWebGpuDeviceSupportsCameraImport(device: GPUDevice): void;
|
|
17
|
+
/**
|
|
18
|
+
* The pixel format of Fishjam output surfaces on this platform: `'rgba8unorm'` on Android
|
|
19
|
+
* (AHardwareBuffer), `'bgra8unorm'` on iOS (IOSurface). Use it as the render-target format of any
|
|
20
|
+
* pipeline that draws into the output texture — a mismatched format renders wrong or black.
|
|
21
|
+
*
|
|
22
|
+
* @group WebGPU
|
|
23
|
+
*/
|
|
24
|
+
export declare function getOutputSurfaceFormat(): GPUTextureFormat;
|
|
25
|
+
//# sourceMappingURL=requiredFeatures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"requiredFeatures.d.ts","sourceRoot":"","sources":["../../../src/webgpu/requiredFeatures.ts"],"names":[],"mappings":"AAYA;;;;;;GAMG;AACH,wBAAgB,+BAA+B,IAAI,cAAc,EAAE,CAElE;AAED;;;;;;GAMG;AACH,wBAAgB,sCAAsC,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAW9E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,IAAI,gBAAgB,CAEzD"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** Result of {@link useCameraWebGpuDevice}. */
|
|
2
|
+
export interface UseCameraWebGpuDeviceResult {
|
|
3
|
+
/** The shared GPUDevice; `null` until acquisition resolves. */
|
|
4
|
+
device: GPUDevice | null;
|
|
5
|
+
/** Acquisition failure (no adapter, missing platform features), if any. */
|
|
6
|
+
error: Error | null;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The app-wide GPUDevice used for camera work, configured with
|
|
10
|
+
* {@link getRequiredWebGpuCameraFeatures}. All callers share one device, so pipelines you build
|
|
11
|
+
* against it work with the textures the source hook hands your render callback.
|
|
12
|
+
*
|
|
13
|
+
* Build your pipelines once the device arrives:
|
|
14
|
+
* ```tsx
|
|
15
|
+
* const { device } = useCameraWebGpuDevice();
|
|
16
|
+
* const effect = useMemo(() => (device ? buildMyEffect(device) : null), [device]);
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @group WebGPU
|
|
20
|
+
*/
|
|
21
|
+
export declare function useCameraWebGpuDevice(): UseCameraWebGpuDeviceResult;
|
|
22
|
+
/**
|
|
23
|
+
* Device resolution for the source hook: the user-provided override (validated) when present,
|
|
24
|
+
* otherwise the shared device. Always called, so hook order stays stable either way.
|
|
25
|
+
*/
|
|
26
|
+
export declare function useCameraWebGpuDeviceWithOverride(override: GPUDevice | undefined): UseCameraWebGpuDeviceResult;
|
|
27
|
+
//# sourceMappingURL=useCameraWebGpuDevice.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCameraWebGpuDevice.d.ts","sourceRoot":"","sources":["../../../src/webgpu/useCameraWebGpuDevice.ts"],"names":[],"mappings":"AA+CA,+CAA+C;AAC/C,MAAM,WAAW,2BAA2B;IAC1C,+DAA+D;IAC/D,MAAM,EAAE,SAAS,GAAG,IAAI,CAAC;IACzB,2EAA2E;IAC3E,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,qBAAqB,IAAI,2BAA2B,CAsBnE;AAED;;;GAGG;AACH,wBAAgB,iCAAiC,CAAC,QAAQ,EAAE,SAAS,GAAG,SAAS,GAAG,2BAA2B,CAqB9G"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The react-native-webgpu runtime singleton (the `RNWebGPU` JSI global). */
|
|
2
|
+
export type WebGpuRuntime = typeof RNWebGPU;
|
|
3
|
+
/**
|
|
4
|
+
* Returns the react-native-webgpu runtime singleton, self-healing when the `RNWebGPU` global is
|
|
5
|
+
* missing on the calling runtime. The library binds the global once at module load, but that
|
|
6
|
+
* binding can be absent after a crash-recovery runtime reload or an install-ordering flake;
|
|
7
|
+
* `WebGPUModule.install()` binds it to the calling runtime and is safe to repeat.
|
|
8
|
+
*
|
|
9
|
+
* @throws When the runtime cannot be installed (react-native-webgpu missing or its native module
|
|
10
|
+
* not linked) — returning the still-undefined global would only defer the failure to an opaque
|
|
11
|
+
* per-frame TypeError.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getWebGpuRuntime(): WebGpuRuntime;
|
|
14
|
+
//# sourceMappingURL=webGpuRuntime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webGpuRuntime.d.ts","sourceRoot":"","sources":["../../../src/webgpu/webGpuRuntime.ts"],"names":[],"mappings":"AAEA,6EAA6E;AAC7E,MAAM,MAAM,aAAa,GAAG,OAAO,QAAQ,CAAC;AAE5C;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAahD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WebGPU camera toolkit — sample the live camera and render your own content into the video you
|
|
3
|
+
* publish with `useManagedPooledTrack` (from the package's main entry point). Requires `react-native-webgpu` (an optional peer of
|
|
4
|
+
* this package; only this entry point loads it).
|
|
5
|
+
*
|
|
6
|
+
* - {@link createCameraShaderBindings} — sample the live camera from your own shaders via
|
|
7
|
+
* `sampleCamera(uv)`, with the platform's YUV decode handled for you.
|
|
8
|
+
* - {@link createCameraPassthroughPipeline} / {@link encodeCameraPassthrough} — a ready-made
|
|
9
|
+
* camera→output pass to publish the camera with zero WGSL, or to build overlays on.
|
|
10
|
+
* - {@link createCameraTextureResolver} — opt-in plain-texture camera for pipelines that can't
|
|
11
|
+
* sample `texture_external`.
|
|
12
|
+
* - {@link useCameraWebGpuDevice} — the shared, camera-import-capable GPUDevice.
|
|
13
|
+
*
|
|
14
|
+
* @packageDocumentation
|
|
15
|
+
*/
|
|
16
|
+
export { type CameraPassthroughPipeline, type CameraPassthroughPipelineOptions, createCameraPassthroughPipeline, encodeCameraPassthrough, } from './webgpu/cameraPassthroughPipeline';
|
|
17
|
+
export { type CameraShaderBindings, createCameraBindGroup, createCameraShaderBindings, type CreateCameraShaderBindingsOptions, sampleCamera, } from './webgpu/cameraShaderBindings';
|
|
18
|
+
export { type CameraTextureResolver, createCameraTextureResolver, resolveCameraTexture, } from './webgpu/cameraTextureResolver';
|
|
19
|
+
export { computeAspectFillCrop, computeSquareCrop, type FrameCrop, FrameCropParams, packFrameCropParams, } from './webgpu/cropUtilities';
|
|
20
|
+
export type { WebGpuFrameRenderContext, WebGpuFrameRenderFunction } from './webgpu/frameRenderContext';
|
|
21
|
+
export { assertWebGpuDeviceSupportsCameraImport, getOutputSurfaceFormat, getRequiredWebGpuCameraFeatures, } from './webgpu/requiredFeatures';
|
|
22
|
+
export { useCameraWebGpuDevice, type UseCameraWebGpuDeviceResult, useCameraWebGpuDeviceWithOverride, } from './webgpu/useCameraWebGpuDevice';
|
|
23
|
+
export { getWebGpuRuntime, type WebGpuRuntime } from './webgpu/webGpuRuntime';
|
|
24
|
+
//# sourceMappingURL=webgpu.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webgpu.d.ts","sourceRoot":"","sources":["../../src/webgpu.ts"],"names":[],"mappings":"AACA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EACL,KAAK,yBAAyB,EAC9B,KAAK,gCAAgC,EACrC,+BAA+B,EAC/B,uBAAuB,GACxB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,KAAK,oBAAoB,EACzB,qBAAqB,EACrB,0BAA0B,EAC1B,KAAK,iCAAiC,EACtC,YAAY,GACb,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,KAAK,qBAAqB,EAC1B,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,KAAK,SAAS,EACd,eAAe,EACf,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAChC,YAAY,EAAE,wBAAwB,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACvG,OAAO,EACL,sCAAsC,EACtC,sBAAsB,EACtB,+BAA+B,GAChC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,qBAAqB,EACrB,KAAK,2BAA2B,EAChC,iCAAiC,GAClC,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,KAAK,aAAa,EAAE,MAAM,wBAAwB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fishjam-cloud/react-native-custom-video-source",
|
|
3
|
+
"version": "0.29.0",
|
|
4
|
+
"description": "Publish your own video frames to Fishjam — forward native buffers or render into a WebGPU surface pool, from any frame source",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"author": "Fishjam Team",
|
|
7
|
+
"main": "./dist/module/index.js",
|
|
8
|
+
"module": "./dist/module/index.js",
|
|
9
|
+
"types": "./dist/typescript/index.d.ts",
|
|
10
|
+
"react-native": "./dist/module/index.js",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/typescript/index.d.ts",
|
|
14
|
+
"react-native": "./dist/module/index.js",
|
|
15
|
+
"import": "./dist/module/index.js",
|
|
16
|
+
"default": "./dist/module/index.js"
|
|
17
|
+
},
|
|
18
|
+
"./webgpu": {
|
|
19
|
+
"types": "./dist/typescript/webgpu.d.ts",
|
|
20
|
+
"react-native": "./dist/module/webgpu.js",
|
|
21
|
+
"import": "./dist/module/webgpu.js",
|
|
22
|
+
"default": "./dist/module/webgpu.js"
|
|
23
|
+
},
|
|
24
|
+
"./package.json": "./package.json"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/**"
|
|
28
|
+
],
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/fishjam-cloud/web-client-sdk.git",
|
|
32
|
+
"directory": "packages/react-native-custom-video-source"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://github.com/fishjam-cloud/web-client-sdk#readme",
|
|
35
|
+
"bugs": "https://github.com/fishjam-cloud/web-client-sdk/issues",
|
|
36
|
+
"keywords": [
|
|
37
|
+
"webrtc",
|
|
38
|
+
"fishjam",
|
|
39
|
+
"webgpu",
|
|
40
|
+
"custom-video"
|
|
41
|
+
],
|
|
42
|
+
"scripts": {
|
|
43
|
+
"tsc": "tsc --noEmit",
|
|
44
|
+
"build:webrtc-workspace": "yarn workspace @fishjam-cloud/react-native-webrtc run prepare",
|
|
45
|
+
"build": "yarn build:webrtc-workspace && bob build",
|
|
46
|
+
"lint": "eslint . --ext .ts,.tsx --fix",
|
|
47
|
+
"prepare": "yarn build:webrtc-workspace && bob build",
|
|
48
|
+
"format": "prettier --write . --ignore-path ./.eslintignore",
|
|
49
|
+
"check:webrtc-published": "node ../../release-automation/check-webrtc-published.mjs"
|
|
50
|
+
},
|
|
51
|
+
"lint-staged": {
|
|
52
|
+
"*": [
|
|
53
|
+
"yarn format"
|
|
54
|
+
],
|
|
55
|
+
"*.{js,ts,tsx}": [
|
|
56
|
+
"yarn lint"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"react-native-builder-bob": {
|
|
60
|
+
"source": "src",
|
|
61
|
+
"output": "dist",
|
|
62
|
+
"targets": [
|
|
63
|
+
[
|
|
64
|
+
"module",
|
|
65
|
+
{
|
|
66
|
+
"configFile": true
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
"typescript",
|
|
71
|
+
{
|
|
72
|
+
"project": "tsconfig.build.json",
|
|
73
|
+
"tsc": "../../node_modules/.bin/tsc"
|
|
74
|
+
}
|
|
75
|
+
]
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
"peerDependencies": {
|
|
79
|
+
"@fishjam-cloud/react-native-webrtc": "0.29.0",
|
|
80
|
+
"react": "*",
|
|
81
|
+
"react-native": "*",
|
|
82
|
+
"react-native-webgpu": ">=0.5.15"
|
|
83
|
+
},
|
|
84
|
+
"peerDependenciesMeta": {
|
|
85
|
+
"react-native-webgpu": {
|
|
86
|
+
"optional": true
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"dependencies": {
|
|
90
|
+
"typegpu": "^0.11.8"
|
|
91
|
+
},
|
|
92
|
+
"devDependencies": {
|
|
93
|
+
"@babel/core": "^7.29.0",
|
|
94
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
95
|
+
"@fishjam-cloud/react-native-webrtc": "0.29.0",
|
|
96
|
+
"@types/react": "19.2.14",
|
|
97
|
+
"@webgpu/types": "0.1.65",
|
|
98
|
+
"eslint-config-expo": "~9.2.0",
|
|
99
|
+
"eslint-import-resolver-typescript": "^3.10.1",
|
|
100
|
+
"eslint-plugin-prettier": "^5.5.1",
|
|
101
|
+
"react": "19.1.0",
|
|
102
|
+
"react-native": "0.85.3",
|
|
103
|
+
"react-native-builder-bob": "^0.18.2",
|
|
104
|
+
"react-native-webgpu": "0.5.15",
|
|
105
|
+
"typescript": "^5.8.3",
|
|
106
|
+
"unplugin-typegpu": "^0.11.5"
|
|
107
|
+
},
|
|
108
|
+
"packageManager": "yarn@4.16.0"
|
|
109
|
+
}
|