Various tweaks; work on read_dcp example.
[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 <libxml++/libxml++.h>
28 #include <boost/shared_ptr.hpp>
29 #include <boost/function.hpp>
30 #include <boost/date_time/posix_time/posix_time.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 KDM;
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         std::string pkl_type () const {
54                 return "text/xml";
55         }
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 (KDM const &);
65         
66         std::string annotation_text () const {
67                 return _annotation_text;
68         }
69         
70         std::string content_title_text () const {
71                 return _content_title_text;
72         }
73         
74         /** @return the type of the content, used by media servers
75          *  to categorise things (e.g. feature, trailer, etc.)
76          */
77         ContentKind content_kind () const {
78                 return _content_kind;
79         }
80
81         std::list<boost::shared_ptr<Reel> > reels () const {
82                 return _reels;
83         }
84
85         std::list<boost::shared_ptr<const Content> > assets () const;
86
87         bool encrypted () const;
88
89         void set_mxf_keys (Key);
90
91         void write_xml (
92                 boost::filesystem::path file,
93                 Standard standard,
94                 XMLMetadata,
95                 boost::shared_ptr<const Signer>
96                 ) const;
97
98         void resolve_refs (std::list<boost::shared_ptr<Object> >);
99         
100 private:
101         std::string _annotation_text;               ///< <AnnotationText>
102         std::string _issue_date;                    ///< <IssueDate>
103         std::string _creator;                       ///< <Creator>
104         std::string _content_title_text;            ///< <ContentTitleText>
105         ContentKind _content_kind;                  ///< <ContentKind>
106         std::string _content_version_id;            ///< <Id> in <ContentVersion>
107         std::string _content_version_label_text;    ///< <LabelText> in <ContentVersion>
108         std::list<boost::shared_ptr<Reel> > _reels;
109 };
110
111 }
112
113 #endif