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.
20 #ifndef LIBDCP_PICTURE_ASSET_H
21 #define LIBDCP_PICTURE_ASSET_H
23 /** @file src/picture_asset.h
24 * @brief An asset made up of JPEG2000 data
28 #include "mxf_asset.h"
35 class MonoPictureFrame;
36 class StereoPictureFrame;
37 class PictureAssetWriter;
39 /** @brief An asset made up of JPEG2000 data */
40 class PictureAsset : public MXFAsset
43 /** Construct a PictureAsset.
44 * This class will not write anything to disk in this constructor, but subclasses may.
46 * @param directory Directory where MXF file is.
47 * @param mxf_name Name of MXF file.
49 PictureAsset (std::string directory, std::string mxf_name);
51 /** Construct a PictureAsset.
52 * This class will not write anything to disk in this constructor, but subclasses may.
54 * @param directory Directory where MXF file is.
55 * @param mxf_name Name of MXF file.
56 * @param progress Signal to use to inform of progres, or 0.
57 * @param fps Video frames per second.
58 * @param intrinsic_duration Total number of frames in the asset.
59 * @param size Size of video frame images in pixels.
62 std::string directory,
64 boost::signals2::signal<void (float)>* progress,
66 int intrinsic_duration,
71 /** Start a progressive write to this asset.
72 * @param overwrite true to overwrite an existing MXF file; in this mode, writing can be resumed to a partially-written MXF; false if the
73 * MXF file does not exist.
74 * @param metadata MXF metadata to use.
76 virtual boost::shared_ptr<PictureAssetWriter> start_write (bool overwrite, MXFMetadata const & metadata = MXFMetadata ()) = 0;
78 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
84 void write_to_cpl (xmlpp::Node *) const;
88 bool frame_buffer_equals (
89 int frame, EqualityOptions opt, boost::function<void (NoteType, std::string)> note,
90 uint8_t const * data_A, unsigned int size_A, uint8_t const * data_B, unsigned int size_B
93 /** picture size in pixels */
97 std::string key_type () const;
98 std::string cpl_node_name () const = 0;
99 virtual int edit_rate_factor () const = 0;
102 /** A 2D (monoscopic) picture asset */
103 class MonoPictureAsset : public PictureAsset
106 /** Construct a MonoPictureAsset, generating the MXF from the JPEG2000 files.
107 * This may take some time; progress is indicated by emission of the Progress signal.
109 * @param files Pathnames of JPEG2000 files, in frame order.
110 * @param directory Directory in which to create MXF file.
111 * @param mxf_name Name of MXF file to create.
112 * @param progress Signal to inform of progress.
113 * @param fps Video frames per second.
114 * @param intrinsic_duration Total number of frames in the asset.
115 * @param size Size of images in pixels.
116 * @param encrypted true if asset should be encrypted.
119 std::vector<std::string> const & files,
120 std::string directory,
121 std::string mxf_name,
122 boost::signals2::signal<void (float)>* progress,
124 int intrinsic_duration,
127 MXFMetadata const & metadata = MXFMetadata ()
130 /** Construct a MonoPictureAsset, generating the MXF from the JPEG2000 files.
131 * This may take some time; progress is indicated by emission of the Progress signal.
133 * @param get_path Functor which returns a JPEG2000 file path for a given frame (frames counted from 0).
134 * @param directory Directory in which to create MXF file.
135 * @param mxf_name Name of MXF file to create.
136 * @param progress Signal to inform of progress.
137 * @param fps Video frames per second.
138 * @param intrinsic_duration Total number of frames in the asset.
139 * @param size Size of images in pixels.
140 * @param encrypted true if asset should be encrypted.
143 boost::function<std::string (int)> get_path,
144 std::string directory,
145 std::string mxf_name,
146 boost::signals2::signal<void (float)>* progress,
148 int intrinsic_duration,
151 MXFMetadata const & metadata = MXFMetadata ()
154 /** Construct a MonoPictureAsset, reading the MXF from disk.
155 * @param directory Directory that the MXF is in.
156 * @param mxf_name The filename of the MXF within `directory'.
158 MonoPictureAsset (std::string directory, std::string mxf_name);
160 /** Construct a MonoPictureAsset for progressive writing using
161 * start_write() and a MonoPictureAssetWriter.
163 * @param directory Directory to put the MXF in.
164 * @param mxf_name Filename of the MXF within this directory.
165 * @param fps Video frames per second.
166 * @param size Size in pixels that the picture frames will be.
168 MonoPictureAsset (std::string directory, std::string mxf_name, int fps, Size size);
170 /** Start a progressive write to a MonoPictureAsset */
171 boost::shared_ptr<PictureAssetWriter> start_write (bool, MXFMetadata const & metadata = MXFMetadata ());
173 boost::shared_ptr<const MonoPictureFrame> get_frame (int n) const;
174 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
177 std::string path_from_list (int f, std::vector<std::string> const & files) const;
178 void construct (boost::function<std::string (int)>, MXFMetadata const &);
179 std::string cpl_node_name () const;
180 int edit_rate_factor () const;
183 /** A 3D (stereoscopic) picture asset */
184 class StereoPictureAsset : public PictureAsset
187 StereoPictureAsset (std::string directory, std::string mxf_name, int fps, int intrinsic_duration);
189 /** Construct a StereoPictureAsset for progressive writing using
190 * start_write() and a StereoPictureAssetWriter.
192 * @param directory Directory to put the MXF in.
193 * @param mxf_name Filename of the MXF within this directory.
194 * @param fps Video frames per second.
195 * @param size Size in pixels that the picture frames will be.
197 StereoPictureAsset (std::string directory, std::string mxf_name, int fps, Size size);
199 /** Start a progressive write to a StereoPictureAsset */
200 boost::shared_ptr<PictureAssetWriter> start_write (bool, MXFMetadata const & metadata = MXFMetadata ());
202 boost::shared_ptr<const StereoPictureFrame> get_frame (int n) const;
203 bool equals (boost::shared_ptr<const Asset> other, EqualityOptions opt, boost::function<void (NoteType, std::string)> note) const;
206 std::string cpl_node_name () const;
207 int edit_rate_factor () const;