Merge master.
[libdcp.git] / src / parse / cpl.h
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/parse/cpl.h
21  *  @brief Classes used to parse a CPL.
22  */
23
24 #include <stdint.h>
25 #include <boost/shared_ptr.hpp>
26 #include <libcxml/cxml.h>
27 #include "../types.h"
28
29 namespace libdcp {
30
31 namespace parse {
32
33 /** @brief A simple representation of a CPL \<Picture\> node */
34 class Picture
35 {
36 public:
37         Picture () {}
38         Picture (boost::shared_ptr<const cxml::Node> node);
39
40         std::string id;
41         std::string annotation_text;
42         Fraction edit_rate;
43         /** Duration of the whole thing */
44         int64_t intrinsic_duration;
45         /** Start point in frames */
46         int64_t entry_point;
47         /** Duration that will actually play */
48         int64_t duration;
49         Fraction frame_rate;
50         Fraction screen_aspect_ratio;
51 };
52
53
54 /** @brief A simple parser for and representation of a CPL \<MainPicture\> node */
55 class MainPicture : public Picture
56 {
57 public:
58         MainPicture () {}
59         MainPicture (boost::shared_ptr<const cxml::Node> node);
60 };
61
62 /** @brief A simple parser for and representation of a CPL \<MainStereoscopicPicture\> node */
63 class MainStereoscopicPicture : public Picture
64 {
65 public:
66         MainStereoscopicPicture () {}
67         MainStereoscopicPicture (boost::shared_ptr<const cxml::Node> node);
68 };
69
70 /** @brief A simple parser for and representation of a CPL \<MainSound\> node */
71 class MainSound
72 {
73 public:
74         MainSound () {}
75         MainSound (boost::shared_ptr<const cxml::Node> node);
76
77         std::string id;
78         std::string annotation_text;
79         Fraction edit_rate;
80         int64_t intrinsic_duration;
81         int64_t entry_point;
82         int64_t duration;
83 };
84
85 /** @brief A simple parser for and representation of a CPL \<MainSubtitle\> node */
86 class MainSubtitle
87 {
88 public:
89         MainSubtitle () {}
90         MainSubtitle (boost::shared_ptr<const cxml::Node> node);
91
92         std::string id;
93         std::string annotation_text;
94         Fraction edit_rate;
95         int64_t intrinsic_duration;
96         int64_t entry_point;
97         int64_t duration;
98 };
99
100 /** @brief A simple parser for and representation of a CPL \<AssetList\> node */
101 class CPLAssetList
102 {
103 public:
104         CPLAssetList () {}
105         CPLAssetList (boost::shared_ptr<const cxml::Node> node);
106
107         boost::shared_ptr<MainPicture> main_picture;
108         boost::shared_ptr<MainStereoscopicPicture> main_stereoscopic_picture;
109         boost::shared_ptr<MainSound> main_sound;
110         boost::shared_ptr<MainSubtitle> main_subtitle;
111 };
112
113 /** @brief A simple parser for and representation of a CPL \<Reel\> node */
114 class Reel
115 {
116 public:
117         Reel () {}
118         Reel (boost::shared_ptr<const cxml::Node> node);
119
120         std::string id;
121         boost::shared_ptr<CPLAssetList> asset_list;
122 };
123
124
125 /** @brief A simple parser for and representation of a CPL \<ContentVersion\> node */
126 class ContentVersion
127 {
128 public:
129         ContentVersion () {}
130         ContentVersion (boost::shared_ptr<const cxml::Node> node);
131
132         std::string id;
133         std::string label_text;
134 };
135
136 /** @class CPL
137  *  @brief Class to parse a CPL
138  *
139  *  This class is used to parse XML CPL files.  It is rarely necessary
140  *  for the caller to use it outside libdcp.
141  */
142 class CPL
143 {
144 public:
145         /** Parse a CPL XML file into our member variables */
146         CPL (std::string file);
147
148         std::string id;
149         std::string annotation_text;
150         std::string issue_date;
151         std::string creator;
152         std::string content_title_text;
153         ContentKind content_kind;
154         boost::shared_ptr<ContentVersion> content_version;
155         std::list<boost::shared_ptr<Reel> > reels;
156 };
157
158 }
159
160 }
161