From ebc764305a66689c1ff1464c74323e7638c17e39 Mon Sep 17 00:00:00 2001 From: Paul Adenot Date: Wed, 17 Apr 2024 18:56:44 +0000 Subject: [PATCH] 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 --- dom/media/platforms/PDMFactory.cpp | 57 +++++++++++++----------- dom/media/platforms/PDMFactory.h | 5 --- modules/libpref/init/StaticPrefList.yaml | 7 +++ 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/dom/media/platforms/PDMFactory.cpp b/dom/media/platforms/PDMFactory.cpp index 00f46385e27d..26a9858c2102 100644 --- a/dom/media/platforms/PDMFactory.cpp +++ b/dom/media/platforms/PDMFactory.cpp @@ -474,7 +474,7 @@ DecodeSupportSet PDMFactory::Supports( void PDMFactory::CreatePDMs() { if (StaticPrefs::media_use_blank_decoder()) { - CreateAndStartupPDM(); + 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(); + 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(); + StartupPDM(WMFDecoderModule::Create()); } #endif #ifdef MOZ_APPLEMEDIA if (StaticPrefs::media_rdd_applemedia_enabled()) { - CreateAndStartupPDM(); + StartupPDM(AppleDecoderModule::Create()); } #endif StartupPDM(FFVPXRuntimeLinker::CreateDecoder()); @@ -546,7 +546,8 @@ void PDMFactory::CreateRddPDMs() { FFmpegRuntimeLinker::LinkStatusCode()); } #endif - CreateAndStartupPDM(); + 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(); + StartupPDM(WMFDecoderModule::Create()); } #endif #ifdef MOZ_APPLEMEDIA if (StaticPrefs::media_utility_applemedia_enabled() && aKind == ipc::SandboxingKind::UTILITY_AUDIO_DECODING_APPLE_MEDIA) { - CreateAndStartupPDM(); + 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(); + 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(); + StartupPDM(MFMediaEngineDecoderModule::Create()); } } #endif @@ -595,31 +597,30 @@ void PDMFactory::CreateUtilityPDMs() { void PDMFactory::CreateContentPDMs() { if (StaticPrefs::media_gpu_process_decoder()) { - CreateAndStartupPDM(RemoteDecodeIn::GpuProcess); + StartupPDM(RemoteDecoderModule::Create(RemoteDecodeIn::GpuProcess)); } if (StaticPrefs::media_rdd_process_enabled()) { - CreateAndStartupPDM(RemoteDecodeIn::RddProcess); + StartupPDM(RemoteDecoderModule::Create(RemoteDecodeIn::RddProcess)); } if (StaticPrefs::media_utility_process_enabled()) { #ifdef MOZ_APPLEMEDIA - CreateAndStartupPDM( - RemoteDecodeIn::UtilityProcess_AppleMedia); + StartupPDM( + RemoteDecoderModule::Create(RemoteDecodeIn::UtilityProcess_AppleMedia)); #endif #ifdef XP_WIN - CreateAndStartupPDM( - 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( - RemoteDecodeIn::UtilityProcess_Generic); + StartupPDM( + RemoteDecoderModule::Create(RemoteDecodeIn::UtilityProcess_Generic)); } #ifdef MOZ_WMF_MEDIA_ENGINE if (StaticPrefs::media_wmf_media_engine_enabled()) { - CreateAndStartupPDM( - 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()) { + if (!StartupPDM(WMFDecoderModule::Create())) { mFailureFlags += DecoderDoctorDiagnostics::Flags::WMFFailedToLoad; } } @@ -642,11 +643,11 @@ void PDMFactory::CreateContentPDMs() { #endif #ifdef MOZ_APPLEMEDIA - CreateAndStartupPDM(); + StartupPDM(AppleDecoderModule::Create()); #endif #ifdef MOZ_OMX if (StaticPrefs::media_omx_enabled()) { - CreateAndStartupPDM(); + StartupPDM(OmxDecoderModule::Create()); } #endif StartupPDM(FFVPXRuntimeLinker::CreateDecoder()); @@ -658,7 +659,8 @@ void PDMFactory::CreateContentPDMs() { } #endif - CreateAndStartupPDM(); + 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()) { + 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(); + StartupPDM(AppleDecoderModule::Create()); #endif #ifdef MOZ_OMX if (StaticPrefs::media_omx_enabled()) { - CreateAndStartupPDM(); + StartupPDM(OmxDecoderModule::Create()); } #endif StartupPDM(FFVPXRuntimeLinker::CreateDecoder()); @@ -712,7 +714,8 @@ void PDMFactory::CreateDefaultPDMs() { } #endif - CreateAndStartupPDM(); + StartupPDM(AgnosticDecoderModule::Create(), + StaticPrefs::media_prefer_non_ffvpx()); if (StaticPrefs::media_gmp_decoder_enabled() && !StartupPDM(GMPDecoderModule::Create(), diff --git a/dom/media/platforms/PDMFactory.h b/dom/media/platforms/PDMFactory.h index c56c11c50654..9a4d4ff6b915 100644 --- a/dom/media/platforms/PDMFactory.h +++ b/dom/media/platforms/PDMFactory.h @@ -79,11 +79,6 @@ class PDMFactory final { void CreateContentPDMs(); void CreateDefaultPDMs(); - template - bool CreateAndStartupPDM(ARGS&&... aArgs) { - return StartupPDM(DECODER_MODULE::Create(std::forward(aArgs)...)); - } - // Startup the provided PDM and add it to our list if successful. bool StartupPDM(already_AddRefed aPDM, bool aInsertAtBeginning = false); diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 55941405d8d7..244ad8017782 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -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)