feat: Implement Frame.close()
(#229)
* Implement `Frame.close()` * close frame in dtor * Update JImageProxyHostObject.cpp * fix close * Check if closed * remove a few logs * r * fix `isValid` and `isReady` * Add JImage * Release JNI frame ref on destroy * fix pod setup * Fix isValid call * Fix `close` not returning a function * throw error if closed twice * iOS: Schedule `console.error` call on JS thread * Android: Log Frame Processor Error to JS * fix syntax * Check if valid `toString()` * Update Frame.ts * Remove `isReady` * Fix JImage accessors * remove `JImage` C++ sources * Throw error if accessing props on closed Frame * Delete `JImage.h`
This commit is contained in:
21
src/Frame.ts
21
src/Frame.ts
@@ -3,13 +3,9 @@
|
||||
*/
|
||||
export interface Frame {
|
||||
/**
|
||||
* Whether the underlying buffer is still valid or not. The buffer will be released after the frame processor returns.
|
||||
* Whether the underlying buffer is still valid or not. The buffer will be released after the frame processor returns, or `close()` is called.
|
||||
*/
|
||||
isValid: boolean;
|
||||
/**
|
||||
* Whether the underlying buffer is marked as "ready" or not.
|
||||
*/
|
||||
isReady: boolean;
|
||||
/**
|
||||
* Returns the width of the frame, in pixels.
|
||||
*/
|
||||
@@ -35,4 +31,19 @@ export interface Frame {
|
||||
* ```
|
||||
*/
|
||||
toString(): string;
|
||||
/**
|
||||
* Closes and disposes the Frame.
|
||||
* Only close frames that you have created yourself, e.g. by copying the frame you receive in a frame processor.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const frameProcessor = useFrameProcessor((frame) => {
|
||||
* const smallerCopy = resize(frame, 480, 270)
|
||||
* // run AI ...
|
||||
* smallerCopy.close()
|
||||
* // don't close `frame`!
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
close(): void;
|
||||
}
|
||||
|
Reference in New Issue
Block a user