Rename j2k_bandwidth -> video_bit_rate.
[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 #ifndef DCPOMATIC_DCP_VIDEO_H
21 #define DCPOMATIC_DCP_VIDEO_H
22
23
24 #include "encode_server_description.h"
25 #include "resolution.h"
26 #include <libcxml/cxml.h>
27 #include <dcp/array_data.h>
28 #include <dcp/openjpeg_image.h>
29
30
31 /** @file  src/dcp_video_frame.h
32  *  @brief A single frame of video destined for a DCP.
33  */
34
35
36 class Log;
37 class PlayerVideo;
38
39
40 /** @class DCPVideo
41  *  @brief A single frame of video destined for a DCP.
42  *
43  *  Given an Image and some settings, this class knows how to encode
44  *  the image to J2K either on the local host or on a remote server.
45  *
46  *  Objects of this class are used for the queue that we keep
47  *  of images that require encoding.
48  */
49 class DCPVideo
50 {
51 public:
52         DCPVideo(std::shared_ptr<const PlayerVideo>, int index, int dcp_fps, int64_t bit_rate, Resolution r);
53         DCPVideo (std::shared_ptr<const PlayerVideo>, cxml::ConstNodePtr);
54
55         DCPVideo (DCPVideo const&) = default;
56         DCPVideo& operator= (DCPVideo const&) = default;
57
58         dcp::ArrayData encode_locally () const;
59         dcp::ArrayData encode_remotely (EncodeServerDescription, int timeout = 30) const;
60
61         int index () const {
62                 return _index;
63         }
64
65         Eyes eyes () const;
66
67         bool same (std::shared_ptr<const DCPVideo> other) const;
68
69         static std::shared_ptr<dcp::OpenJPEGImage> convert_to_xyz(std::shared_ptr<const PlayerVideo> frame);
70
71         void convert_to_xyz(uint16_t* dst) const;
72         dcp::Size get_size() const;
73
74 private:
75
76         void add_metadata (xmlpp::Element *) const;
77
78         std::shared_ptr<const PlayerVideo> _frame;
79         int _index;                      ///< frame index within the DCP's intrinsic duration
80         int _frames_per_second;          ///< Frames per second that we will use for the DCP
81         int64_t _video_bit_rate;         ///< Video bit rate to use
82         Resolution _resolution;          ///< Resolution (2K or 4K)
83 };
84
85 #endif