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 representation of a piece of video (with sound), including naming,
22 * the source content file, and how it should be presented in a DCP.
25 #ifndef DVDOMATIC_FILM_H
26 #define DVDOMATIC_FILM_H
31 #include <boost/thread/mutex.hpp>
32 #include <sigc++/signal.h>
34 #include <libavcodec/avcodec.h>
36 #include "dcp_content_type.h"
37 #include "film_state.h"
43 class ExamineContentJob;
46 * @brief A representation of a video with sound.
48 * A representation of a piece of video (with sound), including naming,
49 * the source content file, and how it should be presented in a DCP.
54 Film (std::string d, bool must_exist = true);
58 void write_metadata () const;
60 /** @return complete path to directory containing the film metadata */
61 std::string directory () const {
62 return _state.directory;
65 std::string content () const;
66 ContentType content_type () const;
68 /** @return name for DVD-o-matic */
69 std::string name () const {
73 /** @return number of pixels to crop from the top of the original picture */
74 int top_crop () const {
75 return _state.top_crop;
78 /** @return number of pixels to crop from the bottom of the original picture */
79 int bottom_crop () const {
80 return _state.bottom_crop;
83 /** @return number of pixels to crop from the left-hand side of the original picture */
84 int left_crop () const {
85 return _state.left_crop;
88 /** @return number of pixels to crop from the right-hand side of the original picture */
89 int right_crop () const {
90 return _state.right_crop;
93 /** @return the format to present this film in (flat, scope, etc.) */
94 Format const * format () const {
98 /** @return video filters that should be used when generating DCPs */
99 std::vector<Filter const *> filters () const {
100 return _state.filters;
103 /** @return scaler algorithm to use */
104 Scaler const * scaler () const {
105 return _state.scaler;
108 /** @return number of frames to put in the DCP, or 0 for all */
109 int dcp_frames () const {
110 return _state.dcp_frames;
113 TrimAction dcp_trim_action () const {
114 return _state.dcp_trim_action;
117 /** @return true to create an A/B comparison DCP, where the left half of the image
118 * is the video without any filters or post-processing, and the right half
119 * has the specified filters and post-processing.
121 bool dcp_ab () const {
122 return _state.dcp_ab;
125 float audio_gain () const {
126 return _state.audio_gain;
129 int audio_delay () const {
130 return _state.audio_delay;
133 int still_duration () const {
134 return _state.still_duration;
137 void set_filters (std::vector<Filter const *> const &);
139 void set_scaler (Scaler const *);
141 /** @return the type of content that this Film represents (feature, trailer etc.) */
142 DCPContentType const * dcp_content_type () {
143 return _state.dcp_content_type;
146 void set_dcp_frames (int);
147 void set_dcp_trim_action (TrimAction);
148 void set_dcp_ab (bool);
150 void set_name (std::string);
151 void set_content (std::string);
152 void set_top_crop (int);
153 void set_bottom_crop (int);
154 void set_left_crop (int);
155 void set_right_crop (int);
156 void set_frames_per_second (float);
157 void set_format (Format const *);
158 void set_dcp_content_type (DCPContentType const *);
159 void set_audio_gain (float);
160 void set_audio_delay (int);
161 void set_still_duration (int);
163 /** @return size, in pixels, of the source (ignoring cropping) */
168 /** @return length, in video frames */
169 int length () const {
170 return _state.length;
173 /** @return nnumber of video frames per second */
174 float frames_per_second () const {
175 return _state.frames_per_second;
178 /** @return number of audio channels */
179 int audio_channels () const {
180 return _state.audio_channels;
183 /** @return audio sample rate, in Hz */
184 int audio_sample_rate () const {
185 return _state.audio_sample_rate;
188 /** @return format of the audio samples */
189 AVSampleFormat audio_sample_format () const {
190 return _state.audio_sample_format;
193 std::string j2k_dir () const;
195 std::vector<std::string> audio_files () const;
197 void update_thumbs_pre_gui ();
198 void update_thumbs_post_gui ();
199 int num_thumbs () const;
200 int thumb_frame (int) const;
201 std::string thumb_file (int) const;
203 void copy_from_dvd_post_gui ();
204 void examine_content ();
205 void examine_content_post_gui ();
206 void send_dcp_to_tms ();
207 void copy_from_dvd ();
209 /** @return true if our metadata has been modified since it was last saved */
210 bool dirty () const {
214 void make_dcp (bool, int freq = 0);
242 boost::shared_ptr<FilmState> state_copy () const;
245 * It is safe to call this from any thread.
251 /** Emitted when some metadata property has changed */
252 mutable sigc::signal1<void, Property> Changed;
255 void read_metadata ();
256 std::string metadata_file () const;
257 void update_dimensions ();
258 void signal_changed (Property);
260 /** The majority of our state. Kept in a separate object
261 * so that it can easily be copied for passing onto long-running
262 * jobs (which then have an unchanging set of parameters).
266 /** true if our metadata has changed since it was last written to disk */
269 /** Log to write to */
272 /** Any running ExamineContentJob, or 0 */
273 boost::shared_ptr<ExamineContentJob> _examine_content_job;