2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 /** @file src/cpl_file.cc
21 * @brief Classes used to parse a CPL.
28 using namespace libdcp;
30 CPLFile::CPLFile (string file)
31 : XMLFile (file, "CompositionPlaylist")
33 id = string_child ("Id");
34 annotation_text = optional_string_child ("AnnotationText");
35 issue_date = string_child ("IssueDate");
36 creator = optional_string_child ("Creator");
37 content_title_text = string_child ("ContentTitleText");
38 content_kind = kind_child ("ContentKind");
39 content_version = optional_type_child<ContentVersion> ("ContentVersion");
40 ignore_child ("RatingList");
41 reels = type_grand_children<CPLReel> ("ReelList", "Reel");
43 ignore_child ("Issuer");
44 ignore_child ("Signer");
45 ignore_child ("Signature");
50 ContentVersion::ContentVersion (xmlpp::Node const * node)
53 id = optional_string_child ("Id");
54 label_text = string_child ("LabelText");
58 CPLReel::CPLReel (xmlpp::Node const * node)
61 id = string_child ("Id");
62 asset_list = type_child<CPLAssetList> ("AssetList");
64 ignore_child ("AnnotationText");
68 CPLAssetList::CPLAssetList (xmlpp::Node const * node)
71 main_picture = optional_type_child<MainPicture> ("MainPicture");
72 main_stereoscopic_picture = optional_type_child<MainStereoscopicPicture> ("MainStereoscopicPicture");
73 main_sound = optional_type_child<MainSound> ("MainSound");
74 main_subtitle = optional_type_child<MainSubtitle> ("MainSubtitle");
79 MainPicture::MainPicture (xmlpp::Node const * node)
85 MainStereoscopicPicture::MainStereoscopicPicture (xmlpp::Node const * node)
91 Picture::Picture (xmlpp::Node const * node)
94 id = string_child ("Id");
95 annotation_text = optional_string_child ("AnnotationText");
96 edit_rate = fraction_child ("EditRate");
97 intrinsic_duration = int64_child ("IntrinsicDuration");
98 entry_point = int64_child ("EntryPoint");
99 duration = int64_child ("Duration");
100 frame_rate = fraction_child ("FrameRate");
102 screen_aspect_ratio = fraction_child ("ScreenAspectRatio");
103 } catch (XMLError& e) {
104 /* Maybe it's not a fraction */
107 float f = float_child ("ScreenAspectRatio");
108 screen_aspect_ratio = Fraction (f * 1000, 1000);
109 } catch (bad_cast& e) {
113 ignore_child ("Hash");
118 MainSound::MainSound (xmlpp::Node const * node)
121 id = string_child ("Id");
122 annotation_text = optional_string_child ("AnnotationText");
123 edit_rate = fraction_child ("EditRate");
124 intrinsic_duration = int64_child ("IntrinsicDuration");
125 entry_point = int64_child ("EntryPoint");
126 duration = int64_child ("Duration");
128 ignore_child ("Hash");
129 ignore_child ("Language");
134 MainSubtitle::MainSubtitle (xmlpp::Node const * node)
137 id = string_child ("Id");
138 annotation_text = optional_string_child ("AnnotationText");
139 edit_rate = fraction_child ("EditRate");
140 intrinsic_duration = int64_child ("IntrinsicDuration");
141 entry_point = int64_child ("EntryPoint");
142 duration = int64_child ("Duration");
144 ignore_child ("Hash");
145 ignore_child ("Language");