fix: Use property accessors on Frame
(#2400)
* fix: Use property accessors on `Frame` * Format * Use `_Nonnull` * fix: Assume nonnull * Use `NS_ASSUME_NONNULL_BEGIN` more * Format C++
This commit is contained in:
parent
9c66a09582
commit
773f278df8
@ -484,7 +484,7 @@ PODS:
|
|||||||
- libwebp (~> 1.0)
|
- libwebp (~> 1.0)
|
||||||
- SDWebImage/Core (~> 5.10)
|
- SDWebImage/Core (~> 5.10)
|
||||||
- SocketRocket (0.6.1)
|
- SocketRocket (0.6.1)
|
||||||
- VisionCamera (3.7.1):
|
- VisionCamera (3.8.0):
|
||||||
- React
|
- React
|
||||||
- React-callinvoker
|
- React-callinvoker
|
||||||
- React-Core
|
- React-Core
|
||||||
@ -724,7 +724,7 @@ SPEC CHECKSUMS:
|
|||||||
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
|
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
|
||||||
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
|
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
|
||||||
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
|
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
|
||||||
VisionCamera: ac444079a315b38ec664cf77ed548c384554f0ca
|
VisionCamera: 8e3454abf4baa43a2b9ad9cfc9723d1cc89d9eb6
|
||||||
Yoga: 4c3aa327e4a6a23eeacd71f61c81df1bcdf677d5
|
Yoga: 4c3aa327e4a6a23eeacd71f61c81df1bcdf677d5
|
||||||
|
|
||||||
PODFILE CHECKSUM: 27f53791141a3303d814e09b55770336416ff4eb
|
PODFILE CHECKSUM: 27f53791141a3303d814e09b55770336416ff4eb
|
||||||
|
@ -12,23 +12,25 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <UIKit/UIImage.h>
|
#import <UIKit/UIImage.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface Frame : NSObject
|
@interface Frame : NSObject
|
||||||
|
|
||||||
- (instancetype _Nonnull)initWithBuffer:(CMSampleBufferRef _Nonnull)buffer orientation:(UIImageOrientation)orientation;
|
- (instancetype)initWithBuffer:(CMSampleBufferRef)buffer orientation:(UIImageOrientation)orientation;
|
||||||
|
|
||||||
- (instancetype)init NS_UNAVAILABLE;
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
|
||||||
@property(nonatomic, readonly) CMSampleBufferRef _Nonnull buffer;
|
@property(nonatomic, readonly) CMSampleBufferRef buffer;
|
||||||
@property(nonatomic, readonly) UIImageOrientation orientation;
|
@property(nonatomic, readonly) UIImageOrientation orientation;
|
||||||
|
|
||||||
// Getters
|
@property(nonatomic, readonly) NSString* pixelFormat;
|
||||||
- (NSString* _Nonnull)pixelFormat;
|
@property(nonatomic, readonly) BOOL isMirrored;
|
||||||
- (BOOL)isMirrored;
|
@property(nonatomic, readonly) BOOL isValid;
|
||||||
- (BOOL)isValid;
|
@property(nonatomic, readonly) size_t width;
|
||||||
- (size_t)width;
|
@property(nonatomic, readonly) size_t height;
|
||||||
- (size_t)height;
|
@property(nonatomic, readonly) double timestamp;
|
||||||
- (double)timestamp;
|
@property(nonatomic, readonly) size_t bytesPerRow;
|
||||||
- (size_t)bytesPerRow;
|
@property(nonatomic, readonly) size_t planesCount;
|
||||||
- (size_t)planesCount;
|
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
@ -11,11 +11,11 @@
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
@implementation Frame {
|
@implementation Frame {
|
||||||
CMSampleBufferRef _Nonnull buffer;
|
CMSampleBufferRef _Nonnull _buffer;
|
||||||
UIImageOrientation orientation;
|
UIImageOrientation _orientation;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (instancetype)initWithBuffer:(CMSampleBufferRef _Nonnull)buffer orientation:(UIImageOrientation)orientation {
|
- (instancetype)initWithBuffer:(CMSampleBufferRef)buffer orientation:(UIImageOrientation)orientation {
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self) {
|
if (self) {
|
||||||
_buffer = buffer;
|
_buffer = buffer;
|
||||||
@ -29,8 +29,13 @@
|
|||||||
CFRelease(_buffer);
|
CFRelease(_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@synthesize buffer = _buffer;
|
- (CMSampleBufferRef)buffer {
|
||||||
@synthesize orientation = _orientation;
|
return _buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (UIImageOrientation)orientation {
|
||||||
|
return _orientation;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSString*)pixelFormat {
|
- (NSString*)pixelFormat {
|
||||||
CMFormatDescriptionRef format = CMSampleBufferGetFormatDescription(_buffer);
|
CMFormatDescriptionRef format = CMSampleBufferGetFormatDescription(_buffer);
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#import <memory.h>
|
#import <memory.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface FrameProcessor : NSObject
|
@interface FrameProcessor : NSObject
|
||||||
|
|
||||||
- (instancetype)init NS_UNAVAILABLE;
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
@ -30,6 +32,8 @@
|
|||||||
- (void)callWithFrameHostObject:(std::shared_ptr<FrameHostObject>)frameHostObject;
|
- (void)callWithFrameHostObject:(std::shared_ptr<FrameHostObject>)frameHostObject;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
- (void)call:(Frame* _Nonnull)frame;
|
- (void)call:(Frame*)frame;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#import "VisionCameraProxy.h"
|
#import "VisionCameraProxy.h"
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The base class of a native Frame Processor Plugin.
|
* The base class of a native Frame Processor Plugin.
|
||||||
*
|
*
|
||||||
@ -32,7 +34,7 @@
|
|||||||
* - proxy: The VisionCameraProxy instance for using the Frame Processor Context, e.g. to initialize SharedArrays.
|
* - proxy: The VisionCameraProxy instance for using the Frame Processor Context, e.g. to initialize SharedArrays.
|
||||||
* - options: An options dictionary passed from the JS side, or `nil` if none.
|
* - options: An options dictionary passed from the JS side, or `nil` if none.
|
||||||
*/
|
*/
|
||||||
- (instancetype _Nonnull)initWithProxy:(VisionCameraProxyHolder* _Nonnull)proxy
|
- (instancetype _Nonnull)initWithProxy:(VisionCameraProxyHolder*)proxy
|
||||||
withOptions:(NSDictionary* _Nullable)options NS_SWIFT_NAME(init(proxy:options:));
|
withOptions:(NSDictionary* _Nullable)options NS_SWIFT_NAME(init(proxy:options:));
|
||||||
|
|
||||||
- (instancetype _Nonnull)init NS_UNAVAILABLE;
|
- (instancetype _Nonnull)init NS_UNAVAILABLE;
|
||||||
@ -44,14 +46,17 @@
|
|||||||
*
|
*
|
||||||
* - Parameters:
|
* - Parameters:
|
||||||
* - frame: The Frame from the Camera. Don't do any ref-counting on this, as VisionCamera handles that.
|
* - frame: The Frame from the Camera. Don't do any ref-counting on this, as VisionCamera handles that.
|
||||||
|
* - arguments: An options dictionary passed from the JS side, or `nil` if none.
|
||||||
* - Returns: You can return any primitive, map or array you want.
|
* - Returns: You can return any primitive, map or array you want.
|
||||||
* See the <a href="https://react-native-vision-camera.com/docs/guides/frame-processors-plugins-overview#types">Types</a>
|
* See the <a href="https://react-native-vision-camera.com/docs/guides/frame-processors-plugins-overview#types">Types</a>
|
||||||
* table for a list of supported types.
|
* table for a list of supported types.
|
||||||
*/
|
*/
|
||||||
- (id _Nullable)callback:(Frame* _Nonnull)frame withArguments:(NSDictionary* _Nullable)arguments;
|
- (id _Nullable)callback:(Frame*)frame withArguments:(NSDictionary* _Nullable)arguments;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
|
||||||
#define VISION_CONCAT2(A, B) A##B
|
#define VISION_CONCAT2(A, B) A##B
|
||||||
#define VISION_CONCAT(A, B) VISION_CONCAT2(A, B)
|
#define VISION_CONCAT(A, B) VISION_CONCAT2(A, B)
|
||||||
|
|
||||||
|
@ -13,15 +13,18 @@
|
|||||||
#import "VisionCameraProxy.h"
|
#import "VisionCameraProxy.h"
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface FrameProcessorPluginRegistry : NSObject
|
@interface FrameProcessorPluginRegistry : NSObject
|
||||||
|
|
||||||
typedef FrameProcessorPlugin* _Nonnull (^PluginInitializerFunction)(VisionCameraProxyHolder* _Nonnull proxy,
|
typedef FrameProcessorPlugin* _Nonnull (^PluginInitializerFunction)(VisionCameraProxyHolder* proxy, NSDictionary* _Nullable options);
|
||||||
NSDictionary* _Nullable options);
|
|
||||||
|
|
||||||
+ (void)addFrameProcessorPlugin:(NSString* _Nonnull)name withInitializer:(PluginInitializerFunction _Nonnull)pluginInitializer;
|
+ (void)addFrameProcessorPlugin:(NSString*)name withInitializer:(PluginInitializerFunction)pluginInitializer;
|
||||||
|
|
||||||
+ (FrameProcessorPlugin* _Nullable)getPlugin:(NSString* _Nonnull)name
|
+ (FrameProcessorPlugin* _Nullable)getPlugin:(NSString*)name
|
||||||
withProxy:(VisionCameraProxyHolder* _Nonnull)proxy
|
withProxy:(VisionCameraProxyHolder*)proxy
|
||||||
withOptions:(NSDictionary* _Nullable)options;
|
withOptions:(NSDictionary* _Nullable)options;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
@ -34,14 +34,15 @@ typedef NS_ENUM(NSInteger, SharedArrayType) {
|
|||||||
Float64Array,
|
Float64Array,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface SharedArray : NSObject
|
@interface SharedArray : NSObject
|
||||||
|
|
||||||
- (instancetype _Nonnull)init NS_UNAVAILABLE;
|
- (instancetype)init NS_UNAVAILABLE;
|
||||||
|
- (instancetype)initWithProxy:(VisionCameraProxyHolder*)proxy type:(SharedArrayType)type size:(NSInteger)size;
|
||||||
- (instancetype _Nonnull)initWithProxy:(VisionCameraProxyHolder* _Nonnull)proxy type:(SharedArrayType)type size:(NSInteger)size;
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
- (instancetype _Nonnull)initWithRuntime:(jsi::Runtime&)runtime typedArray:(std::shared_ptr<vision::TypedArrayBase>)typedArray;
|
- (instancetype)initWithRuntime:(jsi::Runtime&)runtime typedArray:(std::shared_ptr<vision::TypedArrayBase>)typedArray;
|
||||||
|
|
||||||
- (std::shared_ptr<vision::TypedArrayBase>)typedArray;
|
- (std::shared_ptr<vision::TypedArrayBase>)typedArray;
|
||||||
#endif
|
#endif
|
||||||
@ -50,3 +51,5 @@ typedef NS_ENUM(NSInteger, SharedArrayType) {
|
|||||||
@property(nonatomic, readonly) NSInteger count;
|
@property(nonatomic, readonly) NSInteger count;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
@ -42,18 +42,22 @@ private:
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
@interface VisionCameraProxyHolder : NSObject
|
@interface VisionCameraProxyHolder : NSObject
|
||||||
|
|
||||||
- (_Nonnull instancetype)initWithProxy:(void* _Nonnull)proxy;
|
- (_Nonnull instancetype)initWithProxy:(void*)proxy;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
- (VisionCameraProxy* _Nonnull)proxy;
|
- (VisionCameraProxy*)proxy;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface VisionCameraInstaller : NSObject
|
@interface VisionCameraInstaller : NSObject
|
||||||
|
|
||||||
+ (BOOL)installToBridge:(RCTBridge* _Nonnull)bridge;
|
+ (BOOL)installToBridge:(RCTBridge*)bridge;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
NS_ASSUME_NONNULL_END
|
||||||
|
Loading…
Reference in New Issue
Block a user