CameraCapture.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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)depthDataOutput:(AVCaptureDepthDataOutput*)captureDepthOutput didOutputDepthData:(AVDepthData*)depthData timestamp:(CMTime)timestamp connection:(AVCaptureConnection*)connection;
  18. - (void)dataOutputSynchronizer:(AVCaptureDataOutputSynchronizer *)synchronizer didOutputSynchronizedDataCollection:(AVCaptureSynchronizedDataCollection *)synchronizedDataCollection;
  19. + (BOOL)focusPointSupported:(AVCaptureDevice*)captureDevice withFocusMode:(AVCaptureFocusMode)focusMode;
  20. #endif
  21. + (NSMutableArray<CameraCaptureController*>*)getActiveColorAndDepthCameraControllers;
  22. + (void)addColorAndDepthCameraController:(CameraCaptureController*)controller;
  23. + (void)removeColorAndDepthCameraController:(CameraCaptureController*)controller;
  24. + (void)clearColorAndDepthCameraControllers;
  25. + (CameraCaptureController*)findColorAndDepthCameraController:(AVCaptureDevice*)device isDepth:(bool)isDepth;
  26. - (void)capturePixelBufferToMemBuffer:(uint8_t*)dst;
  27. - (int)isCVTextureFlipped;
  28. - (int)setFocusPointWithX:(float)x Y:(float)y;
  29. - (int)setFocusPoint;
  30. - (void)start;
  31. - (void)pause;
  32. - (void)stop;
  33. @property (nonatomic, retain) AVCaptureDevice* captureDevice;
  34. @property (nonatomic, retain) AVCaptureSession* captureSession;
  35. @property (nonatomic, retain) AVCaptureDeviceInput* captureInput;
  36. @property (nonatomic, retain) AVCaptureVideoDataOutput* captureOutput;
  37. #if !PLATFORM_VISIONOS
  38. @property (nonatomic, retain) AVCaptureDepthDataOutput* captureDepthOutput;
  39. @property (nonatomic, retain) AVCaptureDataOutputSynchronizer* captureSynchronizer;
  40. #endif
  41. - (float)pickAvailableFrameRate:(float)fps;
  42. @end
  43. enum WebCamKind
  44. {
  45. kWebCamUnknown = 0,
  46. kWebCamWideAngle = 1,
  47. kWebCamTelephoto = 2,
  48. kWebCamColorAndDepth = 3,
  49. kWebCamUltraWideAngle = 4,
  50. };
  51. @interface CameraCaptureDevice : NSObject
  52. - (bool)isColorAndDepthCaptureDevice;
  53. - (WebCamKind)getKind;
  54. - (void)fillCaptureDeviceResolutions;
  55. - (NSString*)pickPresetFromWidth:(int)w height:(int)h;
  56. - (bool)initCaptureForController:(CameraCaptureController*)controller width:(int)w height:(int)h fps:(float)fps isDepth:(bool)isDepth;
  57. + (bool)initialized;
  58. + (void)createCameraCaptureDevicesArray;
  59. + (void)addCameraCaptureDevice:(AVCaptureDevice*)device;
  60. @end
  61. #endif