2 Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic 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 DCP-o-matic 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 DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "compose.hpp"
23 #include "dcpomatic_assert.h"
28 #include <dcp/raw_convert.h>
29 #include <dcp/reel_asset.h>
30 #include <dcp/reel_file_asset.h>
31 DCPOMATIC_DISABLE_WARNINGS
32 #include <libxml++/libxml++.h>
33 DCPOMATIC_ENABLE_WARNINGS
34 #include <libcxml/cxml.h>
43 using std::shared_ptr;
45 using dcp::raw_convert;
48 bool operator== (Crop const & a, Crop const & b)
50 return (a.left == b.left && a.right == b.right && a.top == b.top && a.bottom == b.bottom);
54 bool operator!= (Crop const & a, Crop const & b)
60 /** @param r Resolution.
61 * @return Untranslated string representation.
64 resolution_to_string (Resolution r)
67 case Resolution::TWO_K:
69 case Resolution::FOUR_K:
73 DCPOMATIC_ASSERT (false);
79 string_to_resolution (string s)
82 return Resolution::TWO_K;
86 return Resolution::FOUR_K;
89 DCPOMATIC_ASSERT (false);
90 return Resolution::TWO_K;
94 Crop::Crop (shared_ptr<cxml::Node> node)
96 left = node->number_child<int> ("LeftCrop");
97 right = node->number_child<int> ("RightCrop");
98 top = node->number_child<int> ("TopCrop");
99 bottom = node->number_child<int> ("BottomCrop");
104 Crop::as_xml (xmlpp::Node* node) const
106 node->add_child("LeftCrop")->add_child_text (raw_convert<string> (left));
107 node->add_child("RightCrop")->add_child_text (raw_convert<string> (right));
108 node->add_child("TopCrop")->add_child_text (raw_convert<string> (top));
109 node->add_child("BottomCrop")->add_child_text (raw_convert<string> (bottom));
114 string_to_text_type (string s)
116 if (s == "unknown") {
117 return TextType::UNKNOWN;
118 } else if (s == "open-subtitle") {
119 return TextType::OPEN_SUBTITLE;
120 } else if (s == "closed-caption") {
121 return TextType::CLOSED_CAPTION;
123 throw MetadataError (String::compose ("Unknown text type %1", s));
129 text_type_to_string (TextType t)
132 case TextType::UNKNOWN:
134 case TextType::OPEN_SUBTITLE:
135 return "open-subtitle";
136 case TextType::CLOSED_CAPTION:
137 return "closed-caption";
139 DCPOMATIC_ASSERT (false);
145 text_type_to_name (TextType t)
148 case TextType::UNKNOWN:
149 return _("Timed text");
150 case TextType::OPEN_SUBTITLE:
151 return _("Open subtitles");
152 case TextType::CLOSED_CAPTION:
153 return _("Closed captions");
155 DCPOMATIC_ASSERT (false);
161 video_frame_type_to_string (VideoFrameType t)
164 case VideoFrameType::TWO_D:
166 case VideoFrameType::THREE_D:
168 case VideoFrameType::THREE_D_LEFT_RIGHT:
169 return "3d-left-right";
170 case VideoFrameType::THREE_D_TOP_BOTTOM:
171 return "3d-top-bottom";
172 case VideoFrameType::THREE_D_ALTERNATE:
173 return "3d-alternate";
174 case VideoFrameType::THREE_D_LEFT:
176 case VideoFrameType::THREE_D_RIGHT:
179 DCPOMATIC_ASSERT (false);
182 DCPOMATIC_ASSERT (false);
187 string_to_video_frame_type (string s)
190 return VideoFrameType::TWO_D;
191 } else if (s == "3d") {
192 return VideoFrameType::THREE_D;
193 } else if (s == "3d-left-right") {
194 return VideoFrameType::THREE_D_LEFT_RIGHT;
195 } else if (s == "3d-top-bottom") {
196 return VideoFrameType::THREE_D_TOP_BOTTOM;
197 } else if (s == "3d-alternate") {
198 return VideoFrameType::THREE_D_ALTERNATE;
199 } else if (s == "3d-left") {
200 return VideoFrameType::THREE_D_LEFT;
201 } else if (s == "3d-right") {
202 return VideoFrameType::THREE_D_RIGHT;
205 DCPOMATIC_ASSERT (false);
209 CPLSummary::CPLSummary (boost::filesystem::path p)
210 : dcp_directory (p.leaf().string())
214 vector<dcp::VerificationNote> notes;
216 for (auto i: notes) {
217 if (i.code() != dcp::VerificationNote::Code::EXTERNAL_ASSET) {
218 /* It's not just a warning about this DCP being a VF */
219 throw dcp::ReadError(dcp::note_to_string(i));
223 cpl_id = dcp.cpls().front()->id();
224 cpl_annotation_text = dcp.cpls().front()->annotation_text();
225 cpl_file = dcp.cpls().front()->file().get();
228 for (auto j: dcp.cpls()) {
229 for (auto k: j->reel_file_assets()) {
230 if (k->encrypted()) {
236 boost::system::error_code ec;
237 auto last_write = boost::filesystem::last_write_time (p, ec);
238 last_write_time = ec ? 0 : last_write;
242 bool operator== (NamedChannel const& a, NamedChannel const& b)
244 return a.name == b.name && a.index == b.index;
249 video_range_to_string (VideoRange r)
252 case VideoRange::FULL:
254 case VideoRange::VIDEO:
257 DCPOMATIC_ASSERT (false);
263 string_to_video_range (string s)
266 return VideoRange::FULL;
267 } else if (s == "video") {
268 return VideoRange::VIDEO;
271 DCPOMATIC_ASSERT (false);
272 return VideoRange::FULL;