2 Copyright (C) 2013-2018 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>
25 #include <libxml++/libxml++.h>
26 #include <libcxml/cxml.h>
33 using boost::shared_ptr;
34 using dcp::raw_convert;
36 bool operator== (Crop const & a, Crop const & b)
38 return (a.left == b.left && a.right == b.right && a.top == b.top && a.bottom == b.bottom);
41 bool operator!= (Crop const & a, Crop const & b)
46 /** @param r Resolution.
47 * @return Untranslated string representation.
50 resolution_to_string (Resolution r)
59 DCPOMATIC_ASSERT (false);
65 string_to_resolution (string s)
75 DCPOMATIC_ASSERT (false);
79 Crop::Crop (shared_ptr<cxml::Node> node)
81 left = node->number_child<int> ("LeftCrop");
82 right = node->number_child<int> ("RightCrop");
83 top = node->number_child<int> ("TopCrop");
84 bottom = node->number_child<int> ("BottomCrop");
88 Crop::as_xml (xmlpp::Node* node) const
90 node->add_child("LeftCrop")->add_child_text (raw_convert<string> (left));
91 node->add_child("RightCrop")->add_child_text (raw_convert<string> (right));
92 node->add_child("TopCrop")->add_child_text (raw_convert<string> (top));
93 node->add_child("BottomCrop")->add_child_text (raw_convert<string> (bottom));
97 string_to_text_type (string s)
101 } else if (s == "open-subtitle") {
102 return TEXT_OPEN_SUBTITLE;
103 } else if (s == "closed-caption") {
104 return TEXT_CLOSED_CAPTION;
106 throw MetadataError (String::compose ("Unknown text type %1", s));
111 text_type_to_string (TextType t)
116 case TEXT_OPEN_SUBTITLE:
117 return "open-subtitle";
118 case TEXT_CLOSED_CAPTION:
119 return "closed-caption";
121 DCPOMATIC_ASSERT (false);
126 text_type_to_name (TextType t)
130 return _("Timed text");
131 case TEXT_OPEN_SUBTITLE:
132 return _("Open subtitles");
133 case TEXT_CLOSED_CAPTION:
134 return _("Closed captions");
136 DCPOMATIC_ASSERT (false);
141 video_frame_type_to_string (VideoFrameType t)
144 case VIDEO_FRAME_TYPE_2D:
146 case VIDEO_FRAME_TYPE_3D:
148 case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
149 return "3d-left-right";
150 case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
151 return "3d-top-bottom";
152 case VIDEO_FRAME_TYPE_3D_ALTERNATE:
153 return "3d-alternate";
154 case VIDEO_FRAME_TYPE_3D_LEFT:
156 case VIDEO_FRAME_TYPE_3D_RIGHT:
159 DCPOMATIC_ASSERT (false);
162 DCPOMATIC_ASSERT (false);
166 string_to_video_frame_type (string s)
169 return VIDEO_FRAME_TYPE_2D;
170 } else if (s == "3d") {
171 return VIDEO_FRAME_TYPE_3D;
172 } else if (s == "3d-left-right") {
173 return VIDEO_FRAME_TYPE_3D_LEFT_RIGHT;
174 } else if (s == "3d-top-bottom") {
175 return VIDEO_FRAME_TYPE_3D_TOP_BOTTOM;
176 } else if (s == "3d-alternate") {
177 return VIDEO_FRAME_TYPE_3D_ALTERNATE;
178 } else if (s == "3d-left") {
179 return VIDEO_FRAME_TYPE_3D_LEFT;
180 } else if (s == "3d-right") {
181 return VIDEO_FRAME_TYPE_3D_RIGHT;
184 DCPOMATIC_ASSERT (false);