2 Copyright (C) 2020 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 "atmos_content.h"
24 #include <dcp/raw_convert.h>
25 DCPOMATIC_DISABLE_WARNINGS
26 #include <libxml++/libxml++.h>
27 DCPOMATIC_ENABLE_WARNINGS
31 using boost::shared_ptr;
34 int const AtmosContentProperty::EDIT_RATE = 700;
37 AtmosContent::AtmosContent (Content* parent)
38 : ContentPart (parent)
45 AtmosContent::AtmosContent (Content* parent, cxml::ConstNodePtr node)
46 : ContentPart (parent)
48 _length = node->number_child<Frame>("AtmosLength");
49 _edit_rate = dcp::Fraction (node->string_child("AtmosEditRate"));
53 shared_ptr<AtmosContent>
54 AtmosContent::from_xml (Content* parent, cxml::ConstNodePtr node)
56 if (!node->optional_node_child("AtmosLength")) {
57 return shared_ptr<AtmosContent>();
60 return shared_ptr<AtmosContent> (new AtmosContent(parent, node));
65 AtmosContent::as_xml (xmlpp::Node* node) const
67 node->add_child("AtmosLength")->add_child_text(dcp::raw_convert<string>(_length));
68 node->add_child("AtmosEditRate")->add_child_text(_edit_rate.as_string());
73 AtmosContent::set_length (Frame len)
75 maybe_set (_length, len, ContentProperty::LENGTH);
80 AtmosContent::set_edit_rate (dcp::Fraction rate)
82 maybe_set (_edit_rate, rate, AtmosContentProperty::EDIT_RATE);