namespace ytLive.Services.Encoder;

/// <summary>
/// Everything the FFmpeg subprocess encoder needs for one go-live (TASK 4 ship
/// step 3). <see cref="RtmpUrl"/> is the FULL ingestion URL — the reusable
/// stream's ingest address plus its stream key (<c>rtmp://a.rtmp.youtube.com/live2/&lt;key&gt;</c>).
/// Resolution/FPS/bitrate come from the active quality tier; audio (TASK 9)
/// streams from the mixer through the named pipe <see cref="AudioPipeName"/>.
/// </summary>
public sealed class EncoderOptions
{
    /// <summary>The audio pipe the mixer streams into; the args reference the
    /// same name for ffmpeg's <c>-i</c>.</summary>
    public const string DefaultAudioPipeName = "ytllive_audio";

    public string RtmpUrl { get; init; } = string.Empty;
    public int Width { get; init; } = 1920;
    public int Height { get; init; } = 1080;
    public int Fps { get; init; } = 60;
    public int BitrateKbps { get; init; } = 8000;

    /// <summary>H.264 encoder name for <c>-c:v</c>; the encoder probes and prefers
    /// nvenc → qsv → amf → libopenh264 when not forced.</summary>
    public string? VideoEncoder { get; init; }

    public int AudioSampleRate { get; init; } = 48000;
    public int AudioChannels { get; init; } = 2;

    /// <summary>Name of the mixer's audio pipe (default <see cref="DefaultAudioPipeName"/>).</summary>
    public string AudioPipeName { get; init; } = DefaultAudioPipeName;

    /// <summary>GOP in frames = Fps × 4s — the YouTube keyframe ≤ 4s compliance bound.</summary>
    public int GopSize => Fps * 4;
}
