2 Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
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.
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.
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.
21 * @brief A class to create a DCP.
29 #include <boost/shared_ptr.hpp>
30 #include <sigc++/sigc++.h>
37 /** @brief Namespace for everything in libdcp */
46 /** @class DCP dcp.h libdcp/dcp.h
47 * @brief A class to create or read a DCP.
54 * @param directory Directory to write files to.
56 * @param content_kind Content kind.
57 * @param fps Frames per second.
58 * @param length Length in frames.
60 DCP (std::string directory, std::string name, ContentKind content_kind, int fps, int length);
62 DCP (std::string directory);
64 /** Add a sound asset.
65 * @param files Pathnames of WAV files to use in the order Left, Right,
66 * Centre, Lfe (sub), Left surround, Right surround; not all files need
69 void add_sound_asset (std::vector<std::string> const & files);
71 /** Add a sound asset.
72 * @param get_path Functor to get the path to the WAV for a given channel.
73 * @param channels Number of channels.
75 void add_sound_asset (sigc::slot<std::string, Channel> get_path, int channels);
77 /** Add a picture asset.
78 * @param files Pathnames of JPEG2000 files, in frame order.
79 * @param width Width of images in pixels.
80 * @param height Height of images in pixels.
82 void add_picture_asset (std::vector<std::string> const & files, int width, int height);
84 /** Add a picture asset.
85 * @param get_path Functor to get path to the JPEG2000 for a given frame.
86 * @param width Width of images in pixels.
87 * @param height Height of images in pixels.
89 void add_picture_asset (sigc::slot<std::string, int> get_path, int width, int height);
91 /** Write the required XML files to the directory that was
92 * passed into the constructor.
94 void write_xml () const;
96 std::string name () const {
100 ContentKind content_kind () const {
101 return _content_kind;
104 int frames_per_second () const {
108 int length () const {
112 boost::shared_ptr<const PictureAsset> picture_asset () const;
113 boost::shared_ptr<const SoundAsset> sound_asset () const;
114 boost::shared_ptr<const SubtitleAsset> subtitle_asset () const;
116 std::list<std::string> equals (DCP const & other, EqualityOptions options) const;
118 /** Emitted with a parameter between 0 and 1 to indicate progress
121 sigc::signal1<void, float> Progress;
125 /** Write the CPL file.
126 * @param cpl_uuid UUID to use.
127 * @return CPL pathname.
129 std::string write_cpl (std::string cpl_uuid) const;
131 /** Write the PKL file.
132 * @param pkl_uuid UUID to use.
133 * @param cpl_uuid UUID of the CPL file.
134 * @param cpl_digest SHA digest of the CPL file.
135 * @param cpl_length Length of the CPL file in bytes.
137 std::string write_pkl (std::string pkl_uuid, std::string cpl_uuid, std::string cpl_digest, int cpl_length) const;
139 /** Write the VOLINDEX file */
140 void write_volindex () const;
142 /** Write the ASSETMAP file.
143 * @param cpl_uuid UUID of our CPL.
144 * @param cpl_length Length of our CPL in bytes.
145 * @param pkl_uuid UUID of our PKL.
146 * @param pkl_length Length of our PKL in bytes.
148 void write_assetmap (std::string cpl_uuid, int cpl_length, std::string pkl_uuid, int pkl_length) const;
153 std::string asset_map;
154 std::list<std::string> subtitles;
157 void scan (Files& files, std::string directory) const;
159 /** the directory that we are writing to */
160 std::string _directory;
161 /** the name of the DCP */
163 /** the content kind of the DCP */
164 ContentKind _content_kind;
165 /** frames per second */
167 /** length in frames */
170 std::list<boost::shared_ptr<Asset> > _assets;