| 
									
										
										
										
											2024-01-12 16:00:36 +01:00
										 |  |  | //
 | 
					
						
							|  |  |  | //  SharedArray.h
 | 
					
						
							|  |  |  | //  VisionCamera
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | //  Created by Marc Rousavy on 12.01.24.
 | 
					
						
							|  |  |  | //  Copyright © 2024 mrousavy. All rights reserved.
 | 
					
						
							|  |  |  | //
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #pragma once
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #import "VisionCameraProxy.h"
 | 
					
						
							|  |  |  | #import <Foundation/Foundation.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							|  |  |  | #import <jsi/jsi.h>
 | 
					
						
							|  |  |  | using namespace facebook; | 
					
						
							|  |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-16 20:02:03 +01:00
										 |  |  | NS_ASSUME_NONNULL_BEGIN | 
					
						
							| 
									
										
										
										
											2024-01-12 16:00:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-18 10:41:26 +01:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * An ArrayBuffer of type uint8 that can be shared between native and JS without copying. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2024-01-16 20:02:03 +01:00
										 |  |  | @interface SharedArray : NSObject | 
					
						
							| 
									
										
										
										
											2024-01-12 16:00:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-16 20:02:03 +01:00
										 |  |  | - (instancetype)init NS_UNAVAILABLE; | 
					
						
							| 
									
										
										
										
											2024-01-18 10:41:26 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Allocates a new SharedArray with the given size. | 
					
						
							|  |  |  |  * Use `data` to write to the SharedArray. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | - (instancetype)initWithProxy:(VisionCameraProxyHolder*)proxy allocateWithSize:(NSInteger)size; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /**
 | 
					
						
							|  |  |  |  * Wraps the given data in a SharedArray without copying. | 
					
						
							|  |  |  |  * Use `data` to write to the SharedArray. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | - (instancetype)initWithProxy:(VisionCameraProxyHolder*)proxy | 
					
						
							|  |  |  |                      wrapData:(uint8_t*)data | 
					
						
							|  |  |  |                      withSize:(NSInteger)size | 
					
						
							|  |  |  |                 freeOnDealloc:(BOOL)freeOnDealloc; | 
					
						
							| 
									
										
										
										
											2024-01-12 16:00:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | #ifdef __cplusplus
 | 
					
						
							| 
									
										
										
										
											2024-01-18 10:41:26 +01:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * Wraps the given JSI ArrayBuffer in a SharedArray for native access. | 
					
						
							|  |  |  |  * Use `data` to write to the SharedArray. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | - (instancetype)initWithRuntime:(jsi::Runtime&)runtime wrapArrayBuffer:(std::shared_ptr<jsi::ArrayBuffer>)arrayBuffer; | 
					
						
							| 
									
										
										
										
											2024-01-12 16:00:36 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-17 20:18:46 +01:00
										 |  |  | - (std::shared_ptr<jsi::ArrayBuffer>)arrayBuffer; | 
					
						
							| 
									
										
										
										
											2024-01-12 16:00:36 +01:00
										 |  |  | #endif
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-18 10:41:26 +01:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * The underlying contents of the ArrayBuffer which can be used for reading and writing. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2024-01-12 16:00:36 +01:00
										 |  |  | @property(nonatomic, readonly, nonnull) uint8_t* data; | 
					
						
							| 
									
										
										
										
											2024-01-18 10:41:26 +01:00
										 |  |  | /**
 | 
					
						
							|  |  |  |  * The size of the ArrayBuffer. | 
					
						
							|  |  |  |  */ | 
					
						
							| 
									
										
										
										
											2024-01-17 18:30:26 +01:00
										 |  |  | @property(nonatomic, readonly) NSInteger size; | 
					
						
							| 
									
										
										
										
											2024-01-12 16:00:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | @end | 
					
						
							| 
									
										
										
										
											2024-01-16 20:02:03 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | NS_ASSUME_NONNULL_END |