forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
/
MFMediaEngineUtils.h
80 lines (64 loc) · 3.13 KB
/
MFMediaEngineUtils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/* 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"
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
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_