UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
WmfPrivate.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Logging/LogMacros.h"
6#include "CoreMinimal.h"
7
8#define WMFMEDIA_SUPPORTED_PLATFORM (PLATFORM_WINDOWS && !UE_SERVER)
9
11
14 //#include <d3d11.h>
15 #include <mftransform.h>
16 #include <mfapi.h>
17 #include <mferror.h>
18 #include <mfidl.h>
19 #include <mfreadwrite.h>
20 #include <Codecapi.h>
21 #include <shlwapi.h>
23
24inline const FString GetComErrorDescription(HRESULT Res)
25{
26 const uint32 BufSize = 4096;
27 WIDECHAR buffer[4096];
29 nullptr,
30 Res,
32 buffer,
33 sizeof(buffer) / sizeof(*buffer),
34 nullptr))
35 {
36 return buffer;
37 }
38 else
39 {
40 return TEXT("[cannot find error description]");
41 }
42}
43
45
46// macro to deal with COM calls inside a function that returns `false` on error
47#define CHECK_HR(COM_call)\
48 {\
49 HRESULT Res = COM_call;\
50 if (FAILED(Res))\
51 {\
52 UE_LOG(WMF, Error, TEXT("`" #COM_call "` failed: 0x%X - %s"), Res, *GetComErrorDescription(Res));\
53 return false;\
54 }\
55 }
56
57// macro to deal with COM calls inside COM method (that returns HRESULT)
58#define CHECK_HR_COM(COM_call)\
59 {\
60 HRESULT Res = COM_call;\
61 if (FAILED(Res))\
62 {\
63 UE_LOG(WMF, Error, TEXT("`" #COM_call "` failed: 0x%X - %s"), Res, *GetComErrorDescription(Res));\
64 return Res;\
65 }\
66 }
67
68// macro to deal with COM calls inside COM method (that simply returns)
69#define CHECK_HR_VOID(COM_call)\
70 {\
71 HRESULT Res = COM_call;\
72 if (FAILED(Res))\
73 {\
74 UE_LOG(WMF, Error, TEXT("`" #COM_call "` failed: 0x%X - %s"), Res, *GetComErrorDescription(Res));\
75 return;\
76 }\
77 }
78
79// macro to deal with COM calls inside a function and return `{}` on error
80// This has the advantage of being able to return any type that can be initialized with `{}`
81#define CHECK_HR_DEFAULT(COM_call)\
82 {\
83 HRESULT Res = COM_call;\
84 if (FAILED(Res))\
85 {\
86 UE_LOG(WMF, Error, TEXT("`" #COM_call "` failed: 0x%X - %s"), Res, *GetComErrorDescription(Res));\
87 return {};\
88 }\
89 }
90
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::WIDECHAR WIDECHAR
A wide character. Normally a signed type.
Definition Platform.h:1133
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define THIRD_PARTY_INCLUDES_START
Definition GenericPlatformCompilerPreSetup.h:63
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
THIRD_PARTY_INCLUDES_START THIRD_PARTY_INCLUDES_END const FString GetComErrorDescription(HRESULT Res)
Definition WmfPrivate.h:24
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Voronoi.cpp:10