2 Copyright (C) 2013 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>
31 using boost::shared_ptr;
32 using dcp::raw_convert;
34 bool operator== (Crop const & a, Crop const & b)
36 return (a.left == b.left && a.right == b.right && a.top == b.top && a.bottom == b.bottom);
39 bool operator!= (Crop const & a, Crop const & b)
44 /** @param r Resolution.
45 * @return Untranslated string representation.
48 resolution_to_string (Resolution r)
57 DCPOMATIC_ASSERT (false);
63 string_to_resolution (string s)
73 DCPOMATIC_ASSERT (false);
77 Crop::Crop (shared_ptr<cxml::Node> node)
79 left = node->number_child<int> ("LeftCrop");
80 right = node->number_child<int> ("RightCrop");
81 top = node->number_child<int> ("TopCrop");
82 bottom = node->number_child<int> ("BottomCrop");
86 Crop::as_xml (xmlpp::Node* node) const
88 node->add_child("LeftCrop")->add_child_text (raw_convert<string> (left));
89 node->add_child("RightCrop")->add_child_text (raw_convert<string> (right));
90 node->add_child("TopCrop")->add_child_text (raw_convert<string> (top));
91 node->add_child("BottomCrop")->add_child_text (raw_convert<string> (bottom));
95 string_to_text_type (string s)
97 if (s == "subtitle") {
99 } else if (s == "ccap") {
100 return TEXT_CLOSED_CAPTION;
102 throw MetadataError (String::compose ("Unknown text type %1", s));
107 text_type_to_string (TextType t)
112 case TEXT_CLOSED_CAPTION:
115 DCPOMATIC_ASSERT (false);
120 video_frame_type_to_string (VideoFrameType t)
123 case VIDEO_FRAME_TYPE_2D:
125 case VIDEO_FRAME_TYPE_3D:
127 case VIDEO_FRAME_TYPE_3D_LEFT_RIGHT:
128 return "3d-left-right";
129 case VIDEO_FRAME_TYPE_3D_TOP_BOTTOM:
130 return "3d-top-bottom";
131 case VIDEO_FRAME_TYPE_3D_ALTERNATE:
132 return "3d-alternate";
133 case VIDEO_FRAME_TYPE_3D_LEFT:
135 case VIDEO_FRAME_TYPE_3D_RIGHT:
138 DCPOMATIC_ASSERT (false);
141 DCPOMATIC_ASSERT (false);
145 string_to_video_frame_type (string s)
148 return VIDEO_FRAME_TYPE_2D;
149 } else if (s == "3d") {
150 return VIDEO_FRAME_TYPE_3D;
151 } else if (s == "3d-left-right") {
152 return VIDEO_FRAME_TYPE_3D_LEFT_RIGHT;
153 } else if (s == "3d-top-bottom") {
154 return VIDEO_FRAME_TYPE_3D_TOP_BOTTOM;
155 } else if (s == "3d-alternate") {
156 return VIDEO_FRAME_TYPE_3D_ALTERNATE;
157 } else if (s == "3d-left") {
158 return VIDEO_FRAME_TYPE_3D_LEFT;
159 } else if (s == "3d-right") {
160 return VIDEO_FRAME_TYPE_3D_RIGHT;
163 DCPOMATIC_ASSERT (false);