namespace libdcp -> dcp.
[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 dcp {
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         std::string key_id;
52 };
53
54
55 /** @brief A simple parser for and representation of a CPL \<MainPicture\> node */
56 class MainPicture : public Picture
57 {
58 public:
59         MainPicture () {}
60         MainPicture (boost::shared_ptr<const cxml::Node> node);
61 };
62
63 /** @brief A simple parser for and representation of a CPL \<MainStereoscopicPicture\> node */
64 class MainStereoscopicPicture : public Picture
65 {
66 public:
67         MainStereoscopicPicture () {}
68         MainStereoscopicPicture (boost::shared_ptr<const cxml::Node> node);
69 };
70
71 /** @brief A simple parser for and representation of a CPL \<MainSound\> node */
72 class MainSound
73 {
74 public:
75         MainSound () {}
76         MainSound (boost::shared_ptr<const cxml::Node> node);
77
78         std::string id;
79         std::string annotation_text;
80         Fraction edit_rate;
81         int64_t intrinsic_duration;
82         int64_t entry_point;
83         int64_t duration;
84         std::string key_id;
85 };
86
87 /** @brief A simple parser for and representation of a CPL \<MainSubtitle\> node */
88 class MainSubtitle
89 {
90 public:
91         MainSubtitle () {}
92         MainSubtitle (boost::shared_ptr<const cxml::Node> node);
93
94         std::string id;
95         std::string annotation_text;
96         Fraction edit_rate;
97         int64_t intrinsic_duration;
98         int64_t entry_point;
99         int64_t duration;
100 };
101
102 /** @brief A simple parser for and representation of a CPL \<AssetList\> node */
103 class CPLAssetList
104 {
105 public:
106         CPLAssetList () {}
107         CPLAssetList (boost::shared_ptr<const cxml::Node> node);
108
109         boost::shared_ptr<MainPicture> main_picture;
110         boost::shared_ptr<MainStereoscopicPicture> main_stereoscopic_picture;
111         boost::shared_ptr<MainSound> main_sound;
112         boost::shared_ptr<MainSubtitle> main_subtitle;
113 };
114
115 /** @brief A simple parser for and representation of a CPL \<Reel\> node */
116 class Reel
117 {
118 public:
119         Reel () {}
120         Reel (boost::shared_ptr<const cxml::Node> node);
121
122         std::string id;
123         boost::shared_ptr<CPLAssetList> asset_list;
124 };
125
126
127 /** @brief A simple parser for and representation of a CPL \<ContentVersion\> node */
128 class ContentVersion
129 {
130 public:
131         ContentVersion () {}
132         ContentVersion (boost::shared_ptr<const cxml::Node> node);
133
134         std::string id;
135         std::string label_text;
136 };
137
138 /** @class CPL
139  *  @brief Class to parse a CPL
140  *
141  *  This class is used to parse XML CPL files.  It is rarely necessary
142  *  for the caller to use it outside libdcp.
143  */
144 class CPL
145 {
146 public:
147         /** Parse a CPL XML file into our member variables */
148         CPL (std::string file);
149
150         std::string id;
151         std::string annotation_text;
152         std::string issue_date;
153         std::string creator;
154         std::string content_title_text;
155         ContentKind content_kind;
156         boost::shared_ptr<ContentVersion> content_version;
157         std::list<boost::shared_ptr<Reel> > reels;
158 };
159
160 }
161
162 }
163