// Copyright Epic Games, Inc. All Rights Reserved. #include "EpicRtcVideoBufferMultiFormat.h" namespace UE::PixelStreaming2 { FEpicRtcVideoBufferMultiFormatBase::FEpicRtcVideoBufferMultiFormatBase(TSharedPtr InFrameCapturer) : FrameCapturer(InFrameCapturer) { } FEpicRtcVideoBufferMultiFormatLayered::FEpicRtcVideoBufferMultiFormatLayered(TSharedPtr InFrameCapturer, FIntPoint SourceResolution) : FEpicRtcVideoBufferMultiFormatBase(InFrameCapturer) , SourceResolution(SourceResolution) { } int FEpicRtcVideoBufferMultiFormatLayered::GetWidth() { return SourceResolution.X; } int FEpicRtcVideoBufferMultiFormatLayered::GetHeight() { return SourceResolution.Y; } TRefCountPtr FEpicRtcVideoBufferMultiFormatLayered::GetLayer(FIntPoint TargetResolution) const { return new FEpicRtcVideoBufferMultiFormat(FrameCapturer, TargetResolution); } FEpicRtcVideoBufferMultiFormat::FEpicRtcVideoBufferMultiFormat(TSharedPtr InFrameCapturer, FIntPoint TargetResolution) : FEpicRtcVideoBufferMultiFormatBase(InFrameCapturer) , Resolution(TargetResolution) { } int FEpicRtcVideoBufferMultiFormat::GetWidth() { return Resolution.X; } int FEpicRtcVideoBufferMultiFormat::GetHeight() { return Resolution.Y; } IPixelCaptureOutputFrame* FEpicRtcVideoBufferMultiFormat::RequestFormat(int32 Format) const { // ensure this frame buffer will always refer to the same frame if (TSharedPtr* CachedFrame = CachedFormat.Find(Format)) { return CachedFrame->Get(); } if (!FrameCapturer) { return nullptr; } constexpr uint32 WaitTimeMS = 500; TSharedPtr Frame = FrameCapturer->WaitForFormat(Format, Resolution, WaitTimeMS); CachedFormat.Add(Format, Frame); return Frame.Get(); } } // namespace UE::PixelStreaming2