summaryrefslogtreecommitdiffstats
path: root/dom/media/ipc/RemoteDecodeUtils.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/media/ipc/RemoteDecodeUtils.cpp
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/ipc/RemoteDecodeUtils.cpp')
-rw-r--r--dom/media/ipc/RemoteDecodeUtils.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/dom/media/ipc/RemoteDecodeUtils.cpp b/dom/media/ipc/RemoteDecodeUtils.cpp
new file mode 100644
index 0000000000..15036a0370
--- /dev/null
+++ b/dom/media/ipc/RemoteDecodeUtils.cpp
@@ -0,0 +1,103 @@
+/* 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 "RemoteDecodeUtils.h"
+#include "mozilla/ipc/UtilityProcessChild.h"
+
+namespace mozilla {
+
+using SandboxingKind = ipc::SandboxingKind;
+
+SandboxingKind GetCurrentSandboxingKind() {
+ MOZ_ASSERT(XRE_IsUtilityProcess());
+ return ipc::UtilityProcessChild::GetSingleton()->mSandbox;
+}
+
+SandboxingKind GetSandboxingKindFromLocation(RemoteDecodeIn aLocation) {
+ switch (aLocation) {
+ case RemoteDecodeIn::UtilityProcess_Generic:
+ return SandboxingKind::GENERIC_UTILITY;
+#ifdef MOZ_APPLEMEDIA
+ case RemoteDecodeIn::UtilityProcess_AppleMedia:
+ return SandboxingKind::UTILITY_AUDIO_DECODING_APPLE_MEDIA;
+ break;
+#endif
+#ifdef XP_WIN
+ case RemoteDecodeIn::UtilityProcess_WMF:
+ return SandboxingKind::UTILITY_AUDIO_DECODING_WMF;
+#endif
+#ifdef MOZ_WMF_MEDIA_ENGINE
+ case RemoteDecodeIn::UtilityProcess_MFMediaEngineCDM:
+ return SandboxingKind::MF_MEDIA_ENGINE_CDM;
+#endif
+ default:
+ MOZ_ASSERT_UNREACHABLE("Unsupported RemoteDecodeIn");
+ return SandboxingKind::COUNT;
+ }
+}
+
+RemoteDecodeIn GetRemoteDecodeInFromKind(SandboxingKind aKind) {
+ switch (aKind) {
+ case SandboxingKind::GENERIC_UTILITY:
+ return RemoteDecodeIn::UtilityProcess_Generic;
+#ifdef MOZ_APPLEMEDIA
+ case SandboxingKind::UTILITY_AUDIO_DECODING_APPLE_MEDIA:
+ return RemoteDecodeIn::UtilityProcess_AppleMedia;
+#endif
+#ifdef XP_WIN
+ case SandboxingKind::UTILITY_AUDIO_DECODING_WMF:
+ return RemoteDecodeIn::UtilityProcess_WMF;
+#endif
+#ifdef MOZ_WMF_MEDIA_ENGINE
+ case SandboxingKind::MF_MEDIA_ENGINE_CDM:
+ return RemoteDecodeIn::UtilityProcess_MFMediaEngineCDM;
+#endif
+ default:
+ MOZ_ASSERT_UNREACHABLE("Unsupported SandboxingKind");
+ return RemoteDecodeIn::Unspecified;
+ }
+}
+
+RemoteDecodeIn GetRemoteDecodeInFromVideoBridgeSource(
+ layers::VideoBridgeSource aSource) {
+ switch (aSource) {
+ case layers::VideoBridgeSource::RddProcess:
+ return RemoteDecodeIn::RddProcess;
+ case layers::VideoBridgeSource::GpuProcess:
+ return RemoteDecodeIn::GpuProcess;
+ case layers::VideoBridgeSource::MFMediaEngineCDMProcess:
+ return RemoteDecodeIn::UtilityProcess_MFMediaEngineCDM;
+ default:
+ MOZ_ASSERT_UNREACHABLE("Unsupported VideoBridgeSource");
+ return RemoteDecodeIn::Unspecified;
+ }
+}
+
+const char* RemoteDecodeInToStr(RemoteDecodeIn aLocation) {
+ switch (aLocation) {
+ case RemoteDecodeIn::RddProcess:
+ return "RDD";
+ case RemoteDecodeIn::GpuProcess:
+ return "GPU";
+ case RemoteDecodeIn::UtilityProcess_Generic:
+ return "Utility Generic";
+#ifdef MOZ_APPLEMEDIA
+ case RemoteDecodeIn::UtilityProcess_AppleMedia:
+ return "Utility AppleMedia";
+#endif
+#ifdef XP_WIN
+ case RemoteDecodeIn::UtilityProcess_WMF:
+ return "Utility WMF";
+#endif
+#ifdef MOZ_WMF_MEDIA_ENGINE
+ case RemoteDecodeIn::UtilityProcess_MFMediaEngineCDM:
+ return "Utility MF Media Engine CDM";
+#endif
+ default:
+ MOZ_ASSERT_UNREACHABLE("Unsupported RemoteDecodeIn");
+ return "Unknown";
+ }
+}
+
+} // namespace mozilla