Bug 1159509 - Support audio AMR-NB for Gonk in MP4Reader. r=jya

This commit is contained in:
Blake Wu 2015-04-30 22:11:13 +08:00
Родитель 8c1db328cb
Коммит f124a393fe
7 изменённых файлов: 20 добавлений и 12 удалений

Просмотреть файл

@ -375,7 +375,8 @@ bool
MP4Reader::IsSupportedAudioMimeType(const nsACString& aMimeType)
{
return (aMimeType.EqualsLiteral("audio/mpeg") ||
aMimeType.EqualsLiteral("audio/mp4a-latm")) &&
aMimeType.EqualsLiteral("audio/mp4a-latm") ||
aMimeType.EqualsLiteral("audio/3gpp")) &&
mPlatform->SupportsMimeType(aMimeType);
}

Просмотреть файл

@ -50,8 +50,9 @@ GonkAudioDecoderManager::GonkAudioDecoderManager(
{
MOZ_COUNT_CTOR(GonkAudioDecoderManager);
MOZ_ASSERT(mAudioChannels);
mUserData.AppendElements(aConfig.mCodecSpecificConfig->Elements(),
aConfig.mCodecSpecificConfig->Length());
mCodecSpecificData = aConfig.mCodecSpecificConfig;
mMimeType = aConfig.mMimeType;
// Pass through mp3 without applying an ADTS header.
if (!aConfig.mMimeType.EqualsLiteral("audio/mp4a-latm")) {
mUseAdts = false;
@ -66,6 +67,7 @@ GonkAudioDecoderManager::~GonkAudioDecoderManager()
android::sp<MediaCodecProxy>
GonkAudioDecoderManager::Init(MediaDataDecoderCallback* aCallback)
{
status_t rv = OK;
if (mLooper != nullptr) {
return nullptr;
}
@ -74,7 +76,7 @@ GonkAudioDecoderManager::Init(MediaDataDecoderCallback* aCallback)
mLooper->setName("GonkAudioDecoderManager");
mLooper->start();
mDecoder = MediaCodecProxy::CreateByType(mLooper, "audio/mp4a-latm", false, nullptr);
mDecoder = MediaCodecProxy::CreateByType(mLooper, mMimeType.get(), false, nullptr);
if (!mDecoder.get()) {
return nullptr;
}
@ -85,8 +87,8 @@ GonkAudioDecoderManager::Init(MediaDataDecoderCallback* aCallback)
}
sp<AMessage> format = new AMessage;
// Fixed values
GADM_LOG("Init Audio channel no:%d, sample-rate:%d", mAudioChannels, mAudioRate);
format->setString("mime", "audio/mp4a-latm");
GADM_LOG("Configure audio mime type:%s, chan no:%d, sample-rate:%d", mMimeType.get(), mAudioChannels, mAudioRate);
format->setString("mime", mMimeType.get());
format->setInt32("channel-count", mAudioChannels);
format->setInt32("sample-rate", mAudioRate);
format->setInt32("aac-profile", mAudioProfile);
@ -95,8 +97,11 @@ GonkAudioDecoderManager::Init(MediaDataDecoderCallback* aCallback)
if (err != OK || !mDecoder->Prepare()) {
return nullptr;
}
status_t rv = mDecoder->Input(mUserData.Elements(), mUserData.Length(), 0,
android::MediaCodec::BUFFER_FLAG_CODECCONFIG);
if (mMimeType.EqualsLiteral("audio/mp4a-latm")) {
rv = mDecoder->Input(mCodecSpecificData->Elements(), mCodecSpecificData->Length(), 0,
android::MediaCodec::BUFFER_FLAG_CODECCONFIG);
}
if (rv == OK) {
return mDecoder;

Просмотреть файл

@ -51,7 +51,6 @@ private:
const uint32_t mAudioChannels;
const uint32_t mAudioRate;
const uint32_t mAudioProfile;
nsTArray<uint8_t> mUserData;
bool mUseAdts;
MediaDataDecoderCallback* mReaderCallback;

Просмотреть файл

@ -65,6 +65,7 @@ bool
GonkDecoderModule::SupportsMimeType(const nsACString& aMimeType)
{
return aMimeType.EqualsLiteral("audio/mp4a-latm") ||
aMimeType.EqualsLiteral("audio/3gpp") ||
aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/mp4v-es") ||
aMimeType.EqualsLiteral("video/avc");

Просмотреть файл

@ -69,6 +69,10 @@ protected:
nsTArray<nsRefPtr<MediaRawData>> mQueueSample;
RefPtr<MediaTaskQueue> mTaskQueue;
nsRefPtr<MediaByteBuffer> mCodecSpecificData;
nsAutoCString mMimeType;
};
// Samples are decoded using the GonkDecoder (MediaCodec)

Просмотреть файл

@ -494,7 +494,7 @@ GonkVideoDecoderManager::codecReserved()
sp<Surface> surface;
status_t rv = OK;
// Fixed values
GVDM_LOG("Configure mime type: %s, widht:%d, height:%d", mMimeType.get(), mVideoWidth, mVideoHeight);
GVDM_LOG("Configure video mime type: %s, widht:%d, height:%d", mMimeType.get(), mVideoWidth, mVideoHeight);
format->setString("mime", mMimeType.get());
format->setInt32("width", mVideoWidth);
format->setInt32("height", mVideoHeight);

Просмотреть файл

@ -147,7 +147,6 @@ private:
android::MediaBuffer* mVideoBuffer;
nsRefPtr<MediaByteBuffer> mCodecSpecificData;
MediaDataDecoderCallback* mReaderCallback;
MediaInfo mInfo;
android::sp<VideoResourceListener> mVideoListener;
@ -178,7 +177,6 @@ private:
// The lock protects mPendingVideoBuffers.
Mutex mPendingVideoBuffersLock;
nsAutoCString mMimeType;
};
} // namespace mozilla