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; /// /// Where the sequence open in the editor lives: the local archive () or a server the /// client is connected to (: 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. /// public interface ISequenceSource : IAsyncDisposable { /// /// 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. /// bool IsRemote { get; } /// A job that may concern the sequence changed (any thread): this PC's engine, or the server's events. event Action? JobChanged; /// Everything the editor shows of the sequence; read off the UI thread. /// The project cannot be read (corrupt, or written by a newer Titano). Task LoadAsync(CancellationToken cancellationToken); /// /// Frame in linear light, oriented, long edge at most ; null /// when the frame cannot be read. The caller owns the buffer. /// ValueTask DecodeAsync(int index, int maxLongEdge, DecodePurpose purpose, CancellationToken cancellationToken); /// /// Stores , edited from (the version last loaded or saved). A /// change made meanwhile by someone else is kept where this edit left the value alone (). /// Returns the stored project. /// Task SaveProjectAsync(ProjectSettings project, ProjectSettings basis, CancellationToken cancellationToken); /// Queues an analysis or render job for the sequence; returns the job id. Task SubmitAsync(ArchiveJobRequest request, CancellationToken cancellationToken); /// Recent jobs that may concern the sequence (queued, running, finished), for the busy state and the cost of Analyse. Task> ListJobsAsync(CancellationToken cancellationToken); } /// A sequence as the editor opens it. /// Frame rows in index order. /// Light analysis of the frame metadata (BRIEF §10.1). /// The saved deep analysis when it describes the current frames, else null. /// Dominant oriented full-resolution width (0 when unknown). /// Default output folder of renders; null when the sequence is not on this PC. /// Finished renders, newest first (an empty output path when the file is not on this PC). /// This PC's projects kept by "Save both" when a sync conflict was settled, newest first. public sealed record SequenceContent( Sequence Sequence, IReadOnlyList Frames, ProjectSettings Project, LightAnalysisReport Light, DeepAnalysisReport? Deep, int SourceWidth, int SourceHeight, string? ExportsFolder, IReadOnlyList Renders, IReadOnlyList SavedCopies) { /// Flags of frames that never reach a render (as the render job skips them). public const FrameFlags NotRendered = FrameFlags.Missing | FrameFlags.Corrupt | FrameFlags.Excluded | FrameFlags.Undecodable; public int Count => Frames.Count; /// Frames the render skips besides the project's exclusions. public IEnumerable NotRenderable() { for (var i = 0; i < Frames.Count; i++) { if ((Frames[i].Flags & NotRendered) != 0) yield return i; } } }