Remove unused constructor.
[dcpomatic.git] / src / lib / video_content.h
1 /*
2     Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 #ifndef DCPOMATIC_VIDEO_CONTENT_H
21 #define DCPOMATIC_VIDEO_CONTENT_H
22
23 #include "content.h"
24 #include "colour_conversion.h"
25 #include "video_content_scale.h"
26
27 class VideoExaminer;
28 class Ratio;
29
30 class VideoContentProperty
31 {
32 public:
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;
41 };
42
43 class VideoContent : public virtual Content
44 {
45 public:
46         VideoContent (boost::shared_ptr<const Film>);
47         VideoContent (boost::shared_ptr<const Film>, boost::filesystem::path);
48         VideoContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr, int);
49         VideoContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
50
51         void as_xml (xmlpp::Node *) const;
52         std::string technical_summary () const;
53         virtual std::string identifier () const;
54
55         virtual void set_default_colour_conversion ();
56
57         Frame video_length () const {
58                 boost::mutex::scoped_lock lm (_mutex);
59                 return _video_length;
60         }
61
62         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;
66                 }
67
68                 return _video_length;
69         }
70
71         dcp::Size video_size () const {
72                 boost::mutex::scoped_lock lm (_mutex);
73                 return _video_size;
74         }
75
76         double video_frame_rate () const;
77
78         /** @return true if this content has a specific video frame rate, false
79          *  if it should use the DCP's rate.
80          */
81         bool has_own_video_frame_rate () const {
82                 boost::mutex::scoped_lock lm (_mutex);
83                 return static_cast<bool>(_video_frame_rate);
84         }
85
86         void set_video_frame_type (VideoFrameType);
87         void set_video_frame_rate (double);
88
89         void set_left_crop (int);
90         void set_right_crop (int);
91         void set_top_crop (int);
92         void set_bottom_crop (int);
93
94         void set_scale (VideoContentScale);
95         void unset_colour_conversion ();
96         void set_colour_conversion (ColourConversion);
97
98         void set_fade_in (Frame);
99         void set_fade_out (Frame);
100
101         VideoFrameType video_frame_type () const {
102                 boost::mutex::scoped_lock lm (_mutex);
103                 return _video_frame_type;
104         }
105
106         Crop crop () const {
107                 boost::mutex::scoped_lock lm (_mutex);
108                 return _crop;
109         }
110
111         int left_crop () const {
112                 boost::mutex::scoped_lock lm (_mutex);
113                 return _crop.left;
114         }
115
116         int right_crop () const {
117                 boost::mutex::scoped_lock lm (_mutex);
118                 return _crop.right;
119         }
120
121         int top_crop () const {
122                 boost::mutex::scoped_lock lm (_mutex);
123                 return _crop.top;
124         }
125
126         int bottom_crop () const {
127                 boost::mutex::scoped_lock lm (_mutex);
128                 return _crop.bottom;
129         }
130
131         /** @return Description of how to scale this content (if indeed it should be scaled) */
132         VideoContentScale scale () const {
133                 boost::mutex::scoped_lock lm (_mutex);
134                 return _scale;
135         }
136
137         boost::optional<ColourConversion> colour_conversion () const {
138                 boost::mutex::scoped_lock lm (_mutex);
139                 return _colour_conversion;
140         }
141
142         boost::optional<double> sample_aspect_ratio () const {
143                 boost::mutex::scoped_lock lm (_mutex);
144                 return _sample_aspect_ratio;
145         }
146
147         bool yuv () const {
148                 boost::mutex::scoped_lock lm (_mutex);
149                 return _yuv;
150         }
151
152         Frame fade_in () const {
153                 boost::mutex::scoped_lock lm (_mutex);
154                 return _fade_in;
155         }
156
157         Frame fade_out () const {
158                 boost::mutex::scoped_lock lm (_mutex);
159                 return _fade_out;
160         }
161
162         dcp::Size video_size_after_3d_split () const;
163         dcp::Size video_size_after_crop () const;
164
165         ContentTime dcp_time_to_content_time (DCPTime) const;
166
167         boost::optional<double> fade (Frame) const;
168
169         void scale_and_crop_to_fit_width ();
170         void scale_and_crop_to_fit_height ();
171
172         std::string processing_description () const;
173
174 protected:
175         void take_from_video_examiner (boost::shared_ptr<VideoExaminer>);
176         void add_properties (std::list<UserProperty> &) const;
177
178         Frame _video_length;
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;
182
183 private:
184         friend struct ffmpeg_pts_offset_test;
185         friend struct best_dcp_frame_rate_test_single;
186         friend struct best_dcp_frame_rate_test_double;
187         friend struct audio_sampling_rate_test;
188
189         void setup_default_colour_conversion ();
190
191         dcp::Size _video_size;
192         VideoFrameType _video_frame_type;
193         Crop _crop;
194         VideoContentScale _scale;
195         /** Sample aspect ratio obtained from the content file's header,
196             if there is one.
197         */
198         boost::optional<double> _sample_aspect_ratio;
199         bool _yuv;
200         Frame _fade_in;
201         Frame _fade_out;
202 };
203
204 #endif