summaryrefslogtreecommitdiffstats
path: root/dom/media/ipc/MFMediaEngineUtils.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /dom/media/ipc/MFMediaEngineUtils.h
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/media/ipc/MFMediaEngineUtils.h')
-rw-r--r--dom/media/ipc/MFMediaEngineUtils.h88
1 files changed, 88 insertions, 0 deletions
diff --git a/dom/media/ipc/MFMediaEngineUtils.h b/dom/media/ipc/MFMediaEngineUtils.h
new file mode 100644
index 0000000000..5054fbb5c4
--- /dev/null
+++ b/dom/media/ipc/MFMediaEngineUtils.h
@@ -0,0 +1,88 @@
+/* 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/. */
+
+#ifndef DOM_MEDIA_IPC_MFMEDIAENGINEUTILS_H_
+#define DOM_MEDIA_IPC_MFMEDIAENGINEUTILS_H_
+
+#include "MFMediaEngineExtra.h"
+#include "ipc/EnumSerializer.h"
+#include "mozilla/Logging.h"
+#include "mozilla/ProfilerMarkerTypes.h"
+
+namespace mozilla {
+
+inline LazyLogModule gMFMediaEngineLog{"MFMediaEngine"};
+
+// https://docs.microsoft.com/en-us/windows/win32/api/mfmediaengine/ne-mfmediaengine-mf_media_engine_event
+using MFMediaEngineEvent = MF_MEDIA_ENGINE_EVENT;
+
+// https://docs.microsoft.com/en-us/windows/win32/api/mfmediaengine/ne-mfmediaengine-mf_media_engine_err
+using MFMediaEngineError = MF_MEDIA_ENGINE_ERR;
+
+#define LOG_AND_WARNING(msg, ...) \
+ do { \
+ NS_WARNING(nsPrintfCString(msg, rv).get()); \
+ MOZ_LOG(gMFMediaEngineLog, LogLevel::Debug, \
+ ("%s:%d, " msg, __FILE__, __LINE__, ##__VA_ARGS__)); \
+ } while (false)
+
+#ifndef RETURN_IF_FAILED
+# define RETURN_IF_FAILED(x) \
+ do { \
+ HRESULT rv = x; \
+ if (MOZ_UNLIKELY(FAILED(rv))) { \
+ LOG_AND_WARNING("(" #x ") failed, rv=%lx", rv); \
+ return rv; \
+ } \
+ } while (false)
+#endif
+
+#ifndef RETURN_VOID_IF_FAILED
+# define RETURN_VOID_IF_FAILED(x) \
+ do { \
+ HRESULT rv = x; \
+ if (MOZ_UNLIKELY(FAILED(rv))) { \
+ LOG_AND_WARNING("(" #x ") failed, rv=%lx", rv); \
+ return; \
+ } \
+ } while (false)
+#endif
+
+#define ENGINE_MARKER(markerName) \
+ PROFILER_MARKER(markerName, MEDIA_PLAYBACK, {}, MediaEngineMarker, Id())
+
+#define ENGINE_MARKER_TEXT(markerName, text) \
+ PROFILER_MARKER(markerName, MEDIA_PLAYBACK, {}, MediaEngineTextMarker, Id(), \
+ text)
+
+const char* MediaEventTypeToStr(MediaEventType aType);
+const char* MediaEngineEventToStr(MF_MEDIA_ENGINE_EVENT aEvent);
+const char* MFMediaEngineErrorToStr(MFMediaEngineError aError);
+const char* GUIDToStr(GUID aGUID);
+const char* MFVideoRotationFormatToStr(MFVideoRotationFormat aFormat);
+const char* MFVideoTransferFunctionToStr(MFVideoTransferFunction aFunc);
+const char* MFVideoPrimariesToStr(MFVideoPrimaries aPrimaries);
+
+} // namespace mozilla
+
+namespace IPC {
+
+template <>
+struct ParamTraits<mozilla::MFMediaEngineError>
+ : public ContiguousEnumSerializerInclusive<
+ mozilla::MFMediaEngineError,
+ mozilla::MFMediaEngineError::MF_MEDIA_ENGINE_ERR_ABORTED,
+ mozilla::MFMediaEngineError::MF_MEDIA_ENGINE_ERR_ENCRYPTED> {};
+
+template <>
+struct ParamTraits<mozilla::MFMediaEngineEvent>
+ : public ContiguousEnumSerializerInclusive<
+ mozilla::MFMediaEngineEvent,
+ mozilla::MFMediaEngineEvent::MF_MEDIA_ENGINE_EVENT_LOADSTART,
+ mozilla::MFMediaEngineEvent::
+ MF_MEDIA_ENGINE_EVENT_AUDIOENDPOINTCHANGE> {};
+
+} // namespace IPC
+
+#endif // DOM_MEDIA_IPC_MFMEDIAENGINECHILD_H_