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 <boost/thread.hpp>
33 #include <sigc++/signal.h>
35 #include <libavcodec/avcodec.h>
37 #include "dcp_content_type.h"
38 #include "film_state.h"
44 class ExamineContentJob;
47 * @brief A representation of a video with sound.
49 * A representation of a piece of video (with sound), including naming,
50 * the source content file, and how it should be presented in a DCP.
55 Film (std::string d, bool must_exist = true);
59 void write_metadata () const;
61 /** @return complete path to directory containing the film metadata */
62 std::string directory () const {
63 return _state.directory;
66 std::string content () const;
67 ContentType content_type () const;
69 /** @return name for DVD-o-matic */
70 std::string name () const {
74 /** @return number of pixels to crop from the sides of the original picture */
79 /** @return the format to present this film in (flat, scope, etc.) */
80 Format const * format () const {
84 /** @return video filters that should be used when generating DCPs */
85 std::vector<Filter const *> filters () const {
86 return _state.filters;
89 /** @return scaler algorithm to use */
90 Scaler const * scaler () const {
94 /** @return number of frames to put in the DCP, or 0 for all */
95 int dcp_frames () const {
96 return _state.dcp_frames;
99 TrimAction dcp_trim_action () const {
100 return _state.dcp_trim_action;
103 /** @return true to create an A/B comparison DCP, where the left half of the image
104 * is the video without any filters or post-processing, and the right half
105 * has the specified filters and post-processing.
107 bool dcp_ab () const {
108 return _state.dcp_ab;
111 float audio_gain () const {
112 return _state.audio_gain;
115 int audio_delay () const {
116 return _state.audio_delay;
119 int still_duration () const {
120 return _state.still_duration;
123 void set_filters (std::vector<Filter const *> const &);
125 void set_scaler (Scaler const *);
127 /** @return the type of content that this Film represents (feature, trailer etc.) */
128 DCPContentType const * dcp_content_type () {
129 return _state.dcp_content_type;
132 void set_dcp_frames (int);
133 void set_dcp_trim_action (TrimAction);
134 void set_dcp_ab (bool);
136 void set_name (std::string);
137 void set_content (std::string);
138 void set_top_crop (int);
139 void set_bottom_crop (int);
140 void set_left_crop (int);
141 void set_right_crop (int);
142 void set_format (Format const *);
143 void set_dcp_content_type (DCPContentType const *);
144 void set_audio_gain (float);
145 void set_audio_delay (int);
146 void set_still_duration (int);
148 /** @return size, in pixels, of the source (ignoring cropping) */
153 /** @return length, in video frames */
154 int length () const {
155 return _state.length;
158 /** @return nnumber of video frames per second */
159 float frames_per_second () const {
160 return _state.frames_per_second;
163 /** @return number of audio channels */
164 int audio_channels () const {
165 return _state.audio_channels;
168 /** @return audio sample rate, in Hz */
169 int audio_sample_rate () const {
170 return _state.audio_sample_rate;
173 /** @return format of the audio samples */
174 AVSampleFormat audio_sample_format () const {
175 return _state.audio_sample_format;
178 std::string j2k_dir () const;
180 std::vector<std::string> audio_files () const;
182 void update_thumbs_pre_gui ();
183 void update_thumbs_post_gui ();
184 int num_thumbs () const;
185 int thumb_frame (int) const;
186 std::string thumb_file (int) const;
188 void copy_from_dvd_post_gui ();
189 void examine_content ();
190 void examine_content_post_gui ();
191 void send_dcp_to_tms ();
192 void copy_from_dvd ();
194 /** @return true if our metadata has been modified since it was last saved */
195 bool dirty () const {
199 void make_dcp (bool, int freq = 0);
224 boost::shared_ptr<FilmState> state_copy () const;
227 * It is safe to call this from any thread.
233 int encoded_frames () const;
235 /** Emitted when some metadata property has changed */
236 mutable sigc::signal1<void, Property> Changed;
239 void read_metadata ();
240 std::string metadata_file () const;
241 void update_dimensions ();
242 void signal_changed (Property);
244 /** The majority of our state. Kept in a separate object
245 * so that it can easily be copied for passing onto long-running
246 * jobs (which then have an unchanging set of parameters).
250 /** true if our metadata has changed since it was last written to disk */
253 /** Log to write to */
256 /** Any running ExamineContentJob, or 0 */
257 boost::shared_ptr<ExamineContentJob> _examine_content_job;