2 Copyright (C) 2013-2014 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
24 #include "colour_conversion.h"
25 #include "video_content_scale.h"
30 class VideoContentProperty
33 static int const VIDEO_SIZE;
34 static int const VIDEO_FRAME_RATE;
35 static int const VIDEO_FRAME_TYPE;
36 static int const VIDEO_CROP;
37 static int const VIDEO_SCALE;
38 static int const COLOUR_CONVERSION;
39 static int const VIDEO_FADE_IN;
40 static int const VIDEO_FADE_OUT;
43 class VideoContent : public virtual Content
46 VideoContent (boost::shared_ptr<const Film>);
47 VideoContent (boost::shared_ptr<const Film>, DCPTime, ContentTime);
48 VideoContent (boost::shared_ptr<const Film>, boost::filesystem::path);
49 VideoContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
50 VideoContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
52 void as_xml (xmlpp::Node *) const;
53 std::string technical_summary () const;
54 virtual std::string identifier () const;
56 ContentTime video_length () const {
57 boost::mutex::scoped_lock lm (_mutex);
61 ContentTime video_length_after_3d_combine () const {
62 boost::mutex::scoped_lock lm (_mutex);
63 if (_video_frame_type == VIDEO_FRAME_TYPE_3D_ALTERNATE) {
64 return ContentTime (_video_length.get() / 2);
70 dcp::Size video_size () const {
71 boost::mutex::scoped_lock lm (_mutex);
75 float video_frame_rate () const {
76 boost::mutex::scoped_lock lm (_mutex);
77 return _video_frame_rate;
80 void set_video_frame_type (VideoFrameType);
81 void set_video_frame_rate (float);
83 void set_left_crop (int);
84 void set_right_crop (int);
85 void set_top_crop (int);
86 void set_bottom_crop (int);
88 void set_scale (VideoContentScale);
89 void unset_colour_conversion ();
90 void set_colour_conversion (ColourConversion);
91 void set_default_colour_conversion (bool signal = true);
93 void set_fade_in (ContentTime);
94 void set_fade_out (ContentTime);
96 VideoFrameType video_frame_type () const {
97 boost::mutex::scoped_lock lm (_mutex);
98 return _video_frame_type;
102 boost::mutex::scoped_lock lm (_mutex);
106 int left_crop () const {
107 boost::mutex::scoped_lock lm (_mutex);
111 int right_crop () const {
112 boost::mutex::scoped_lock lm (_mutex);
116 int top_crop () const {
117 boost::mutex::scoped_lock lm (_mutex);
121 int bottom_crop () const {
122 boost::mutex::scoped_lock lm (_mutex);
126 /** @return Description of how to scale this content (if indeed it should be scaled) */
127 VideoContentScale scale () const {
128 boost::mutex::scoped_lock lm (_mutex);
132 boost::optional<ColourConversion> colour_conversion () const {
133 boost::mutex::scoped_lock lm (_mutex);
134 return _colour_conversion;
137 boost::optional<float> sample_aspect_ratio () const {
138 boost::mutex::scoped_lock lm (_mutex);
139 return _sample_aspect_ratio;
142 ContentTime fade_in () const {
143 boost::mutex::scoped_lock lm (_mutex);
147 ContentTime fade_out () const {
148 boost::mutex::scoped_lock lm (_mutex);
152 dcp::Size video_size_after_3d_split () const;
153 dcp::Size video_size_after_crop () const;
155 ContentTime dcp_time_to_content_time (DCPTime) const;
157 boost::optional<float> fade (VideoFrame) const;
159 void scale_and_crop_to_fit_width ();
160 void scale_and_crop_to_fit_height ();
162 std::string processing_description () const;
165 void take_from_video_examiner (boost::shared_ptr<VideoExaminer>);
167 ContentTime _video_length;
168 float _video_frame_rate;
171 friend struct ffmpeg_pts_offset_test;
172 friend struct best_dcp_frame_rate_test_single;
173 friend struct best_dcp_frame_rate_test_double;
174 friend struct audio_sampling_rate_test;
176 void setup_default_colour_conversion ();
178 dcp::Size _video_size;
179 VideoFrameType _video_frame_type;
181 VideoContentScale _scale;
182 boost::optional<ColourConversion> _colour_conversion;
183 /** Sample aspect ratio obtained from the content file's header,
186 boost::optional<float> _sample_aspect_ratio;
187 ContentTime _fade_in;
188 ContentTime _fade_out;