2 Copyright (C) 2013-2016 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 DCPOMATIC_VIDEO_CONTENT_H
21 #define DCPOMATIC_VIDEO_CONTENT_H
23 #include "colour_conversion.h"
24 #include "video_content_scale.h"
29 class VideoContentProperty
32 static int const VIDEO_SIZE;
33 static int const VIDEO_FRAME_RATE;
34 static int const VIDEO_FRAME_TYPE;
35 static int const VIDEO_CROP;
36 static int const VIDEO_SCALE;
37 static int const COLOUR_CONVERSION;
38 static int const VIDEO_FADE_IN;
39 static int const VIDEO_FADE_OUT;
45 VideoContent (boost::shared_ptr<const Film>);
46 VideoContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
47 VideoContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
49 void as_xml (xmlpp::Node *) const;
50 std::string technical_summary () const;
51 std::string identifier () const;
53 void set_default_colour_conversion ();
55 Frame video_length () const {
56 boost::mutex::scoped_lock lm (_mutex);
60 Frame video_length_after_3d_combine () const {
61 boost::mutex::scoped_lock lm (_mutex);
62 if (_video_frame_type == VIDEO_FRAME_TYPE_3D_ALTERNATE) {
63 return _video_length / 2;
69 dcp::Size video_size () const {
70 boost::mutex::scoped_lock lm (_mutex);
74 double video_frame_rate () const;
76 /** @return true if this content has a specific video frame rate, false
77 * if it should use the DCP's rate.
79 bool has_own_video_frame_rate () const {
80 boost::mutex::scoped_lock lm (_mutex);
81 return static_cast<bool>(_video_frame_rate);
84 void set_video_frame_type (VideoFrameType);
85 void set_video_frame_rate (double);
87 void set_left_crop (int);
88 void set_right_crop (int);
89 void set_top_crop (int);
90 void set_bottom_crop (int);
92 void set_scale (VideoContentScale);
93 void unset_colour_conversion ();
94 void set_colour_conversion (ColourConversion);
96 void set_fade_in (Frame);
97 void set_fade_out (Frame);
99 VideoFrameType video_frame_type () const {
100 boost::mutex::scoped_lock lm (_mutex);
101 return _video_frame_type;
105 boost::mutex::scoped_lock lm (_mutex);
109 int left_crop () const {
110 boost::mutex::scoped_lock lm (_mutex);
114 int right_crop () const {
115 boost::mutex::scoped_lock lm (_mutex);
119 int top_crop () const {
120 boost::mutex::scoped_lock lm (_mutex);
124 int bottom_crop () const {
125 boost::mutex::scoped_lock lm (_mutex);
129 /** @return Description of how to scale this content (if indeed it should be scaled) */
130 VideoContentScale scale () const {
131 boost::mutex::scoped_lock lm (_mutex);
135 boost::optional<ColourConversion> colour_conversion () const {
136 boost::mutex::scoped_lock lm (_mutex);
137 return _colour_conversion;
140 boost::optional<double> sample_aspect_ratio () const {
141 boost::mutex::scoped_lock lm (_mutex);
142 return _sample_aspect_ratio;
146 boost::mutex::scoped_lock lm (_mutex);
150 Frame fade_in () const {
151 boost::mutex::scoped_lock lm (_mutex);
155 Frame fade_out () const {
156 boost::mutex::scoped_lock lm (_mutex);
160 dcp::Size video_size_after_3d_split () const;
161 dcp::Size video_size_after_crop () const;
163 ContentTime dcp_time_to_content_time (DCPTime) const;
165 boost::optional<double> fade (Frame) const;
167 void scale_and_crop_to_fit_width ();
168 void scale_and_crop_to_fit_height ();
170 std::string processing_description () const;
173 void take_from_video_examiner (boost::shared_ptr<VideoExaminer>);
174 void add_properties (std::list<UserProperty> &) const;
176 boost::weak_ptr<const Film> _film;
179 /** Video frame rate, or not set if this content should use the DCP's frame rate */
180 boost::optional<double> _video_frame_rate;
181 boost::optional<ColourConversion> _colour_conversion;
183 friend struct ffmpeg_pts_offset_test;
184 friend struct best_dcp_frame_rate_test_single;
185 friend struct best_dcp_frame_rate_test_double;
186 friend struct audio_sampling_rate_test;
188 void setup_default_colour_conversion ();
190 dcp::Size _video_size;
191 VideoFrameType _video_frame_type;
193 VideoContentScale _scale;
194 /** Sample aspect ratio obtained from the content file's header,
197 boost::optional<double> _sample_aspect_ratio;