#include "core/render_report.hpp"
#include <sstream>
namespace smartcut::core {
RenderReport RenderReport::from_plan(const RenderPlan& plan) { RenderReport report; report.planned_operations_ = plan.operations().size(); report.audio_ready_ = !plan.operations().empty(); for (std::size_t i = 0; i < plan.operations().size(); ++i) { const auto& operation = plan.operations()[i]; report.copy_operations_ += operation.kind == "CopyVideoPackets"; report.encode_operations_ += operation.kind == "EncodeVideoBoundary"; report.audio_operations_ += operation.stream_type == "audio"; report.audio_ready_ = report.audio_ready_ && operation.audio_policy == "copy-complete-source-audio-packets" && operation.audio_stream != static_cast<std::size_t>(-1) && operation.audio_time_base_num > 0 && operation.audio_time_base_den > 0; if (operation.stream_type == "video" && operation.kind == "CopyVideoPackets") report.ranges_.push_back({i, operation.source_uuid, operation.first_frame, operation.end_frame, "packet-copy-selected"}); } return report; }
std::string RenderReport::to_json() const { std::ostringstream output; output << "{\"schema\":\"render-report-v1\",\"planned_operations\":" << planned_operations_ << ",\"copy_operations\":" << copy_operations_ << ",\"encode_operations\":" << encode_operations_ << ",\"audio_operations\":" << audio_operations_ << ",\"audio_ready\":" << (audio_ready_ ? "true" : "false") << ",\"completion\":\"" << (audio_ready_ ? "PENDING-VALIDATION" : "BLOCKED-AUDIO-POLICY") << "\",\"copy_ranges\":["; for (std::size_t i = 0; i < ranges_.size(); ++i) { if (i) output << ','; const auto& range = ranges_[i]; output << "{\"operation_index\":" << range.operation_index << ",\"source_uuid\":\"" << range.source_uuid << "\",\"first_frame\":" << range.first_frame << ",\"end_frame\":" << range.end_frame << ",\"execution\":\"" << range.execution << "\"}"; } output << "],\"validation\":\"pending-executor\"}"; return output.str(); }
}
