I added the Microphone device with AVCaptureSession
. I need audio through the delegateMethod . this method writing the audio on Server every time when I am getting it.
But AUDIO FORMAT is not right. Server required in PCM. So how can I get the audio data in PCM format?
Here is the method that writing data on server:
(void)captureOutput:(AVCaptureOutput *)captureOutput
didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer
fromConnection:(AVCaptureConnection *)connection
{
AudioBufferList audioBufferList;
NSMutableData *data=[[NSMutableData alloc] init];
CMBlockBufferRef blockBuffer;
CMSampleBufferGetAudioBufferListWithRetainedBlockBuffer(sampleBuffer, NULL, &audioBufferList, sizeof(audioBufferList), NULL, NULL, 0, &blockBuffer);
for( int y=0; y<audioBufferList.mNumberBuffers; y++ )
{
AudioBuffer audioBuffer = audioBufferList.mBuffers[y];
Byte *frame = (Byte*)audioBuffer.mData;
[data appendBytes:frame length:audioBuffer.mDataByteSize];
}
CFRelease(blockBuffer);
blockBuffer=NULL;
[outputStream write:[data bytes]maxLength:[data length]];
}
IS THERE ANY WHY TO ADD AUDIO SETTING IN THIS PHASE CODE SO THAT I CAN GET THE DATA ACCORDING TO MY REQUIREMENT.
I Suggest you review this apple developer document about AVCaptureAudioDataOutput and here is the sample code about reading and writing using AVReaderWriter.