2 Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
4 This file is part of libdcp.
6 libdcp is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 libdcp is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with libdcp. If not, see <http://www.gnu.org/licenses/>.
19 In addition, as a special exception, the copyright holders give
20 permission to link the code of portions of this program with the
21 OpenSSL library under certain conditions as described in each
22 individual source file, and distribute linked combinations
25 You must obey the GNU General Public License in all respects
26 for all of the code used other than OpenSSL. If you modify
27 file(s) with this exception, you may extend this exception to your
28 version of the file(s), but you are not obligated to do so. If you
29 do not wish to do so, delete this exception statement from your
30 version. If you delete this exception statement from all source
31 files in the program, then also delete it here.
35 #include "compose.hpp"
40 #include "reel_picture_asset.h"
41 #include "reel_sound_asset.h"
42 #include "reel_subtitle_asset.h"
44 #include "verify_report.h"
47 using std::shared_ptr;
50 using boost::optional;
54 void write_line(File& file, string format)
56 file.puts(string(format + "\n").c_str());
60 template <typename... Args>
61 void write_line(File& file, string format, Args... args)
63 file.puts(String::compose(format + "\n", std::forward<Args>(args)...).c_str());
68 dcp::verify_report(dcp::VerificationResult const& result, Formatter& formatter)
70 auto document = formatter.document();
71 auto body = formatter.body();
73 formatter.heading("DCP verification report");
75 if (result.dcps.size() > 1) {
76 formatter.subheading("DCPs");
78 formatter.subheading("DCP");
81 auto reel_asset_details = [&formatter](shared_ptr<dcp::ReelAsset> asset) {
82 formatter.list_item(String::compose("UUID: %1", asset->id()));
83 formatter.list_item(String::compose("Intrinsic duration: %1", asset->intrinsic_duration()));
84 formatter.list_item(String::compose("Entry point: %1", asset->entry_point().get_value_or(0)));
85 formatter.list_item(String::compose("Duration: %1", asset->duration().get_value_or(0)));
86 if (asset->annotation_text()) {
87 formatter.list_item(String::compose("Annotation text: %1", *asset->annotation_text()));
91 auto write_notes = [&formatter](dcp::VerificationResult const& result, optional<string> cpl_id) {
92 for (auto note: result.notes) {
93 if (note.cpl_id() == cpl_id) {
94 auto const note_as_string = dcp::note_to_string(note, formatter.process_string(), formatter.process_filename());
95 if (note.type() == dcp::VerificationNote::Type::OK) {
96 formatter.list_item(note_as_string, string("ok"));
97 } else if (note.type() == dcp::VerificationNote::Type::WARNING) {
98 formatter.list_item(note_as_string, string("warning"));
99 } else if (note.type() == dcp::VerificationNote::Type::ERROR) {
100 formatter.list_item(note_as_string, string("error"));
106 for (auto dcp: result.dcps) {
107 auto ul = formatter.unordered_list();
108 for (auto cpl: dcp->cpls()) {
109 formatter.list_item(String::compose("CPL ID: %1", cpl->id()));
111 for (auto reel: cpl->reels()) {
112 formatter.list_item(String::compose("Reel: %1", reel_index++));
113 auto ul2 = formatter.unordered_list();
114 if (auto pic = reel->main_picture()) {
115 formatter.list_item("Main picture");
116 auto ul3 = formatter.unordered_list();
117 reel_asset_details(pic);
118 formatter.list_item(String::compose("Frame rate: %1", pic->frame_rate().numerator));
119 formatter.list_item(String::compose("Screen aspect ratio: %1x%2", pic->screen_aspect_ratio().numerator, pic->screen_aspect_ratio().denominator));
121 if (auto sound = reel->main_sound()) {
122 formatter.list_item("Main sound");
123 auto ul3 = formatter.unordered_list();
124 reel_asset_details(sound);
126 if (auto sub = reel->main_subtitle()) {
127 formatter.list_item("Main subtitle");
128 auto ul3 = formatter.unordered_list();
129 reel_asset_details(sub);
130 if (sub->language()) {
131 formatter.list_item(String::compose("Language: %1", *sub->language()));
135 write_notes(result, cpl->id());
139 if (std::count_if(result.notes.begin(), result.notes.end(), [](VerificationNote const& note) { return !note.cpl_id(); }) > 0) {
140 formatter.subheading("Report");
141 write_notes(result, {});