/** * useVideoCapture — video recording + frame extraction API. * * Sibling of ``useCapture`` for the "sweep a shelf with a video" flow * that feeds the stitcher. The hook's state machine is: * * idle → recording → stopping → idle (success) * idle → recording → idle (recording errored) * idle → recording → stopping → idle (user cancelled) * * API shape — `startRecording` returns a `Promise` that: * - resolves with the recorded file when the user releases the * shutter and `stopRecording()` is called (vision-camera fires * `onRecordingFinished`), * - rejects if vision-camera fires `onRecordingError` at any point * (e.g. `` was rendered without `video={true}`, disk * full mid-recording, permission revoked). * * Why a single future instead of separate finished/error callbacks? * Lets host code use the natural async/await pattern. Earlier we * used a callback + a parked resolver in the host screen; that * masked start-time errors (the resolver hung forever) and produced * confusing cascade errors when `stopRecording` ran against a * non-recording camera. * * Frame extraction lives behind the `extractFrames` method but is * deferred to the higher-level `stitchVideo()` SDK API now — host * apps shouldn't have to manage their own tmp dir. This shim is * kept for parity / future use; it currently throws. */ import { Camera, type VideoFile } from 'react-native-vision-camera'; export type VideoCaptureState = 'idle' | 'recording' | 'stopping' | 'extracting'; export interface UseVideoCaptureReturn { state: VideoCaptureState; /** * Begin recording on the given camera ref. Returns a Promise that * resolves with the resulting `VideoFile` once `stopRecording()` * has been called and vision-camera writes the file to disk, or * rejects on any recording error. * * Callers who only need fire-and-forget can ignore the returned * promise; the hook still tracks state internally. */ startRecording: (cameraRef: React.RefObject) => Promise; /** * Tell vision-camera to stop the active recording. If no recording * is in progress (e.g. it errored at start) this is a safe no-op. * The recorded file flows back through the promise returned by * `startRecording`, NOT through this method's return. */ stopRecording: (cameraRef: React.RefObject) => Promise; /** * Cancel the active recording without delivering the file. The * promise from `startRecording` will reject with a cancellation * error so awaiters unblock instead of receiving a stale file. */ cancelRecording: (cameraRef: React.RefObject) => Promise; /** * Decode an mp4 into N evenly-spaced still frames, written to * ``outputDir``. Throws NOT_IMPLEMENTED — call `stitchVideo` from * the SDK index instead, which combines extract + stitch in one * native bridge call so the JS thread never has to round-trip * frame paths. */ extractFrames: (opts: ExtractFramesOptions) => Promise; } export interface ExtractFramesOptions { videoPath: string; outputDir: string; frameCount: number; /** JPEG quality [0-100]. Defaults to 85. */ quality?: number; } export interface ExtractFramesResult { framePaths: string[]; durationMs: number; } export declare function useVideoCapture(): UseVideoCaptureReturn; //# sourceMappingURL=useVideoCapture.d.ts.map