Decoding AAC using MediaCodec API on Android
- by Benjamin Reed
I'm trying to used the MediaCodec API on Android to decode an AAC stream. (It's raw AAC.) I tried using the MediaFormat.createAudioFormat() to create the format object to pass to MediaCodec.configure(), but I kept getting errors when using AAC (audio/mp4a-latm). (It works with MP3 (audio/mpeg) though...)
Finally I created a MediaExtractor for an AAC file and looked at the format object it was producing. I saw that it included the key "csd-0" for a ByteBuffer composed of two bytes both with the value 0x12. If I include that key and value in the format object that I used to configure the AAC codec, everything works.
Does anyone have an idea what is going on? The documentation states that I shouldn't configure that key. Does anyone have a pointer to MediaCodec examples to decode AAC files without using MediaExtractor to generate the format object?