Basics of OV/supplemental support when reading.
[libdcp.git] / src / 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 #ifndef LIBDCP_CPL_H
21 #define LIBDCP_CPL_H
22
23 #include <list>
24 #include <boost/shared_ptr.hpp>
25 #include <boost/function.hpp>
26 #include <boost/date_time/posix_time/posix_time.hpp>
27 #include <libxml++/libxml++.h>
28 #include "types.h"
29 #include "certificates.h"
30
31 namespace libdcp {
32
33 namespace parse {
34         class AssetMap;
35         class AssetMapAsset;
36 }
37         
38 class Asset;
39 class Reel;
40 class XMLMetadata;
41 class MXFMetadata;
42 class Encryption;
43 class KDM;
44         
45 /** @brief A CPL within a DCP */
46 class CPL
47 {
48 public:
49         CPL (std::string directory, std::string name, ContentKind content_kind, int length, int frames_per_second);
50         CPL (std::string directory, std::string file, std::list<boost::shared_ptr<const parse::AssetMap> > asset_maps, bool require_mxfs = true);
51
52         void add_reel (boost::shared_ptr<Reel> reel);
53         
54         /** @return the length in frames */
55         int length () const {
56                 return _length;
57         }
58
59         /** @return the type of the content, used by media servers
60          *  to categorise things (e.g. feature, trailer, etc.)
61          */
62         ContentKind content_kind () const {
63                 return _content_kind;
64         }
65
66         std::list<boost::shared_ptr<Reel> > reels () const {
67                 return _reels;
68         }
69
70         /** @return the CPL's name, as will be presented on projector
71          *  media servers and theatre management systems.
72          */
73         std::string name () const {
74                 return _name;
75         }
76
77         /** @return the number of frames per second */
78         int frames_per_second () const {
79                 return _fps;
80         }
81
82         std::list<boost::shared_ptr<const Asset> > assets () const;
83
84         bool encrypted () const;
85
86         std::string id () const {
87                 return _id;
88         }
89         
90         bool equals (CPL const & other, EqualityOptions options, boost::function<void (NoteType, std::string)> note) const;
91         
92         void write_xml (bool, XMLMetadata const &, boost::shared_ptr<Encryption>) const;
93         void write_to_assetmap (xmlpp::Node *) const;
94         void write_to_pkl (xmlpp::Node *) const;
95
96         boost::shared_ptr<xmlpp::Document> make_kdm (
97                 CertificateChain const &,
98                 std::string const &,
99                 boost::shared_ptr<const Certificate>,
100                 boost::posix_time::ptime from,
101                 boost::posix_time::ptime until,
102                 bool,
103                 MXFMetadata const &,
104                 XMLMetadata const &
105                 ) const;
106
107         void add_kdm (KDM const &);
108         
109 private:
110         boost::shared_ptr<parse::AssetMapAsset> asset_from_id (std::list<boost::shared_ptr<const parse::AssetMap> > asset_maps, std::string id) const;
111         
112         std::string _directory;
113         /** the name of the DCP */
114         std::string _name;
115         /** the content kind of the CPL */
116         ContentKind _content_kind;
117         /** length in frames */
118         mutable int _length;
119         /** frames per second */
120         int _fps;
121         /** reels */
122         std::list<boost::shared_ptr<Reel> > _reels;
123
124         /** our UUID */
125         std::string _id;
126         /** a SHA1 digest of our XML */
127         mutable std::string _digest;
128 };
129
130 }
131
132 #endif