TASK 4 ship step 3: encoder + RTMP push — FFmpeg subprocess with probed H.264 picker, BGRA stdin feed, stderr health parsing, graceful stop — 122 tests passing, 0 warnings

This commit is contained in:
2026-08-12 20:32:24 -07:00
parent e494dce311
commit ba427e85e1
13 changed files with 891 additions and 62 deletions
+25
View File
@@ -0,0 +1,25 @@
using ytLive.Models;
namespace ytLive.Services.Encoder;
/// <summary>
/// The live encoder seam (TASK 4 ship step 3): start an FFmpeg subprocess that
/// encodes raw BGRA frames from stdin and pushes FLV to an RTMP ingestion URL,
/// raising parsed health stats from stderr. The frame producer (compositor →
/// capture managers, TASK 4 ship step 5) feeds <see cref="SubmitFrameAsync"/> at
/// capture rate; this service serializes writes, parses progress, and tears the
/// process down gracefully. Constructor-injected <see cref="IFfmpegLocator"/> +
/// process factory keep it hermetic (tests fake both).
/// </summary>
public interface IFfmpegEncoder : IDisposable
{
/// <summary>Fires on each parsed ffmpeg <c>-stats</c> progress line (~2 Hz).</summary>
event EventHandler<StreamHealth>? HealthUpdated;
/// <summary>Fires when the subprocess dies unexpectedly (non-zero exit while live).</summary>
event EventHandler<string>? ProcessFailed;
Task StartAsync(EncoderOptions options, CancellationToken cancellationToken = default);
Task SubmitFrameAsync(VideoFrame frame, CancellationToken cancellationToken = default);
Task StopAsync(CancellationToken cancellationToken = default);
}