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"
24 #include <dcp/raw_convert.h>
27 #include <dcp/reel_mxf.h>
28 #include <dcp/reel_asset.h>
29 #include <libxml++/libxml++.h>
30 #include <libcxml/cxml.h>
31 #include <boost/foreach.hpp>
38 using boost::shared_ptr;
39 using dcp::raw_convert;
41 bool operator== (Crop const & a, Crop const & b)
43 return (a.left == b.left && a.right == b.right && a.top == b.top && a.bottom == b.bottom);
46 bool operator!= (Crop const & a, Crop const & b)
51 /** @param r Resolution.
52 * @return Untranslated string representation.
55 resolution_to_string (Resolution r)
64 DCPOMATIC_ASSERT (false);
70 string_to_resolution (string s)
80 DCPOMATIC_ASSERT (false);
84 Crop::Crop (shared_ptr<cxml::Node> node)
86 left = node->number_child<int> ("LeftCrop");
87 right = node->number_child<int> ("RightCrop");
88 top = node->number_child<int> ("TopCrop");
89 bottom = node->number_child<int> ("BottomCrop");
93 Crop::as_xml (xmlpp::Node* node) const
95 node->add_child("LeftCrop")->add_child_text (raw_convert<string> (left));
96 node->add_child("RightCrop")->add_child_text (raw_convert<string> (right));
97 node->add_child("TopCrop")->add_child_text (raw_convert<string> (top));
98 node->add_child("BottomCrop")->add_child_text (raw_convert<string> (bottom));
102 string_to_text_type (string s)
104 if (s == "unknown") {
106 } else if (s == "open-subtitle") {
107 return TEXT_OPEN_SUBTITLE;
108 } else if (s == "closed-caption") {
109 return TEXT_CLOSED_CAPTION;
111 throw MetadataError (String::compose ("Unknown text type %1", s));
116 text_type_to_string (TextType t)
121 case TEXT_OPEN_SUBTITLE:
122 return "open-subtitle";
123 case TEXT_CLOSED_CAPTION:
124 return "closed-caption";
126 DCPOMATIC_ASSERT (false);
131 text_type_to_name (TextType t)
135 return _("Timed text");
136 case TEXT_OPEN_SUBTITLE:
137 return _("Open subtitles");
138 case TEXT_CLOSED_CAPTION:
139 return _("Closed captions");
141 DCPOMATIC_ASSERT (false);
146 video_frame_type_to_string (VideoFrameType t)
149 case VIDEO_FRAME_TYPE_2D:
151 case VIDEO_FRAME_TYPE_3D:
153 case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
154 return "3d-left-right";
155 case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
156 return "3d-top-bottom";
157 case VIDEO_FRAME_TYPE_3D_ALTERNATE:
158 return "3d-alternate";
159 case VIDEO_FRAME_TYPE_3D_LEFT:
161 case VIDEO_FRAME_TYPE_3D_RIGHT:
164 DCPOMATIC_ASSERT (false);
167 DCPOMATIC_ASSERT (false);
171 string_to_video_frame_type (string s)
174 return VIDEO_FRAME_TYPE_2D;
175 } else if (s == "3d") {
176 return VIDEO_FRAME_TYPE_3D;
177 } else if (s == "3d-left-right") {
178 return VIDEO_FRAME_TYPE_3D_LEFT_RIGHT;
179 } else if (s == "3d-top-bottom") {
180 return VIDEO_FRAME_TYPE_3D_TOP_BOTTOM;
181 } else if (s == "3d-alternate") {
182 return VIDEO_FRAME_TYPE_3D_ALTERNATE;
183 } else if (s == "3d-left") {
184 return VIDEO_FRAME_TYPE_3D_LEFT;
185 } else if (s == "3d-right") {
186 return VIDEO_FRAME_TYPE_3D_RIGHT;
189 DCPOMATIC_ASSERT (false);
192 CPLSummary::CPLSummary (boost::filesystem::path p)
193 : dcp_directory (p.leaf().string())
198 cpl_id = dcp.cpls().front()->id();
199 cpl_annotation_text = dcp.cpls().front()->annotation_text();
200 cpl_file = dcp.cpls().front()->file().get();
203 BOOST_FOREACH (shared_ptr<dcp::CPL> j, dcp.cpls()) {
204 BOOST_FOREACH (shared_ptr<const dcp::ReelAsset> k, j->reel_assets()) {
205 shared_ptr<const dcp::ReelMXF> mxf = boost::dynamic_pointer_cast<const dcp::ReelMXF> (k);
206 if (mxf && mxf->key_id()) {
212 last_write_time = boost::filesystem::last_write_time (p);