// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "IPixelStreaming2Stats.h" #include "Video/Decoders/Configs/VideoDecoderConfigAV1.h" #include "Video/Decoders/Configs/VideoDecoderConfigH264.h" #include "Video/Decoders/Configs/VideoDecoderConfigVP8.h" #include "Video/Decoders/Configs/VideoDecoderConfigVP9.h" #include "Video/Resources/VideoResourceCPU.h" #include "Video/Resources/VideoResourceRHI.h" #include "Video/VideoDecoder.h" #include "epic_rtc/core/video/video_decoder.h" #include "epic_rtc_helper/memory/ref_count_impl_helper.h" #include #include namespace UE::PixelStreaming2 { template TVideoResource> class TEpicRtcVideoDecoder : public EpicRtcVideoDecoderInterface { public: TEpicRtcVideoDecoder(EpicRtcVideoCodecInfoInterface* CodecInfo); // Begin EpicRtcVideoDecoderInterface [[nodiscard]] virtual EpicRtcStringView GetName() const override; virtual EpicRtcVideoDecoderConfig GetConfig() const override; virtual EpicRtcMediaResult SetConfig(const EpicRtcVideoDecoderConfig& VideoDecoderConfig) override; virtual EpicRtcMediaResult Decode(const EpicRtcEncodedVideoFrame& Frame) override; virtual void RegisterCallback(EpicRtcVideoDecoderCallbackInterface* Callback) override; virtual void Reset() override; // End EpicRtcVideoDecoderInterface private: TSharedPtr> Decoder; TUniquePtr InitialVideoConfig; EpicRtcVideoDecoderConfig DecoderConfig; TRefCountPtr VideoDecoderCallback; TRefCountPtr CodecInfo; uint16_t FrameCount; // clang-format off using DecoderResourceType = typename std::conditional, FResolvableVideoResourceRHI, typename std::conditional, FResolvableVideoResourceCPU, // We only support RHI and CPU resources so if we create one that isn't this type it will error (on purpose) void>::type>::type; DecoderResourceType DecoderResource; // clang-format on private: bool LateInitDecoder(); public: // Begin EpicRtcRefCountInterface EPICRTC_REFCOUNT_INTERFACE_IN_PLACE // End EpicRtcRefCountInterface }; } // namespace UE::PixelStreaming2