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