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"
26 #include <dcp/raw_convert.h>
27 #include <dcp/reel_asset.h>
28 #include <dcp/reel_file_asset.h>
29 #include <dcp/warnings.h>
30 LIBDCP_DISABLE_WARNINGS
31 #include <libxml++/libxml++.h>
32 LIBDCP_ENABLE_WARNINGS
33 #include <libcxml/cxml.h>
41 using std::shared_ptr;
43 using dcp::raw_convert;
46 /** @param r Resolution.
47 * @return Untranslated string representation.
50 resolution_to_string (Resolution r)
53 case Resolution::TWO_K:
55 case Resolution::FOUR_K:
59 DCPOMATIC_ASSERT (false);
65 string_to_resolution (string s)
68 return Resolution::TWO_K;
72 return Resolution::FOUR_K;
75 DCPOMATIC_ASSERT (false);
76 return Resolution::TWO_K;
81 string_to_text_type (string s)
84 return TextType::UNKNOWN;
85 } else if (s == "open-subtitle") {
86 return TextType::OPEN_SUBTITLE;
87 } else if (s == "closed-caption") {
88 return TextType::CLOSED_CAPTION;
90 throw MetadataError (String::compose ("Unknown text type %1", s));
95 text_type_to_string (TextType t)
98 case TextType::UNKNOWN:
100 case TextType::OPEN_SUBTITLE:
101 return "open-subtitle";
102 case TextType::CLOSED_CAPTION:
103 return "closed-caption";
105 DCPOMATIC_ASSERT (false);
110 text_type_to_name (TextType t)
113 case TextType::UNKNOWN:
114 return _("Timed text");
115 case TextType::OPEN_SUBTITLE:
116 return _("Open subtitles");
117 case TextType::CLOSED_CAPTION:
118 return _("Closed captions");
120 DCPOMATIC_ASSERT (false);
125 video_frame_type_to_string (VideoFrameType t)
128 case VideoFrameType::TWO_D:
130 case VideoFrameType::THREE_D:
132 case VideoFrameType::THREE_D_LEFT_RIGHT:
133 return "3d-left-right";
134 case VideoFrameType::THREE_D_TOP_BOTTOM:
135 return "3d-top-bottom";
136 case VideoFrameType::THREE_D_ALTERNATE:
137 return "3d-alternate";
138 case VideoFrameType::THREE_D_LEFT:
140 case VideoFrameType::THREE_D_RIGHT:
143 DCPOMATIC_ASSERT (false);
146 DCPOMATIC_ASSERT (false);
150 string_to_video_frame_type (string s)
153 return VideoFrameType::TWO_D;
154 } else if (s == "3d") {
155 return VideoFrameType::THREE_D;
156 } else if (s == "3d-left-right") {
157 return VideoFrameType::THREE_D_LEFT_RIGHT;
158 } else if (s == "3d-top-bottom") {
159 return VideoFrameType::THREE_D_TOP_BOTTOM;
160 } else if (s == "3d-alternate") {
161 return VideoFrameType::THREE_D_ALTERNATE;
162 } else if (s == "3d-left") {
163 return VideoFrameType::THREE_D_LEFT;
164 } else if (s == "3d-right") {
165 return VideoFrameType::THREE_D_RIGHT;
168 DCPOMATIC_ASSERT (false);
171 CPLSummary::CPLSummary (boost::filesystem::path p)
172 : dcp_directory (p.leaf().string())
176 vector<dcp::VerificationNote> notes;
178 for (auto i: notes) {
179 if (i.code() != dcp::VerificationNote::Code::EXTERNAL_ASSET) {
180 /* It's not just a warning about this DCP being a VF */
181 throw dcp::ReadError(dcp::note_to_string(i));
185 cpl_id = dcp.cpls().front()->id();
186 cpl_annotation_text = dcp.cpls().front()->annotation_text();
187 cpl_file = dcp.cpls().front()->file().get();
190 for (auto j: dcp.cpls()) {
191 for (auto k: j->reel_file_assets()) {
192 if (k->encrypted()) {
198 boost::system::error_code ec;
199 auto last_write = boost::filesystem::last_write_time (p, ec);
200 last_write_time = ec ? 0 : last_write;
204 bool operator== (NamedChannel const& a, NamedChannel const& b)
206 return a.name == b.name && a.index == b.index;
211 video_range_to_string (VideoRange r)
214 case VideoRange::FULL:
216 case VideoRange::VIDEO:
219 DCPOMATIC_ASSERT (false);
225 string_to_video_range (string s)
228 return VideoRange::FULL;
229 } else if (s == "video") {
230 return VideoRange::VIDEO;
233 DCPOMATIC_ASSERT (false);
234 return VideoRange::FULL;