Preserve native broadcast video and add patient shared stream startup

This commit is contained in:
2026-10-25 16:59:56 +01:00
parent bd7395f045
commit 11a34a5195
27 changed files with 708 additions and 139 deletions
+6 -5
View File
@@ -23,13 +23,14 @@ public sealed class LiveStreamRelay : IDisposable
private readonly object gate = new();
private int opened;
private readonly TimeSpan idleGrace;
private readonly TimeSpan startupTimeout;
private readonly TimeSpan readTimeout;
public LiveStreamRelay(IServerApplicationHost host) : this(new HttpClient(new SocketsHttpHandler { ConnectTimeout = TimeSpan.FromSeconds(3), AllowAutoRedirect = false }), host.HttpPort) { }
private Func<TimeSpan> startupBudget, readBudget;
private TimeSpan startupTimeout => startupBudget();
private TimeSpan readTimeout => readBudget();
public LiveStreamRelay(IServerApplicationHost host) : this(new HttpClient(new SocketsHttpHandler { ConnectTimeout = TimeSpan.FromSeconds(3), AllowAutoRedirect = false }), host.HttpPort) { startupBudget = () => TimeSpan.FromSeconds(StartupBudget.Seconds); readBudget = () => TimeSpan.FromSeconds(StartupBudget.StallSeconds); }
public LiveStreamRelay(HttpClient client, int port, TimeSpan? idleGrace = null, TimeSpan? startupTimeout = null, TimeSpan? readTimeout = null)
{
this.startupTimeout = startupTimeout ?? TimeSpan.FromSeconds(20);
this.readTimeout = readTimeout ?? TimeSpan.FromSeconds(8);
startupBudget = () => startupTimeout ?? TimeSpan.FromSeconds(20);
readBudget = () => readTimeout ?? TimeSpan.FromSeconds(8);
if (this.startupTimeout <= TimeSpan.Zero) throw new ArgumentOutOfRangeException(nameof(startupTimeout));
if (this.readTimeout <= TimeSpan.Zero) throw new ArgumentOutOfRangeException(nameof(readTimeout));
this.client = client; client.Timeout = Timeout.InfiniteTimeSpan; this.port = port; this.idleGrace = idleGrace ?? TimeSpan.FromSeconds(15);