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