Bug 1153876 - Support MPEG-4 Codec, mp4v-es. r=jya. r=cpearce.

--HG--
extra : rebase_source : 596b37eab0d6d77c020b752212063b42ad6f5f3f
This commit is contained in:
Blake Wu 2015-04-20 21:57:29 +08:00
Родитель 62b9185477
Коммит eeb2174b40
8 изменённых файлов: 44 добавлений и 5 удалений

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

@ -112,6 +112,7 @@ public:
, mDisplay(nsIntSize(aWidth, aHeight))
, mStereoMode(StereoMode::MONO)
, mImage(nsIntSize(aWidth, aHeight))
, mCodecSpecificConfig(new MediaByteBuffer)
, mExtraData(new MediaByteBuffer)
{
}
@ -130,7 +131,7 @@ public:
// Size in pixels of decoded video's image.
nsIntSize mImage;
nsRefPtr<MediaByteBuffer> mCodecSpecificConfig;
nsRefPtr<MediaByteBuffer> mExtraData;
};

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

@ -345,6 +345,7 @@ bool
MP4Reader::IsSupportedVideoMimeType(const nsACString& aMimeType)
{
return (aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/mp4v-es") ||
aMimeType.EqualsLiteral("video/avc") ||
aMimeType.EqualsLiteral("video/x-vnd.on2.vp6")) &&
mPlatform->SupportsMimeType(aMimeType);

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

@ -61,4 +61,12 @@ GonkDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
}
}
bool
GonkDecoderModule::SupportsMimeType(const nsACString& aMimeType)
{
return aMimeType.EqualsLiteral("audio/mp4a-latm") ||
aMimeType.EqualsLiteral("video/mp4") ||
aMimeType.EqualsLiteral("video/mp4v-es") ||
aMimeType.EqualsLiteral("video/avc");
}
} // namespace mozilla

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

@ -34,6 +34,9 @@ public:
virtual ConversionRequired
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
virtual bool SupportsMimeType(const nsACString& aMimeType) override;
};
} // namespace mozilla

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

@ -175,7 +175,7 @@ GonkMediaDataDecoder::ProcessDecode(MediaRawData* aSample)
{
nsresult rv = mManager->Input(aSample);
if (rv != NS_OK) {
NS_WARNING("GonkAudioDecoder failed to input data");
NS_WARNING("GonkMediaDataDecoder failed to input data");
GMDD_LOG("Failed to input data err: %d",int(rv));
mCallback->Error();
return;

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

@ -57,12 +57,14 @@ GonkVideoDecoderManager::GonkVideoDecoderManager(
NS_ASSERTION(!NS_IsMainThread(), "Should not be on main thread.");
MOZ_ASSERT(mImageContainer);
MOZ_COUNT_CTOR(GonkVideoDecoderManager);
mMimeType = aConfig.mMimeType;
mVideoWidth = aConfig.mDisplay.width;
mVideoHeight = aConfig.mDisplay.height;
mDisplayWidth = aConfig.mDisplay.width;
mDisplayHeight = aConfig.mDisplay.height;
mInfo.mVideo = aConfig;
mCodecSpecificData = aConfig.mCodecSpecificConfig;
nsIntRect pictureRect(0, 0, mVideoWidth, mVideoHeight);
nsIntSize frameSize(mVideoWidth, mVideoHeight);
mPicture = pictureRect;
@ -105,9 +107,8 @@ GonkVideoDecoderManager::Init(MediaDataDecoderCallback* aCallback)
if (mLooper->start() != OK || mManagerLooper->start() != OK ) {
return nullptr;
}
mDecoder = MediaCodecProxy::CreateByType(mLooper, "video/avc", false, mVideoListener);
mDecoder = MediaCodecProxy::CreateByType(mLooper, mMimeType.get(), false, mVideoListener);
mDecoder->AskMediaCodecAndWait();
uint32_t capability = MediaCodecProxy::kEmptyCapability;
if (mDecoder->getCapability(&capability) == OK && (capability &
MediaCodecProxy::kCanExposeGraphicBuffer)) {
@ -390,10 +391,12 @@ GonkVideoDecoderManager::Output(int64_t aStreamOffset,
if (mDecoder->UpdateOutputBuffers()) {
return Output(aStreamOffset, aOutData);
}
GVDM_LOG("Fails to update output buffers!");
return NS_ERROR_FAILURE;
}
case -EAGAIN:
{
GVDM_LOG("Need to try again!");
return NS_ERROR_NOT_AVAILABLE;
}
case android::ERROR_END_OF_STREAM:
@ -493,7 +496,8 @@ GonkVideoDecoderManager::codecReserved()
sp<Surface> surface;
// Fixed values
format->setString("mime", "video/avc");
GVDM_LOG("Configure mime type: %s, widht:%d, height:%d", mMimeType.get(), mVideoWidth, mVideoHeight);
format->setString("mime", mMimeType.get());
format->setInt32("width", mVideoWidth);
format->setInt32("height", mVideoHeight);
if (mNativeWindow != nullptr) {
@ -501,6 +505,12 @@ GonkVideoDecoderManager::codecReserved()
}
mDecoder->configure(format, surface, nullptr, 0);
mDecoder->Prepare();
status_t rv = mDecoder->Input(mCodecSpecificData->Elements(), mCodecSpecificData->Length(), 0,
android::MediaCodec::BUFFER_FLAG_CODECCONFIG);
if (rv != OK) {
GVDM_LOG("Failed to configure codec!!!!");
mReaderCallback->Error();
}
}
void

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

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

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

@ -166,6 +166,19 @@ MP4VideoInfo::Update(const MetaData* aMetaData, const char* aMimeType)
mImage.height = FindInt32(aMetaData, kKeyHeight);
FindData(aMetaData, kKeyAVCC, mExtraData);
if (!mExtraData->Length()) {
if (FindData(aMetaData, kKeyESDS, mExtraData)) {
ESDS esds(mExtraData->Elements(), mExtraData->Length());
const void* data;
size_t size;
if (esds.getCodecSpecificInfo(&data, &size) == OK) {
const uint8_t* cdata = reinterpret_cast<const uint8_t*>(data);
mCodecSpecificConfig->AppendElements(cdata, size);
}
}
}
}
bool