using Titano.Core.Analysis.Deep;
using Titano.Core.Archiving;
using Titano.Core.Imaging;
using Titano.Core.Model;
namespace Titano.Data.Processing;
///
/// Saved deep-analysis reports (.titano/analysis.json, BRIEF §10.2) for hosts that hand them on: a server serves
/// one to the editors of its clients only while it still describes the sequence (§14.5).
///
public static class DeepReports
{
///
/// The saved report of when it describes its frames as a host with
/// reads them now; null when there is none, it covers another number of frames, or it
/// found unreadable a frame that has been read from its proxy since (an original that host cannot decode, whose proxy
/// arrived after the analysis): its verdict and its advice to exclude that frame no longer hold.
///
public static async Task ReadCurrentAsync(TitanoDatabase db, Archive archive, Sequence sequence, ImageDecoder decoder,
CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(archive);
ArgumentNullException.ThrowIfNull(sequence);
var frames = await SequenceFrames.LoadAsync(db, archive, sequence, useProxies: false, decoder, cancellationToken).ConfigureAwait(false);
return SequenceAnalyser.ReadReport(new ArchivePaths(archive.RootPath).Sequence(sequence.Folder), frames);
}
}