UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FrameGrabber.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
9
10class SWindow;
11
79
81{
82 virtual ~IFramePayload() {}
83
88 virtual bool OnFrameReady_RenderThread(FColor* ColorBuffer, FIntPoint BufferSize, FIntPoint TargetSize) const { return true; }
89};
90
92
117
125{
126public:
136
139
140public:
141
144
147
150
153
156
157public:
158
161
164
165protected:
166
169
171 MOVIESCENECAPTURE_API void OnFrameReady(int32 SurfaceIndex, FColor* ColorBuffer, int32 Width, int32 Height);
172
173private:
174
177 FFrameGrabber& operator=(const FFrameGrabber&);
178
184 void* TargetWindowPtr;
185
187 FDelegateHandle OnBackBufferReadyToPresent;
188
190 TArray<FCapturedFrameData> CapturedFrames;
191
193 mutable FCriticalSection CapturedFramesMutex;
194
196 struct FResolveSurface
197 {
198 FResolveSurface(EPixelFormat InPixelFormat, FIntPoint BufferSize) : Surface(InPixelFormat, BufferSize) {}
199
200 FFramePayloadPtr Payload;
202 };
204
206 int32 CurrentFrameIndex;
207
209 int32 SlateRenderIndex;
210
212 FThreadSafeCounter OutstandingFrameCount;
213
215 TArray<FFramePayloadPtr> RenderThread_PendingFramePayloads;
216
217 int32 FrameGrabLatency;
218
220 enum class EFrameGrabberState
221 {
222 Inactive, Active, PendingShutdown
223 };
224 EFrameGrabberState State;
225
227 FIntPoint TargetSize;
228};
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::FPlatformRecursiveMutex FCriticalSection
Definition CriticalSection.h:53
TSharedPtr< IFramePayload, ESPMode::ThreadSafe > FFramePayloadPtr
Definition FrameGrabber.h:91
EPixelFormat
Definition PixelFormat.h:16
@ PF_B8G8R8A8
Definition PixelFormat.h:19
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition IDelegateInstance.h:14
Definition Event.h:21
Definition FrameGrabber.h:125
MOVIESCENECAPTURE_API void StartCapturingFrames()
Definition FrameGrabber.cpp:268
MOVIESCENECAPTURE_API ~FFrameGrabber()
Definition FrameGrabber.cpp:255
MOVIESCENECAPTURE_API bool IsCapturingFrames() const
Definition FrameGrabber.cpp:280
MOVIESCENECAPTURE_API void OnFrameReady(int32 SurfaceIndex, FColor *ColorBuffer, int32 Width, int32 Height)
Definition FrameGrabber.cpp:421
MOVIESCENECAPTURE_API void OnBackBufferReadyToPresentCallback(SWindow &SlateWindow, const FTextureRHIRef &BackBuffer)
Definition FrameGrabber.cpp:361
MOVIESCENECAPTURE_API void Shutdown()
Definition FrameGrabber.cpp:312
MOVIESCENECAPTURE_API void StopCapturingFrames()
Definition FrameGrabber.cpp:302
MOVIESCENECAPTURE_API bool HasOutstandingFrames() const
Definition FrameGrabber.cpp:328
MOVIESCENECAPTURE_API void CaptureThisFrame(FFramePayloadPtr Payload)
Definition FrameGrabber.cpp:285
MOVIESCENECAPTURE_API TArray< FCapturedFrameData > GetCapturedFrames()
Definition FrameGrabber.cpp:336
Definition ThreadSafeBool.h:17
Definition ThreadSafeCounter.h:14
Definition SWindow.h:243
Definition Array.h:670
Definition AndroidPlatformMisc.h:14
Definition SharedPointer.h:692
UE_FORCEINLINE_HINT ObjectType * Get() const
Definition SharedPointer.h:1065
Definition SharedPointer.h:153
Definition FrameGrabber.h:95
TArray< FColor > ColorBuffer
Definition FrameGrabber.h:105
FCapturedFrameData(FCapturedFrameData &&In)
Definition FrameGrabber.h:98
FIntPoint BufferSize
Definition FrameGrabber.h:108
FCapturedFrameData & operator=(FCapturedFrameData &&In)
Definition FrameGrabber.h:99
FFramePayloadPtr Payload
Definition FrameGrabber.h:111
T * GetPayload()
Definition FrameGrabber.h:102
FCapturedFrameData(FIntPoint InBufferSize, FFramePayloadPtr InPayload)
Definition FrameGrabber.h:96
Definition Color.h:486
Definition FrameGrabber.h:14
MOVIESCENECAPTURE_API void ResolveRenderTarget(FViewportSurfaceReader *RenderToReadback, const FTextureRHIRef &BackBuffer, TFunction< void(FColor *, int32, int32)> Callback)
Definition FrameGrabber.cpp:90
EPixelFormat PixelFormat
Definition FrameGrabber.h:72
FTextureRHIRef ReadbackTexture
Definition FrameGrabber.h:63
void SetWindowSize(FIntPoint InWindowSize)
Definition FrameGrabber.h:47
MOVIESCENECAPTURE_API ~FViewportSurfaceReader()
Definition FrameGrabber.cpp:40
MOVIESCENECAPTURE_API FIntPoint GetCurrentSize() const
FEvent * AvailableEvent
Definition FrameGrabber.h:60
bool bQueuedForCapture
Definition FrameGrabber.h:77
FIntPoint WindowSize
Definition FrameGrabber.h:69
bool WasEverQueued() const
Definition FrameGrabber.h:49
FThreadSafeBool bEnabled
Definition FrameGrabber.h:57
bool bIsEnabled
Definition FrameGrabber.h:75
MOVIESCENECAPTURE_API void BlockUntilAvailable()
Definition FrameGrabber.cpp:69
MOVIESCENECAPTURE_API void Reset()
Definition FrameGrabber.cpp:80
MOVIESCENECAPTURE_API void Initialize()
Definition FrameGrabber.cpp:47
FIntRect CaptureRect
Definition FrameGrabber.h:66
MOVIESCENECAPTURE_API void Resize(uint32 Width, uint32 Height)
Definition FrameGrabber.cpp:53
void SetCaptureRect(FIntRect InCaptureRect)
Definition FrameGrabber.h:44
Definition FrameGrabber.h:81
virtual ~IFramePayload()
Definition FrameGrabber.h:82
virtual bool OnFrameReady_RenderThread(FColor *ColorBuffer, FIntPoint BufferSize, FIntPoint TargetSize) const
Definition FrameGrabber.h:88
Definition IntPoint.h:25