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;
41 class VideoContent : public virtual Content
46 VideoContent (boost::shared_ptr<const Film>);
47 VideoContent (boost::shared_ptr<const Film>, Time, VideoContent::Frame);
48 VideoContent (boost::shared_ptr<const Film>, boost::filesystem::path);
49 VideoContent (boost::shared_ptr<const Film>, boost::shared_ptr<const cxml::Node>, 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 information () const;
55 virtual std::string identifier () const;
57 VideoContent::Frame video_length () const {
58 boost::mutex::scoped_lock lm (_mutex);
62 VideoContent::Frame video_length_after_3d_combine () const {
63 boost::mutex::scoped_lock lm (_mutex);
64 if (_video_frame_type == VIDEO_FRAME_TYPE_3D_ALTERNATE) {
65 return _video_length / 2;
71 libdcp::Size video_size () const {
72 boost::mutex::scoped_lock lm (_mutex);
76 float video_frame_rate () const {
77 boost::mutex::scoped_lock lm (_mutex);
78 return _video_frame_rate;
81 float original_video_frame_rate () const {
82 boost::mutex::scoped_lock lm (_mutex);
83 return _original_video_frame_rate;
86 void set_video_frame_type (VideoFrameType);
87 void set_video_frame_rate (float);
89 void set_left_crop (int);
90 void set_right_crop (int);
91 void set_top_crop (int);
92 void set_bottom_crop (int);
94 void set_scale (VideoContentScale);
95 void unset_colour_conversion ();
96 void set_colour_conversion (ColourConversion);
97 void set_default_colour_conversion ();
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 libdcp::Size video_size_after_3d_split () const;
141 libdcp::Size video_size_after_crop () const;
143 VideoContent::Frame time_to_content_video_frames (Time) const;
145 void scale_and_crop_to_fit_width ();
146 void scale_and_crop_to_fit_height ();
149 void take_from_video_examiner (boost::shared_ptr<VideoExaminer>);
151 VideoContent::Frame _video_length;
152 float _original_video_frame_rate;
153 float _video_frame_rate;
156 friend class ffmpeg_pts_offset_test;
157 friend class best_dcp_frame_rate_test_single;
158 friend class best_dcp_frame_rate_test_double;
159 friend class audio_sampling_rate_test;
161 libdcp::Size _video_size;
162 VideoFrameType _video_frame_type;
164 VideoContentScale _scale;
165 boost::optional<ColourConversion> _colour_conversion;