mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1206977: P2. Wrap PDM creation in a new PDMFactory class. r=cpearce
There is no change of behaviour from the original PlatformDecoderModule.
This commit is contained in:
parent
6fd5b969a5
commit
d024ce2042
@ -240,15 +240,13 @@ MediaFormatReader::IsWaitingOnCDMResource() {
|
||||
bool
|
||||
MediaFormatReader::IsSupportedAudioMimeType(const nsACString& aMimeType)
|
||||
{
|
||||
return mPlatform && (mPlatform->SupportsMimeType(aMimeType) ||
|
||||
PlatformDecoderModule::AgnosticMimeType(aMimeType));
|
||||
return mPlatform && mPlatform->SupportsMimeType(aMimeType);
|
||||
}
|
||||
|
||||
bool
|
||||
MediaFormatReader::IsSupportedVideoMimeType(const nsACString& aMimeType)
|
||||
{
|
||||
return mPlatform && (mPlatform->SupportsMimeType(aMimeType) ||
|
||||
PlatformDecoderModule::AgnosticMimeType(aMimeType));
|
||||
return mPlatform && mPlatform->SupportsMimeType(aMimeType);
|
||||
}
|
||||
|
||||
nsRefPtr<MediaDecoderReader::MetadataPromise>
|
||||
|
244
dom/media/platforms/PDMFactory.cpp
Normal file
244
dom/media/platforms/PDMFactory.cpp
Normal file
@ -0,0 +1,244 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "PDMFactory.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include "WMFDecoderModule.h"
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
#include "FFmpegRuntimeLinker.h"
|
||||
#endif
|
||||
#ifdef MOZ_APPLEMEDIA
|
||||
#include "AppleDecoderModule.h"
|
||||
#endif
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
#include "GonkDecoderModule.h"
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "AndroidDecoderModule.h"
|
||||
#endif
|
||||
#include "GMPDecoderModule.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/TaskQueue.h"
|
||||
|
||||
#include "mozilla/SharedThreadPool.h"
|
||||
|
||||
#include "MediaInfo.h"
|
||||
#include "FuzzingWrapper.h"
|
||||
#include "H264Converter.h"
|
||||
|
||||
#include "OpusDecoder.h"
|
||||
#include "VorbisDecoder.h"
|
||||
#include "VPXDecoder.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern already_AddRefed<PlatformDecoderModule> CreateAgnosticDecoderModule();
|
||||
extern already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule();
|
||||
|
||||
bool PDMFactory::sUseBlankDecoder = false;
|
||||
bool PDMFactory::sGonkDecoderEnabled = false;
|
||||
bool PDMFactory::sAndroidMCDecoderEnabled = false;
|
||||
bool PDMFactory::sAndroidMCDecoderPreferred = false;
|
||||
bool PDMFactory::sGMPDecoderEnabled = false;
|
||||
bool PDMFactory::sEnableFuzzingWrapper = false;
|
||||
uint32_t PDMFactory::sVideoOutputMinimumInterval_ms = 0;
|
||||
bool PDMFactory::sDontDelayInputExhausted = false;
|
||||
|
||||
/* static */
|
||||
void
|
||||
PDMFactory::Init()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
static bool alreadyInitialized = false;
|
||||
if (alreadyInitialized) {
|
||||
return;
|
||||
}
|
||||
alreadyInitialized = true;
|
||||
|
||||
Preferences::AddBoolVarCache(&sUseBlankDecoder,
|
||||
"media.fragmented-mp4.use-blank-decoder");
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
Preferences::AddBoolVarCache(&sGonkDecoderEnabled,
|
||||
"media.fragmented-mp4.gonk.enabled", false);
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
Preferences::AddBoolVarCache(&sAndroidMCDecoderEnabled,
|
||||
"media.fragmented-mp4.android-media-codec.enabled", false);
|
||||
Preferences::AddBoolVarCache(&sAndroidMCDecoderPreferred,
|
||||
"media.fragmented-mp4.android-media-codec.preferred", false);
|
||||
#endif
|
||||
|
||||
Preferences::AddBoolVarCache(&sGMPDecoderEnabled,
|
||||
"media.fragmented-mp4.gmp.enabled", false);
|
||||
|
||||
Preferences::AddBoolVarCache(&sEnableFuzzingWrapper,
|
||||
"media.decoder.fuzzing.enabled", false);
|
||||
Preferences::AddUintVarCache(&sVideoOutputMinimumInterval_ms,
|
||||
"media.decoder.fuzzing.video-output-minimum-interval-ms", 0);
|
||||
Preferences::AddBoolVarCache(&sDontDelayInputExhausted,
|
||||
"media.decoder.fuzzing.dont-delay-inputexhausted", false);
|
||||
|
||||
#ifdef XP_WIN
|
||||
WMFDecoderModule::Init();
|
||||
#endif
|
||||
#ifdef MOZ_APPLEMEDIA
|
||||
AppleDecoderModule::Init();
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
FFmpegRuntimeLinker::Link();
|
||||
#endif
|
||||
}
|
||||
|
||||
PDMFactory::PDMFactory()
|
||||
: mCurrentPDM(CreatePDM())
|
||||
{
|
||||
if (!mCurrentPDM || NS_FAILED(mCurrentPDM->Startup())) {
|
||||
mCurrentPDM = CreateAgnosticDecoderModule();
|
||||
}
|
||||
}
|
||||
|
||||
PDMFactory::~PDMFactory()
|
||||
{
|
||||
}
|
||||
|
||||
already_AddRefed<MediaDataDecoder>
|
||||
PDMFactory::CreateDecoder(const TrackInfo& aConfig,
|
||||
FlushableTaskQueue* aTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback,
|
||||
layers::LayersBackend aLayersBackend,
|
||||
layers::ImageContainer* aImageContainer)
|
||||
{
|
||||
MOZ_ASSERT(mCurrentPDM);
|
||||
|
||||
nsRefPtr<MediaDataDecoder> m;
|
||||
|
||||
bool hasPlatformDecoder = mCurrentPDM->SupportsMimeType(aConfig.mMimeType);
|
||||
|
||||
if (aConfig.GetAsAudioInfo()) {
|
||||
if (!hasPlatformDecoder && VorbisDataDecoder::IsVorbis(aConfig.mMimeType)) {
|
||||
m = new VorbisDataDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aTaskQueue,
|
||||
aCallback);
|
||||
} else if (!hasPlatformDecoder && OpusDataDecoder::IsOpus(aConfig.mMimeType)) {
|
||||
m = new OpusDataDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aTaskQueue,
|
||||
aCallback);
|
||||
} else {
|
||||
m = mCurrentPDM->CreateAudioDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aTaskQueue,
|
||||
aCallback);
|
||||
}
|
||||
return m.forget();
|
||||
}
|
||||
|
||||
if (!aConfig.GetAsVideoInfo()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MediaDataDecoderCallback* callback = aCallback;
|
||||
nsRefPtr<DecoderCallbackFuzzingWrapper> callbackWrapper;
|
||||
if (sEnableFuzzingWrapper) {
|
||||
callbackWrapper = new DecoderCallbackFuzzingWrapper(aCallback);
|
||||
callbackWrapper->SetVideoOutputMinimumInterval(
|
||||
TimeDuration::FromMilliseconds(sVideoOutputMinimumInterval_ms));
|
||||
callbackWrapper->SetDontDelayInputExhausted(sDontDelayInputExhausted);
|
||||
callback = callbackWrapper.get();
|
||||
}
|
||||
|
||||
if (H264Converter::IsH264(aConfig)) {
|
||||
nsRefPtr<H264Converter> h
|
||||
= new H264Converter(mCurrentPDM,
|
||||
*aConfig.GetAsVideoInfo(),
|
||||
aLayersBackend,
|
||||
aImageContainer,
|
||||
aTaskQueue,
|
||||
callback);
|
||||
const nsresult rv = h->GetLastError();
|
||||
if (NS_SUCCEEDED(rv) || rv == NS_ERROR_NOT_INITIALIZED) {
|
||||
// The H264Converter either successfully created the wrapped decoder,
|
||||
// or there wasn't enough AVCC data to do so. Otherwise, there was some
|
||||
// problem, for example WMF DLLs were missing.
|
||||
m = h.forget();
|
||||
}
|
||||
} else if (!hasPlatformDecoder && VPXDecoder::IsVPX(aConfig.mMimeType)) {
|
||||
m = new VPXDecoder(*aConfig.GetAsVideoInfo(),
|
||||
aImageContainer,
|
||||
aTaskQueue,
|
||||
callback);
|
||||
} else {
|
||||
m = mCurrentPDM->CreateVideoDecoder(*aConfig.GetAsVideoInfo(),
|
||||
aLayersBackend,
|
||||
aImageContainer,
|
||||
aTaskQueue,
|
||||
callback);
|
||||
}
|
||||
|
||||
if (callbackWrapper && m) {
|
||||
m = new DecoderFuzzingWrapper(m.forget(), callbackWrapper.forget());
|
||||
}
|
||||
|
||||
return m.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
PDMFactory::SupportsMimeType(const nsACString& aMimeType)
|
||||
{
|
||||
MOZ_ASSERT(mCurrentPDM);
|
||||
return mCurrentPDM->SupportsMimeType(aMimeType) ||
|
||||
VPXDecoder::IsVPX(aMimeType) ||
|
||||
OpusDataDecoder::IsOpus(aMimeType) ||
|
||||
VorbisDataDecoder::IsVorbis(aMimeType);
|
||||
}
|
||||
|
||||
already_AddRefed<PlatformDecoderModule>
|
||||
PDMFactory::CreatePDM()
|
||||
{
|
||||
if (sGMPDecoderEnabled) {
|
||||
nsRefPtr<PlatformDecoderModule> m(new GMPDecoderModule());
|
||||
return m.forget();
|
||||
}
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if(sAndroidMCDecoderPreferred && sAndroidMCDecoderEnabled){
|
||||
nsRefPtr<PlatformDecoderModule> m(new AndroidDecoderModule());
|
||||
return m.forget();
|
||||
}
|
||||
#endif
|
||||
if (sUseBlankDecoder) {
|
||||
return CreateBlankDecoderModule();
|
||||
}
|
||||
#ifdef XP_WIN
|
||||
nsRefPtr<PlatformDecoderModule> m(new WMFDecoderModule());
|
||||
return m.forget();
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
nsRefPtr<PlatformDecoderModule> mffmpeg = FFmpegRuntimeLinker::CreateDecoderModule();
|
||||
if (mffmpeg) {
|
||||
return mffmpeg.forget();
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_APPLEMEDIA
|
||||
nsRefPtr<PlatformDecoderModule> m(new AppleDecoderModule());
|
||||
return m.forget();
|
||||
#endif
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
if (sGonkDecoderEnabled) {
|
||||
nsRefPtr<PlatformDecoderModule> m(new GonkDecoderModule());
|
||||
return m.forget();
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if(sAndroidMCDecoderEnabled){
|
||||
nsRefPtr<PlatformDecoderModule> m(new AndroidDecoderModule());
|
||||
return m.forget();
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
80
dom/media/platforms/PDMFactory.h
Normal file
80
dom/media/platforms/PDMFactory.h
Normal file
@ -0,0 +1,80 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#if !defined(PDMFactory_h_)
|
||||
#define PDMFactory_h_
|
||||
|
||||
#include "PlatformDecoderModule.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
class PDMFactory : public PlatformDecoderModule {
|
||||
public:
|
||||
PDMFactory();
|
||||
virtual ~PDMFactory();
|
||||
|
||||
// Call on the main thread to initialize the static state
|
||||
// needed by Create().
|
||||
static void Init();
|
||||
|
||||
already_AddRefed<MediaDataDecoder>
|
||||
CreateDecoder(const TrackInfo& aConfig,
|
||||
FlushableTaskQueue* aTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback,
|
||||
layers::LayersBackend aLayersBackend = layers::LayersBackend::LAYERS_NONE,
|
||||
layers::ImageContainer* aImageContainer = nullptr) override;
|
||||
|
||||
bool SupportsMimeType(const nsACString& aMimeType) override;
|
||||
|
||||
ConversionRequired
|
||||
DecoderNeedsConversion(const TrackInfo& aConfig) const override
|
||||
{
|
||||
MOZ_CRASH("Should never reach this function");
|
||||
return ConversionRequired::kNeedNone;
|
||||
}
|
||||
|
||||
protected:
|
||||
// Decode thread.
|
||||
already_AddRefed<MediaDataDecoder>
|
||||
CreateVideoDecoder(const VideoInfo& aConfig,
|
||||
layers::LayersBackend aLayersBackend,
|
||||
layers::ImageContainer* aImageContainer,
|
||||
FlushableTaskQueue* aVideoTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback) override
|
||||
{
|
||||
MOZ_CRASH("Should never reach this function");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// Decode thread.
|
||||
already_AddRefed<MediaDataDecoder>
|
||||
CreateAudioDecoder(const AudioInfo& aConfig,
|
||||
FlushableTaskQueue* aAudioTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback) override
|
||||
{
|
||||
MOZ_CRASH("Should never reach this function");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
private:
|
||||
already_AddRefed<PlatformDecoderModule> CreatePDM();
|
||||
|
||||
// Caches pref media.fragmented-mp4.use-blank-decoder
|
||||
static bool sUseBlankDecoder;
|
||||
static bool sGonkDecoderEnabled;
|
||||
static bool sAndroidMCDecoderPreferred;
|
||||
static bool sAndroidMCDecoderEnabled;
|
||||
static bool sGMPDecoderEnabled;
|
||||
static bool sEnableFuzzingWrapper;
|
||||
static uint32_t sVideoOutputMinimumInterval_ms;
|
||||
static bool sDontDelayInputExhausted;
|
||||
|
||||
nsRefPtr<PlatformDecoderModule> mCurrentPDM;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif /* PDMFactory_h_ */
|
@ -5,40 +5,11 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "PlatformDecoderModule.h"
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include "WMFDecoderModule.h"
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
#include "FFmpegRuntimeLinker.h"
|
||||
#endif
|
||||
#ifdef MOZ_APPLEMEDIA
|
||||
#include "AppleDecoderModule.h"
|
||||
#endif
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
#include "GonkDecoderModule.h"
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
#include "AndroidDecoderModule.h"
|
||||
#endif
|
||||
#include "GMPDecoderModule.h"
|
||||
|
||||
#include "mozilla/Preferences.h"
|
||||
#include "mozilla/TaskQueue.h"
|
||||
|
||||
#include "PDMFactory.h"
|
||||
#ifdef MOZ_EME
|
||||
#include "EMEDecoderModule.h"
|
||||
#include "mozilla/CDMProxy.h"
|
||||
#endif
|
||||
#include "mozilla/SharedThreadPool.h"
|
||||
|
||||
#include "MediaInfo.h"
|
||||
#include "FuzzingWrapper.h"
|
||||
#include "H264Converter.h"
|
||||
|
||||
#include "OpusDecoder.h"
|
||||
#include "VorbisDecoder.h"
|
||||
#include "VPXDecoder.h"
|
||||
|
||||
PRLogModuleInfo* GetPDMLog() {
|
||||
static PRLogModuleInfo* log = nullptr;
|
||||
@ -50,65 +21,12 @@ PRLogModuleInfo* GetPDMLog() {
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
extern already_AddRefed<PlatformDecoderModule> CreateAgnosticDecoderModule();
|
||||
extern already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule();
|
||||
|
||||
bool PlatformDecoderModule::sUseBlankDecoder = false;
|
||||
bool PlatformDecoderModule::sFFmpegDecoderEnabled = false;
|
||||
bool PlatformDecoderModule::sGonkDecoderEnabled = false;
|
||||
bool PlatformDecoderModule::sAndroidMCDecoderEnabled = false;
|
||||
bool PlatformDecoderModule::sAndroidMCDecoderPreferred = false;
|
||||
bool PlatformDecoderModule::sGMPDecoderEnabled = false;
|
||||
bool PlatformDecoderModule::sEnableFuzzingWrapper = false;
|
||||
uint32_t PlatformDecoderModule::sVideoOutputMinimumInterval_ms = 0;
|
||||
bool PlatformDecoderModule::sDontDelayInputExhausted = false;
|
||||
|
||||
/* static */
|
||||
void
|
||||
PlatformDecoderModule::Init()
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
static bool alreadyInitialized = false;
|
||||
if (alreadyInitialized) {
|
||||
return;
|
||||
}
|
||||
alreadyInitialized = true;
|
||||
|
||||
Preferences::AddBoolVarCache(&sUseBlankDecoder,
|
||||
"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 MOZ_WIDGET_ANDROID
|
||||
Preferences::AddBoolVarCache(&sAndroidMCDecoderEnabled,
|
||||
"media.fragmented-mp4.android-media-codec.enabled", false);
|
||||
Preferences::AddBoolVarCache(&sAndroidMCDecoderPreferred,
|
||||
"media.fragmented-mp4.android-media-codec.preferred", false);
|
||||
#endif
|
||||
|
||||
Preferences::AddBoolVarCache(&sGMPDecoderEnabled,
|
||||
"media.fragmented-mp4.gmp.enabled", false);
|
||||
|
||||
Preferences::AddBoolVarCache(&sEnableFuzzingWrapper,
|
||||
"media.decoder.fuzzing.enabled", false);
|
||||
Preferences::AddUintVarCache(&sVideoOutputMinimumInterval_ms,
|
||||
"media.decoder.fuzzing.video-output-minimum-interval-ms", 0);
|
||||
Preferences::AddBoolVarCache(&sDontDelayInputExhausted,
|
||||
"media.decoder.fuzzing.dont-delay-inputexhausted", false);
|
||||
|
||||
#ifdef XP_WIN
|
||||
WMFDecoderModule::Init();
|
||||
#endif
|
||||
#ifdef MOZ_APPLEMEDIA
|
||||
AppleDecoderModule::Init();
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
FFmpegRuntimeLinker::Link();
|
||||
#endif
|
||||
PDMFactory::Init();
|
||||
}
|
||||
|
||||
#ifdef MOZ_EME
|
||||
@ -142,135 +60,7 @@ already_AddRefed<PlatformDecoderModule>
|
||||
PlatformDecoderModule::Create()
|
||||
{
|
||||
// Note: This (usually) runs on the decode thread.
|
||||
|
||||
nsRefPtr<PlatformDecoderModule> m(CreatePDM());
|
||||
|
||||
if (m && NS_SUCCEEDED(m->Startup())) {
|
||||
return m.forget();
|
||||
}
|
||||
return CreateAgnosticDecoderModule();
|
||||
}
|
||||
|
||||
/* static */
|
||||
already_AddRefed<PlatformDecoderModule>
|
||||
PlatformDecoderModule::CreatePDM()
|
||||
{
|
||||
if (sGMPDecoderEnabled) {
|
||||
nsRefPtr<PlatformDecoderModule> m(new GMPDecoderModule());
|
||||
return m.forget();
|
||||
}
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if(sAndroidMCDecoderPreferred && sAndroidMCDecoderEnabled){
|
||||
nsRefPtr<PlatformDecoderModule> m(new AndroidDecoderModule());
|
||||
return m.forget();
|
||||
}
|
||||
#endif
|
||||
if (sUseBlankDecoder) {
|
||||
return CreateBlankDecoderModule();
|
||||
}
|
||||
#ifdef XP_WIN
|
||||
nsRefPtr<PlatformDecoderModule> m(new WMFDecoderModule());
|
||||
return m.forget();
|
||||
#endif
|
||||
#ifdef MOZ_FFMPEG
|
||||
nsRefPtr<PlatformDecoderModule> mffmpeg = FFmpegRuntimeLinker::CreateDecoderModule();
|
||||
if (mffmpeg) {
|
||||
return mffmpeg.forget();
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_APPLEMEDIA
|
||||
nsRefPtr<PlatformDecoderModule> m(new AppleDecoderModule());
|
||||
return m.forget();
|
||||
#endif
|
||||
#ifdef MOZ_GONK_MEDIACODEC
|
||||
if (sGonkDecoderEnabled) {
|
||||
nsRefPtr<PlatformDecoderModule> m(new GonkDecoderModule());
|
||||
return m.forget();
|
||||
}
|
||||
#endif
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
if(sAndroidMCDecoderEnabled){
|
||||
nsRefPtr<PlatformDecoderModule> m(new AndroidDecoderModule());
|
||||
return m.forget();
|
||||
}
|
||||
#endif
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
already_AddRefed<MediaDataDecoder>
|
||||
PlatformDecoderModule::CreateDecoder(const TrackInfo& aConfig,
|
||||
FlushableTaskQueue* aTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback,
|
||||
layers::LayersBackend aLayersBackend,
|
||||
layers::ImageContainer* aImageContainer)
|
||||
{
|
||||
nsRefPtr<MediaDataDecoder> m;
|
||||
|
||||
bool hasPlatformDecoder = SupportsMimeType(aConfig.mMimeType);
|
||||
|
||||
if (aConfig.GetAsAudioInfo()) {
|
||||
if (!hasPlatformDecoder && VorbisDataDecoder::IsVorbis(aConfig.mMimeType)) {
|
||||
m = new VorbisDataDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aTaskQueue,
|
||||
aCallback);
|
||||
} else if (!hasPlatformDecoder && OpusDataDecoder::IsOpus(aConfig.mMimeType)) {
|
||||
m = new OpusDataDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aTaskQueue,
|
||||
aCallback);
|
||||
} else {
|
||||
m = CreateAudioDecoder(*aConfig.GetAsAudioInfo(),
|
||||
aTaskQueue,
|
||||
aCallback);
|
||||
}
|
||||
return m.forget();
|
||||
}
|
||||
|
||||
if (!aConfig.GetAsVideoInfo()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
MediaDataDecoderCallback* callback = aCallback;
|
||||
nsRefPtr<DecoderCallbackFuzzingWrapper> callbackWrapper;
|
||||
if (sEnableFuzzingWrapper) {
|
||||
callbackWrapper = new DecoderCallbackFuzzingWrapper(aCallback);
|
||||
callbackWrapper->SetVideoOutputMinimumInterval(
|
||||
TimeDuration::FromMilliseconds(sVideoOutputMinimumInterval_ms));
|
||||
callbackWrapper->SetDontDelayInputExhausted(sDontDelayInputExhausted);
|
||||
callback = callbackWrapper.get();
|
||||
}
|
||||
|
||||
if (H264Converter::IsH264(aConfig)) {
|
||||
nsRefPtr<H264Converter> h
|
||||
= new H264Converter(this,
|
||||
*aConfig.GetAsVideoInfo(),
|
||||
aLayersBackend,
|
||||
aImageContainer,
|
||||
aTaskQueue,
|
||||
callback);
|
||||
const nsresult rv = h->GetLastError();
|
||||
if (NS_SUCCEEDED(rv) || rv == NS_ERROR_NOT_INITIALIZED) {
|
||||
// The H264Converter either successfully created the wrapped decoder,
|
||||
// or there wasn't enough AVCC data to do so. Otherwise, there was some
|
||||
// problem, for example WMF DLLs were missing.
|
||||
m = h.forget();
|
||||
}
|
||||
} else if (!hasPlatformDecoder && VPXDecoder::IsVPX(aConfig.mMimeType)) {
|
||||
m = new VPXDecoder(*aConfig.GetAsVideoInfo(),
|
||||
aImageContainer,
|
||||
aTaskQueue,
|
||||
callback);
|
||||
} else {
|
||||
m = CreateVideoDecoder(*aConfig.GetAsVideoInfo(),
|
||||
aLayersBackend,
|
||||
aImageContainer,
|
||||
aTaskQueue,
|
||||
callback);
|
||||
}
|
||||
|
||||
if (callbackWrapper && m) {
|
||||
m = new DecoderFuzzingWrapper(m.forget(), callbackWrapper.forget());
|
||||
}
|
||||
|
||||
nsRefPtr<PlatformDecoderModule> m = new PDMFactory;
|
||||
return m.forget();
|
||||
}
|
||||
|
||||
@ -282,14 +72,4 @@ PlatformDecoderModule::SupportsMimeType(const nsACString& aMimeType)
|
||||
aMimeType.EqualsLiteral("video/avc");
|
||||
}
|
||||
|
||||
/* static */
|
||||
bool
|
||||
PlatformDecoderModule::AgnosticMimeType(const nsACString& aMimeType)
|
||||
{
|
||||
return VPXDecoder::IsVPX(aMimeType) ||
|
||||
OpusDataDecoder::IsOpus(aMimeType) ||
|
||||
VorbisDataDecoder::IsVorbis(aMimeType);
|
||||
}
|
||||
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -63,8 +63,6 @@ public:
|
||||
// PlatformDecoderModule created per MP4Reader.
|
||||
// This is called on the decode task queue.
|
||||
static already_AddRefed<PlatformDecoderModule> Create();
|
||||
// As Create() but do not initialize the created PlatformDecoderModule.
|
||||
static already_AddRefed<PlatformDecoderModule> CreatePDM();
|
||||
|
||||
// Perform any per-instance initialization.
|
||||
// This is called on the decode task queue.
|
||||
@ -87,7 +85,10 @@ public:
|
||||
FlushableTaskQueue* aTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback,
|
||||
layers::LayersBackend aLayersBackend = layers::LayersBackend::LAYERS_NONE,
|
||||
layers::ImageContainer* aImageContainer = nullptr);
|
||||
layers::ImageContainer* aImageContainer = nullptr)
|
||||
{
|
||||
MOZ_CRASH();
|
||||
}
|
||||
|
||||
// An audio decoder module must support AAC by default.
|
||||
// A video decoder must support H264 by default.
|
||||
@ -95,10 +96,6 @@ public:
|
||||
// to be extended
|
||||
virtual bool SupportsMimeType(const nsACString& aMimeType);
|
||||
|
||||
// MimeType can be decoded with shipped decoders if no platform decoders exist
|
||||
static bool AgnosticMimeType(const nsACString& aMimeType);
|
||||
|
||||
|
||||
enum ConversionRequired {
|
||||
kNeedNone,
|
||||
kNeedAVCC,
|
||||
@ -115,6 +112,8 @@ protected:
|
||||
virtual ~PlatformDecoderModule() {}
|
||||
|
||||
friend class H264Converter;
|
||||
friend class PDMFactory;
|
||||
|
||||
// Creates a Video decoder. The layers backend is passed in so that
|
||||
// decoders can determine whether hardware accelerated decoding can be used.
|
||||
// Asynchronous decoding of video should be done in runnables dispatched
|
||||
@ -147,17 +146,6 @@ protected:
|
||||
CreateAudioDecoder(const AudioInfo& aConfig,
|
||||
FlushableTaskQueue* aAudioTaskQueue,
|
||||
MediaDataDecoderCallback* aCallback) = 0;
|
||||
|
||||
// Caches pref media.fragmented-mp4.use-blank-decoder
|
||||
static bool sUseBlankDecoder;
|
||||
static bool sFFmpegDecoderEnabled;
|
||||
static bool sGonkDecoderEnabled;
|
||||
static bool sAndroidMCDecoderPreferred;
|
||||
static bool sAndroidMCDecoderEnabled;
|
||||
static bool sGMPDecoderEnabled;
|
||||
static bool sEnableFuzzingWrapper;
|
||||
static uint32_t sVideoOutputMinimumInterval_ms;
|
||||
static bool sDontDelayInputExhausted;
|
||||
};
|
||||
|
||||
// A callback used by MediaDataDecoder to return output/errors to the
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "PlatformDecoderModule.h"
|
||||
#include "FFmpegAudioDecoder.h"
|
||||
#include "FFmpegH264Decoder.h"
|
||||
#include "FFmpegRuntimeLinker.h"
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
@ -23,7 +24,7 @@ public:
|
||||
{
|
||||
uint32_t major, minor;
|
||||
GetVersion(major, minor);
|
||||
if (major < 54 && !sFFmpegDecoderEnabled) {
|
||||
if (major < 54 && !FFmpegRuntimeLinker::sFFmpegDecoderEnabled) {
|
||||
return nullptr;
|
||||
}
|
||||
nsRefPtr<PlatformDecoderModule> pdm = new FFmpegDecoderModule();
|
||||
|
@ -9,12 +9,15 @@
|
||||
#include "FFmpegRuntimeLinker.h"
|
||||
#include "mozilla/ArrayUtils.h"
|
||||
#include "FFmpegLog.h"
|
||||
#include "mozilla/Preferences.h"
|
||||
|
||||
#define NUM_ELEMENTS(X) (sizeof(X) / sizeof((X)[0]))
|
||||
|
||||
namespace mozilla
|
||||
{
|
||||
|
||||
bool FFmpegRuntimeLinker::sFFmpegDecoderEnabled = false;
|
||||
|
||||
FFmpegRuntimeLinker::LinkStatus FFmpegRuntimeLinker::sLinkStatus =
|
||||
LinkStatus_INIT;
|
||||
|
||||
@ -59,6 +62,9 @@ FFmpegRuntimeLinker::Link()
|
||||
return sLinkStatus == LinkStatus_SUCCEEDED;
|
||||
}
|
||||
|
||||
Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled,
|
||||
"media.fragmented-mp4.ffmpeg.enabled", false);
|
||||
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
|
||||
for (size_t i = 0; i < ArrayLength(sLibs); i++) {
|
||||
|
@ -22,6 +22,8 @@ public:
|
||||
static void Unlink();
|
||||
static already_AddRefed<PlatformDecoderModule> CreateDecoderModule();
|
||||
|
||||
static bool sFFmpegDecoderEnabled;
|
||||
|
||||
private:
|
||||
static void* sLinkedLib;
|
||||
static const AvCodecLib* sLib;
|
||||
|
@ -18,6 +18,7 @@ UNIFIED_SOURCES += [
|
||||
'agnostic/OpusDecoder.cpp',
|
||||
'agnostic/VorbisDecoder.cpp',
|
||||
'agnostic/VPXDecoder.cpp',
|
||||
'PDMFactory.cpp',
|
||||
'PlatformDecoderModule.cpp',
|
||||
'wrappers/FuzzingWrapper.cpp',
|
||||
'wrappers/H264Converter.cpp'
|
||||
|
Loading…
Reference in New Issue
Block a user