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 sides of the original picture */
78 /** @return the format to present this film in (flat, scope, etc.) */
79 Format const * format () const {
83 /** @return video filters that should be used when generating DCPs */
84 std::vector<Filter const *> filters () const {
85 return _state.filters;
88 /** @return scaler algorithm to use */
89 Scaler const * scaler () const {
93 /** @return number of frames to put in the DCP, or 0 for all */
94 int dcp_frames () const {
95 return _state.dcp_frames;
98 TrimAction dcp_trim_action () const {
99 return _state.dcp_trim_action;
102 /** @return true to create an A/B comparison DCP, where the left half of the image
103 * is the video without any filters or post-processing, and the right half
104 * has the specified filters and post-processing.
106 bool dcp_ab () const {
107 return _state.dcp_ab;
110 float audio_gain () const {
111 return _state.audio_gain;
114 int audio_delay () const {
115 return _state.audio_delay;
118 int still_duration () const {
119 return _state.still_duration;
122 void set_filters (std::vector<Filter const *> const &);
124 void set_scaler (Scaler const *);
126 /** @return the type of content that this Film represents (feature, trailer etc.) */
127 DCPContentType const * dcp_content_type () {
128 return _state.dcp_content_type;
131 void set_dcp_frames (int);
132 void set_dcp_trim_action (TrimAction);
133 void set_dcp_ab (bool);
135 void set_name (std::string);
136 void set_content (std::string);
137 void set_top_crop (int);
138 void set_bottom_crop (int);
139 void set_left_crop (int);
140 void set_right_crop (int);
141 void set_format (Format const *);
142 void set_dcp_content_type (DCPContentType const *);
143 void set_audio_gain (float);
144 void set_audio_delay (int);
145 void set_still_duration (int);
147 /** @return size, in pixels, of the source (ignoring cropping) */
152 /** @return length, in video frames */
153 int length () const {
154 return _state.length;
157 /** @return nnumber of video frames per second */
158 float frames_per_second () const {
159 return _state.frames_per_second;
162 /** @return number of audio channels */
163 int audio_channels () const {
164 return _state.audio_channels;
167 /** @return audio sample rate, in Hz */
168 int audio_sample_rate () const {
169 return _state.audio_sample_rate;
172 /** @return format of the audio samples */
173 AVSampleFormat audio_sample_format () const {
174 return _state.audio_sample_format;
177 std::string j2k_dir () const;
179 std::vector<std::string> audio_files () const;
181 void update_thumbs_pre_gui ();
182 void update_thumbs_post_gui ();
183 int num_thumbs () const;
184 int thumb_frame (int) const;
185 std::string thumb_file (int) const;
187 void copy_from_dvd_post_gui ();
188 void examine_content ();
189 void examine_content_post_gui ();
190 void send_dcp_to_tms ();
191 void copy_from_dvd ();
193 /** @return true if our metadata has been modified since it was last saved */
194 bool dirty () const {
198 void make_dcp (bool, int freq = 0);
223 boost::shared_ptr<FilmState> state_copy () const;
226 * It is safe to call this from any thread.
232 int encoded_frames () const;
234 /** Emitted when some metadata property has changed */
235 mutable sigc::signal1<void, Property> Changed;
238 void read_metadata ();
239 std::string metadata_file () const;
240 void update_dimensions ();
241 void signal_changed (Property);
243 /** The majority of our state. Kept in a separate object
244 * so that it can easily be copied for passing onto long-running
245 * jobs (which then have an unchanging set of parameters).
249 /** true if our metadata has changed since it was last written to disk */
252 /** Log to write to */
255 /** Any running ExamineContentJob, or 0 */
256 boost::shared_ptr<ExamineContentJob> _examine_content_job;