Tweak comment.
[libdcp.git] / src / dcp.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 /** @file  src/dcp.h
21  *  @brief A class to create a DCP.
22  */
23
24 #ifndef LIBDCP_DCP_H
25 #define LIBDCP_DCP_H
26
27 #include <string>
28 #include <vector>
29 #include <boost/shared_ptr.hpp>
30 #include <sigc++/sigc++.h>
31 #include "types.h"
32
33 namespace xmlpp {
34         class Node;
35 }
36
37 /** @brief Namespace for everything in libdcp */
38 namespace libdcp
39 {
40
41 class Asset;    
42
43 /** @class DCP dcp.h libdcp/dcp.h
44  *  @brief A class to create or read a DCP.
45  */
46         
47 class DCP
48 {
49 public:
50         /** Construct a DCP.
51          *  @param directory Directory to write files to.
52          *  @param name Name.
53          *  @param content_kind Content kind.
54          *  @param fps Frames per second.
55          *  @param length Length in frames.
56          */
57         DCP (std::string directory, std::string name, ContentKind content_kind, int fps, int length);
58
59         DCP (std::string directory);
60
61         /** Add a sound asset.
62          *  @param files Pathnames of WAV files to use in the order Left, Right,
63          *  Centre, Lfe (sub), Left surround, Right surround; not all files need
64          *  to be present.
65          */
66         void add_sound_asset (std::vector<std::string> const & files);
67
68         /** Add a sound asset.
69          *  @param get_path Functor to get the path to the WAV for a given channel.
70          *  @param channels Number of channels.
71          */
72         void add_sound_asset (sigc::slot<std::string, Channel> get_path, int channels);
73
74         /** Add a picture asset.
75          *  @param files Pathnames of JPEG2000 files, in frame order.
76          *  @param width Width of images in pixels.
77          *  @param height Height of images in pixels.
78          */
79         void add_picture_asset (std::vector<std::string> const & files, int width, int height);
80
81         /** Add a picture asset.
82          *  @param get_path Functor to get path to the JPEG2000 for a given frame.
83          *  @param width Width of images in pixels.
84          *  @param height Height of images in pixels.
85          */
86         void add_picture_asset (sigc::slot<std::string, int> get_path, int width, int height);
87
88         /** Write the required XML files to the directory that was
89          *  passed into the constructor.
90          */
91         void write_xml () const;
92
93         std::string name () const {
94                 return _name;
95         }
96
97         ContentKind content_kind () const {
98                 return _content_kind;
99         }
100
101         int frames_per_second () const {
102                 return _fps;
103         }
104
105         int length () const {
106                 return _length;
107         }
108
109         std::list<std::string> equals (DCP const & other, EqualityOptions options) const;
110
111         /** Emitted with a parameter between 0 and 1 to indicate progress
112          *  for long jobs.
113          */
114         sigc::signal1<void, float> Progress;
115
116 private:
117
118         /** Write the CPL file.
119          *  @param cpl_uuid UUID to use.
120          *  @return CPL pathname.
121          */
122         std::string write_cpl (std::string cpl_uuid) const;
123
124         /** Write the PKL file.
125          *  @param pkl_uuid UUID to use.
126          *  @param cpl_uuid UUID of the CPL file.
127          *  @param cpl_digest SHA digest of the CPL file.
128          *  @param cpl_length Length of the CPL file in bytes.
129          */
130         std::string write_pkl (std::string pkl_uuid, std::string cpl_uuid, std::string cpl_digest, int cpl_length) const;
131         
132         /** Write the VOLINDEX file */
133         void write_volindex () const;
134
135         /** Write the ASSETMAP file.
136          *  @param cpl_uuid UUID of our CPL.
137          *  @param cpl_length Length of our CPL in bytes.
138          *  @param pkl_uuid UUID of our PKL.
139          *  @param pkl_length Length of our PKL in bytes.
140          */
141         void write_assetmap (std::string cpl_uuid, int cpl_length, std::string pkl_uuid, int pkl_length) const;
142
143         /** the directory that we are writing to */
144         std::string _directory;
145         /** the name of the DCP */
146         std::string _name;
147         /** the content kind of the DCP */
148         ContentKind _content_kind;
149         /** frames per second */
150         int _fps;
151         /** length in frames */
152         int _length;
153         /** assets */
154         std::list<boost::shared_ptr<Asset> > _assets;
155 };
156
157 }
158
159 #endif