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