0

I'm decoding an online AAC stream with MediaCodec and trying to play it with AudioTrack. AudioTrack requires an AudioFormat which requires knowing the details of PCM encoding. I was able to get the audio to play correctly by configuring it as ENCODING_PCM_16BIT but is that guaranteed to always be 16-bit PCM encoding? I want to avoid making that assumption.

I would expect MediaCodec.Callback.onOutputFormatChanged to get the encoding information as part of it's MediaFormat parameter, which seems like it should be the case by this https://stackoverflow.com/a/49812393/2399236, but this is all the information I get out of the media format by calling toString() on it:

aac-drc-heavy-compression=1
sample-rate=48000
aac-drc-boost-level=127
aac-drc-output-loudness=-1
mime=audio/raw
channel-count=2
aac-drc-effect-type=3
aac-drc-cut-level=127
aac-encoded-target-level=-1
aac-max-output-channel_count=8
aac-target-ref-level=64
aac-drc-album-mode=0

Should I just assume that it's 16-bit PCM, or is there any way to get that information?

Note: I'm targetting min SDK 28, currently testing in debugger on emulated Pixel 2 API 30.

barteks2x
  • 1,275
  • 12
  • 24
  • Your title is not a summary of your issue. Also, consider to re-write your question just with clear info. – X T Aug 07 '22 at 16:19
  • How is it not a summary of my issue (edited it anyway)? I also don't know what isn't clear about the information I provided. Should I provide the code? It's over 100 lines. – barteks2x Aug 07 '22 at 16:25

0 Answers0