Merge branch 'or1p4-p5' into or1-p4

This commit is contained in:
Alby96 committed 2026-11-04 19:49:17 +01:00
commit a433b55be3
27 files changed
+663 -47

No files matched your search

@@ -551,10 +551,17 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
public bool CanRender => RenderBlockedReason is null;
/// <summary>The settings format a render of <see cref="RenderExport"/> needs (<see cref="Chronos.Data.Processing.ProcessingJobs.RequiredFormat"/>).</summary>
private int RenderFormat =>
Chronos.Data.Processing.ProcessingJobs.RequiredFormat(Session.Project, RenderExport, Session.Content.SourceWidth, Session.Content.SourceHeight);
/// <summary>Why the project's export cannot be rendered now, localised; null when it can.</summary>
public string? RenderBlockedReason => Plan switch
{
_ when IsRemote && !Shell.Services.Sync.CanRender => Loc.L("Tooltips.Editor.Render.NoRight", ServerName),
// Settings or proportions the server would render otherwise (owner review 1, phase 4: an older server, Send and render too).
_ when IsRemote && ServerJobs.NeedsNewerServer(RenderFormat, Shell.Services.Sync.SettingsFormat)
is { } newer => newer,
_ when IsOutdated => Loc.L("Tooltips.Editor.Outdated", ServerName),
null when _planned => Loc.L("Tooltips.Editor.Render.NoSource"),
null => Loc.L("Tooltips.Editor.Render.Planning"),
+7
View File
@@ -56,6 +56,13 @@ internal sealed class ServerJobs : IAsyncDisposable
/// <summary>The connection the jobs travel on (the source's other calls use it too).</summary>
public IRemoteSequenceApi Api { get; }
/// <summary>
/// Why something that needs settings format <paramref name="required"/> cannot go to a server that reads
/// <paramref name="serverFormat"/> (owner review 1, phase 4: a render, a push, Send and render); null when it can. The
/// desktop disables the action with this as its tooltip.
/// </summary>
public static string? NeedsNewerServer(int required, int serverFormat) => required > serverFormat ? Loc.L("Tooltips.Server.NeedsNewerServer") : null;
/// <summary>Queues <paramref name="request"/> on the server (its priority set after, when it is not the user's); returns the job id.</summary>
/// <exception cref="EditorException">The sequence is gone from the server.</exception>
public async Task<Guid> SubmitAsync(ArchiveJobRequest request, CancellationToken cancellationToken)
+1 -1
View File
@@ -118,7 +118,7 @@
<ContextMenu>
<MenuItem Header="{l:Loc Editor.Project.SaveVersion}" Command="{Binding Project.SaveVersionCommand}" InputGestureText="Ctrl+S"
ToolTip="{Binding Project.SaveVersionToolTip}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Editor.Project.Sync}" Command="{Binding Project.SyncCommand}" ToolTip="{Binding Project.StateToolTip}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Editor.Project.Sync}" Command="{Binding Project.SyncCommand}" ToolTip="{Binding Project.SyncToolTip}" ToolTipService.ShowOnDisabled="True" />
<MenuItem Header="{l:Loc Editor.Project.History}" Command="{Binding Project.HistoryCommand}" ToolTip="{l:Loc Tooltips.Editor.Project.History}" />
<Separator />
<MenuItem Header="{l:Loc Editor.Project.Open}" Command="{Binding Project.OpenProjectCommand}" ToolTip="{l:Loc Tooltips.Editor.Project.Open}" />
+11 -1
View File
@@ -81,6 +81,16 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
public bool HasProjects =>
services.Server.IsConnected && services.Server.Flow.Info?.Capabilities is { } capabilities && capabilities.Contains(ServerCapabilities.Projects);
/// <summary>
/// The highest project settings format the signed-in server reads and renders (owner review 1, phase 4); 1 while signed
/// out and for an older server, which does not announce it. Pushes and renders that need more are held back
/// (<see cref="ServerJobs.NeedsNewerServer"/>).
/// </summary>
public int SettingsFormat => SettingsFormatOf(services.Server.IsConnected ? services.Server.Flow.Info : null);
/// <summary>The settings format a server's <c>server/info</c> announces; 1 when it announces none (an older server).</summary>
public static int SettingsFormatOf(ServerInfo? info) => info?.SettingsFormat is > 0 and var format ? format : ProjectSettings.BaseVersion;
/// <summary>The home of a workspace project of server sequence <paramref name="remoteId"/>; null while signed out or when the server keeps no projects.</summary>
public BundleHome? ServerHome(Guid remoteId) => Server is { } server && HasProjects ? new BundleHome(BundleHome.ServerKind, remoteId, null, server) : null;
@@ -95,7 +105,7 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
if (home.IsArchive || !HasProjects || Volatile.Read(ref _credentials) is not { } credentials
|| !string.Equals(home.Server, SyncService.ServerKey(credentials.Address), StringComparison.OrdinalIgnoreCase))
return null;
return new ServerProjectHome(SessionClient(credentials), home.SequenceId, services.Server.ServerName);
return new ServerProjectHome(SessionClient(credentials), home.SequenceId, services.Server.ServerName, SettingsFormat);
}
/// <summary>
@@ -108,7 +108,7 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
_source = source;
_session = session;
_ui = ui;
_sync = new AsyncRelayCommand(() => SyncAsync(), () => !_isSyncing);
_sync = new AsyncRelayCommand(() => SyncAsync(), () => !_isSyncing && PushBlockedReason is null);
_updateMedia = new AsyncRelayCommand(UpdateMediaAsync, () => _copyJob == Guid.Empty);
SaveVersionCommand = new RelayCommand(OpenSaveVersion, () => CanSaveVersion);
HistoryCommand = new AsyncRelayCommand(OpenHistoryAsync);
@@ -146,6 +146,18 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
public string StateToolTip => WorkspaceText.StateToolTip(_status, _isSyncing, IsServerHome);
/// <summary>
/// Why the project cannot be sent to its server now (owner review 1, phase 4): its settings are of a format the server
/// does not read (an older Chronos Server, which would refuse them); null when they can, and for a project of this PC's
/// archive. Sync is disabled with this as its tooltip, and a render of the server's is held.
/// </summary>
public string? PushBlockedReason => IsServerHome && _source.Workspace is { } workspace && _host.HomeOf(workspace.Home) is { } home
? ServerJobs.NeedsNewerServer(_session.Project.WrittenFormat, home.SettingsFormat)
: null;
/// <summary>Sync in the menu: why it is disabled, else where the project stands.</summary>
public string SyncToolTip => PushBlockedReason ?? StateToolTip;
/// <summary>The ▾ button: its name, then where the project stands, then what the menu holds.</summary>
public string MenuToolTip => Loc.L("Tooltips.Editor.Project.Menu", Name, StateText);
@@ -270,6 +282,12 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
if (_host.Settings.WorkspaceVersionOnRender && !await SaveForRenderAsync()) return false;
// Rendered on this PC from the originals the workspace holds (phase 5c): the project renders as it is.
if (!IsServerHome || _source.RendersLocally) return true;
// Settings the server cannot read are neither sent nor rendered there (owner review 1, phase 4: an older server).
if (PushBlockedReason is { } newer)
{
_ui.Notify(Loc.L("Editor.Workspace.RenderHeld"), newer, isError: true);
return false;
}
await StoreEditAsync();
var status = await _host.StatusAsync(ProjectId);
if (_disposed) return false;
@@ -386,6 +404,12 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
public async Task SyncAsync(bool quiet = false)
{
if (_isSyncing) return;
// Settings the server cannot read stay here until it is updated (owner review 1, phase 4): Sync says why.
if (PushBlockedReason is { } newer)
{
if (!quiet) _ui.Notify(Loc.L("Editor.Workspace.NotSent"), newer, isError: true);
return;
}
SetSyncing(true);
try
{
@@ -1026,6 +1050,8 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
OnPropertyChanged(nameof(StateText));
OnPropertyChanged(nameof(StateKind));
OnPropertyChanged(nameof(StateToolTip));
OnPropertyChanged(nameof(PushBlockedReason));
OnPropertyChanged(nameof(SyncToolTip));
OnPropertyChanged(nameof(MenuToolTip));
OnPropertyChanged(nameof(MenuName));
OnPropertyChanged(nameof(HasMediaUpdate));
@@ -1044,6 +1070,7 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
OnPropertyChanged(nameof(CopyOriginalsToolTip));
OnPropertyChanged(nameof(ProxiesOnlyToolTip));
_updateMedia.RaiseCanExecuteChanged();
_sync.RaiseCanExecuteChanged();
CommandManager.InvalidateRequerySuggested();
}
}
@@ -1,5 +1,6 @@
using System.Runtime.InteropServices;
using Chronos.Core.Diagnostics;
using Chronos.Core.Export;
using Chronos.Core.Video;
using Chronos.Core.Windows.Interop;
@@ -13,7 +14,8 @@ namespace Chronos.Core.Windows.MediaFoundation;
public sealed class MediaFoundationEncoderProvider : IVideoEncoderProvider
{
private const string LogCategory = MediaFoundationEncoders.LogCategory;
private const int SoftwareH264MaxWidth = 4096, SoftwareH264MaxHeight = 2304; // Microsoft H.264 encoder, level 5.2
// Microsoft H.264 encoder, level 5.2: long edge × short edge, portrait UHD included (EncoderSelector.Takes).
private const int SoftwareH264MaxWidth = 4096, SoftwareH264MaxHeight = 2304;
private readonly Lazy<IReadOnlyList<EncoderCapability>> _capabilities = new(BuildCapabilities);
public string Name => "Media Foundation";
@@ -25,7 +27,7 @@ public sealed class MediaFoundationEncoderProvider : IVideoEncoderProvider
if (!SettingsSupported(settings)) return false;
foreach (var c in Capabilities)
{
if (Fits(c.Codec, c.Name, c.Hardware, c.SupportsTenBit, settings) && settings.Width <= c.MaxWidth && settings.Height <= c.MaxHeight) return true;
if (Fits(c.Codec, c.Name, c.Hardware, c.SupportsTenBit, settings) && EncoderSelector.Takes(c, settings.Width, settings.Height)) return true;
}
return false;
}
+18 -3
View File
@@ -182,6 +182,17 @@ public static class EncoderSelector
return new EncoderSelection { Status = EncoderSelectionStatus.Unavailable, Settings = settings, Notices = notices };
}
/// <summary>
/// The capability's size limit takes a <paramref name="width"/>×<paramref name="height"/> frame either way round: the
/// limit is a long edge × short edge (owner review 1, phase 4: Media Foundation's software H.264 encoder, announced as
/// 4096×2304, writes portrait UHD 2160×3840 too; checked on a real encode).
/// </summary>
public static bool Takes(EncoderCapability capability, int width, int height)
{
ArgumentNullException.ThrowIfNull(capability);
return (width <= capability.MaxWidth && height <= capability.MaxHeight) || (height <= capability.MaxWidth && width <= capability.MaxHeight);
}
private static List<(IVideoEncoderProvider Provider, EncoderCapability Capability)> Candidates(IReadOnlyList<IVideoEncoderProvider> providers, VideoCodec codec) =>
[.. providers.SelectMany(p => p.Capabilities.Where(c => c.Codec == codec).Select(c => (p, c)))];
@@ -203,12 +214,16 @@ public static class EncoderSelector
s = s with { Width = check.SuggestedWidth, Height = check.SuggestedHeight };
notices.Add(new EncoderNotice(EncoderNotices.ResolutionCappedByLevel, check.HighestLevel.Name, Size(s)));
}
if (s.Width > capability.MaxWidth || s.Height > capability.MaxHeight)
if (!Takes(capability, s.Width, s.Height))
{
var scale = double.Min((double)capability.MaxWidth / s.Width, (double)capability.MaxHeight / s.Height);
// The limit turned to the frame's orientation (long edge × short edge, Takes).
var (maxWidth, maxHeight) = (s.Width >= s.Height) == (capability.MaxWidth >= capability.MaxHeight)
? (capability.MaxWidth, capability.MaxHeight)
: (capability.MaxHeight, capability.MaxWidth);
var scale = double.Min((double)maxWidth / s.Width, (double)maxHeight / s.Height);
var width = int.Max(2, (int)(s.Width * scale) & ~1);
var height = int.Max(2, (int)double.Round(width * (double)s.Height / s.Width / 2) * 2);
if (height > capability.MaxHeight) height = capability.MaxHeight & ~1;
if (height > maxHeight) height = maxHeight & ~1;
s = s with { Width = width, Height = height };
notices.Add(new EncoderNotice(EncoderNotices.ResolutionCappedByEncoder, capability.Name, Size(s)));
}
@@ -2,6 +2,8 @@ using Chronos.Core.Diagnostics;
using Chronos.Core.Export;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Core.Project;
using Chronos.Core.Render;
using Chronos.Core.Video;
using Chronos.Data.Jobs;
using Chronos.Protocol;
@@ -32,8 +34,11 @@ internal sealed class ManagedRenderJobHandler(RenderJobHandler render, Processin
try
{
parameters = ProcessingJobs.ReadParameters(job.ParametersJson);
// Most jobs are decided by the main codec, before the export is read.
if (Produces(parameters.Codec) && RenderJobHandler.Targets(ProcessingJobs.ReadExport(parameters.PresetJson), parameters.PresetName).All(t => Produces(t.Export)))
// Most jobs are decided by the main codec, before the export is read. The job's own output is checked at the size the
// job names (the server's: the chosen proportions fitted in a fixed-size preset, owner review 1, phase 4).
if (Produces(parameters.Codec) && RenderJobHandler.Targets(ProcessingJobs.ReadExport(parameters.PresetJson), parameters.PresetName)
.Select((t, i) => i == 0 && t.Export is { Width: > 0, Height: > 0 } ? Produces(t.Export, parameters.Width, parameters.Height) : Produces(t.Export))
.All(produced => produced))
return true;
}
catch (Exception ex) when (ex is not OperationCanceledException)
@@ -55,7 +60,7 @@ internal sealed class ManagedRenderJobHandler(RenderJobHandler render, Processin
}
public Task RunAsync(JobContext context) =>
render.RunAsync(context, target => Produces(target.Export) ? target : Fallback(context, target));
render.RunAsync(context, (target, project) => Produces(target.Export, project) ? target : Fallback(context, target));
/// <summary>The output as MJPEG in AVI with the managed preset's quality, at the size and frame rate asked for.</summary>
private static ExportTarget Fallback(JobContext context, ExportTarget target)
@@ -83,6 +88,21 @@ internal sealed class ManagedRenderJobHandler(RenderJobHandler render, Processin
private bool Produces(string codec) =>
_capabilities.Any(c => string.Equals(ProcessingJobs.CodecName(c.Codec), codec, StringComparison.OrdinalIgnoreCase));
private bool Produces(ResolvedExport export) =>
_capabilities.Any(c => c.Codec == export.Codec && export.Width <= c.MaxWidth && export.Height <= c.MaxHeight);
/// <summary>A managed encoder writes <paramref name="export"/> at the preset's size (a free-size preset is not checked by size).</summary>
private bool Produces(ResolvedExport export) => Produces(export, export.Width, export.Height);
/// <summary>
/// A managed encoder writes <paramref name="export"/> at the size <paramref name="project"/> gives it: a fixed-size preset
/// adapted to the chosen proportions (<see cref="RenderSize"/>, 4K at 9:16 = 2160×3840).
/// </summary>
private bool Produces(ResolvedExport export, ProjectSettings project)
{
if (export is not { Width: > 0, Height: > 0 }) return Produces(export);
// A fixed-size preset's output does not depend on the source's size.
var (width, height) = RenderSize.Of(project.Camera, export, export.Width, export.Height);
return Produces(export, width, height);
}
private bool Produces(ResolvedExport export, int width, int height) =>
_capabilities.Any(c => c.Codec == export.Codec && EncoderSelector.Takes(c, width, height));
}
@@ -30,10 +30,13 @@ internal sealed class RenderJobHandler(ChronosDatabase db, ProcessingOptions opt
{
public JobKind Kind => JobKind.Render;
public Task RunAsync(JobContext context) => RunAsync(context, target => target);
public Task RunAsync(JobContext context) => RunAsync(context, (target, _) => target);
/// <summary>Runs the job with each output still to render passed through <paramref name="adapt"/> (the server's managed stand-ins).</summary>
internal async Task RunAsync(JobContext context, Func<ExportTarget, ExportTarget> adapt)
/// <summary>
/// Runs the job with each output still to render passed through <paramref name="adapt"/> with the settings rendered (the
/// server's managed stand-ins, which look at the size those settings give the output).
/// </summary>
internal async Task RunAsync(JobContext context, Func<ExportTarget, ProjectSettings, ExportTarget> adapt)
{
var cancellation = context.Cancellation;
var (parameters, export) = ProcessingJobs.ReadRender(context.Job.ParametersJson);
@@ -72,7 +75,7 @@ internal sealed class RenderJobHandler(ChronosDatabase db, ProcessingOptions opt
Discard(output, keepOutput: recorded.Any(r => r.OutputPath == Stored(paths, output)));
names.Release(output); // free again for the entry's new attempt
}
var targets = all.Select((t, i) => (i, t)).Where(t => !done.Contains(t.i)).Select(t => (t.i, adapt(t.t))).ToList();
var targets = all.Select((t, i) => (i, t)).Where(t => !done.Contains(t.i)).Select(t => (t.i, adapt(t.t, project))).ToList();
if (targets.Count == 0) return;
var companions = await GprCompanions.FindAsync(db, archive, frames.Frames, cancellation).ConfigureAwait(false);
+85 -11
View File
@@ -5,6 +5,7 @@ using Chronos.Core.Export;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Core.Project;
using Chronos.Core.Render;
using Chronos.Core.Video;
using Chronos.Data.Archiving.Jobs;
using Chronos.Protocol;
@@ -28,15 +29,17 @@ public static class ProcessingJobs
/// <summary>
/// <see cref="JobKind.Render"/> of one sequence. <paramref name="export"/> (preset, overrides, name template,
/// folder, batch) replaces the project's export section; <paramref name="project"/> embeds the settings to render,
/// null renders the sequence's current project. <paramref name="sourceWidth"/>×<paramref name="sourceHeight"/>
/// stands in for a preset without a fixed size, so render nodes can match the job by resolution.
/// null renders the sequence's current project. <paramref name="sourceWidth"/>×<paramref name="sourceHeight"/> (the
/// frames' Exif-oriented size) gives the output size of the settings rendered (<see cref="RenderSize"/>; the sequence's
/// own when <paramref name="project"/> is null), so render nodes can match the job by resolution, and the settings
/// format the render needs (<see cref="RenderRules.RequiredFormat"/>).
/// </summary>
public static ArchiveJobRequest Render(Sequence sequence, ExportSettings export, int sourceWidth, int sourceHeight, ProjectSettings? project = null,
bool useProxies = false)
{
ArgumentNullException.ThrowIfNull(sequence);
ArgumentNullException.ThrowIfNull(export);
var parameters = Parameters(export, sourceWidth, sourceHeight, project?.ToJson(), useProxies);
var parameters = Parameters(export, sourceWidth, sourceHeight, project?.ToJson(), useProxies, project ?? ReadSettings(sequence.SettingsJson));
return new ArchiveJobRequest(JobKind.Render, [sequence.Id], RenderLabel(sequence.DisplayTitle, parameters.PresetName),
JsonSerializer.Serialize(parameters, ProtocolJson.Default.RenderJobParameters), JobPriority.User);
}
@@ -80,20 +83,22 @@ public static class ProcessingJobs
/// <summary>
/// A posted render job as one job per preset, as <see cref="RenderEach"/> makes them (a render node uploads one file
/// per job): the job itself when it has no batch; otherwise its own preset, then each batch preset with its own values,
/// all with the job's project and proxy choice. <paramref name="sourceWidth"/>×<paramref name="sourceHeight"/> stands in
/// for a batch preset without a fixed size.
/// all with the job's project and proxy choice. <paramref name="sourceWidth"/>×<paramref name="sourceHeight"/> (the
/// frames' Exif-oriented size) stands in for a batch preset without a fixed size. With the <paramref name="settings"/>
/// the job renders, every job gets the output size and the settings format its render needs (<see cref="Routed"/>);
/// without them, the job keeps the size it was posted with and each batch preset its preset's.
/// </summary>
/// <exception cref="InvalidDataException">The preset JSON is not an export section.</exception>
public static IReadOnlyList<RenderJobParameters> Split(RenderJobParameters parameters, int sourceWidth, int sourceHeight)
public static IReadOnlyList<RenderJobParameters> Split(RenderJobParameters parameters, int sourceWidth, int sourceHeight, ProjectSettings? settings = null)
{
ArgumentNullException.ThrowIfNull(parameters);
var export = ReadExport(parameters.PresetJson);
var batch = BatchPresets(export).ToList();
if (batch.Count == 0) return [parameters];
var own = batch.Count == 0 ? parameters : parameters with { PresetJson = JsonSerializer.Serialize(export with { Batch = [] }, ProcessingJson.Default.ExportSettings) };
return
[
parameters with { PresetJson = JsonSerializer.Serialize(export with { Batch = [] }, ProcessingJson.Default.ExportSettings) },
.. batch.Select(id => Parameters(BatchExport(export, id), sourceWidth, sourceHeight, parameters.SettingsJson, parameters.UseProxies) with
settings is null ? own : Routed(own, settings, sourceWidth, sourceHeight),
.. batch.Select(id => Parameters(BatchExport(export, id), sourceWidth, sourceHeight, parameters.SettingsJson, parameters.UseProxies, settings) with
{
ProjectId = parameters.ProjectId,
ProjectVersionId = parameters.ProjectVersionId,
@@ -101,6 +106,61 @@ public static class ProcessingJobs
];
}
/// <summary>
/// A render job's parameters with the output size and the settings format a render of <paramref name="settings"/> needs
/// (owner review 1, phase 4: the chosen proportions win over a fixed-size preset, a quarter turn swaps a source-sized
/// output). A fixed-size preset's box is the size the job was posted with: an older client posts the preset's, this one
/// the adapted size, which adapts to itself. Other presets are sized on the source. The format is at least the one the
/// job was posted with.
/// </summary>
/// <exception cref="InvalidDataException">The preset JSON is not an export section.</exception>
public static RenderJobParameters Routed(RenderJobParameters parameters, ProjectSettings settings, int sourceWidth, int sourceHeight)
{
ArgumentNullException.ThrowIfNull(parameters);
ArgumentNullException.ThrowIfNull(settings);
var resolved = ExportResolver.Resolve(ReadExport(parameters.PresetJson));
var box = resolved.Width > 0 && resolved.Height > 0 && parameters.Width > 0 && parameters.Height > 0
? resolved with { Width = parameters.Width, Height = parameters.Height }
: resolved;
var (width, height) = Size(settings, box, sourceWidth, sourceHeight) ?? (parameters.Width, parameters.Height);
return parameters with
{
Width = width,
Height = height,
RequiredSettingsFormat = int.Max(parameters.RequiredSettingsFormat, RequiredFormat(settings, resolved, sourceWidth, sourceHeight)),
};
}
/// <summary>
/// The settings format a render of <paramref name="settings"/> with <paramref name="export"/> and each of its batch
/// presets needs (the highest <see cref="RenderRules.RequiredFormat"/> of them): what a server or a render node must read
/// to render it as this Chronos would.
/// </summary>
public static int RequiredFormat(ProjectSettings settings, ExportSettings export, int sourceWidth, int sourceHeight)
{
ArgumentNullException.ThrowIfNull(settings);
ArgumentNullException.ThrowIfNull(export);
return BatchPresets(export).Select(id => ExportResolver.Resolve(BatchExport(export, id))).Prepend(ExportResolver.Resolve(export))
.Max(resolved => RequiredFormat(settings, resolved, sourceWidth, sourceHeight));
}
/// <summary>
/// Project settings read for their output size and format, a newer Chronos's too (its format stands); null when there
/// are none or the text is not a project.
/// </summary>
public static ProjectSettings? ReadSettings(string? settingsJson)
{
if (string.IsNullOrWhiteSpace(settingsJson)) return null;
try
{
return ProjectSettings.FromJson(settingsJson, allowNewer: true);
}
catch (JsonException)
{
return null;
}
}
/// <summary>
/// One <see cref="Render"/> job per preset of <paramref name="export"/>: its preset, then each batch preset with its
/// own values. For a server: a render node uploads one file per job, so a batch must not travel as one job.
@@ -128,13 +188,27 @@ public static class ProcessingJobs
internal static ExportSettings BatchExport(ExportSettings export, string presetId) =>
new() { Preset = new Auto<string>().WithManual(presetId), NameTemplate = export.NameTemplate, Folder = export.Folder };
private static RenderJobParameters Parameters(ExportSettings export, int sourceWidth, int sourceHeight, string? settingsJson, bool useProxies)
/// <param name="settings">The settings rendered, for the output size and the format (else read from <paramref name="settingsJson"/>); unknown, the preset's size.</param>
private static RenderJobParameters Parameters(ExportSettings export, int sourceWidth, int sourceHeight, string? settingsJson, bool useProxies,
ProjectSettings? settings = null)
{
var resolved = ExportResolver.Resolve(export);
settings ??= ReadSettings(settingsJson);
var (width, height) = (settings is null ? null : Size(settings, resolved, sourceWidth, sourceHeight))
?? (resolved.Width > 0 ? resolved.Width : sourceWidth, resolved.Height > 0 ? resolved.Height : sourceHeight);
var format = settings is null ? ProjectSettings.BaseVersion : RequiredFormat(settings, resolved, sourceWidth, sourceHeight);
return new RenderJobParameters(PresetName(resolved), JsonSerializer.Serialize(export, ProcessingJson.Default.ExportSettings), CodecName(resolved.Codec),
resolved.Width > 0 ? resolved.Width : sourceWidth, resolved.Height > 0 ? resolved.Height : sourceHeight, useProxies, settingsJson);
width, height, useProxies, settingsJson, RequiredSettingsFormat: format);
}
/// <summary>The output size of <paramref name="settings"/> with <paramref name="export"/> (<see cref="RenderSize.Of"/>); null without a source size.</summary>
private static (int Width, int Height)? Size(ProjectSettings settings, ResolvedExport export, int sourceWidth, int sourceHeight) =>
sourceWidth > 0 && sourceHeight > 0 ? RenderSize.Of(settings.Camera, export, sourceWidth, sourceHeight) : null;
/// <summary><see cref="RenderRules.RequiredFormat"/>; without a source size, the format the settings are written in.</summary>
private static int RequiredFormat(ProjectSettings settings, ResolvedExport export, int sourceWidth, int sourceHeight) =>
sourceWidth > 0 && sourceHeight > 0 ? RenderRules.RequiredFormat(settings, export, sourceWidth, sourceHeight) : settings.WrittenFormat;
/// <summary>Codec name in job parameters and render-node capabilities ("h264", "hevc", "mjpeg", "pngsequence"…).</summary>
public static string CodecName(VideoCodec codec) => codec.ToString().ToLowerInvariant();
+10 -1
View File
@@ -1,6 +1,7 @@
using System.Text.Json;
using Chronos.Core.Archiving;
using Chronos.Core.IO;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Core.Project;
using Chronos.Data.Archiving;
@@ -22,7 +23,10 @@ internal sealed class ProjectStore(ChronosDatabase db, SequenceWriter writer)
public static ProjectSettings Read(Sequence sequence, SequencePaths folder) =>
Parse(sequence.SettingsJson ?? (File.Exists(folder.ProjectPath) ? AtomicFile.ReadAllText(folder.ProjectPath) : null));
/// <exception cref="InvalidDataException">The settings are not valid JSON or come from a newer Chronos.</exception>
/// <exception cref="InvalidDataException">
/// The settings are not valid JSON, or come from a newer Chronos (<c>Errors.Render.NewerSettings</c>, which a render's
/// job shows as its error).
/// </exception>
public static ProjectSettings Parse(string? json)
{
if (string.IsNullOrWhiteSpace(json)) return new ProjectSettings();
@@ -34,6 +38,11 @@ internal sealed class ProjectStore(ChronosDatabase db, SequenceWriter writer)
{
throw new InvalidDataException(ex.Message, ex);
}
catch (InvalidDataException ex)
{
// A settings format above this Chronos's (owner review 1, phase 4: a server, a node or a desktop that is older).
throw new InvalidDataException(Loc.L("Errors.Render.NewerSettings"), ex);
}
}
/// <summary>Applies <paramref name="edit"/> to the settings in force and stores the result when it differs; false when nothing changed.</summary>
@@ -7,6 +7,7 @@ using Chronos.Core.Export;
using Chronos.Core.Imaging;
using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Core.Project;
using Chronos.Core.Render;
using Chronos.Core.Video;
using Chronos.Data.Archiving;
@@ -117,10 +118,11 @@ public sealed class RenderNodeClient : IAsyncDisposable
/// <summary>Registers this node (again) and returns its id.</summary>
public async Task<Guid> RegisterAsync(CancellationToken cancellationToken)
{
// Each encoder carries its own limit; the node-wide one (for servers that read only that) is the largest offered.
// Each encoder carries its own limit; the node-wide one (for servers that read only that) is the largest offered. The
// settings format the node reads keeps it from jobs it would render otherwise than asked (owner review 1, phase 4).
var encoders = Encoders;
var request = new RegisterNodeRequest(_options.ClientName, encoders, encoders.Select(e => e.MaxWidth).DefaultIfEmpty().Max(),
encoders.Select(e => e.MaxHeight).DefaultIfEmpty().Max());
encoders.Select(e => e.MaxHeight).DefaultIfEmpty().Max(), ProjectSettings.CurrentVersion);
var node = await _client.RegisterNodeAsync(request, cancellationToken).ConfigureAwait(false);
_nodeId = node.Id;
return node.Id;
@@ -76,6 +76,12 @@ public interface IProjectHome
/// then. Null from a home that keeps none: the frames are read every time.
/// </summary>
Task<string?> FramesStampAsync(CancellationToken cancellationToken) => Task.FromResult<string?>(null);
/// <summary>
/// The highest project settings format the home stores and renders (owner review 1, phase 4); a version of a higher one
/// is not pushed to it (an older server refuses it, 422 <c>newer_format</c>). This PC's archive reads what this Chronos does.
/// </summary>
int SettingsFormat => ProjectSettings.CurrentVersion;
}
/// <summary>A sequence of this PC's archive as its projects' home: the archive's <see cref="ProjectService"/>.</summary>
@@ -27,15 +27,20 @@ public sealed class ServerProjectHome : IProjectHome
private const int MaxPage = 200;
/// <param name="serverName">The server's name as its <c>server/info</c> gives it, for the project file; the address's host when null.</param>
public ServerProjectHome(ChronosClient client, Guid sequenceId, string? serverName = null)
/// <param name="settingsFormat">The settings format its <c>server/info</c> announces (<see cref="ServerInfo.SettingsFormat"/>); null, an older server's 1.</param>
public ServerProjectHome(ChronosClient client, Guid sequenceId, string? serverName = null, int? settingsFormat = null)
{
ArgumentNullException.ThrowIfNull(client);
Client = client;
SequenceId = sequenceId;
Server = SyncService.ServerKey(client.BaseAddress);
ServerName = string.IsNullOrWhiteSpace(serverName) ? client.BaseAddress.Host : serverName.Trim();
SettingsFormat = settingsFormat is > 0 and var format ? format : ProjectSettings.BaseVersion;
}
/// <summary>The highest settings format the server reads (owner review 1, phase 4); 1 for an older server, which does not announce it.</summary>
public int SettingsFormat { get; }
public ChronosClient Client { get; }
/// <summary>The server's sequence.</summary>
+21 -6
View File
@@ -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);
+3 -1
View File
@@ -2,6 +2,7 @@ using System.Globalization;
using System.Reflection;
using Chronos.Core.Imaging;
using Chronos.Core.Localization;
using Chronos.Core.Project;
using Chronos.Data;
using Chronos.Protocol;
using Chronos.Server.Configuration;
@@ -47,7 +48,8 @@ public static class SystemEndpoints
state.TlsFingerprint,
["jpeg", "png", "tiff", "dng", "cr2", "cr3", "nef", "arw", "raf", "orf", "rw2", "pef", "heic", "webp"],
new ServerLimits(options.MaxUploadBytes, options.ChunkSizeBytes, PasswordHasher.MinimumLength),
PhotoExtensions), ProtocolJson.Default.ServerInfo)).AllowAnonymousCaller();
PhotoExtensions,
ProjectSettings.CurrentVersion), ProtocolJson.Default.ServerInfo)).AllowAnonymousCaller();
api.MapGet("/i18n/{culture}", (string culture) =>
{
@@ -11,8 +11,9 @@ namespace Chronos.Server.Jobs;
/// Whether a queued render job that needs a platform encoder still waits for a render node (BRIEF §14.7); once it does
/// not, the server's own engine renders it in a managed format. A job waits at least as long as a node may stay silent
/// (<see cref="ServerOptions.NodeTimeoutSeconds"/>), so a node that is restarting or reconnecting takes it back, and
/// then as long as an online node can encode its codec at its size. The server's render handler asks for every queued
/// job it examines, so the online nodes are read at most once a second.
/// then as long as an online node reads the settings format it needs (<see cref="RenderJobParameters.RequiredSettingsFormat"/>)
/// and can encode its codec at its size. The server's render handler asks for every queued job it examines, so the online
/// nodes are read at most once a second.
/// </summary>
public sealed class RenderNodeAvailability(ChronosDatabase db, ServerOptions options, TimeProvider time)
{
@@ -34,7 +35,7 @@ public sealed class RenderNodeAvailability(ChronosDatabase db, ServerOptions opt
snapshot = new Snapshot(Stopwatch.GetTimestamp(), [.. online.Select(Dto.Capabilities).OfType<RegisterNodeRequest>()]);
Volatile.Write(ref _snapshot, snapshot);
}
return snapshot.Nodes.Any(node => RenderNodeService.CanEncode(node, parameters));
return snapshot.Nodes.Any(node => RenderNodeService.Renders(node, parameters));
}
/// <summary>What the online nodes announced, and when it was read (a <see cref="Stopwatch"/> timestamp).</summary>
+40 -4
View File
@@ -6,6 +6,7 @@ using Chronos.Core.Model;
using Chronos.Core.Project;
using Chronos.Data;
using Chronos.Data.Jobs;
using Chronos.Data.Processing;
using Chronos.Data.Projects;
using Chronos.Data.Repositories;
using Chronos.Protocol;
@@ -86,7 +87,10 @@ public sealed class RenderNodeService(
// A render the server's own engine started (it left a checkpoint) resumes there: only it knows that attempt's
// leftovers and the batch entries it recorded.
if (queued.Checkpoint is not null) continue;
if (JobEndpoints.ParseRender(queued.ParametersJson) is not { } parameters || capabilities is null || !CanEncode(capabilities, parameters)) continue;
if (JobEndpoints.ParseRender(queued.ParametersJson) is not { } parameters || capabilities is null || !Renders(capabilities, parameters)) continue;
// What the job renders now decides too (owner review 1, phase 4): the sequence's own settings may have changed
// since it was queued, and a job of an older server carries no settings format.
if (await RoutedAsync(queued, parameters, cancellationToken) is { } routed && !Renders(capabilities, routed)) continue;
if (await db.Jobs.TryClaimAsync(queued.Id, NodeKey(node), cancellationToken) is not { } job) continue;
jobs.Publish(job);
if (job.TargetIds.Count != 1 || await db.Sequences.GetAsync(job.TargetIds[0], cancellationToken) is not { } sequence)
@@ -134,6 +138,27 @@ public sealed class RenderNodeService(
: null;
}
/// <summary>
/// The job's parameters with the output size and settings format of the settings a node would render now
/// (<see cref="ProcessingJobs.Routed"/>); null when they cannot be told (no sequence, settings that cannot be read, a
/// version that is not the sequence's), which the claim reports as it does today.
/// </summary>
private async Task<RenderJobParameters?> RoutedAsync(Job queued, RenderJobParameters parameters, CancellationToken cancellationToken)
{
if (queued.TargetIds is not [var sequenceId] || await db.Sequences.GetAsync(sequenceId, cancellationToken) is not { } sequence) return null;
if (await SettingsAsync(parameters, sequence, cancellationToken) is not { } settings || ProcessingJobs.ReadSettings(settings.Json) is not { } read) return null;
try
{
var (width, height) = await JobEndpoints.SourceSizeAsync(db, sequence.Id, parameters, cancellationToken);
return ProcessingJobs.Routed(parameters, read, width, height);
}
catch (InvalidDataException)
{
// Not an export section: the render says so.
return null;
}
}
/// <summary>Settings with positions that wait for their photos (a project version's portable form, settings synced from another copy).</summary>
private static bool Waits(string settingsJson) => settingsJson.Contains("pendingFrames", StringComparison.OrdinalIgnoreCase);
@@ -311,14 +336,25 @@ public sealed class RenderNodeService(
if (state != node.State) events.Publish(new NodeStateEvent(node.Id, node.ClientName, state));
}
/// <summary>
/// The node renders the job as asked: it reads the settings format the job needs (<see cref="RegisterNodeRequest.SettingsFormat"/>,
/// 1 for an older node) and can encode it (<see cref="CanEncode"/>).
/// </summary>
internal static bool Renders(RegisterNodeRequest node, RenderJobParameters job) => job.RequiredSettingsFormat <= node.SettingsFormat && CanEncode(node, job);
/// <summary>
/// The node has an encoder for the job's codec that handles its resolution: the encoder's own limit, else the node's
/// (0 = no announced limit).
/// (0 = no announced limit). A node of settings format 2 or more takes the limit as a long edge × short edge, as its
/// encoders do (<see cref="Core.Export.EncoderSelector.Takes"/>: portrait UHD on a 4096×2304 encoder); an older node
/// would shrink a portrait frame to the limit as announced, so it is held to it.
/// </summary>
internal static bool CanEncode(RegisterNodeRequest node, RenderJobParameters job) =>
node.Encoders.Any(e => string.Equals(e.Codec, job.Codec, StringComparison.OrdinalIgnoreCase)
&& Fits(job.Width, e.MaxWidth > 0 ? e.MaxWidth : node.MaxWidth)
&& Fits(job.Height, e.MaxHeight > 0 ? e.MaxHeight : node.MaxHeight));
&& Fits(job.Width, job.Height, e.MaxWidth > 0 ? e.MaxWidth : node.MaxWidth, e.MaxHeight > 0 ? e.MaxHeight : node.MaxHeight,
eitherWay: node.SettingsFormat >= 2));
private static bool Fits(int width, int height, int maxWidth, int maxHeight, bool eitherWay) =>
(Fits(width, maxWidth) && Fits(height, maxHeight)) || (eitherWay && Fits(height, maxWidth) && Fits(width, maxHeight));
private static bool Fits(int size, int limit) => limit <= 0 || size <= limit;
@@ -244,6 +244,55 @@ public sealed class ServerHomeTests(TestContext context)
}
}
[Test]
public async Task AServerThatReadsAnOlderFormatIsNotSentSettingsItCannotRead()
{
Assert.Null(ServerJobs.NeedsNewerServer(ProjectSettings.BaseVersion, ProjectSettings.BaseVersion));
Assert.Equal(Loc.L("Tooltips.Server.NeedsNewerServer"), ServerJobs.NeedsNewerServer(2, ProjectSettings.BaseVersion));
// A server that says no format reads the base one; a session-less home too.
Assert.Equal(ProjectSettings.BaseVersion, Chronos.App.Server.SyncHost.SettingsFormatOf(new ServerInfo("Studio NAS", "1.3.0", 1, [], null, [], new ServerLimits(0, 0))));
Assert.Equal(ProjectSettings.BaseVersion, Chronos.App.Server.SyncHost.SettingsFormatOf(null));
Assert.Equal(ProjectSettings.CurrentVersion, Chronos.App.Server.SyncHost.SettingsFormatOf(
new ServerInfo("Studio NAS", "1.4.0", 1, [], null, [], new ServerLimits(0, 0), SettingsFormat: ProjectSettings.CurrentVersion)));
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 4);
var host = bed.Host(new AppSettings { WorkspaceAutoSync = false, WorkspaceVersionOnRender = false });
var server = new FakeServer(bed) { SettingsFormat = ProjectSettings.BaseVersion };
Connect(host, server);
var projectId = await CheckoutAsync(bed, host);
var source = new WorkspaceSequenceSource(host.Sync, projectId, bed.Db, DecoderFactory.CreateClient(null), bed.Engine,
new WorkspaceServerHome(() => null, () => null));
var content = await source.LoadAsync(bed.Ct);
var session = new EditorSession(source, content, [], TimeSpan.FromMilliseconds(20));
var ui = new RecordingUi();
await using (session)
using (var menu = new ProjectMenuViewModel(host, source, session, ui))
{
await menu.RefreshAsync();
// A change of the base format goes to the older server as before.
Assert.True(session.SetHero(2));
Assert.Null(menu.PushBlockedReason);
Assert.True(menu.SyncCommand.CanExecute(null));
// A turn needs format 2: Sync is disabled saying why, and a render of it is held.
Assert.True(session.Edit(p => p with { Camera = p.Camera with { Rotate = 90 } }));
Assert.True(await session.FlushAsync());
Assert.Equal(Loc.L("Tooltips.Server.NeedsNewerServer"), menu.PushBlockedReason);
Assert.Equal(menu.PushBlockedReason, menu.SyncToolTip);
Assert.False(menu.SyncCommand.CanExecute(null));
Assert.False(await menu.ReadyToRenderAsync(), "the server cannot read it");
Assert.Equal((Loc.L("Editor.Workspace.RenderHeld"), true), (ui.Toasts[^1].Title, ui.Toasts[^1].IsError));
var before = host.Store.Find(projectId)!.ReadBundle().Workspace!.Base!.VersionId;
await menu.SyncAsync();
Assert.Equal(before, host.Store.Find(projectId)!.ReadBundle().Workspace!.Base!.VersionId, "nothing was sent");
// A server of this format takes it.
server.SettingsFormat = ProjectSettings.CurrentVersion;
Assert.Null(menu.PushBlockedReason);
Assert.True(menu.SyncCommand.CanExecute(null));
}
}
/// <summary>The home a workspace project of the test sequence names on <see cref="Server"/>.</summary>
private static BundleHome ServerHome(WorkspaceTestBed bed) => new(BundleHome.ServerKind, bed.SequenceId, null, Server);
@@ -276,6 +325,9 @@ public sealed class ServerHomeTests(TestContext context)
public HashSet<Guid> Deleted { get; } = [];
/// <summary>The settings format the server reads, as its info says.</summary>
public int SettingsFormat { get; set; } = ProjectSettings.CurrentVersion;
public async Task<HomeSequence> SequenceAsync(CancellationToken cancellationToken)
{
var sequence = await Reach(() => Inner.SequenceAsync(cancellationToken));
@@ -128,6 +128,22 @@ public sealed class EncoderSelectorTests
Assert.Equal((1080, 606), (odd.Settings.Width, odd.Settings.Height));
}
[Test]
public void APortraitFrameReadsTheLimitTurned()
{
// An encoder announced as 4096×2304 takes 4K at 9:16: its limit is long edge × short edge.
var portrait = EncoderSelector.Select(Request(VideoCodec.H264, 2160, 3840), Client(SoftwareH264), EncoderHost.Client);
Assert.Equal((2160, 3840), (portrait.Settings.Width, portrait.Settings.Height));
Assert.False(portrait.Notices.Any(n => n.Key is EncoderNotices.ResolutionCappedByEncoder or EncoderNotices.ResolutionCappedByLevel), "not capped");
var capped = EncoderSelector.Select(Request(VideoCodec.H264, 4320, 7680), Client(SoftwareH264), EncoderHost.Client);
Assert.Equal((2304, 4096), (capped.Settings.Width, capped.Settings.Height));
Assert.True(capped.Notices.Any(n => n.Key == EncoderNotices.ResolutionCappedByEncoder));
Assert.True(EncoderSelector.Takes(SoftwareH264, 2304, 4096));
Assert.False(EncoderSelector.Takes(SoftwareH264, 2400, 3840), "the short edge is over the limit");
}
[Test]
public void BitRateIsCappedByTheHighestLevel()
{
@@ -1,3 +1,4 @@
using Chronos.Core.Export;
using Chronos.Core.Imaging;
using Chronos.Core.Video;
@@ -26,7 +27,7 @@ internal sealed class CapturingEncoderProvider(string name, params EncoderCapabi
public (int Frame, Exception Error)? FailAt { get; set; }
public bool CanEncode(EncodeSettings settings) => capabilities.Any(c =>
c.Codec == settings.Codec && settings.Width <= c.MaxWidth && settings.Height <= c.MaxHeight && (settings.BitDepth == 8 || c.SupportsTenBit));
c.Codec == settings.Codec && EncoderSelector.Takes(c, settings.Width, settings.Height) && (settings.BitDepth == 8 || c.SupportsTenBit));
public IVideoEncoderSession Open(EncodeSettings settings)
{
@@ -1,3 +1,4 @@
using Chronos.Core.Export;
using Chronos.Core.Imaging;
using Chronos.Core.Video;
using Chronos.Core.Windows.MediaFoundation;
@@ -143,6 +144,61 @@ public sealed class MediaFoundationEncoderTests(TestContext context)
Assert.Equal(60, report.FrameCount);
}
/// <summary>
/// Owner review 1, phase 4: 4K at 9:16 is 2160×3840. Each H.264 encoder of this machine is asked for portrait UHD and
/// its landscape twin: none takes one and refuses the other, so the announced limits are a long edge × short edge
/// (<see cref="EncoderSelector.Takes"/>), and portrait UHD is announced wherever landscape UHD is. Encoders that refuse
/// both (Microsoft's DX12 encoder on some GPUs) are left to the provider, which then opens the next one.
/// </summary>
[Test]
[WindowsOnly]
[Timeout(180_000)]
public void PortraitUhdH264EncodesWhereLandscapeDoes()
{
RequireMediaFoundation();
var provider = new MediaFoundationEncoderProvider();
var h264 = provider.Capabilities.Where(c => c.Codec == VideoCodec.H264).ToList();
if (h264.Count == 0) TestContext.Skip("No H.264 encoder on this machine");
foreach (var capability in h264)
{
var (portrait, landscape) = (Accepts(capability, 2160, 3840), Accepts(capability, 3840, 2160));
Assert.Equal(landscape, portrait, $"{capability.Name} takes portrait UHD as it takes landscape UHD");
Assert.Equal(EncoderSelector.Takes(capability, 3840, 2160), EncoderSelector.Takes(capability, 2160, 3840), "announced either way round");
}
var request = Settings(Path.Combine(context.CreateTempDirectory(), "portrait.mp4"), VideoCodec.H264, 8);
Assert.Equal(provider.CanEncode(request with { Width = 3840, Height = 2160 }), provider.CanEncode(request with { Width = 2160, Height = 3840 }));
bool Accepts(EncoderCapability capability, int width, int height)
{
var settings = Settings(Path.Combine(context.CreateTempDirectory(), $"{width}x{height}.mp4"), VideoCodec.H264, 8) with
{
Width = width,
Height = height,
EncoderName = capability.Name,
PreferHardware = capability.Hardware,
BitRate = 20_000_000,
};
try
{
using (var session = provider.Open(settings))
{
using var frame = new ImageBuffer(width, height);
for (var c = 0; c < 3; c++) frame.Plane(c).Fill(0.25f);
for (var f = 0; f < 3; f++) session.WriteFrame(frame, Frame30);
session.Complete();
}
var report = Mp4Inspector.Inspect(settings.OutputPath);
context.Log($"{capability.Name} {width}×{height}: {report}");
return report.IsValid && (report.Width, report.Height) == (width, height);
}
catch (NotSupportedException ex)
{
context.Log($"{capability.Name} {width}×{height}: refused ({ex.InnerException?.Message ?? ex.Message})");
return false;
}
}
}
[Test]
[WindowsOnly]
[Timeout(60_000)]
@@ -0,0 +1,54 @@
using Chronos.Core.Diagnostics.Synthetic;
using Chronos.Core.Localization;
using Chronos.Core.Project;
using Chronos.Data.Archiving;
using Chronos.Data.Processing;
using Chronos.Testing;
namespace Chronos.Data.Tests.Processing;
/// <summary>
/// The project of a sequence as the engine reads and writes it (owner review 1, phase 4): a format-1 project stays format 1
/// through every edit that uses nothing newer, a transform raises it to 2 and its removal brings it back, and settings of
/// a newer Chronos are refused saying so in the user's language.
/// </summary>
[Category("processing")]
public sealed class ProjectStoreTests(TestContext context)
{
[Test]
public async Task AnEditNeverRaisesTheFormatOfAProjectThatUsesNothingNewer()
{
await using var fixture = await ProcessingFixture.CreateAsync(context);
var sequence = await fixture.AddAsync(SyntheticSequence.Create(new SyntheticSequenceOptions { Width = 64, Height = 48, FrameCount = 4 }));
var store = new ProjectStore(fixture.Db, new SequenceWriter(new ArchiveServiceOptions { Owner = "test", LeaseWait = TimeSpan.FromSeconds(20) }));
async Task<int> StoredFormatAsync()
{
var row = (await fixture.Db.Sequences.GetAsync(sequence.Id, fixture.Ct))!;
var file = await File.ReadAllTextAsync(fixture.Folder(sequence).ProjectPath, fixture.Ct);
Assert.Equal(row.SettingsJson, file, "the index and project.json hold the same text");
return ProjectContent.FormatOf(file);
}
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Exposure = p.Exposure with { ExposureOffsetEv = 0.5 } }, fixture.Ct));
Assert.Equal(ProjectSettings.BaseVersion, await StoredFormatAsync());
// A read project of the base format is never stamped higher, even when it says the highest this Chronos reads.
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Version = ProjectSettings.CurrentVersion, HeroFrame = 2 }, fixture.Ct));
Assert.Equal(ProjectSettings.BaseVersion, await StoredFormatAsync());
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Camera = p.Camera with { Rotate = 90 } }, fixture.Ct));
Assert.Equal(2, await StoredFormatAsync());
Assert.True(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Camera = p.Camera with { Rotate = 0 } }, fixture.Ct));
Assert.Equal(ProjectSettings.BaseVersion, await StoredFormatAsync());
Assert.False(await store.UpdateAsync(fixture.Archive.Paths, sequence, p => p with { Version = ProjectSettings.BaseVersion }, fixture.Ct), "nothing changed");
}
[Test]
public void SettingsOfANewerChronosAreRefusedSayingSo()
{
var refused = Assert.Throws<InvalidDataException>(() => ProjectStore.Parse("""{"version":3,"camera":{"rotate":90}}"""));
Assert.Equal(Loc.L("Errors.Render.NewerSettings"), refused.Message);
Assert.Equal(90, ProjectStore.Parse("""{"version":2,"camera":{"rotate":90}}""").Camera.Rotate);
// Text that is not a project keeps its own reason.
Assert.NotEqual(Loc.L("Errors.Render.NewerSettings"), Assert.Throws<InvalidDataException>(() => ProjectStore.Parse("[1]")).Message);
}
}
@@ -599,6 +599,65 @@ public sealed class RenderJobTests(TestContext context)
Assert.SequenceEqual(["mjpeg", "gif"], ProcessingJobs.Split(posted, 96, 64).Select(p => p.Codec));
}
/// <summary>
/// Owner review 1, phase 4: a render job carries the output size its settings give it (the chosen proportions win over a
/// fixed-size preset, a quarter turn swaps a source-sized output) and the settings format its render needs, so a render
/// node is matched to what it will write; a job posted by an older client gets both from the server (<see cref="ProcessingJobs.Split"/>).
/// </summary>
[Test]
public void RenderJobsCarryTheSizeAndFormatOfTheirSettings()
{
var sequence = new Sequence { Id = Guid.CreateVersion7(), ArchiveId = Guid.CreateVersion7(), Folder = "Synthetic", Title = "Roof" };
var uhd = new ExportSettings { Preset = new Auto<string>().WithManual("4k-h264") };
var portrait = new ProjectSettings { Camera = new CameraSettings { Aspect = new Auto<string>().WithManual("9:16") } };
static Chronos.Protocol.RenderJobParameters Read(Chronos.Data.Archiving.Jobs.ArchiveJobRequest request) => ProcessingJobs.ReadRender(request.ParametersJson).Parameters;
var adapted = Read(ProcessingJobs.Render(sequence, uhd, 6000, 4000, portrait));
Assert.Equal((2160, 3840, 2), (adapted.Width, adapted.Height, adapted.RequiredSettingsFormat));
var source = Read(ProcessingJobs.Render(sequence, uhd, 6000, 4000, new ProjectSettings()));
Assert.Equal((3840, 2160, 1), (source.Width, source.Height, source.RequiredSettingsFormat));
// A source-sized output turns with the picture; the turn needs format 2.
var png = new ExportSettings { Preset = new Auto<string>().WithManual("png-sequence") };
var turned = Read(ProcessingJobs.Render(sequence, png, 6000, 4000, new ProjectSettings { Camera = new CameraSettings { Rotate = 90 } }));
Assert.Equal((4000, 6000, 2), (turned.Width, turned.Height, turned.RequiredSettingsFormat));
// The sequence's own settings when the job embeds none.
var own = Read(ProcessingJobs.Render(sequence with { SettingsJson = portrait.ToJson() }, uhd, 6000, 4000));
Assert.Equal((2160, 3840, 2), (own.Width, own.Height, own.RequiredSettingsFormat));
// Posted by an older client (the preset's size, no format) with a batch: the server sizes each job for the settings.
var posted = Read(ProcessingJobs.Render(sequence, uhd with { Batch = ["1080p-h264"] }, 6000, 4000)) with { SettingsJson = portrait.ToJson() };
Assert.Equal((3840, 2160, 1), (posted.Width, posted.Height, posted.RequiredSettingsFormat));
var split = ProcessingJobs.Split(posted, 6000, 4000, portrait);
Assert.SequenceEqual([(2160, 3840, 2), (1080, 1920, 2)], split.Select(p => (p.Width, p.Height, p.RequiredSettingsFormat)));
Assert.Equal(split[0], ProcessingJobs.Routed(split[0], portrait, 6000, 4000), "a size already adapted stays");
Assert.Equal((3840, 2160, 1), ProcessingJobs.Split(posted, 6000, 4000).Select(p => (p.Width, p.Height, p.RequiredSettingsFormat)).First(),
"settings that cannot be read keep the size the job was posted with");
// What the desktop asks of a server before a render: the highest format of the export and its batch.
Assert.Equal(1, ProcessingJobs.RequiredFormat(portrait, png, 6000, 4000), "a source-sized output keeps the proportions");
Assert.Equal(2, ProcessingJobs.RequiredFormat(portrait, png with { Batch = ["4k-h264"] }, 6000, 4000));
}
/// <summary>Settings of a newer Chronos fail the render with the reason in the user's language, never as an English message.</summary>
[Test]
public async Task AnOverFormatRenderFailsSayingANewerChronosIsNeeded()
{
await using var fx = await ProcessingFixture.CreateAsync(context);
var sequence = await fx.AddAsync(Scene());
await fx.StartEngineAsync();
var parameters = ProcessingJobs.ReadRender(ProcessingJobs.Render(sequence, Mjpeg, 96, 64).ParametersJson).Parameters with
{
SettingsJson = """{"version":3,"camera":{"rotate":90},"grade":{"lut":"teal"}}""",
};
var request = new Chronos.Data.Archiving.Jobs.ArchiveJobRequest(JobKind.Render, [sequence.Id], "newer",
System.Text.Json.JsonSerializer.Serialize(parameters, Chronos.Protocol.ProtocolJson.Default.RenderJobParameters), JobPriority.User);
Assert.Equal(3, ProcessingJobs.ReadRender(ProcessingJobs.Render(sequence, Mjpeg, 96, 64,
ProjectSettings.FromJson(parameters.SettingsJson, allowNewer: true)).ParametersJson).Parameters.RequiredSettingsFormat, "routed to none older");
var failed = await fx.WaitForAsync((await fx.EnqueueAsync(request)).Id, JobState.Failed);
Assert.Equal(Loc.L("Errors.Render.NewerSettings"), failed.Error);
Assert.Empty(await fx.Db.Renders.ListBySequenceAsync(sequence.Id, fx.Ct));
}
/// <summary>MJPEG job parameters whose preset JSON is <paramref name="presetJson"/>.</summary>
private static string WithPreset(string presetJson) => System.Text.Json.JsonSerializer.Serialize(
new Chronos.Protocol.RenderJobParameters("MJPEG", presetJson, "mjpeg", 96, 64, false, null), Chronos.Protocol.ProtocolJson.Default.RenderJobParameters);
@@ -498,6 +498,42 @@ public sealed class ProjectTests(TestContext context)
Assert.Contains(ServerCapabilities.Projects, (await client.GetInfoAsync(context.Cancellation)).Capabilities);
}
/// <summary>
/// Owner review 1, phase 4: the server announces the settings format it reads, and takes the versions of the formats it
/// reads (1, and 2 with a turn or a look), refusing a newer one with 422 <c>newer_format</c>, nothing stored.
/// </summary>
[Test]
public async Task TheServerTakesTheSettingsFormatsItAnnounces()
{
await using var server = await TestServer.StartAsync(context, services: ArchiveModule.Register);
using (var anonymous = new ChronosClient(server.HttpBase, new CertificatePinning([]), "tests"))
Assert.Equal(ProjectSettings.CurrentVersion, (await anonymous.GetInfoAsync(context.Cancellation)).SettingsFormat);
Assert.Equal(2, ProjectSettings.CurrentVersion);
var (http, _, token) = await server.UserAsync("alberto", "editor");
using var alberto = Client(server, token);
var sid = await SequenceAsync(server, token, 2);
var main = (await alberto.ListProjectsAsync(sid)).Single(p => p.IsMain);
var head = await alberto.GetProjectHeadAsync(sid, main.Id);
var home = ProjectWire.ToHomeFrames(await alberto.GetProjectFramesAsync(sid));
var plain = Version(head, new ProjectSettings { Exposure = new ExposureSettings { ExposureOffsetEv = 0.3 } }, home);
Assert.Equal(1, plain.SettingsFormat);
var v2 = Assert.NotNull((await alberto.PushProjectVersionAsync(sid, main.Id, plain)).Version);
var turned = Version(v2, new ProjectSettings { Camera = new CameraSettings { Rotate = 90, Mirror = true }, Look = new LookSettings { Filter = "sepia" } }, home);
Assert.Equal(2, turned.SettingsFormat);
var v3 = Assert.NotNull((await alberto.PushProjectVersionAsync(sid, main.Id, turned)).Version);
Assert.Equal(2, ProjectContent.FormatOf(v3.SettingsJson));
var mirrored = ProjectSettings.FromJson(Assert.NotNull((await server.Database.Sequences.GetAsync(sid))!.SettingsJson));
Assert.Equal((90, true, "sepia"), (mirrored.Camera.Rotate, mirrored.Camera.Mirror, mirrored.Look?.Filter), "Main's head is the sequence's settings");
const string future = """{"version":3,"camera":{"rotate":90}}""";
var newer = Version(v3, new ProjectSettings(), home) with { SettingsJson = future, ContentHash = ProjectContent.Hash(future), SettingsFormat = 3 };
using (var raw = await http.PostAsJsonAsync($"/api/v1/sequences/{sid}/projects/{main.Id}/versions", newer, ProtocolJson.Default.ProjectVersionDto))
await raw.ExpectErrorAsync(HttpStatusCode.UnprocessableEntity, ProjectErrors.NewerFormat);
Assert.Equal(3, (await alberto.GetProjectAsync(sid, main.Id)).HeadNumber);
}
[Test]
public async Task TheFramesOfAHomeAreOfOneFramesVersionWithTheAliasesOfItsConversions()
{
@@ -132,6 +132,9 @@ public sealed class RenderNodeClientTests(TestContext context)
Assert.SequenceEqual(["apng", "gif", "mjpeg"], registered.Encoders.Select(e => e.Codec).Order(StringComparer.Ordinal));
// Each encoder announces its own largest output, so the server matches job sizes per codec.
Assert.True(registered.Encoders.All(e => (e.MaxWidth, e.MaxHeight) == (65535, 65535)), "per-encoder limits");
// And the settings format it renders (owner review 1, phase 4), so the server gives it only jobs it renders as asked.
var stored = Assert.NotNull(Chronos.Server.Api.Dto.Capabilities(Assert.NotNull(await server.Database.RenderNodes.GetAsync(id))));
Assert.Equal(ProjectSettings.CurrentVersion, stored.SettingsFormat);
}
[Test]
@@ -3,10 +3,14 @@ using System.Net.Http.Json;
using System.Text.Json;
using Microsoft.Extensions.DependencyInjection;
using Chronos.Core.Archiving;
using Chronos.Core.Project;
using Chronos.Data;
using Chronos.Data.Archiving;
using Chronos.Data.Processing;
using Chronos.Data.Repositories;
using Chronos.Protocol;
using Chronos.Protocol.Client;
using Chronos.Server.Api;
using Chronos.Server.Jobs;
using Chronos.Server.Storage;
using Chronos.Testing;
@@ -94,6 +98,96 @@ public sealed class RenderNodeTests(TestContext context)
Assert.Equal(uhd.Id, (await claim.ReadAsync(ProtocolJson.Default.ClaimedJob)).Job.Id);
}
/// <summary>
/// Owner review 1, phase 4: a node that does not announce its settings format (an older Chronos) reads format 1, and is
/// never given a job it would render otherwise than asked: settings of format 2 (a turn), the chosen proportions in a
/// fixed-size preset (4K at 9:16 = 2160×3840), or a sequence's settings changed to format 2 after the job was queued. A
/// node of format 2 takes them, a portrait UHD frame on an encoder announced as 4096×2304 included.
/// </summary>
[Test]
public async Task OnlyNodesThatReadTheSettingsFormatTakeTheJobsThatNeedIt()
{
await using var server = await TestServer.StartAsync(context);
var (editor, _, _) = await server.UserAsync("alberto", "editor", renderNode: true);
using var old = await editor.PostAsync("/api/v1/nodes/register", new StringContent(
"""{"clientName":"old-pc","encoders":[{"codec":"h264","name":"H.264 Encoder MFT","hardware":false,"tenBit":false}],"maxWidth":4096,"maxHeight":4096}""",
System.Text.Encoding.UTF8, "application/json"));
var older = await old.ReadAsync(ProtocolJson.Default.RenderNodeDto);
var stored = Assert.NotNull(Dto.Capabilities(Assert.NotNull(await server.Database.RenderNodes.GetAsync(older.Id))));
Assert.Equal(1, stored.SettingsFormat);
var sequence = await JobApiTests.CreateSequenceAsync(editor);
var turned = new ProjectSettings { Camera = new CameraSettings { Rotate = 90 } }.ToJson();
var portrait = new ProjectSettings { Camera = new CameraSettings { Aspect = new Auto<string>().WithManual("9:16") } }.ToJson();
var v2 = await JobApiTests.CreateAsync(editor, "render", sequence, WithSettings(H264Job(3840, 2160), turned));
var proportions = await JobApiTests.CreateAsync(editor, "render", sequence, WithSettings(H264Job(3840, 2160), portrait));
var routed = ProcessingJobs.ReadRender((await server.Database.Jobs.GetAsync(proportions.Id))!.ParametersJson).Parameters;
Assert.Equal((2160, 3840, 2), (routed.Width, routed.Height, routed.RequiredSettingsFormat), "the server sized the job posted at the preset's size");
// Queued as format 1, then the sequence's own settings took a turn.
var plain = await JobApiTests.CreateAsync(editor, "render", sequence, H264Job(3840, 2160));
Assert.Equal(1, ProcessingJobs.ReadRender((await server.Database.Jobs.GetAsync(plain.Id))!.ParametersJson).Parameters.RequiredSettingsFormat);
var row = (await server.Database.Sequences.GetAsync(sequence))!;
await server.Database.Sequences.EditAsync(sequence, new SequenceEdit { SettingsJson = turned }, row.SettingsVersion);
using (var none = await editor.PostAsync($"/api/v1/nodes/{older.Id}/claim", null)) await none.ExpectAsync(HttpStatusCode.NoContent);
// The software H.264 encoder takes portrait UHD as a long edge × short edge, on a node that knows it.
using var registered = await editor.PostAsJsonAsync("/api/v1/nodes/register", new RegisterNodeRequest("studio-pc",
[new NodeEncoder("h264", "H.264 Encoder MFT", false, false, 4096, 2304)], 4096, 2304, SettingsFormat: 2), ProtocolJson.Default.RegisterNodeRequest);
var newer = await registered.ReadAsync(ProtocolJson.Default.RenderNodeDto);
var claimed = new List<Guid>();
for (var i = 0; i < 3; i++)
{
using var claim = await editor.PostAsync($"/api/v1/nodes/{newer.Id}/claim", null);
claimed.Add((await claim.ReadAsync(ProtocolJson.Default.ClaimedJob)).Job.Id);
}
Assert.SequenceEqual(new[] { v2.Id, proportions.Id, plain.Id }.Order(), claimed.Order());
}
/// <summary>
/// An encoder's limit is a long edge × short edge on a node of format 2 (its encoders take portrait UHD within 4096×2304);
/// an older node shrinks a frame to the limit as announced, so it is held to that.
/// </summary>
[Test]
public void APortraitFrameFitsALandscapeLimitOnlyOnANodeThatKnowsIt()
{
var job = new RenderJobParameters("4K", "{}", "h264", 2160, 3840, UseProxies: false, null, RequiredSettingsFormat: 2);
NodeEncoder[] software = [new("h264", "H.264 Encoder MFT", false, false, 4096, 2304)];
var older = new RegisterNodeRequest("old-pc", software, 4096, 2304);
var newer = older with { ClientName = "studio-pc", SettingsFormat = 2 };
Assert.False(RenderNodeService.CanEncode(older, job));
Assert.True(RenderNodeService.CanEncode(newer, job));
Assert.True(RenderNodeService.Renders(newer, job));
Assert.False(RenderNodeService.Renders(older, job with { Width = 1080, Height = 1920 }), "format 2 is never sent to a format-1 node");
Assert.True(RenderNodeService.Renders(older, job with { Width = 3840, Height = 2160, RequiredSettingsFormat = 1 }));
Assert.False(RenderNodeService.CanEncode(newer, job with { Width = 2400 }), "both edges above the short limit");
}
/// <summary>A job waits for a node only while one online could render it: one of an older settings format cannot.</summary>
[Test]
public async Task AJobDoesNotWaitForNodesThatCannotReadItsSettings()
{
await using var server = await TestServer.StartAsync(context, o => o.NodeTimeoutSeconds = 60);
var (editor, _, _) = await server.UserAsync("alberto", "editor", renderNode: true);
await RegisterAsync(editor, "old-pc", "h264", 4096);
var sequence = await JobApiTests.CreateSequenceAsync(editor);
var turned = new ProjectSettings { Camera = new CameraSettings { Rotate = 90 } }.ToJson();
var created = await JobApiTests.CreateAsync(editor, "render", sequence, WithSettings(H264Job(1920, 1080), turned));
var queued = (await server.Database.Jobs.GetAsync(created.Id))!;
var parameters = ProcessingJobs.ReadRender(queued.ParametersJson).Parameters;
Assert.Equal(2, parameters.RequiredSettingsFormat);
// Waited longer than a node may stay silent: only an online node that renders it keeps it waiting.
var job = queued with { Created = DateTimeOffset.UtcNow - TimeSpan.FromSeconds(61) };
RenderNodeAvailability Availability() => new(server.Database, server.Options, TimeProvider.System);
Assert.True(await Availability().AwaitsNodeAsync(queued with { Created = DateTimeOffset.UtcNow }, parameters, context.Cancellation), "a node may be reconnecting");
Assert.False(await Availability().AwaitsNodeAsync(job, parameters, context.Cancellation), "only a node of format 1 is online");
Assert.True(await Availability().AwaitsNodeAsync(job, parameters with { RequiredSettingsFormat = 1 }, context.Cancellation), "it renders a job of format 1");
using (var registered = await editor.PostAsJsonAsync("/api/v1/nodes/register", new RegisterNodeRequest("studio-pc", [new NodeEncoder("h264", "NVENC", true, false)],
4096, 4096, SettingsFormat: 2), ProtocolJson.Default.RegisterNodeRequest))
await registered.ExpectAsync(HttpStatusCode.OK);
Assert.True(await Availability().AwaitsNodeAsync(job, parameters, context.Cancellation), "a node of format 2 is online");
}
[Test]
public async Task TheOutputUploadBecomesARenderAndFinishesTheJob()
{
@@ -244,6 +338,10 @@ public sealed class RenderNodeTests(TestContext context)
new RenderJobParameters("H.264", """{"preset":{"isAuto":false,"manual":"4k-h264"}}""", "h264", width, height, UseProxies: false, null),
ProtocolJson.Default.RenderJobParameters);
/// <summary>Render job parameters <paramref name="parametersJson"/> with <paramref name="settingsJson"/> embedded.</summary>
private static string WithSettings(string parametersJson, string settingsJson) => JsonSerializer.Serialize(
JsonSerializer.Deserialize(parametersJson, ProtocolJson.Default.RenderJobParameters)! with { SettingsJson = settingsJson }, ProtocolJson.Default.RenderJobParameters);
internal static async Task<RenderNodeDto> RegisterAsync(HttpClient client, string name, string codec, int maxWidth)
{
using var response = await client.PostAsJsonAsync("/api/v1/nodes/register",