0

I am working on conference related application, i have first capture audio with CaptureSession, now I want to play the audio data dynamically without saving into file. I have tried with AVQueue it seems both CaptureSession and AVQueue won't work together when I starts queue it stops capture, so What can I do now to play audio captured through CaptureSession?

thanks for your helps

Newbee
  • 3,231
  • 7
  • 42
  • 74

2 Answers2

0

You will need to convert your audioData into NSData:

- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer: (CMSampleBufferRef)sampleBuffer
   fromConnection:(AVCaptureConnection *)connection {

  NSData *audioData = yourFunction here to convert//[self audioFromSampleBuffer:sampleBuffer];
  dispatch_async(dispatch_get_main_queue(), ^{
    NSError *e;
    AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithData:data error:&e];
    NSLog(@"%@",[e description]);
    [player setDelegate:self];
    [player play];
  }
}

EDIT : refer Recording_Audio_on_an_iPhone_with_AVAudioRecorder link.

Paresh Navadiya
  • 38,095
  • 11
  • 81
  • 132
  • hi prince, did you tried this way? worked? Can you please tell me which way you converted sampleBuffer to NSData. – Newbee Nov 06 '12 at 12:50
  • that link they are playing using file, But I want to play the raw data as it is received. – Newbee Nov 06 '12 at 13:06
0

I have fixed the problem using AudioUnit method, Note: when we process audio data captured in AVCapturesession using AudioUnit, we need to ensure AudioUnit is not trying to access capture devices (Mic in my case), that is the reason it stopped capture call back.

Newbee
  • 3,231
  • 7
  • 42
  • 74