UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
IMFSampleWrapper.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "HAL/Platform.h"
6#include "MediaPacket.h"
8#include "VideoCommon.h"
9
10#if PLATFORM_WINDOWS
11
12namespace AVEncoder
13{
14
15//
16// Wrapper for IMFSample, to make it easier to report errors
17//
18class UE_DEPRECATED(5.4, "AVEncoder has been deprecated. Please use the AVCodecs plugin family instead.") FIMFSampleWrapper
19{
20public:
22 FIMFSampleWrapper(EPacketType InMediaType = EPacketType::Invalid, IMFSample* InSample = nullptr)
25 {
26 }
28
29 const IMFSample* GetSample() const
30 {
31 return Sample;
32 }
33
34 IMFSample* GetSample()
35 {
36 return Sample;
37 }
38
40
41 AVENCODER_API FTimespan GetTime() const;
42
43 AVENCODER_API void SetTime(FTimespan Time);
44
45 AVENCODER_API FTimespan GetDuration() const;
46
47 AVENCODER_API void SetDuration(FTimespan Duration);
48
49 AVENCODER_API bool IsVideoKeyFrame() const;
50
51 AVENCODER_API int GetBufferCount() const;
52
63 template<typename T>
64 bool IterateBuffers(T&& Func)
65 {
66 int BufferCount = GetBufferCount();
67 for (int Idx = 0; Idx < BufferCount; ++Idx)
68 {
70 verify(SUCCEEDED(Sample->GetBufferByIndex(0, MediaBuffer.GetInitReference())));
71
72 BYTE* SrcData = nullptr;
73 DWORD MaxLength = 0;
74 DWORD CurrentLength = 0;
75 verify(SUCCEEDED(MediaBuffer->Lock(&SrcData, &MaxLength, &CurrentLength)));
76 bool res = Func(Idx, TArrayView<uint8>(SrcData, CurrentLength));
77 verify(SUCCEEDED(MediaBuffer->Unlock()));
78 if (!res)
79 {
80 return false;
81 }
82 }
83 return true;
84 }
85
86 bool IsValid() const
87 {
88 return Sample.IsValid();
89 }
90
91 void Reset()
92 {
93 Sample = nullptr;
94 }
95
96 AVENCODER_API FIMFSampleWrapper Clone() const;
97
98private:
103};
104
105}
106
107#endif // PLATFORM_WINDOWS
108
#define verify(expr)
Definition AssertionMacros.h:319
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
Definition ArrayView.h:139
Definition RefCounting.h:454
unsigned char BYTE
Definition lz4.cpp:305
Definition AudioEncoder.cpp:7
void Sample(float *Dst, float X, float Y, float Z)
Definition FieldSystemNoiseAlgo.cpp:59
@ MaxLength
[PropertyMetadata] Used for FString and FText properties. Indicates the maximum length of the value t...
Definition ObjectMacros.h:1449
unsigned long DWORD
Definition MinimalWindowsApi.h:67
Definition Timespan.h:76