Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GPUImageVideoCameraDelegate for video sample buffer handling #32

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions FastttCamera/FastttCameraInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import <UIKit/UIKit.h>
#import <CoreMedia/CoreMedia.h>
#import "FastttCameraTypes.h"
#import "FastttCapturedImage.h"
#import "UIViewController+FastttCamera.h"
Expand Down Expand Up @@ -314,4 +315,13 @@
*/
- (void)userDeniedCameraPermissionsForCameraController:(id<FastttCameraInterface>)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
11 changes: 10 additions & 1 deletion FastttCamera/Filters/FastttFilterCamera.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#import "FastttFilter.h"
#import "FastttCapturedImage+Process.h"

@interface FastttFilterCamera () <FastttFocusDelegate>
@interface FastttFilterCamera () <FastttFocusDelegate, GPUImageVideoCameraDelegate>

@property (nonatomic, strong) IFTTTDeviceOrientation *deviceOrientation;
@property (nonatomic, strong) FastttFocus *fastFocus;
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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