Rough support for 3D.
[libdcp.git] / src / cpl.cc
1 /*
2     Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 /** @file  src/cpl.cc
21  *  @brief Classes used to parse a CPL.
22  */
23
24 #include <iostream>
25 #include "cpl.h"
26
27 using namespace std;
28 using namespace libdcp;
29
30 CPL::CPL (string file)
31         : XMLFile (file, "CompositionPlaylist")
32 {
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");
42
43         ignore_node ("Issuer");
44         ignore_node ("Signer");
45         ignore_node ("Signature");
46
47         done ();
48 }
49
50 ContentVersion::ContentVersion (xmlpp::Node const * node)
51         : XMLNode (node)
52 {
53         id = string_node ("Id");
54         label_text = string_node ("LabelText");
55         done ();
56 }
57
58 CPLReel::CPLReel (xmlpp::Node const * node)
59         : XMLNode (node)
60 {
61         id = string_node ("Id");
62         asset_list = sub_node<CPLAssetList> ("AssetList");
63
64         done ();
65 }
66
67 CPLAssetList::CPLAssetList (xmlpp::Node const * node)
68         : XMLNode (node)
69 {
70         main_picture = optional_sub_node<MainPicture> ("MainPicture");
71         main_stereoscopic_picture = optional_sub_node<MainStereoscopicPicture> ("MainStereoscopicPicture");
72         main_sound = optional_sub_node<MainSound> ("MainSound");
73         main_subtitle = optional_sub_node<MainSubtitle> ("MainSubtitle");
74
75         done ();
76 }
77
78 MainPicture::MainPicture (xmlpp::Node const * node)
79         : Picture (node)
80 {
81
82 }
83
84 MainStereoscopicPicture::MainStereoscopicPicture (xmlpp::Node const * node)
85         : Picture (node)
86 {
87
88 }
89
90 Picture::Picture (xmlpp::Node const * node)
91         : XMLNode (node)
92 {
93         id = string_node ("Id");
94         annotation_text = optional_string_node ("AnnotationText");
95         edit_rate = fraction_node ("EditRate");
96         intrinsic_duration = int64_node ("IntrinsicDuration");
97         entry_point = int64_node ("EntryPoint");
98         duration = int64_node ("Duration");
99         frame_rate = fraction_node ("FrameRate");
100         try {
101                 screen_aspect_ratio = fraction_node ("ScreenAspectRatio");
102         } catch (XMLError& e) {
103                 /* Maybe it's not a fraction */
104         }
105         try {
106                 float f = float_node ("ScreenAspectRatio");
107                 screen_aspect_ratio = Fraction (f * 1000, 1000);
108         } catch (bad_cast& e) {
109
110         }
111
112         ignore_node ("Hash");
113
114         done ();
115 }
116
117 MainSound::MainSound (xmlpp::Node const * node)
118         : XMLNode (node)
119 {
120         id = string_node ("Id");
121         annotation_text = optional_string_node ("AnnotationText");
122         edit_rate = fraction_node ("EditRate");
123         intrinsic_duration = int64_node ("IntrinsicDuration");
124         entry_point = int64_node ("EntryPoint");
125         duration = int64_node ("Duration");
126
127         ignore_node ("Hash");
128         
129         done ();
130 }
131
132 MainSubtitle::MainSubtitle (xmlpp::Node const * node)
133         : XMLNode (node)
134 {
135         id = string_node ("Id");
136         annotation_text = optional_string_node ("AnnotationText");
137         edit_rate = fraction_node ("EditRate");
138         intrinsic_duration = int64_node ("IntrinsicDuration");
139         entry_point = int64_node ("EntryPoint");
140         duration = int64_node ("Duration");
141
142         ignore_node ("Hash");
143         
144         done ();
145 }