From 72ba78579a92659c6a5323caa478fe6b02e0abe21ed3f20c42573fbf68658eb1 Mon Sep 17 00:00:00 2001 From: copecone Date: Tue, 18 Aug 2026 14:16:40 +0900 Subject: [PATCH] Add `RenderResult` --- API/RenderResult.cs | 70 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 API/RenderResult.cs diff --git a/API/RenderResult.cs b/API/RenderResult.cs new file mode 100644 index 0000000..e560bf8 --- /dev/null +++ b/API/RenderResult.cs @@ -0,0 +1,70 @@ +using System; + +namespace ADOFAIRenderer.API +{ + /// + /// Represents the result and metadata of a completed or cancelled render session. + /// + public class RenderResult + { + /// + /// Indicates whether the rendering session completed successfully. + /// + public bool Success { get; } + + /// + /// The absolute output path of the rendered video file. Empty string if rendering failed or output was not created. + /// + public string OutputPath { get; } + + /// + /// Total number of video frames sent to the encoder. + /// + public long TotalFrames { get; } + + /// + /// The calculated video duration in seconds (based on TotalFrames and FPS). + /// + public double VideoDuration { get; } + + /// + /// Total wall-clock time spent rendering. + /// + public TimeSpan RenderDuration { get; } + + /// + /// File size of the output video in bytes (0 if failed or file does not exist). + /// + public long FileSizeBytes { get; } + + /// + /// Error message or reason if rendering failed or was cancelled; null on success. + /// + public string? ErrorMessage { get; } + + public RenderResult( + bool success, + string outputPath, + long totalFrames, + double videoDuration, + TimeSpan renderDuration, + long fileSizeBytes = 0, + string? errorMessage = null) + { + Success = success; + OutputPath = outputPath; + TotalFrames = totalFrames; + VideoDuration = videoDuration; + RenderDuration = renderDuration; + FileSizeBytes = fileSizeBytes; + ErrorMessage = errorMessage; + } + + public override string ToString() + { + return Success + ? $"[RenderResult: Success, Output={OutputPath}, Frames={TotalFrames}, VideoDuration={VideoDuration:F2}s, Time={RenderDuration.TotalSeconds:F1}s, Size={FileSizeBytes / 1024.0 / 1024.0:F2}MB]" + : $"[RenderResult: Failed/Cancelled, Error={ErrorMessage ?? "Unknown"}]"; + } + } +}