MGVideoManager.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // MGVideoManager.h
  3. // MGLivenessDetection
  4. //
  5. // Created by 张英堂 on 16/3/31.
  6. // Copyright © 2016年 megvii. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "MGImage.h"
  10. #import "MGBaseDefine.h"
  11. @protocol MGVideoDelegate;
  12. @interface MGVideoManager : NSObject
  13. @property (nonatomic, assign) id<MGVideoDelegate> videoDelegate;
  14. - (dispatch_queue_t)getVideoQueue;
  15. /**
  16. * 初始化方法
  17. *
  18. * @param sessionPreset 相机分辨率 如果设置为空,则默认为 AVCaptureSessionPreset640x480
  19. * @param devicePosition 前置或者后置相机,则默认为 前置相机
  20. * @param record 是否录像
  21. * @param sound 是否录音,必须在录像模式下设置 yes 才有用
  22. * @return 实例化对象
  23. */
  24. + (instancetype)videoPreset:(NSString *)sessionPreset
  25. devicePosition:(AVCaptureDevicePosition)devicePosition
  26. videoRecord:(BOOL)record
  27. videoSound:(BOOL)sound;
  28. @property (nonatomic, strong, readonly) AVCaptureSession *videoSession;
  29. @property (nonatomic, strong, readonly) AVCaptureDeviceInput *videoInput;
  30. @property (nonatomic, assign, readonly) AVCaptureDevicePosition devicePosition;
  31. ///**
  32. // * 视频流的最大帧率
  33. // */
  34. //@property (nonatomic, assign) int maxFrame;
  35. /**
  36. * 视频流的预览layer 默认全屏大小
  37. * @return 实例化对象
  38. */
  39. -(AVCaptureVideoPreviewLayer *)videoPreview;
  40. /**
  41. * 视频流的方向
  42. */
  43. @property(nonatomic, assign) AVCaptureVideoOrientation videoOrientation;
  44. /**
  45. * 开启视频流
  46. */
  47. - (void)startRunning;
  48. /**
  49. * 关闭视频流
  50. */
  51. - (void)stopRunning;
  52. /**
  53. * 开始录像
  54. */
  55. - (void)startRecording;
  56. /**
  57. * 关闭录像
  58. *
  59. * @return 录像存放地址
  60. */
  61. - (NSString *)stopRceording;
  62. - (CMFormatDescriptionRef)formatDescription;
  63. /** only valid after startRunning has been called */
  64. - (CGAffineTransform)transformFromVideoBufferOrientationToOrientation:(AVCaptureVideoOrientation)orientation
  65. withAutoMirroring:(BOOL)mirroring;
  66. @end
  67. @protocol MGVideoDelegate <NSObject>
  68. @required
  69. - (void)MGCaptureOutput:(AVCaptureOutput *)captureOutput
  70. didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
  71. fromConnection:(AVCaptureConnection *)connection;
  72. - (void)MGCaptureOutput:(AVCaptureOutput *)captureOutput error:(NSError *)error;
  73. @end