feat(server): route renders by settings format and adapted size; gate older servers
Owner review 1, phase 4 (P5). A render job now carries the output size its settings give (RenderSize, proportions win) and the settings format it needs, resolved on the server before the job is split, so only nodes that read that format and whose encoder takes the frame claim it, and a job no online node can read no longer waits for one. Nodes and the server announce the format they read; settings of a newer Chronos fail saying so. Encoder size limits are read as long edge x short edge: Media Foundation's software H.264 encoder, announced as 4096x2304, accepts portrait 2160x3840 (probed on this PC), so EncoderSelector and the provider take either orientation and cap a portrait frame against the turned limit. On the desktop, Sync and Send-and-render are disabled with the NeedsNewerServer tooltip while the server reads an older format than the working settings need. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
e4364c4f25
commit
fca6c8dfea
27 files changed
+663
-47
No files matched your search
@@ -1,6 +1,7 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data;
|
||||
using Chronos.Data.Archiving;
|
||||
using Chronos.Data.Jobs;
|
||||
@@ -102,20 +103,20 @@ public static class JobEndpoints
|
||||
// A render of a project version (owner review 2, R8): of the sequence's projects, a project alone pinned to its head.
|
||||
var (render, missing) = await ProjectRenderAsync(db, archives, targets[0], parsed, ct);
|
||||
if (missing is not null) return ApiErrors.NotFound(context, missing);
|
||||
var parametersJson = render == parsed ? request.ParametersJson : JsonSerializer.Serialize(render, ProtocolJson.Default.RenderJobParameters);
|
||||
// A batch becomes one job per preset: a render node uploads one file per job (BRIEF §14.7).
|
||||
// A batch becomes one job per preset: a render node uploads one file per job (BRIEF §14.7). Each gets the size and the
|
||||
// settings format of the settings it renders (owner review 1, phase 4), so it goes only to a node that renders it as asked.
|
||||
IReadOnlyList<RenderJobParameters> each;
|
||||
try
|
||||
{
|
||||
var (width, height) = await SourceSizeAsync(db, targets[0], render, ct);
|
||||
each = ProcessingJobs.Split(render, width, height);
|
||||
each = ProcessingJobs.Split(render, width, height, await RenderedSettingsAsync(db, targets[0], render, ct));
|
||||
}
|
||||
catch (InvalidDataException)
|
||||
{
|
||||
return ApiErrors.BadRequest(context, "invalid_parameters", "parametersJson");
|
||||
}
|
||||
queue = each.Count == 1
|
||||
? [(ProcessingJobs.RenderLabel(label, render.PresetName), parametersJson)]
|
||||
queue = each is [var one] && one == parsed
|
||||
? [(ProcessingJobs.RenderLabel(label, render.PresetName), request.ParametersJson)]
|
||||
: [.. each.Select(p => (ProcessingJobs.RenderLabel(label, p.PresetName), (string?)JsonSerializer.Serialize(p, ProtocolJson.Default.RenderJobParameters)))];
|
||||
}
|
||||
else if (request.ParametersJson is not null && !IsJsonObject(request.ParametersJson))
|
||||
@@ -186,8 +187,22 @@ public static class JobEndpoints
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The settings a render job renders, for its size and settings format: those it embeds, else the project version's it
|
||||
/// names, else the sequence's own; a newer Chronos's too (their format stands). Null when they cannot be read (or the
|
||||
/// version is not there): the job keeps the size it was posted with, and its render says why it cannot read them.
|
||||
/// </summary>
|
||||
internal static async Task<ProjectSettings?> RenderedSettingsAsync(ChronosDatabase db, Guid sequenceId, RenderJobParameters render, CancellationToken ct)
|
||||
{
|
||||
if (render.SettingsJson is { } embedded) return ProcessingJobs.ReadSettings(embedded);
|
||||
if (render.ProjectVersionId is { } versionId)
|
||||
return await db.Projects.GetVersionAsync(versionId, ct) is { } version ? ProcessingJobs.ReadSettings(version.SettingsJson) : null;
|
||||
if (await db.Sequences.GetAsync(sequenceId, ct) is not { } sequence) return null;
|
||||
return sequence.SettingsJson is null ? new ProjectSettings() : ProcessingJobs.ReadSettings(sequence.SettingsJson);
|
||||
}
|
||||
|
||||
/// <summary>The oriented size of the sequence's first frame (what a preset without a fixed size renders at), else the job's size.</summary>
|
||||
private static async Task<(int Width, int Height)> SourceSizeAsync(ChronosDatabase db, Guid sequenceId, RenderJobParameters render, CancellationToken ct) =>
|
||||
internal static async Task<(int Width, int Height)> SourceSizeAsync(ChronosDatabase db, Guid sequenceId, RenderJobParameters render, CancellationToken ct) =>
|
||||
(await db.Frames.ListBySequenceAsync(sequenceId, limit: 1, cancellationToken: ct)).FirstOrDefault() is { Width: > 0, Height: > 0 } frame
|
||||
? frame.Orientation is >= 5 and <= 8 ? (frame.Height, frame.Width) : (frame.Width, frame.Height)
|
||||
: (render.Width, render.Height);
|
||||
|
||||
Reference in new issue
Block a user