From c85f12a745dd89c17ecb7f800f780b0204176d0d Mon Sep 17 00:00:00 2001 From: Horace Ho Date: Wed, 12 Aug 2015 11:15:07 +0800 Subject: [PATCH] Add GPUImageVideoCameraDelegate --- FastttCamera/FastttCameraInterface.h | 10 ++++++++++ FastttCamera/Filters/FastttFilterCamera.m | 11 ++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/FastttCamera/FastttCameraInterface.h b/FastttCamera/FastttCameraInterface.h index 5349c49..f6a478e 100644 --- a/FastttCamera/FastttCameraInterface.h +++ b/FastttCamera/FastttCameraInterface.h @@ -7,6 +7,7 @@ // #import +#import #import "FastttCameraTypes.h" #import "FastttCapturedImage.h" #import "UIViewController+FastttCamera.h" @@ -314,4 +315,13 @@ */ - (void)userDeniedCameraPermissionsForCameraController:(id)cameraController; +/** + * Called for every video sample from GPUImageVideoCamera + * + * @param sampleBuffer The CMSampleBuffer + * + * @note Use this optional method to handle the CMSampleBuffer + */ +- (void)willOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer; + @end diff --git a/FastttCamera/Filters/FastttFilterCamera.m b/FastttCamera/Filters/FastttFilterCamera.m index 1d3ef3e..304772d 100644 --- a/FastttCamera/Filters/FastttFilterCamera.m +++ b/FastttCamera/Filters/FastttFilterCamera.m @@ -16,7 +16,7 @@ #import "FastttFilter.h" #import "FastttCapturedImage+Process.h" -@interface FastttFilterCamera () +@interface FastttFilterCamera () @property (nonatomic, strong) IFTTTDeviceOrientation *deviceOrientation; @property (nonatomic, strong) FastttFocus *fastFocus; @@ -426,6 +426,7 @@ - (void)_setupCaptureSession _stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:position]; _stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait; _stillCamera.horizontallyMirrorFrontFacingCamera = YES; + _stillCamera.delegate = self; switch (position) { case AVCaptureDevicePositionBack: @@ -723,4 +724,12 @@ - (BOOL)handleTapFocusAtPoint:(CGPoint)touchPoint return NO; } +#pragma mark - GPUImageVideoCameraDelegate + +- (void)willOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer { + if ([self.delegate respondsToSelector:@selector(willOutputSampleBuffer:)]) { + [self.delegate willOutputSampleBuffer:sampleBuffer]; + } +} + @end