Created
October 6, 2015 18:19
-
-
Save schifano/9c7a599547b2df7e9a1e to your computer and use it in GitHub Desktop.
An incomplete example.
This file contains hidden or 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 *session = [[AVCaptureSession alloc] init]; | |
AVCaptureDevice *captureDevice = [[AVCaptureDevice alloc] init]; | |
// Add input/output devices | |
// Check what media type is supported by the device | |
NSArray *devices = [AVCaptureDevice devices]; | |
for (AVCaptureDevice *device in devices) { | |
NSLog(@"Device name: %@", [device localizedName]); | |
if ([device hasMediaType:AVMediaTypeVideo]) { | |
if ([device position] == AVCaptureDevicePositionFront){ | |
NSLog(@"Device position: front"); | |
captureDevice = device; | |
// We have a front-facing video device | |
if (captureDevice != NULL) { | |
NSLog(@"Capture device found"); | |
// Add a device to the AVCaptureSession, AVCaptureDeviceInput | |
NSError *error; | |
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error]; | |
if (!input) { | |
// Handle error | |
} | |
} | |
} else { | |
NSLog(@"Device position: back - Don't want"); | |
} | |
} | |
} | |
// Start data flow - eventually want to also stopRunning | |
[session startRunning]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks