Extract resolution.h
[dcpomatic.git] / src / lib / dcp_video.h
1 /*
2     Copyright (C) 2012-2016 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21
22 #include "encode_server_description.h"
23 #include "resolution.h"
24 #include <libcxml/cxml.h>
25 #include <dcp/array_data.h>
26
27
28 /** @file  src/dcp_video_frame.h
29  *  @brief A single frame of video destined for a DCP.
30  */
31
32
33 class Log;
34 class PlayerVideo;
35
36
37 /** @class DCPVideo
38  *  @brief A single frame of video destined for a DCP.
39  *
40  *  Given an Image and some settings, this class knows how to encode
41  *  the image to J2K either on the local host or on a remote server.
42  *
43  *  Objects of this class are used for the queue that we keep
44  *  of images that require encoding.
45  */
46 class DCPVideo
47 {
48 public:
49         DCPVideo (std::shared_ptr<const PlayerVideo>, int index, int dcp_fps, int bandwidth, Resolution r);
50         DCPVideo (std::shared_ptr<const PlayerVideo>, cxml::ConstNodePtr);
51
52         DCPVideo (DCPVideo const&) = default;
53         DCPVideo& operator= (DCPVideo const&) = default;
54
55         dcp::ArrayData encode_locally () const;
56         dcp::ArrayData encode_remotely (EncodeServerDescription, int timeout = 30) const;
57
58         int index () const {
59                 return _index;
60         }
61
62         Eyes eyes () const;
63
64         bool same (std::shared_ptr<const DCPVideo> other) const;
65
66         static std::shared_ptr<dcp::OpenJPEGImage> convert_to_xyz (std::shared_ptr<const PlayerVideo> frame, dcp::NoteHandler note);
67
68 private:
69
70         void add_metadata (xmlpp::Element *) const;
71
72         std::shared_ptr<const PlayerVideo> _frame;
73         int _index;                      ///< frame index within the DCP's intrinsic duration
74         int _frames_per_second;          ///< Frames per second that we will use for the DCP
75         int _j2k_bandwidth;              ///< J2K bandwidth to use
76         Resolution _resolution;          ///< Resolution (2K or 4K)
77 };