#pragma once #include "screencast/capture/capture.h" #include "screencast/codec/error.h" #include #include #include #include namespace sc { struct EncodedFrame { uint64_t capture_timestamp_ns = 0; uint32_t rtp_timestamp = 0; bool is_keyframe = false; std::vector data; // Annex-B H.264 NAL units }; struct EncoderConfig { std::string codec_name = "h264"; int width = 0; int height = 0; int frame_rate_num = 30; int frame_rate_den = 1; int bitrate_kbps = 4000; bool hardware_accel = false; }; class Encoder { public: virtual ~Encoder() = default; // Encode one captured frame. Returns an empty vector if the encoder emits // no packet for this frame. virtual CodecResult> encode(const CapturedFrame& frame) = 0; // Flush the encoder and return any remaining packets. virtual CodecResult> flush() = 0; // Force the next output frame to be a keyframe. virtual void request_keyframe() = 0; // Codec-specific parameters required by a decoder (SPS/PPS for H.264). virtual std::vector get_extradata() const = 0; }; class EncoderFactory { public: static CodecResult> create(const EncoderConfig& config); }; } // namespace sc