A dead encoder used to run the whole stop path, so a one-second blip ended the broadcast. Now a dropped push is relaunched against the same ingest while the broadcast is still alive. - `Services/StreamRetryPolicy.cs` — immediate, +1 s, +2 s, +3 s. Minimum waits on purpose (creator ruling): YouTube's grace is short, so every second not pushing is grace spent. - `Services/StreamRecovery.cs` — the loop, with the audio pipe recreated before every attempt (its server is single-instance and unusable after the old client dies, so a naive relaunch fails on a missing input). After a push comes up it asks the API whether the broadcast survived: "complete" ends recovery as `BroadcastComplete` instead of showing a live sign over a dead stream; an API hiccup counts as recovered rather than ending a healthy session. - `FramePump.EncoderFailed` — a dead push is recoverable; a compositor fault still goes through `Failed` and ends the session, because retrying it would loop. - `MainViewModel.Recovery.cs` — wires the steps, reports each episode into the left panel alert stack (one row per episode, updated in place, log range painted), and cancels on Stop. - Alert stack polish: a rule and a gap now separate the stack from the scene layers (they read as one list before), and the licence indicator uses the creator's wording — `STEAM ID NOT PRESENT` / `Steam ID Limit: 30fps` / `Click for More Info`, becoming `STEAM ID PRESENT` / `60fps` with a close control once owned. Tests: `StreamRecoveryTests` (schedule, recover on attempt 2 with the pipe restarted each time, complete-broadcast honesty, unknown liveness, give-up, cancel, audio-restart fault), `FramePumpTests` now pin that process death raises `EncoderFailed` and not `Failed`. FAST gate: 538 passed (one documented pre-existing audio failure), 0 warnings.
39 lines
1.5 KiB
C#
39 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ytLive.Services;
|
|
|
|
/// <summary>
|
|
/// TASK 32·1: how many times to relaunch the push, and how long to wait between tries.
|
|
/// <para><b>Minimum waits, deliberately</b> (creator ruling 2026-11-05): YouTube is not generous about
|
|
/// holding a broadcast whose ingest has gone quiet, so every second spent not pushing is grace spent.
|
|
/// The first attempt is immediate — there is nothing to wait for when the socket has just died.</para>
|
|
/// <para>Pure so the schedule is asserted without waiting on it.</para>
|
|
/// </summary>
|
|
public sealed class StreamRetryPolicy
|
|
{
|
|
/// <summary>Immediate, then +1 s, +2 s, +3 s — four attempts inside about six seconds.</summary>
|
|
public static readonly StreamRetryPolicy Default = new(new[]
|
|
{
|
|
TimeSpan.Zero,
|
|
TimeSpan.FromSeconds(1),
|
|
TimeSpan.FromSeconds(2),
|
|
TimeSpan.FromSeconds(3),
|
|
});
|
|
|
|
public IReadOnlyList<TimeSpan> Waits { get; }
|
|
|
|
public StreamRetryPolicy(IReadOnlyList<TimeSpan> waits)
|
|
{
|
|
if (waits == null || waits.Count == 0)
|
|
throw new ArgumentException("A retry policy needs at least one attempt.", nameof(waits));
|
|
Waits = waits;
|
|
}
|
|
|
|
public int Attempts => Waits.Count;
|
|
|
|
/// <summary>The wait BEFORE <paramref name="attemptIndex"/> (0-based).</summary>
|
|
public TimeSpan WaitBefore(int attemptIndex)
|
|
=> attemptIndex < 0 || attemptIndex >= Waits.Count ? TimeSpan.Zero : Waits[attemptIndex];
|
|
}
|