#pragma once #include "screencast/codec/encoder.h" #include "screencast/codec/error.h" #include #include #include #include namespace sc { // Decoded video frame in YUV420P planar format (the native decoder output, // passed to the renderer without any colorspace conversion). struct DecodedFrame { int width = 0; int height = 0; uint64_t capture_timestamp_ns = 0; // YUV420P planes; each row is `stride` bytes wide and may be padded // beyond the picture width. std::vector plane_y; std::vector plane_u; std::vector plane_v; int stride_y = 0; int stride_u = 0; int stride_v = 0; }; struct DecoderConfig { std::string codec_name = "h264"; int width = 0; int height = 0; std::vector extradata; // SPS/PPS for H.264 // Probe a hardware decoder (v4l2 mem2mem) first and fall back to the // software decoder automatically. Disable with --swdecode. bool hardware_accel = true; }; class Decoder { public: virtual ~Decoder() = default; // Feed one encoded frame. Returns decoded frames when available. virtual CodecResult> decode(const EncodedFrame& frame) = 0; }; class DecoderFactory { public: static CodecResult> create(const DecoderConfig& config); }; } // namespace sc