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
48 VideoContent (boost::shared_ptr<const Film>);
49 VideoContent (boost::shared_ptr<const Film>, DCPTime, ContentTime);
50 VideoContent (boost::shared_ptr<const Film>, boost::filesystem::path);
51 VideoContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
52 VideoContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
54 void as_xml (xmlpp::Node *) const;
55 std::string technical_summary () const;
56 virtual std::string information () const;
57 virtual std::string identifier () const;
59 ContentTime video_length () const {
60 boost::mutex::scoped_lock lm (_mutex);
64 ContentTime video_length_after_3d_combine () const {
65 boost::mutex::scoped_lock lm (_mutex);
66 if (_video_frame_type == VIDEO_FRAME_TYPE_3D_ALTERNATE) {
67 return ContentTime (_video_length.get() / 2);
73 dcp::Size video_size () const {
74 boost::mutex::scoped_lock lm (_mutex);
78 float video_frame_rate () const {
79 boost::mutex::scoped_lock lm (_mutex);
80 return _video_frame_rate;
83 void set_video_frame_type (VideoFrameType);
84 void set_video_frame_rate (float);
86 void set_left_crop (int);
87 void set_right_crop (int);
88 void set_top_crop (int);
89 void set_bottom_crop (int);
91 void set_scale (VideoContentScale);
92 void set_colour_conversion (ColourConversion);
94 void set_fade_in (ContentTime);
95 void set_fade_out (ContentTime);
97 VideoFrameType video_frame_type () const {
98 boost::mutex::scoped_lock lm (_mutex);
99 return _video_frame_type;
103 boost::mutex::scoped_lock lm (_mutex);
107 int left_crop () const {
108 boost::mutex::scoped_lock lm (_mutex);
112 int right_crop () const {
113 boost::mutex::scoped_lock lm (_mutex);
117 int top_crop () const {
118 boost::mutex::scoped_lock lm (_mutex);
122 int bottom_crop () const {
123 boost::mutex::scoped_lock lm (_mutex);
127 /** @return Description of how to scale this content (if indeed it should be scaled) */
128 VideoContentScale scale () const {
129 boost::mutex::scoped_lock lm (_mutex);
133 ColourConversion colour_conversion () const {
134 boost::mutex::scoped_lock lm (_mutex);
135 return _colour_conversion;
138 ContentTime fade_in () const {
139 boost::mutex::scoped_lock lm (_mutex);
143 ContentTime fade_out () const {
144 boost::mutex::scoped_lock lm (_mutex);
148 dcp::Size video_size_after_3d_split () const;
149 dcp::Size video_size_after_crop () const;
151 ContentTime dcp_time_to_content_time (DCPTime) const;
153 boost::optional<float> fade (VideoFrame) const;
155 void scale_and_crop_to_fit_width ();
156 void scale_and_crop_to_fit_height ();
159 void take_from_video_examiner (boost::shared_ptr<VideoExaminer>);
161 ContentTime _video_length;
162 float _video_frame_rate;
165 friend struct ffmpeg_pts_offset_test;
166 friend struct best_dcp_frame_rate_test_single;
167 friend struct best_dcp_frame_rate_test_double;
168 friend struct audio_sampling_rate_test;
170 void setup_default_colour_conversion ();
172 dcp::Size _video_size;
173 VideoFrameType _video_frame_type;
175 VideoContentScale _scale;
176 ColourConversion _colour_conversion;
177 ContentTime _fade_in;
178 ContentTime _fade_out;