// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "HAL/Platform.h" #include "MediaSamples.h" #include "IElectraTextureSample.h" #include "IMediaTextureSampleConverter.h" #import #import class FElectraMediaTexConvApple; class ELECTRASAMPLES_API FElectraTextureSample final : public IElectraTextureSampleBase , public IMediaTextureSampleConverter { public: FElectraTextureSample(const TWeakPtr& InTexConv); virtual ~FElectraTextureSample(); bool FinishInitialization() override; //~ IMediaTextureSample interface const void* GetBuffer() override; EMediaTextureSampleFormat GetFormat() const override; uint32 GetStride() const override; FRHITexture* GetTexture() const override; IMediaTextureSampleConverter* GetMediaTextureSampleConverter() override; void ShutdownPoolable() override; TSharedPtr, ESPMode::ThreadSafe> Buffer; CVImageBufferRef ImageBufferRef = nullptr; EMediaTextureSampleFormat SampleFormat = EMediaTextureSampleFormat::Undefined; uint32 Stride = 0; TWeakPtr TexConv; uint32 GetConverterInfoFlags() const override; bool Convert(FRHICommandListImmediate& RHICmdList, FTextureRHIRef& InDstTexture, const FConversionHints& Hints) override; }; using FElectraTextureSamplePtr = TSharedPtr; using FElectraTextureSampleRef = TSharedRef; class ELECTRASAMPLES_API FElectraMediaTexConvApple { public: FElectraMediaTexConvApple(); ~FElectraMediaTexConvApple(); #if WITH_ENGINE void ConvertTexture(FTextureRHIRef& InDstTexture, CVImageBufferRef InImageBufferRef, bool bFullRange, EMediaTextureSampleFormat Format, const FMatrix44f& YUVMtx, const UE::Color::FColorSpace& SourceColorSpace, UE::Color::EEncoding EncodingType, float NormalizationFactor); UE_DEPRECATED(5.5, "This ConvertTexture function is deprecated, please use the version with FColorSpace instead.") void ConvertTexture(FTextureRHIRef& InDstTexture, CVImageBufferRef InImageBufferRef, bool bFullRange, EMediaTextureSampleFormat Format, const FMatrix44f& YUVMtx, const FMatrix44d& GamutToXYZMtx, UE::Color::EEncoding EncodingType, float NormalizationFactor) { } #endif private: #if WITH_ENGINE /** The Metal texture cache for unbuffered texture uploads. */ CVMetalTextureCacheRef MetalTextureCache; #endif }; class ELECTRASAMPLES_API FElectraTextureSamplePool : public TMediaObjectPool { using TextureSample = FElectraTextureSample; public: FElectraTextureSamplePool() : TMediaObjectPool(this) , TexConv(new FElectraMediaTexConvApple()) {} TextureSample *Alloc() const { return new TextureSample(TexConv); } private: TSharedPtr TexConv; };