Considerable re-work of KDM class to express the difference between encrypted and...
[libdcp.git] / src / cpl.h
1 /*
2     Copyright (C) 2014 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 "types.h"
24 #include "certificates.h"
25 #include "key.h"
26 #include "asset.h"
27 #include "metadata.h"
28 #include <libxml++/libxml++.h>
29 #include <boost/shared_ptr.hpp>
30 #include <boost/function.hpp>
31 #include <boost/optional.hpp>
32 #include <boost/filesystem.hpp>
33 #include <list>
34
35 namespace dcp {
36         
37 class Content;
38 class Reel;
39 class XMLMetadata;
40 class MXFMetadata;
41 class Signer;
42 class DecryptedKDM;
43         
44 /** @class CPL
45  *  @brief A Composition Playlist.
46  */
47 class CPL : public Asset
48 {
49 public:
50         CPL (std::string annotation_text, ContentKind content_kind);
51         CPL (boost::filesystem::path file);
52
53         bool equals (
54                 CPL const & other,
55                 EqualityOptions options,
56                 boost::function<void (NoteType, std::string)> note
57                 ) const;
58
59         void add (boost::shared_ptr<Reel> reel);
60         void add (DecryptedKDM const &);
61
62         /** @return contents of the &lt;AnnotationText&gt; node */
63         std::string annotation_text () const {
64                 return _annotation_text;
65         }
66         
67         /** @return contents of the &lt;ContentTitleText&gt; node */
68         std::string content_title_text () const {
69                 return _content_title_text;
70         }
71
72         /** @return contents of the &lt;Id&gt; node within &lt;ContentVersion&gt; */
73         void set_content_version_id (std::string id) {
74                 _content_version_id = id;
75         }
76
77         /** @return contents of the &lt;LabelText&gt; node within &lt;ContentVersion&gt; */
78         void set_content_version_label_text (std::string text) {
79                 _content_version_label_text = text;
80         }
81         
82         /** @return the type of the content, used by media servers
83          *  to categorise things (e.g. feature, trailer, etc.)
84          */
85         ContentKind content_kind () const {
86                 return _content_kind;
87         }
88
89         /** @return the reels in this CPL */
90         std::list<boost::shared_ptr<Reel> > reels () const {
91                 return _reels;
92         }
93
94         /** @return the Content in this CPL across all its reels
95          *  (Content is picture, sound and subtitles)
96          */
97         std::list<boost::shared_ptr<const Content> > content () const;
98
99         bool encrypted () const;
100
101         void set_mxf_keys (Key);
102
103         void write_xml (
104                 boost::filesystem::path file,
105                 Standard standard,
106                 boost::shared_ptr<const Signer>
107                 ) const;
108
109         void resolve_refs (std::list<boost::shared_ptr<Object> >);
110
111 protected:
112         /** @return type string for PKLs for this asset */
113         std::string pkl_type (Standard standard) const;
114
115 private:
116         std::string _annotation_text;               ///< &lt;AnnotationText&gt;
117         /** &lt;Issuer&gt;, &lt;Creator&gt; and &lt;IssueDate&gt;.  These are grouped
118          *  because they occur together in a few places.
119          */
120         XMLMetadata _metadata;
121         std::string _content_title_text;            ///< &lt;ContentTitleText&gt;
122         ContentKind _content_kind;                  ///< &lt;ContentKind&gt;
123         std::string _content_version_id;            ///< &lt;Id&gt; in &lt;ContentVersion&gt;
124         std::string _content_version_label_text;    ///< &lt;LabelText&gt; in &lt;ContentVersion&gt;
125         std::list<boost::shared_ptr<Reel> > _reels;
126 };
127
128 }
129
130 #endif