SLAvCaptureSession.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // SLAvCaptureSession.h
  3. // DarkMode
  4. //
  5. // Created by wsl on 2019/11/7.
  6. // Copyright © 2019 https://github.com/wsl2ls ----- All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. #import <AVFoundation/AVFoundation.h>
  11. @class SLAvCaptureSession;
  12. /// 采集工具输出代理
  13. @protocol SLAvCaptureSessionDelegate <NSObject>
  14. @optional
  15. /// 实时输出采集的音视频样本 提供对外接口 方便自定义处理
  16. /// @param captureSession 采集会话
  17. /// @param sampleBuffer 缓冲样本
  18. /// @param connection 输入和输出之前的连接
  19. - (void)captureSession:(SLAvCaptureSession *_Nullable)captureSession didOutputVideoSampleBuffer:(CMSampleBufferRef _Nullable )sampleBuffer fromConnection:(AVCaptureConnection *_Nullable)connection;
  20. - (void)captureSession:(SLAvCaptureSession *_Nullable)captureSession didOutputAudioSampleBuffer:(CMSampleBufferRef _Nullable )sampleBuffer fromConnection:(AVCaptureConnection *_Nullable)connection;
  21. @end
  22. NS_ASSUME_NONNULL_BEGIN
  23. /// 摄像头采集工具
  24. @interface SLAvCaptureSession : NSObject
  25. /// 摄像头采集内容预览视图
  26. @property (nonatomic, strong, nullable) UIView *preview;
  27. /// 是否正在采集运行
  28. @property (nonatomic, assign, readonly) BOOL isRunning;
  29. /// 摄像头方向 默认后置摄像头
  30. @property (nonatomic, assign, readonly) AVCaptureDevicePosition devicePosition;
  31. /// 手机方向 只在 isRunning == YES时 才更新
  32. @property (nonatomic, assign, readonly) UIDeviceOrientation shootingOrientation;
  33. /// 闪光灯状态 默认是关闭的,即黑暗情况下拍照不打开闪光灯 (打开/关闭/自动)
  34. @property (nonatomic, assign) AVCaptureFlashMode flashMode;
  35. /// 当前焦距 默认最小值1 最大值6
  36. @property (nonatomic, assign) CGFloat videoZoomFactor;
  37. /// 捕获工具输出代理
  38. @property (nonatomic, weak) id<SLAvCaptureSessionDelegate> delegate;
  39. ///启动采集
  40. - (void)startRunning;
  41. ///结束采集
  42. - (void)stopRunning;
  43. /// 聚焦点 默认是连续聚焦模式
  44. - (void)focusAtPoint:(CGPoint)focalPoint;
  45. /// 切换前/后置摄像头
  46. - (void)switchsCamera:(AVCaptureDevicePosition)devicePosition;
  47. @end
  48. NS_ASSUME_NONNULL_END