daily pastebin goal
50%
SHARE
TWEET

Untitled

a guest Jan 19th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. _captureSession = [[AVCaptureSession alloc] init];
  2.   [self.captureSession setSessionPreset:AVCaptureSessionPresetLow];
  3.  
  4.  
  5.   // Setup Audio input
  6.   AVCaptureDevice *audioDevice = [AVCaptureDevice
  7.                                 defaultDeviceWithMediaType:AVMediaTypeAudio];
  8.   AVCaptureDeviceInput *captureAudioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:&error];
  9.   if(error){
  10.       NSLog(@"Error Start capture Audio=%@", error);
  11.   }else{
  12.       if ([self.captureSession canAddInput:captureAudioInput]){
  13.           [self.captureSession addInput:captureAudioInput];
  14.       }
  15.   }
  16.  
  17.  
  18.   // Setup Audio output
  19.   AVCaptureAudioDataOutput *audioCaptureOutput = [[AVCaptureAudioDataOutput alloc] init];
  20.   if ([self.captureSession canAddOutput:audioCaptureOutput]){
  21.       [self.captureSession addOutput:audioCaptureOutput];
  22.   }
  23.   [audioCaptureOutput release];
  24.  
  25.  
  26.   //We create a serial queue
  27.   dispatch_queue_t audioQueue= dispatch_queue_create("audioQueue", NULL);
  28.   [audioCaptureOutput setSampleBufferDelegate:self queue:audioQueue];
  29.   dispatch_release(audioQueue);
  30.  
  31.  
  32.   /*We start the capture*/
  33.   [self.captureSession startRunning];
  34.    
  35. - (void)captureOutput:(AVCaptureOutput *)captureOutput  didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
  36.  
  37.   // do something with sampleBuffer
  38.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top