Bug 1073805 - Apply ADTS header for Gonk. r=cpearce.

This commit is contained in:
Ralph Giles 2014-10-30 17:01:00 -07:00
parent 54fefa2ced
commit 5281f82c2d
2 changed files with 19 additions and 0 deletions

View File

@ -9,6 +9,7 @@
#include <ICrypto.h>
#include "GonkAudioDecoderManager.h"
#include "MediaDecoderReader.h"
#include "mp4_demuxer/Adts.h"
#include "VideoUtils.h"
#include "nsTArray.h"
#include "prlog.h"
@ -42,11 +43,16 @@ GonkAudioDecoderManager::GonkAudioDecoderManager(
, mAudioRate(aConfig.samples_per_second)
, mAudioProfile(aConfig.aac_profile)
, mAudioBuffer(nullptr)
, mUseAdts(true)
{
MOZ_COUNT_CTOR(GonkAudioDecoderManager);
MOZ_ASSERT(mAudioChannels);
mUserData.AppendElements(&aConfig.audio_specific_config[0],
aConfig.audio_specific_config.length());
// Pass through mp3 without applying an ADTS header.
if (strcmp(aConfig.mime_type, "audio/mp4a-latm") != 0) {
mUseAdts = false;
}
}
GonkAudioDecoderManager::~GonkAudioDecoderManager()
@ -215,6 +221,18 @@ GonkAudioDecoderManager::Input(mp4_demuxer::MP4Sample* aSample)
ALOG("Decoder is not inited");
return NS_ERROR_UNEXPECTED;
}
if (aSample && mUseAdts) {
int8_t frequency_index =
mp4_demuxer::Adts::GetFrequencyIndex(mAudioRate);
bool rv = mp4_demuxer::Adts::ConvertSample(mAudioChannels,
frequency_index,
mAudioProfile,
aSample);
if (!rv) {
ALOG("Failed to apply ADTS header");
return NS_ERROR_FAILURE;
}
}
status_t rv;
if (aSample) {

View File

@ -45,6 +45,7 @@ private:
const uint32_t mAudioRate;
const uint32_t mAudioProfile;
nsTArray<uint8_t> mUserData;
bool mUseAdts;
MediaDataDecoderCallback* mReaderCallback;
android::MediaBuffer* mAudioBuffer;