fix(history): file each session under the real encoder, not "unknown"
FfmpegEncoder resolved the encoder name into its OWN StreamHealth instance, while the view model read CurrentHealth — a different object. So every recorded session was filed as "unknown", and the rate history's encoder key (evidence about NVENC says nothing about QSV) had nothing to key on. The name now travels on the encoder interface and the pump forwards it: IFfmpegEncoder.VideoEncoderName -> FramePump.EncoderName. Caught while adding it: reading _framePump.EncoderName from RefreshRateProposal throws, because that call runs at MainViewModel ctor line 354 and the pump is built at line 468. Eight tests failed with the same NullReferenceException, which took a while to see because the harness's test output is buffered — the first honest look at per-test logging named it in one line. Guarded; the history falls back to the last session's encoder for that tier, which is exactly the pre-first-session case the fallback already existed for. Tests: FramePumpTests gains the encoder-name assertion (null before start, h264_nvenc after), and the three fake encoders implement the new member. 675 pass, 0 warnings.
This commit is contained in:
@@ -580,6 +580,8 @@ public sealed class BrandFlashOutputTests
|
||||
/// production encoder uses, so the assertion is about the bytes on the wire.</summary>
|
||||
private sealed class CapturingEncoder : IFfmpegEncoder
|
||||
{
|
||||
public string? VideoEncoderName => "h264_nvenc";
|
||||
|
||||
public readonly List<VideoFrame> Frames = new();
|
||||
public readonly TaskCompletionSource FirstFrame =
|
||||
new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
|
||||
@@ -86,6 +86,8 @@ public sealed class EncoderRestartTests
|
||||
|
||||
private sealed class CapturingEncoder : IFfmpegEncoder
|
||||
{
|
||||
public string? VideoEncoderName => "h264_nvenc";
|
||||
|
||||
public readonly TaskCompletionSource<bool> FirstFrame = new(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
public event Action<EncoderOptions>? Started;
|
||||
public Action? Stopped { get; set; }
|
||||
|
||||
@@ -22,6 +22,8 @@ public class FramePumpTests
|
||||
{
|
||||
private sealed class FakeEncoder : IFfmpegEncoder
|
||||
{
|
||||
public string? VideoEncoderName => "h264_nvenc";
|
||||
|
||||
public readonly List<VideoFrame> Frames = new();
|
||||
public readonly List<byte[]> Backings = new();
|
||||
public int StartCount;
|
||||
@@ -133,6 +135,22 @@ public class FramePumpTests
|
||||
}
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task The_pump_reports_which_encoder_the_session_runs()
|
||||
{
|
||||
// The rate history is keyed by encoder: evidence recorded against NVENC must not be applied to a
|
||||
// machine that later runs QSV. Before this the name went to a StreamHealth copy nobody read, so
|
||||
// every filed session said "unknown".
|
||||
var encoder = new FakeEncoder();
|
||||
using var pump = NewPump(encoder);
|
||||
|
||||
Assert.Null(pump.EncoderName); // nothing has started yet
|
||||
await pump.StartAsync();
|
||||
Assert.Equal("h264_nvenc", pump.EncoderName);
|
||||
|
||||
await pump.StopAsync();
|
||||
}
|
||||
|
||||
/// <summary>The ONE integration test for TASK 5: the real service (hermetic
|
||||
/// HTTP) returns the reusable stream's RTMP URL, the provider seam hands it
|
||||
/// to the pump, and the pump starts the encoder with that exact URL — the
|
||||
|
||||
Reference in New Issue
Block a user