зеркало из https://github.com/mozilla/gecko-dev.git
Bug 941302 - Part 3: Changes for adding Gonk Decode Module. r=cpearce
From de67de8646b413bce991789b42d09f398b162b53 Mon Sep 17 00:00:00 2001
This commit is contained in:
Родитель
3afc1b9fac
Коммит
a5df92b66f
|
@ -309,7 +309,10 @@ pref("dom.indexedDB.warningQuota", 5);
|
|||
pref("media.preload.default", 1); // default to preload none
|
||||
pref("media.preload.auto", 2); // preload metadata if preload=auto
|
||||
pref("media.cache_size", 4096); // 4MB media cache
|
||||
|
||||
#ifdef MOZ_FMP4
|
||||
// Enable/Disable Gonk Decoder Module
|
||||
pref("media.fragmented-mp4.gonk.enabled", false);
|
||||
#endif
|
||||
// The default number of decoded video frames that are enqueued in
|
||||
// MediaDecoderReader's mVideoQueue.
|
||||
pref("media.video-queue.default-size", 3);
|
||||
|
|
|
@ -135,6 +135,12 @@ IsAppleAvailable()
|
|||
#endif
|
||||
}
|
||||
|
||||
static bool
|
||||
IsGonkMP4DecoderAvailable()
|
||||
{
|
||||
return Preferences::GetBool("media.fragmented-mp4.gonk.enabled", false);
|
||||
}
|
||||
|
||||
static bool
|
||||
HavePlatformMPEGDecoders()
|
||||
{
|
||||
|
@ -145,6 +151,7 @@ HavePlatformMPEGDecoders()
|
|||
#endif
|
||||
IsFFmpegAvailable() ||
|
||||
IsAppleAvailable() ||
|
||||
IsGonkMP4DecoderAvailable() ||
|
||||
// TODO: Other platforms...
|
||||
false;
|
||||
}
|
||||
|
|
|
@ -236,8 +236,14 @@ private:
|
|||
};
|
||||
#endif
|
||||
|
||||
bool MP4Reader::IsWaitingMediaResources()
|
||||
{
|
||||
bool MP4Reader::IsWaitingOnCodecResource() {
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
return mVideo.mDecoder && mVideo.mDecoder->IsWaitingMediaResources();
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
bool MP4Reader::IsWaitingOnCDMResource() {
|
||||
#ifdef MOZ_EME
|
||||
nsRefPtr<CDMProxy> proxy;
|
||||
{
|
||||
|
@ -263,6 +269,15 @@ bool MP4Reader::IsWaitingMediaResources()
|
|||
#endif
|
||||
}
|
||||
|
||||
bool MP4Reader::IsWaitingMediaResources()
|
||||
{
|
||||
// IsWaitingOnCDMResource() *must* come first, because we don't know whether
|
||||
// we can create a decoder until the CDM is initialized and it has told us
|
||||
// whether *it* will decode, or whether we need to create a PDM to do the
|
||||
// decoding
|
||||
return IsWaitingOnCDMResource() || IsWaitingOnCodecResource();
|
||||
}
|
||||
|
||||
void
|
||||
MP4Reader::ExtractCryptoInitData(nsTArray<uint8_t>& aInitData)
|
||||
{
|
||||
|
@ -304,7 +319,12 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo,
|
|||
// an encrypted stream and we need to wait for a CDM to be set, we don't
|
||||
// need to reinit the demuxer.
|
||||
mDemuxerInitialized = true;
|
||||
} else if (mPlatform && !IsWaitingMediaResources()) {
|
||||
*aInfo = mInfo;
|
||||
*aTags = nullptr;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (mDemuxer->Crypto().valid) {
|
||||
#ifdef MOZ_EME
|
||||
if (!sIsEMEEnabled) {
|
||||
|
@ -750,4 +770,36 @@ MP4Reader::GetBuffered(dom::TimeRanges* aBuffered, int64_t aStartTime)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
bool MP4Reader::IsDormantNeeded()
|
||||
{
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
return mVideo.mDecoder && mVideo.mDecoder->IsDormantNeeded();
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
void MP4Reader::ReleaseMediaResources()
|
||||
{
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
// Before freeing a video codec, all video buffers needed to be released
|
||||
// even from graphics pipeline.
|
||||
VideoFrameContainer* container = mDecoder->GetVideoFrameContainer();
|
||||
if (container) {
|
||||
container->ClearCurrentFrame();
|
||||
}
|
||||
if (mVideo.mDecoder) {
|
||||
mVideo.mDecoder->ReleaseMediaResources();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void MP4Reader::NotifyResourcesStatusChanged()
|
||||
{
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
if (mDecoder) {
|
||||
mDecoder->NotifyWaitingForResourcesStatusChanged();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -58,7 +58,10 @@ public:
|
|||
virtual nsresult GetBuffered(dom::TimeRanges* aBuffered,
|
||||
int64_t aStartTime) MOZ_OVERRIDE;
|
||||
|
||||
// For Media Resource Management
|
||||
virtual bool IsWaitingMediaResources() MOZ_OVERRIDE;
|
||||
virtual bool IsDormantNeeded() MOZ_OVERRIDE;
|
||||
virtual void ReleaseMediaResources() MOZ_OVERRIDE;
|
||||
|
||||
virtual nsresult ResetDecode() MOZ_OVERRIDE;
|
||||
|
||||
|
@ -83,6 +86,9 @@ private:
|
|||
bool Decode(mp4_demuxer::TrackType aTrack);
|
||||
void Flush(mp4_demuxer::TrackType aTrack);
|
||||
void DrainComplete(mp4_demuxer::TrackType aTrack);
|
||||
void NotifyResourcesStatusChanged();
|
||||
bool IsWaitingOnCodecResource();
|
||||
bool IsWaitingOnCDMResource();
|
||||
|
||||
nsAutoPtr<mp4_demuxer::MP4Demuxer> mDemuxer;
|
||||
nsAutoPtr<PlatformDecoderModule> mPlatform;
|
||||
|
@ -107,6 +113,12 @@ private:
|
|||
virtual void DrainComplete() MOZ_OVERRIDE {
|
||||
mReader->DrainComplete(mType);
|
||||
}
|
||||
virtual void NotifyResourcesStatusChanged() MOZ_OVERRIDE {
|
||||
mReader->NotifyResourcesStatusChanged();
|
||||
}
|
||||
virtual void ReleaseMediaResources() MOZ_OVERRIDE {
|
||||
mReader->ReleaseMediaResources();
|
||||
}
|
||||
private:
|
||||
MP4Reader* mReader;
|
||||
mp4_demuxer::TrackType mType;
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
#ifdef MOZ_APPLEMEDIA
|
||||
#include "AppleDecoderModule.h"
|
||||
#endif
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
#include "GonkDecoderModule.h"
|
||||
#endif
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#ifdef MOZ_EME
|
||||
#include "EMEDecoderModule.h"
|
||||
|
@ -28,6 +32,7 @@ extern PlatformDecoderModule* CreateBlankDecoderModule();
|
|||
|
||||
bool PlatformDecoderModule::sUseBlankDecoder = false;
|
||||
bool PlatformDecoderModule::sFFmpegDecoderEnabled = false;
|
||||
bool PlatformDecoderModule::sGonkDecoderEnabled = false;
|
||||
|
||||
/* static */
|
||||
void
|
||||
|
@ -44,6 +49,10 @@ PlatformDecoderModule::Init()
|
|||
"media.fragmented-mp4.use-blank-decoder");
|
||||
Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled,
|
||||
"media.fragmented-mp4.ffmpeg.enabled", false);
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
Preferences::AddBoolVarCache(&sGonkDecoderEnabled,
|
||||
"media.fragmented-mp4.gonk.enabled", false);
|
||||
#endif
|
||||
#ifdef XP_WIN
|
||||
WMFDecoderModule::Init();
|
||||
#endif
|
||||
|
@ -132,6 +141,11 @@ PlatformDecoderModule::Create()
|
|||
if (NS_SUCCEEDED(m->Startup())) {
|
||||
return m.forget();
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
if (sGonkDecoderEnabled) {
|
||||
return new GonkDecoderModule();
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -125,6 +125,7 @@ protected:
|
|||
// Caches pref media.fragmented-mp4.use-blank-decoder
|
||||
static bool sUseBlankDecoder;
|
||||
static bool sFFmpegDecoderEnabled;
|
||||
static bool sGonkDecoderEnabled;
|
||||
};
|
||||
|
||||
// A callback used by MediaDataDecoder to return output/errors to the
|
||||
|
@ -146,6 +147,10 @@ public:
|
|||
virtual void InputExhausted() = 0;
|
||||
|
||||
virtual void DrainComplete() = 0;
|
||||
|
||||
virtual void NotifyResourcesStatusChanged() {};
|
||||
|
||||
virtual void ReleaseMediaResources() {};
|
||||
};
|
||||
|
||||
// MediaDataDecoder is the interface exposed by decoders created by the
|
||||
|
@ -211,6 +216,15 @@ public:
|
|||
// returned.
|
||||
virtual nsresult Shutdown() = 0;
|
||||
|
||||
// For Codec Resource Management
|
||||
virtual bool IsWaitingMediaResources() {
|
||||
return false;
|
||||
};
|
||||
virtual bool IsDormantNeeded() {
|
||||
return false;
|
||||
};
|
||||
virtual void ReleaseMediaResources() {};
|
||||
virtual void ReleaseDecoder() {};
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -59,12 +59,16 @@ if CONFIG['MOZ_APPLEMEDIA']:
|
|||
'-framework AudioToolbox',
|
||||
]
|
||||
|
||||
if CONFIG['ANDROID_VERSION'] >= '18'and CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
|
||||
DEFINES['MOZ_GONK_MEDIACODEC'] = True
|
||||
DIRS += ['gonk']
|
||||
|
||||
include('/ipc/chromium/chromium-config.mozbuild')
|
||||
|
||||
LOCAL_INCLUDES += [
|
||||
'../base',
|
||||
]
|
||||
|
||||
|
||||
FINAL_LIBRARY = 'xul'
|
||||
|
||||
FAIL_ON_WARNINGS = True
|
||||
|
|
Загрузка…
Ссылка в новой задаче