Inorder to get the devices those are acting as input devices, below method can be used
[AVCaptureDevice devices]
this returns an array of devices that are currently connected and available for capture. The array contains all devices those were connected at the time of calling the method. Application also supposed to observe for AVCaptureDeviceWasConnectedNotification and AVCaptureDeviceWasDisconnectedNotification to know whether the availability of device was changed.
The array when ran the code returned two devices
__NSArrayI 0x600000033b40>(
assuming one is for vide and another is for video.
Lets say we want to capture Audio, in that case, the code will be like below
//create a capture session
AVCaptureSession *captureSession = [[AVCaptureSession alloc] init];
//now we need to begin configuring the capture session
[captureSession beginConfiguration];
//as part of the configuration, add the input device
AVCaptureDeviceInput *audioInput = [[AVCaptureDeviceInput alloc] initWithDevice:audioDevice error:nil];
[captureSession addInput:audioInput];
//Now add the output
AVCaptureAudioDataOutput audioDataOutput = [[AVCaptureAudioDataOutput alloc] init];
[captureSession addOutput: audioDataOutput];
//create an audio queue
dispatch_queue_t dipAudioQueue = dispatch_queue_create(“AudioQueue”, NULL);
//now ask the AVCaptureAudioDataOutput to callback to the application on the queue. Since the out captured is called back on queue, it doesn’t get blocked. However, if there is any delay in finishing the callback didOutPutSampleBuffer, then the new sample will be dropped.
[audioDataOutput setSampleBufferDelegate:self dipAudioQueue];
No comments:
Post a Comment