I am trying to decode AAC encoded files in my application and to initialise the MediaFormat
object used to initialise my MediaCodec
object, This is the code for setting up the variables for the MediaFormat
object
MediaExtractor mediaExtractor = new MediaExtractor();
try {
mediaExtractor.setDataSource(audioFilePath);
} catch (IOException e) {
return false;
}
Log.d(TAG, "Number of tracks in the file are:" + mediaExtractor.getTrackCount());
MediaFormat mediaFormat = mediaExtractor.getTrackFormat(0);
Log.d(TAG, "mediaFormat:" + mediaFormat.toString());
mSampleRate = mediaFormat.getInteger(MediaFormat.KEY_SAMPLE_RATE);
Log.d(TAG, "mSampleRate: " + mSampleRate);
mChannels = mediaFormat.getInteger(MediaFormat.KEY_CHANNEL_COUNT);
Log.d(TAG, "mChannels number of channels: " + mChannels);
// Reading the duration from the file and converting from micro seconds to milliseconds.
mDuration = (int) (mediaFormat.getLong(MediaFormat.KEY_DURATION) / 1000);
Log.d(TAG, "duration: " + mDuration);
// Getting the csd-0 info from the file ..
mCSDBuffer = mediaFormat.getByteBuffer("csd-0");
The problem I am facing is that the statement mCSDBuffer = mediaFormat.getByteBuffer("csd-0")
fetches me null
for the same file on some devices. The application is in production and I see this error on armabi-v7a/armabi
processors devices with android API level of 17, 18 and 19 and most of these errors are on Samsung devices. Any direction on this?