Is there a 'simple' way of decoding and playing AAC frames without going the coreaudio route?
Is this even possible?
I get ADTS frames from the network I put in NSData
Then I create a AudioStreamBasicDescription matching what's inside the ADTS header.
AudioStreamBasicDescription audioFormat;
audioFormat.mSampleRate = 48000.00;
audioFormat.mFormatID = kAudioFormatMPEG4AAC;
audioFormat.mFormatFlags = kMPEG4Object_AAC_LC;
audioFormat.mBytesPerPacket= 0;
audioFormat.mFramesPerPacket= 1024;
audioFormat.mBytesPerFrame= 0;
audioFormat.mChannelsPerFrame= 2;
audioFormat.mBitsPerChannel= 0;
audioFormat.mReserved= 0;
CMFormatDescriptionRef format = NULL;
OSStatus status = CMAudioFormatDescriptionCreate(kCFAllocatorDefault, &audioFormat, 0, nil, 0, nil, nil, &format);After that I remove the ADTS header and retain the data.
Then i create a CMBlockBufferRef:
CMBlockBufferRef frameBuffer;
OSStatus status = CMBlockBufferCreateWithMemoryBlock(NULL, (void *)[audioData bytes], [audioData length],
kCFAllocatorNull, NULL, 0,[audioData length], 0, &frameBuffer);And finally a CMSampleBufferRef :
CMSampleBufferRef sampleBuffer;
status = CMSampleBufferCreate(kCFAllocatorDefault, frameBuffer, true, NULL /readyCallback*/,
NULL, format, 1, 1, &timing, 0, NULL, &sampleBuffer);Then I just put the audio data into the "AVSampleBufferDisplayLayer" where i put the H264 video.
[renderLayer enqueueSampleBuffer:sampleBuffer];
No sound of cource.
Question 1: Can a "AVSampleBufferDisplayLayer" deal with audio?
Question 2: Is there a non coreaudio method of decoding AAC audio... audioengine? Something simple without going down the 200 lines of code route?
Thanks for helping..
/A