CameraCapture.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #pragma once
  2. #if !PLATFORM_TVOS && UNITY_USES_WEBCAM
  3. #import <AVFoundation/AVFoundation.h>
  4. #if PLATFORM_VISIONOS
  5. @interface CameraCaptureController : NSObject<AVCaptureVideoDataOutputSampleBufferDelegate>
  6. #else
  7. @interface CameraCaptureController : NSObject<AVCaptureVideoDataOutputSampleBufferDelegate, AVCaptureDataOutputSynchronizerDelegate>
  8. #endif
  9. - (bool)initCapture:(AVCaptureDevice*)device;
  10. - (bool)initCapture:(AVCaptureDevice*)device preset:(NSString*)preset fps:(float)fps;
  11. - (void)setCaptureFPS:(float)fps;
  12. - (bool)initColorAndDepthCameraCapture:(AVCaptureDevice*)device preset:(NSString*)preset fps:(float)fps isDepth:(bool)isDepth;
  13. - (void)initColorAndDepthCameraCaptureSession;
  14. - (void)clearColorAndDepthCameraCaptureSession;
  15. - (void)captureOutput:(AVCaptureOutput*)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection*)connection;
  16. #if !PLATFORM_VISIONOS
  17. - (void)dataOutputSynchronizer:(AVCaptureDataOutputSynchronizer *)synchronizer didOutputSynchronizedDataCollection:(AVCaptureSynchronizedDataCollection *)synchronizedDataCollection;
  18. + (BOOL)focusPointSupported:(AVCaptureDevice*)captureDevice withFocusMode:(AVCaptureFocusMode)focusMode;
  19. #endif
  20. + (NSMutableArray<CameraCaptureController*>*)getActiveColorAndDepthCameraControllers;
  21. + (void)addColorAndDepthCameraController:(CameraCaptureController*)controller;
  22. + (void)removeColorAndDepthCameraController:(CameraCaptureController*)controller;
  23. + (void)clearColorAndDepthCameraControllers;
  24. + (CameraCaptureController*)findColorAndDepthCameraController:(AVCaptureDevice*)device isDepth:(bool)isDepth;
  25. - (void)capturePixelBufferToMemBuffer:(uint8_t*)dst;
  26. - (int)isCVTextureFlipped;
  27. - (int)setFocusPointWithX:(float)x Y:(float)y;
  28. - (int)setFocusPoint;
  29. - (void)start;
  30. - (void)pause;
  31. - (void)stop;
  32. @property (nonatomic, retain) AVCaptureDevice* captureDevice;
  33. @property (nonatomic, retain) AVCaptureSession* captureSession;
  34. @property (nonatomic, retain) AVCaptureDeviceInput* captureInput;
  35. @property (nonatomic, retain) AVCaptureVideoDataOutput* captureOutput;
  36. #if !PLATFORM_VISIONOS
  37. @property (nonatomic, retain) AVCaptureDepthDataOutput* captureDepthOutput;
  38. @property (nonatomic, retain) AVCaptureDataOutputSynchronizer* captureSynchronizer;
  39. #endif
  40. - (float)pickAvailableFrameRate:(float)fps;
  41. @end
  42. enum WebCamKind
  43. {
  44. kWebCamWideAngle = 1,
  45. kWebCamTelephoto = 2,
  46. kWebCamColorAndDepth = 3,
  47. kWebCamUltraWideAngle = 4,
  48. };
  49. @interface CameraCaptureDevice : NSObject
  50. - (bool)isColorAndDepthCaptureDevice;
  51. - (WebCamKind)getKind;
  52. - (void)fillCaptureDeviceResolutions;
  53. - (NSString*)pickPresetFromWidth:(int)w height:(int)h;
  54. - (bool)initCaptureForController:(CameraCaptureController*)controller width:(int)w height:(int)h fps:(float)fps isDepth:(bool)isDepth;
  55. + (bool)initialized;
  56. + (void)createCameraCaptureDevicesArray;
  57. + (void)addCameraCaptureDevice:(AVCaptureDevice*)device;
  58. @end
  59. #endif