summaryrefslogtreecommitdiffstats
path: root/dom/media/platforms/PDMFactory.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
commit59203c63bb777a3bacec32fb8830fba33540e809 (patch)
tree58298e711c0ff0575818c30485b44a2f21bf28a0 /dom/media/platforms/PDMFactory.cpp
parentAdding upstream version 126.0.1. (diff)
downloadfirefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz
firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/platforms/PDMFactory.cpp')
-rw-r--r--dom/media/platforms/PDMFactory.cpp62
1 files changed, 34 insertions, 28 deletions
diff --git a/dom/media/platforms/PDMFactory.cpp b/dom/media/platforms/PDMFactory.cpp
index 00f46385e2..f640ee4506 100644
--- a/dom/media/platforms/PDMFactory.cpp
+++ b/dom/media/platforms/PDMFactory.cpp
@@ -27,6 +27,7 @@
#include "mozilla/RemoteDecoderManagerChild.h"
#include "mozilla/RemoteDecoderModule.h"
#include "mozilla/SharedThreadPool.h"
+#include "mozilla/StaticMutex.h"
#include "mozilla/StaticPrefs_media.h"
#include "mozilla/SyncRunnable.h"
#include "mozilla/TaskQueue.h"
@@ -474,7 +475,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 +501,7 @@ void PDMFactory::CreatePDMs() {
void PDMFactory::CreateGpuPDMs() {
#ifdef XP_WIN
if (StaticPrefs::media_wmf_enabled()) {
- CreateAndStartupPDM<WMFDecoderModule>();
+ StartupPDM(WMFDecoderModule::Create());
}
#endif
}
@@ -529,12 +530,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 +547,8 @@ void PDMFactory::CreateRddPDMs() {
FFmpegRuntimeLinker::LinkStatusCode());
}
#endif
- CreateAndStartupPDM<AgnosticDecoderModule>();
+ StartupPDM(AgnosticDecoderModule::Create(),
+ StaticPrefs::media_prefer_non_ffvpx());
}
void PDMFactory::CreateUtilityPDMs() {
@@ -555,13 +557,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 +584,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 +598,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 +633,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 +644,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 +660,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 +684,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 +693,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 +715,8 @@ void PDMFactory::CreateDefaultPDMs() {
}
#endif
- CreateAndStartupPDM<AgnosticDecoderModule>();
+ StartupPDM(AgnosticDecoderModule::Create(),
+ StaticPrefs::media_prefer_non_ffvpx());
if (StaticPrefs::media_gmp_decoder_enabled() &&
!StartupPDM(GMPDecoderModule::Create(),
@@ -783,9 +787,11 @@ void PDMFactory::SetCDMProxy(CDMProxy* aProxy) {
mEMEPDM = MakeRefPtr<EMEDecoderModule>(aProxy, m);
}
+StaticMutex sSupportedMutex;
+
/* static */
media::MediaCodecsSupported PDMFactory::Supported(bool aForceRefresh) {
- MOZ_ASSERT(NS_IsMainThread());
+ StaticMutexAutoLock lock(sSupportedMutex);
static auto calculate = []() {
auto pdm = MakeRefPtr<PDMFactory>();