c424f96d3e4b321cb71de6016d495264872fd12d
[dcpomatic.git] / src / lib / atmos_content.cc
1 /*
2     Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21
22 #include "atmos_content.h"
23 #include <dcp/raw_convert.h>
24 #include <libxml++/libxml++.h>
25
26
27 using std::string;
28 using boost::shared_ptr;
29
30
31 int const AtmosContentProperty::EDIT_RATE = 700;
32
33
34 AtmosContent::AtmosContent (Content* parent)
35         : ContentPart (parent)
36         , _length (0)
37 {
38
39 }
40
41
42 AtmosContent::AtmosContent (Content* parent, cxml::ConstNodePtr node)
43         : ContentPart (parent)
44 {
45         _length = node->number_child<Frame>("Length");
46         _edit_rate = dcp::Fraction (node->string_child("EditRate"));
47 }
48
49
50 shared_ptr<AtmosContent>
51 AtmosContent::from_xml (Content* parent, cxml::ConstNodePtr node)
52 {
53         return shared_ptr<AtmosContent> (new AtmosContent(parent, node));
54 }
55
56
57 void
58 AtmosContent::as_xml (xmlpp::Node* node) const
59 {
60         node->add_child("Length")->add_child_text(dcp::raw_convert<string>(_length));
61         node->add_child("EditRate")->add_child_text(_edit_rate.as_string());
62 }
63
64
65 void
66 AtmosContent::set_length (Frame len)
67 {
68         maybe_set (_length, len, ContentProperty::LENGTH);
69 }
70
71
72 void
73 AtmosContent::set_edit_rate (dcp::Fraction rate)
74 {
75         maybe_set (_edit_rate, rate, AtmosContentProperty::EDIT_RATE);
76 }
77