2 Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef DCPOMATIC_VIDEO_CONTENT_H
22 #define DCPOMATIC_VIDEO_CONTENT_H
24 #include "colour_conversion.h"
25 #include "video_content_scale.h"
26 #include "dcpomatic_time.h"
27 #include "user_property.h"
29 #include "content_part.h"
30 #include <boost/thread/mutex.hpp>
31 #include <boost/weak_ptr.hpp>
32 #include <boost/enable_shared_from_this.hpp>
39 class VideoContentProperty
42 static int const SIZE;
43 static int const FRAME_TYPE;
44 static int const CROP;
45 static int const SCALE;
46 static int const COLOUR_CONVERSION;
47 static int const FADE_IN;
48 static int const FADE_OUT;
51 class VideoContent : public ContentPart, public boost::enable_shared_from_this<VideoContent>
54 VideoContent (Content* parent);
55 VideoContent (Content* parent, std::vector<boost::shared_ptr<Content> >);
57 void as_xml (xmlpp::Node *) const;
58 std::string technical_summary () const;
59 std::string identifier () const;
60 void use_template (boost::shared_ptr<const VideoContent> c);
62 Frame length () const {
63 boost::mutex::scoped_lock lm (_mutex);
67 Frame length_after_3d_combine () const {
68 boost::mutex::scoped_lock lm (_mutex);
69 if (_frame_type == VIDEO_FRAME_TYPE_3D_ALTERNATE) {
76 dcp::Size size () const {
77 boost::mutex::scoped_lock lm (_mutex);
81 void set_frame_type (VideoFrameType);
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);
92 void set_fade_in (Frame);
93 void set_fade_out (Frame);
95 VideoFrameType frame_type () const {
96 boost::mutex::scoped_lock lm (_mutex);
101 boost::mutex::scoped_lock lm (_mutex);
105 int left_crop () const {
106 boost::mutex::scoped_lock lm (_mutex);
110 int right_crop () const {
111 boost::mutex::scoped_lock lm (_mutex);
115 int top_crop () const {
116 boost::mutex::scoped_lock lm (_mutex);
120 int bottom_crop () const {
121 boost::mutex::scoped_lock lm (_mutex);
125 /** @return Description of how to scale this content (if indeed it should be scaled) */
126 VideoContentScale scale () const {
127 boost::mutex::scoped_lock lm (_mutex);
131 boost::optional<ColourConversion> colour_conversion () const {
132 boost::mutex::scoped_lock lm (_mutex);
133 return _colour_conversion;
136 boost::optional<double> sample_aspect_ratio () const {
137 boost::mutex::scoped_lock lm (_mutex);
138 return _sample_aspect_ratio;
142 boost::mutex::scoped_lock lm (_mutex);
146 Frame fade_in () const {
147 boost::mutex::scoped_lock lm (_mutex);
151 Frame fade_out () const {
152 boost::mutex::scoped_lock lm (_mutex);
156 dcp::Size size_after_3d_split () const;
157 dcp::Size size_after_crop () const;
159 boost::optional<double> fade (Frame) const;
161 void scale_and_crop_to_fit_width ();
162 void scale_and_crop_to_fit_height ();
164 std::string processing_description () const;
166 void set_length (Frame);
168 void take_from_examiner (boost::shared_ptr<VideoExaminer>);
169 void add_properties (std::list<UserProperty> &) const;
171 static boost::shared_ptr<VideoContent> from_xml (Content* parent, cxml::ConstNodePtr, int);
175 friend struct ffmpeg_pts_offset_test;
176 friend struct best_dcp_frame_rate_test_single;
177 friend struct best_dcp_frame_rate_test_double;
178 friend struct audio_sampling_rate_test;
180 VideoContent (Content* parent, cxml::ConstNodePtr, int);
181 void setup_default_colour_conversion ();
184 boost::optional<ColourConversion> _colour_conversion;
186 VideoFrameType _frame_type;
188 VideoContentScale _scale;
189 /** Sample aspect ratio obtained from the content file's header, if there is one */
190 boost::optional<double> _sample_aspect_ratio;