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