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)
|
||||
- SDWebImage/Core (~> 5.10)
|
||||
- SocketRocket (0.6.1)
|
||||
- VisionCamera (3.7.1):
|
||||
- VisionCamera (3.8.0):
|
||||
- React
|
||||
- React-callinvoker
|
||||
- React-Core
|
||||
@ -724,7 +724,7 @@ SPEC CHECKSUMS:
|
||||
SDWebImage: a7f831e1a65eb5e285e3fb046a23fcfbf08e696d
|
||||
SDWebImageWebPCoder: 908b83b6adda48effe7667cd2b7f78c897e5111d
|
||||
SocketRocket: f32cd54efbe0f095c4d7594881e52619cfe80b17
|
||||
VisionCamera: ac444079a315b38ec664cf77ed548c384554f0ca
|
||||
VisionCamera: 8e3454abf4baa43a2b9ad9cfc9723d1cc89d9eb6
|
||||
Yoga: 4c3aa327e4a6a23eeacd71f61c81df1bcdf677d5
|
||||
|
||||
PODFILE CHECKSUM: 27f53791141a3303d814e09b55770336416ff4eb
|
||||
|
@ -12,23 +12,25 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIImage.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface Frame : NSObject
|
||||
|
||||
- (instancetype _Nonnull)initWithBuffer:(CMSampleBufferRef _Nonnull)buffer orientation:(UIImageOrientation)orientation;
|
||||
|
||||
- (instancetype)initWithBuffer:(CMSampleBufferRef)buffer orientation:(UIImageOrientation)orientation;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
|
||||
@property(nonatomic, readonly) CMSampleBufferRef _Nonnull buffer;
|
||||
@property(nonatomic, readonly) CMSampleBufferRef buffer;
|
||||
@property(nonatomic, readonly) UIImageOrientation orientation;
|
||||
|
||||
// Getters
|
||||
- (NSString* _Nonnull)pixelFormat;
|
||||
- (BOOL)isMirrored;
|
||||
- (BOOL)isValid;
|
||||
- (size_t)width;
|
||||
- (size_t)height;
|
||||
- (double)timestamp;
|
||||
- (size_t)bytesPerRow;
|
||||
- (size_t)planesCount;
|
||||
@property(nonatomic, readonly) NSString* pixelFormat;
|
||||
@property(nonatomic, readonly) BOOL isMirrored;
|
||||
@property(nonatomic, readonly) BOOL isValid;
|
||||
@property(nonatomic, readonly) size_t width;
|
||||
@property(nonatomic, readonly) size_t height;
|
||||
@property(nonatomic, readonly) double timestamp;
|
||||
@property(nonatomic, readonly) size_t bytesPerRow;
|
||||
@property(nonatomic, readonly) size_t planesCount;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@ -11,11 +11,11 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@implementation Frame {
|
||||
CMSampleBufferRef _Nonnull buffer;
|
||||
UIImageOrientation orientation;
|
||||
CMSampleBufferRef _Nonnull _buffer;
|
||||
UIImageOrientation _orientation;
|
||||
}
|
||||
|
||||
- (instancetype)initWithBuffer:(CMSampleBufferRef _Nonnull)buffer orientation:(UIImageOrientation)orientation {
|
||||
- (instancetype)initWithBuffer:(CMSampleBufferRef)buffer orientation:(UIImageOrientation)orientation {
|
||||
self = [super init];
|
||||
if (self) {
|
||||
_buffer = buffer;
|
||||
@ -29,8 +29,13 @@
|
||||
CFRelease(_buffer);
|
||||
}
|
||||
|
||||
@synthesize buffer = _buffer;
|
||||
@synthesize orientation = _orientation;
|
||||
- (CMSampleBufferRef)buffer {
|
||||
return _buffer;
|
||||
}
|
||||
|
||||
- (UIImageOrientation)orientation {
|
||||
return _orientation;
|
||||
}
|
||||
|
||||
- (NSString*)pixelFormat {
|
||||
CMFormatDescriptionRef format = CMSampleBufferGetFormatDescription(_buffer);
|
||||
|
@ -19,6 +19,8 @@
|
||||
#import <memory.h>
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FrameProcessor : NSObject
|
||||
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
@ -30,6 +32,8 @@
|
||||
- (void)callWithFrameHostObject:(std::shared_ptr<FrameHostObject>)frameHostObject;
|
||||
#endif
|
||||
|
||||
- (void)call:(Frame* _Nonnull)frame;
|
||||
- (void)call:(Frame*)frame;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@ -12,6 +12,8 @@
|
||||
#import "VisionCameraProxy.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* - 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:));
|
||||
|
||||
- (instancetype _Nonnull)init NS_UNAVAILABLE;
|
||||
@ -44,14 +46,17 @@
|
||||
*
|
||||
* - Parameters:
|
||||
* - 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.
|
||||
* 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.
|
||||
*/
|
||||
- (id _Nullable)callback:(Frame* _Nonnull)frame withArguments:(NSDictionary* _Nullable)arguments;
|
||||
- (id _Nullable)callback:(Frame*)frame withArguments:(NSDictionary* _Nullable)arguments;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
||||
#define VISION_CONCAT2(A, B) A##B
|
||||
#define VISION_CONCAT(A, B) VISION_CONCAT2(A, B)
|
||||
|
||||
|
@ -13,15 +13,18 @@
|
||||
#import "VisionCameraProxy.h"
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface FrameProcessorPluginRegistry : NSObject
|
||||
|
||||
typedef FrameProcessorPlugin* _Nonnull (^PluginInitializerFunction)(VisionCameraProxyHolder* _Nonnull proxy,
|
||||
NSDictionary* _Nullable options);
|
||||
typedef FrameProcessorPlugin* _Nonnull (^PluginInitializerFunction)(VisionCameraProxyHolder* proxy, 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
|
||||
withProxy:(VisionCameraProxyHolder* _Nonnull)proxy
|
||||
+ (FrameProcessorPlugin* _Nullable)getPlugin:(NSString*)name
|
||||
withProxy:(VisionCameraProxyHolder*)proxy
|
||||
withOptions:(NSDictionary* _Nullable)options;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@ -34,14 +34,15 @@ typedef NS_ENUM(NSInteger, SharedArrayType) {
|
||||
Float64Array,
|
||||
};
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface SharedArray : NSObject
|
||||
|
||||
- (instancetype _Nonnull)init NS_UNAVAILABLE;
|
||||
|
||||
- (instancetype _Nonnull)initWithProxy:(VisionCameraProxyHolder* _Nonnull)proxy type:(SharedArrayType)type size:(NSInteger)size;
|
||||
- (instancetype)init NS_UNAVAILABLE;
|
||||
- (instancetype)initWithProxy:(VisionCameraProxyHolder*)proxy type:(SharedArrayType)type size:(NSInteger)size;
|
||||
|
||||
#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;
|
||||
#endif
|
||||
@ -50,3 +51,5 @@ typedef NS_ENUM(NSInteger, SharedArrayType) {
|
||||
@property(nonatomic, readonly) NSInteger count;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
@ -42,18 +42,22 @@ private:
|
||||
};
|
||||
#endif
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface VisionCameraProxyHolder : NSObject
|
||||
|
||||
- (_Nonnull instancetype)initWithProxy:(void* _Nonnull)proxy;
|
||||
- (_Nonnull instancetype)initWithProxy:(void*)proxy;
|
||||
|
||||
#ifdef __cplusplus
|
||||
- (VisionCameraProxy* _Nonnull)proxy;
|
||||
- (VisionCameraProxy*)proxy;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
@interface VisionCameraInstaller : NSObject
|
||||
|
||||
+ (BOOL)installToBridge:(RCTBridge* _Nonnull)bridge;
|
||||
+ (BOOL)installToBridge:(RCTBridge*)bridge;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
|
Loading…
Reference in New Issue
Block a user