2 Copyright (C) 2013-2021 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_TYPES_H
22 #define DCPOMATIC_TYPES_H
44 /** The version number of the protocol used to communicate
45 * with servers. Intended to be bumped when incompatibilities
46 * are introduced. v2 uses 64+n
48 * 64 - first version used
49 * 65 - v2.16.0 - checksums added to communication
51 #define SERVER_LINK_VERSION (64+1)
53 /** A film of F seconds at f FPS will be Ff frames;
54 Consider some delta FPS d, so if we run the same
55 film at (f + d) FPS it will last F(f + d) seconds.
57 Hence the difference in length over the length of the film will
58 be F(f + d) - Ff frames
63 So if we accept a difference of 1 frame, ie 1/f seconds, we can
70 So for a 3hr film, ie F = 3 * 60 * 60 = 10800, the acceptable
71 FPS error is 1/F ~= 0.0001 ~= 1e-4
73 #define VIDEO_FRAME_RATE_EPSILON (1e-4)
75 /** Port on which EncodeServer listens for frame encoding requests */
76 #define ENCODE_FRAME_PORT (Config::instance()->server_port_base())
77 /** Port on which EncodeServer listens for DCPOMATIC_HELLO from masters */
78 #define HELLO_PORT (Config::instance()->server_port_base()+1)
79 /** Port on which EncodeServerFinder in the main DCP-o-matic listens for replies to DCPOMATIC_HELLO from servers */
80 #define MAIN_SERVER_PRESENCE_PORT (Config::instance()->server_port_base()+2)
81 /** Port on which EncodeServerFinder in the batch converter listens for replies to DCPOMATIC_HELLO from servers */
82 #define BATCH_SERVER_PRESENCE_PORT (Config::instance()->server_port_base()+3)
83 /** Port on which batch converter listens for job requests */
84 #define BATCH_JOB_PORT (Config::instance()->server_port_base()+4)
85 /** Port on which player listens for play requests */
86 #define PLAYER_PLAY_PORT (Config::instance()->server_port_base()+5)
88 typedef std::vector<std::shared_ptr<Content>> ContentList;
89 typedef std::vector<std::shared_ptr<FFmpegContent>> FFmpegContentList;
91 typedef int64_t Frame;
93 enum class VideoFrameType
96 /** `True' 3D content, e.g. 3D DCPs */
101 /** This content is all the left frames of some 3D */
103 /** This content is all the right frames of some 3D */
107 std::string video_frame_type_to_string (VideoFrameType);
108 VideoFrameType string_to_video_frame_type (std::string);
135 enum class VideoRange
137 FULL, ///< full, or "JPEG" (0-255 for 8-bit)
138 VIDEO ///< video, or "MPEG" (16-235 for 8-bit)
141 extern std::string video_range_to_string (VideoRange r);
142 extern VideoRange string_to_video_range (std::string s);
145 /** Type of captions.
147 * The generally accepted definitions seem to be:
148 * - subtitles: text for an audience who doesn't speak the film's language
149 * - captions: text for a hearing-impaired audience
151 * - closed: only visible by some audience members
153 * At the moment DoM supports open subtitles and closed captions.
155 * There is some use of the word `subtitle' in the code which may mean
156 * caption in some contexts.
166 extern std::string text_type_to_string (TextType t);
167 extern std::string text_type_to_name (TextType t);
168 extern TextType string_to_text_type (std::string s);
171 * @brief A description of the crop of an image or video.
175 Crop () : left (0), right (0), top (0), bottom (0) {}
176 Crop (int l, int r, int t, int b) : left (l), right (r), top (t), bottom (b) {}
177 explicit Crop (std::shared_ptr<cxml::Node>);
179 /** Number of pixels to remove from the left-hand side */
181 /** Number of pixels to remove from the right-hand side */
183 /** Number of pixels to remove from the top */
185 /** Number of pixels to remove from the bottom */
188 dcp::Size apply (dcp::Size s, int minimum = 4) const {
189 s.width -= left + right;
190 s.height -= top + bottom;
192 if (s.width < minimum) {
196 if (s.height < minimum) {
203 void as_xml (xmlpp::Node *) const;
206 extern bool operator== (Crop const & a, Crop const & b);
207 extern bool operator!= (Crop const & a, Crop const & b);
211 CPLSummary (boost::filesystem::path p);
213 CPLSummary (std::string d, std::string i, std::string a, boost::filesystem::path f, bool e, time_t t)
216 , cpl_annotation_text (a)
219 , last_write_time (t)
222 std::string dcp_directory;
224 boost::optional<std::string> cpl_annotation_text;
225 boost::filesystem::path cpl_file;
226 /** true if this CPL has any encrypted assets */
228 time_t last_write_time;
231 enum class Resolution {
236 std::string resolution_to_string (Resolution);
237 Resolution string_to_resolution (std::string);
239 enum class FileTransferProtocol {
244 enum class EmailProtocol {
255 NamedChannel (std::string name_, int index_)
265 bool operator== (NamedChannel const& a, NamedChannel const& b);