What is the data stored in CMSampleBuffer when using AVCaptureAudioDataOutput? It delivers CMSampleBuffers via delegate method –captureOutput:didOutputSampleBuffer:fromConnection:
but what's inside CMSampleBuffer? PCM or compressed? What are the samplerates, number of channels, etc.? How this can be used for streaming audio from device?
Googling for several hours didn't helped me.
Thanks in advance
looks like you can get the ASBD this way:
sampleBuffer->
CMSampleBufferGetFormatDescription ->
CMAudioFormatDescriptionGetStreamBasicDescription
then the ASBD will detail the frame sizes, if it is compressed, endianness, etc.
To demonstrate this (with no error checking) and get the sample rate:
CMSampleBufferRef cmSampleBuffer = ...;
CMFormatDescriptionRef formatDescription =
CMSampleBufferGetFormatDescription(cmSampleBuffer);
const AudioStreamBasicDescription* const asbd =
CMAudioFormatDescriptionGetStreamBasicDescription(formatDescription);
double sampleRate = asbd->mSampleRate;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With