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.
21 * @brief Classes used to parse a CPL.
28 using namespace libdcp;
30 CPL::CPL (string file)
31 : XMLFile (file, "CompositionPlaylist")
33 id = string_node ("Id");
34 annotation_text = optional_string_node ("AnnotationText");
35 issue_date = string_node ("IssueDate");
36 creator = string_node ("Creator");
37 content_title_text = string_node ("ContentTitleText");
38 content_kind = kind_node ("ContentKind");
39 content_version = optional_sub_node<ContentVersion> ("ContentVersion");
40 ignore_node ("RatingList");
41 reels = sub_nodes<CPLReel> ("ReelList", "Reel");
43 ignore_node ("Issuer");
44 ignore_node ("Signer");
45 ignore_node ("Signature");
50 ContentVersion::ContentVersion (xmlpp::Node const * node)
53 id = string_node ("Id");
54 label_text = string_node ("LabelText");
58 CPLReel::CPLReel (xmlpp::Node const * node)
61 id = string_node ("Id");
62 asset_list = sub_node<CPLAssetList> ("AssetList");
67 CPLAssetList::CPLAssetList (xmlpp::Node const * node)
70 main_picture = sub_node<MainPicture> ("MainPicture");
71 main_sound = optional_sub_node<MainSound> ("MainSound");
72 main_subtitle = optional_sub_node<MainSubtitle> ("MainSubtitle");
77 MainPicture::MainPicture (xmlpp::Node const * node)
80 id = string_node ("Id");
81 annotation_text = optional_string_node ("AnnotationText");
82 edit_rate = fraction_node ("EditRate");
83 intrinsic_duration = int64_node ("IntrinsicDuration");
84 entry_point = int64_node ("EntryPoint");
85 duration = int64_node ("Duration");
86 frame_rate = fraction_node ("FrameRate");
88 screen_aspect_ratio = fraction_node ("ScreenAspectRatio");
89 } catch (XMLError& e) {
90 /* Maybe it's not a fraction */
93 float f = float_node ("ScreenAspectRatio");
94 screen_aspect_ratio = Fraction (f * 1000, 1000);
95 } catch (bad_cast& e) {
104 MainSound::MainSound (xmlpp::Node const * node)
107 id = string_node ("Id");
108 annotation_text = optional_string_node ("AnnotationText");
109 edit_rate = fraction_node ("EditRate");
110 intrinsic_duration = int64_node ("IntrinsicDuration");
111 entry_point = int64_node ("EntryPoint");
112 duration = int64_node ("Duration");
114 ignore_node ("Hash");
119 MainSubtitle::MainSubtitle (xmlpp::Node const * node)
122 id = string_node ("Id");
123 annotation_text = optional_string_node ("AnnotationText");
124 edit_rate = fraction_node ("EditRate");
125 intrinsic_duration = int64_node ("IntrinsicDuration");
126 entry_point = int64_node ("EntryPoint");
127 duration = int64_node ("Duration");
129 ignore_node ("Hash");