Created
October 17, 2012 17:21
-
-
Save Rich86man/3906840 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (AVCaptureSession*)captureSession | |
{ | |
if(!_captureSession) { | |
_captureSession = [[AVCaptureSession alloc] init]; | |
_captureSession.sessionPreset = AVCaptureSessionPresetMedium; | |
AVCaptureDeviceInput* videoInput = [AVCaptureDeviceInput deviceInputWithDevice:[AVCaptureDevice frontFacingCameraIfAvailable] error:nil]; | |
AVCaptureDeviceInput * audioInput = [AVCaptureDeviceInput deviceInputWithDevice:[AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio] error:nil]; | |
[self.captureSession beginConfiguration]; | |
[_captureSession addInput:videoInput]; | |
[_captureSession addInput:audioInput]; | |
[self.captureSession addOutput:self.fileOutput]; | |
[self.videoConnection setVideoOrientation:[[UIDevice currentDevice] orientation]]; | |
[self.captureSession commitConfiguration]; | |
} | |
return _captureSession; | |
} | |
- (AVCaptureVideoPreviewLayer*)captureVideoPreviewLayer | |
{ | |
if (!_captureVideoPreviewLayer) { | |
_captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession]; | |
_captureVideoPreviewLayer.frame = self.videoPlaceholderView.bounds; | |
_captureVideoPreviewLayer.orientation = [[UIDevice currentDevice] orientation]; | |
_captureVideoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill; | |
} | |
return _captureVideoPreviewLayer; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment