Bug 1892066 - Bug 1891175 - Allow switching between using ffvpx-based decoders and other decoders, with a pref. r=alwu

I'm cleaning up a bunch of those. We'll probably want to use libvpx through
ffmpeg at some point, and remove the older decoder integration (if possible).

For now this pref will do what we want. I've also removed gratuitous variadic
template usage.

Differential Revision: https://phabricator.services.mozilla.com/D207710
This commit is contained in:
Paul Adenot 2024-04-17 18:56:44 +00:00
Родитель be74ed5dc8
Коммит ebc764305a
3 изменённых файлов: 37 добавлений и 32 удалений

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

@ -474,7 +474,7 @@ DecodeSupportSet PDMFactory::Supports(
void PDMFactory::CreatePDMs() {
if (StaticPrefs::media_use_blank_decoder()) {
CreateAndStartupPDM<BlankDecoderModule>();
StartupPDM(BlankDecoderModule::Create());
// The Blank PDM SupportsMimeType reports true for all codecs; the creation
// of its decoder is infallible. As such it will be used for all media, we
// can stop creating more PDM from this point.
@ -500,7 +500,7 @@ void PDMFactory::CreatePDMs() {
void PDMFactory::CreateGpuPDMs() {
#ifdef XP_WIN
if (StaticPrefs::media_wmf_enabled()) {
CreateAndStartupPDM<WMFDecoderModule>();
StartupPDM(WMFDecoderModule::Create());
}
#endif
}
@ -529,12 +529,12 @@ void PDMFactory::CreateRddPDMs() {
#ifdef XP_WIN
if (StaticPrefs::media_wmf_enabled() &&
StaticPrefs::media_rdd_wmf_enabled()) {
CreateAndStartupPDM<WMFDecoderModule>();
StartupPDM(WMFDecoderModule::Create());
}
#endif
#ifdef MOZ_APPLEMEDIA
if (StaticPrefs::media_rdd_applemedia_enabled()) {
CreateAndStartupPDM<AppleDecoderModule>();
StartupPDM(AppleDecoderModule::Create());
}
#endif
StartupPDM(FFVPXRuntimeLinker::CreateDecoder());
@ -546,7 +546,8 @@ void PDMFactory::CreateRddPDMs() {
FFmpegRuntimeLinker::LinkStatusCode());
}
#endif
CreateAndStartupPDM<AgnosticDecoderModule>();
StartupPDM(AgnosticDecoderModule::Create(),
StaticPrefs::media_prefer_non_ffvpx());
}
void PDMFactory::CreateUtilityPDMs() {
@ -555,13 +556,13 @@ void PDMFactory::CreateUtilityPDMs() {
if (StaticPrefs::media_wmf_enabled() &&
StaticPrefs::media_utility_wmf_enabled() &&
aKind == ipc::SandboxingKind::UTILITY_AUDIO_DECODING_WMF) {
CreateAndStartupPDM<WMFDecoderModule>();
StartupPDM(WMFDecoderModule::Create());
}
#endif
#ifdef MOZ_APPLEMEDIA
if (StaticPrefs::media_utility_applemedia_enabled() &&
aKind == ipc::SandboxingKind::UTILITY_AUDIO_DECODING_APPLE_MEDIA) {
CreateAndStartupPDM<AppleDecoderModule>();
StartupPDM(AppleDecoderModule::Create());
}
#endif
if (aKind == ipc::SandboxingKind::GENERIC_UTILITY) {
@ -582,12 +583,13 @@ void PDMFactory::CreateUtilityPDMs() {
StaticPrefs::media_android_media_codec_preferred());
}
#endif
CreateAndStartupPDM<AgnosticDecoderModule>();
StartupPDM(AgnosticDecoderModule::Create(),
StaticPrefs::media_prefer_non_ffvpx());
}
#ifdef MOZ_WMF_MEDIA_ENGINE
if (aKind == ipc::SandboxingKind::MF_MEDIA_ENGINE_CDM) {
if (StaticPrefs::media_wmf_media_engine_enabled()) {
CreateAndStartupPDM<MFMediaEngineDecoderModule>();
StartupPDM(MFMediaEngineDecoderModule::Create());
}
}
#endif
@ -595,31 +597,30 @@ void PDMFactory::CreateUtilityPDMs() {
void PDMFactory::CreateContentPDMs() {
if (StaticPrefs::media_gpu_process_decoder()) {
CreateAndStartupPDM<RemoteDecoderModule>(RemoteDecodeIn::GpuProcess);
StartupPDM(RemoteDecoderModule::Create(RemoteDecodeIn::GpuProcess));
}
if (StaticPrefs::media_rdd_process_enabled()) {
CreateAndStartupPDM<RemoteDecoderModule>(RemoteDecodeIn::RddProcess);
StartupPDM(RemoteDecoderModule::Create(RemoteDecodeIn::RddProcess));
}
if (StaticPrefs::media_utility_process_enabled()) {
#ifdef MOZ_APPLEMEDIA
CreateAndStartupPDM<RemoteDecoderModule>(
RemoteDecodeIn::UtilityProcess_AppleMedia);
StartupPDM(
RemoteDecoderModule::Create(RemoteDecodeIn::UtilityProcess_AppleMedia));
#endif
#ifdef XP_WIN
CreateAndStartupPDM<RemoteDecoderModule>(
RemoteDecodeIn::UtilityProcess_WMF);
StartupPDM(RemoteDecoderModule::Create(RemoteDecodeIn::UtilityProcess_WMF));
#endif
// WMF and AppleMedia should be created before Generic because the order
// affects what decoder module would be chose first.
CreateAndStartupPDM<RemoteDecoderModule>(
RemoteDecodeIn::UtilityProcess_Generic);
StartupPDM(
RemoteDecoderModule::Create(RemoteDecodeIn::UtilityProcess_Generic));
}
#ifdef MOZ_WMF_MEDIA_ENGINE
if (StaticPrefs::media_wmf_media_engine_enabled()) {
CreateAndStartupPDM<RemoteDecoderModule>(
RemoteDecodeIn::UtilityProcess_MFMediaEngineCDM);
StartupPDM(RemoteDecoderModule::Create(
RemoteDecodeIn::UtilityProcess_MFMediaEngineCDM));
}
#endif
@ -631,7 +632,7 @@ void PDMFactory::CreateContentPDMs() {
# ifdef MOZ_WMF
if (!StaticPrefs::media_rdd_process_enabled() ||
!StaticPrefs::media_rdd_wmf_enabled()) {
if (!CreateAndStartupPDM<WMFDecoderModule>()) {
if (!StartupPDM(WMFDecoderModule::Create())) {
mFailureFlags += DecoderDoctorDiagnostics::Flags::WMFFailedToLoad;
}
}
@ -642,11 +643,11 @@ void PDMFactory::CreateContentPDMs() {
#endif
#ifdef MOZ_APPLEMEDIA
CreateAndStartupPDM<AppleDecoderModule>();
StartupPDM(AppleDecoderModule::Create());
#endif
#ifdef MOZ_OMX
if (StaticPrefs::media_omx_enabled()) {
CreateAndStartupPDM<OmxDecoderModule>();
StartupPDM(OmxDecoderModule::Create());
}
#endif
StartupPDM(FFVPXRuntimeLinker::CreateDecoder());
@ -658,7 +659,8 @@ void PDMFactory::CreateContentPDMs() {
}
#endif
CreateAndStartupPDM<AgnosticDecoderModule>();
StartupPDM(AgnosticDecoderModule::Create(),
StaticPrefs::media_prefer_non_ffvpx());
#if !defined(MOZ_WIDGET_ANDROID) // Still required for video?
}
#endif // !defined(MOZ_WIDGET_ANDROID)
@ -681,7 +683,7 @@ void PDMFactory::CreateContentPDMs() {
void PDMFactory::CreateDefaultPDMs() {
#ifdef XP_WIN
if (StaticPrefs::media_wmf_enabled()) {
if (!CreateAndStartupPDM<WMFDecoderModule>()) {
if (!StartupPDM(WMFDecoderModule::Create())) {
mFailureFlags += DecoderDoctorDiagnostics::Flags::WMFFailedToLoad;
}
} else if (StaticPrefs::media_decoder_doctor_wmf_disabled_is_failure()) {
@ -690,11 +692,11 @@ void PDMFactory::CreateDefaultPDMs() {
#endif
#ifdef MOZ_APPLEMEDIA
CreateAndStartupPDM<AppleDecoderModule>();
StartupPDM(AppleDecoderModule::Create());
#endif
#ifdef MOZ_OMX
if (StaticPrefs::media_omx_enabled()) {
CreateAndStartupPDM<OmxDecoderModule>();
StartupPDM(OmxDecoderModule::Create());
}
#endif
StartupPDM(FFVPXRuntimeLinker::CreateDecoder());
@ -712,7 +714,8 @@ void PDMFactory::CreateDefaultPDMs() {
}
#endif
CreateAndStartupPDM<AgnosticDecoderModule>();
StartupPDM(AgnosticDecoderModule::Create(),
StaticPrefs::media_prefer_non_ffvpx());
if (StaticPrefs::media_gmp_decoder_enabled() &&
!StartupPDM(GMPDecoderModule::Create(),

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

@ -79,11 +79,6 @@ class PDMFactory final {
void CreateContentPDMs();
void CreateDefaultPDMs();
template <typename DECODER_MODULE, typename... ARGS>
bool CreateAndStartupPDM(ARGS&&... aArgs) {
return StartupPDM(DECODER_MODULE::Create(std::forward<ARGS>(aArgs)...));
}
// Startup the provided PDM and add it to our list if successful.
bool StartupPDM(already_AddRefed<PlatformDecoderModule> aPDM,
bool aInsertAtBeginning = false);

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

@ -9965,6 +9965,13 @@
#endif
mirror: always
# The codecs in the vendored ffmpeg copy are usually prefered to the other
# codecs. This allows changing this policy for testing purposes.
- name: media.prefer-non-ffvpx
type: RelaxedAtomicBool
value: false
mirror: always
- name: media.rdd-process.enabled
type: RelaxedAtomicBool
#if defined(XP_WIN)