0abff749bdc0ef8966feb2136c7182460838e31c
[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 #include <list>
21 #include <boost/shared_ptr.hpp>
22 #include <boost/function.hpp>
23 #include "types.h"
24
25 namespace libdcp {
26
27 class AssetMap;
28 class Asset;
29 class Reel;
30 class XMLMetadata;
31
32 /** @brief A CPL within a DCP */
33 class CPL
34 {
35 public:
36         CPL (std::string directory, std::string name, ContentKind content_kind, int length, int frames_per_second);
37         CPL (std::string directory, std::string file, boost::shared_ptr<const AssetMap> asset_map, bool require_mxfs = true);
38
39         void add_reel (boost::shared_ptr<const Reel> reel);
40         
41         /** @return the length in frames */
42         int length () const {
43                 return _length;
44         }
45
46         /** @return the type of the content, used by media servers
47          *  to categorise things (e.g. feature, trailer, etc.)
48          */
49         ContentKind content_kind () const {
50                 return _content_kind;
51         }
52
53         std::list<boost::shared_ptr<const Reel> > reels () const {
54                 return _reels;
55         }
56
57         /** @return the CPL's name, as will be presented on projector
58          *  media servers and theatre management systems.
59          */
60         std::string name () const {
61                 return _name;
62         }
63
64         /** @return the number of frames per second */
65         int frames_per_second () const {
66                 return _fps;
67         }
68
69         std::list<boost::shared_ptr<const Asset> > assets () const;
70         
71         bool equals (CPL const & other, EqualityOptions options, boost::function<void (NoteType, std::string)> note) const;
72         
73         void write_xml (XMLMetadata const &) const;
74         void write_to_assetmap (std::ostream& s) const;
75         void write_to_pkl (std::ostream& s) const;
76         
77 private:
78         std::string _directory;
79         /** the name of the DCP */
80         std::string _name;
81         /** the content kind of the CPL */
82         ContentKind _content_kind;
83         /** length in frames */
84         mutable int _length;
85         /** frames per second */
86         int _fps;
87         /** reels */
88         std::list<boost::shared_ptr<const Reel> > _reels;
89
90         /** our UUID */
91         std::string _uuid;
92         /** a SHA1 digest of our XML */
93         mutable std::string _digest;
94 };
95
96 }