Server sequences that are not in the local index open through a RemoteSequenceSource: proxies from the cache, project from the server's settings with their version (a 409 merges again), analysis report from the server, analyses and renders posted as server jobs (one per preset) and followed through the server's events. Set hero now reaches the index (SequenceEdit.HeroFrameId) so the Library card shows it. The Export tab gains the Sync option (remembered in the project) and restores "Save both" copies through undo. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
84 lines
4.1 KiB
C#
84 lines
4.1 KiB
C#
using Titano.Core.Analysis;
|
|
using Titano.Core.Analysis.Deep;
|
|
using Titano.Core.Imaging;
|
|
using Titano.Core.Model;
|
|
using Titano.Core.Project;
|
|
using Titano.Data.Archiving.Jobs;
|
|
|
|
namespace Titano.App.Editor;
|
|
|
|
/// <summary>
|
|
/// Where the sequence open in the editor lives: the local archive (<see cref="LocalSequenceSource"/>) or a server the
|
|
/// client is connected to (<see cref="RemoteSequenceSource"/>: proxies from the cache, project and jobs through the
|
|
/// API). The editor reads frames, saves the project, queues jobs and follows them only through this interface.
|
|
/// </summary>
|
|
public interface ISequenceSource : IAsyncDisposable
|
|
{
|
|
/// <summary>
|
|
/// The sequence lives on a server (BRIEF §14.5 "edit with proxies, render where the originals are"): its project is
|
|
/// saved there and its renders and analyses run there, one job per preset.
|
|
/// </summary>
|
|
bool IsRemote { get; }
|
|
|
|
/// <summary>A job that may concern the sequence changed (any thread): this PC's engine, or the server's events.</summary>
|
|
event Action<Job>? JobChanged;
|
|
|
|
/// <summary>Everything the editor shows of the sequence; read off the UI thread.</summary>
|
|
/// <exception cref="InvalidDataException">The project cannot be read (corrupt, or written by a newer Titano).</exception>
|
|
Task<SequenceContent> LoadAsync(CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Frame <paramref name="index"/> in linear light, oriented, long edge at most <paramref name="maxLongEdge"/>; null
|
|
/// when the frame cannot be read. The caller owns the buffer.
|
|
/// </summary>
|
|
ValueTask<ImageBuffer?> DecodeAsync(int index, int maxLongEdge, DecodePurpose purpose, CancellationToken cancellationToken);
|
|
|
|
/// <summary>
|
|
/// Stores <paramref name="project"/>, edited from <paramref name="basis"/> (the version last loaded or saved). A
|
|
/// change made meanwhile by someone else is kept where this edit left the value alone (<see cref="ProjectMerge"/>).
|
|
/// Returns the stored project.
|
|
/// </summary>
|
|
Task<ProjectSettings> SaveProjectAsync(ProjectSettings project, ProjectSettings basis, CancellationToken cancellationToken);
|
|
|
|
/// <summary>Queues an analysis or render job for the sequence; returns the job id.</summary>
|
|
Task<Guid> SubmitAsync(ArchiveJobRequest request, CancellationToken cancellationToken);
|
|
|
|
/// <summary>Recent jobs that may concern the sequence (queued, running, finished), for the busy state and the cost of Analyse.</summary>
|
|
Task<IReadOnlyList<Job>> ListJobsAsync(CancellationToken cancellationToken);
|
|
}
|
|
|
|
/// <summary>A sequence as the editor opens it.</summary>
|
|
/// <param name="Frames">Frame rows in index order.</param>
|
|
/// <param name="Light">Light analysis of the frame metadata (BRIEF §10.1).</param>
|
|
/// <param name="Deep">The saved deep analysis when it describes the current frames, else null.</param>
|
|
/// <param name="SourceWidth">Dominant oriented full-resolution width (0 when unknown).</param>
|
|
/// <param name="ExportsFolder">Default output folder of renders; null when the sequence is not on this PC.</param>
|
|
/// <param name="Renders">Finished renders, newest first (an empty output path when the file is not on this PC).</param>
|
|
/// <param name="SavedCopies">This PC's projects kept by "Save both" when a sync conflict was settled, newest first.</param>
|
|
public sealed record SequenceContent(
|
|
Sequence Sequence,
|
|
IReadOnlyList<Frame> Frames,
|
|
ProjectSettings Project,
|
|
LightAnalysisReport Light,
|
|
DeepAnalysisReport? Deep,
|
|
int SourceWidth,
|
|
int SourceHeight,
|
|
string? ExportsFolder,
|
|
IReadOnlyList<Render> Renders,
|
|
IReadOnlyList<SavedCopy> SavedCopies)
|
|
{
|
|
/// <summary>Flags of frames that never reach a render (as the render job skips them).</summary>
|
|
public const FrameFlags NotRendered = FrameFlags.Missing | FrameFlags.Corrupt | FrameFlags.Excluded | FrameFlags.Undecodable;
|
|
|
|
public int Count => Frames.Count;
|
|
|
|
/// <summary>Frames the render skips besides the project's exclusions.</summary>
|
|
public IEnumerable<int> NotRenderable()
|
|
{
|
|
for (var i = 0; i < Frames.Count; i++)
|
|
{
|
|
if ((Frames[i].Flags & NotRendered) != 0) yield return i;
|
|
}
|
|
}
|
|
}
|