Extract named_channel.h
[dcpomatic.git] / src / lib / types.h
1 /*
2     Copyright (C) 2013-2021 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 #ifndef DCPOMATIC_TYPES_H
23 #define DCPOMATIC_TYPES_H
24
25
26 #include "position.h"
27 #include "rect.h"
28 #include <dcp/util.h>
29 #include <vector>
30 #include <stdint.h>
31
32
33 class Content;
34 class VideoContent;
35 class AudioContent;
36 class TextContent;
37 class FFmpegContent;
38
39
40 /** The version number of the protocol used to communicate
41  *  with servers.  Intended to be bumped when incompatibilities
42  *  are introduced.  v2 uses 64+n
43  *
44  *  64 - first version used
45  *  65 - v2.16.0 - checksums added to communication
46  */
47 #define SERVER_LINK_VERSION (64+1)
48
49 /** A film of F seconds at f FPS will be Ff frames;
50     Consider some delta FPS d, so if we run the same
51     film at (f + d) FPS it will last F(f + d) seconds.
52
53     Hence the difference in length over the length of the film will
54     be F(f + d) - Ff frames
55     = Ff + Fd - Ff frames
56     = Fd frames
57     = Fd/f seconds
58
59     So if we accept a difference of 1 frame, ie 1/f seconds, we can
60     say that
61
62     1/f = Fd/f
63     ie 1 = Fd
64     ie d = 1/F
65
66     So for a 3hr film, ie F = 3 * 60 * 60 = 10800, the acceptable
67     FPS error is 1/F ~= 0.0001 ~= 1e-4
68 */
69 #define VIDEO_FRAME_RATE_EPSILON (1e-4)
70
71 /** Port on which EncodeServer listens for frame encoding requests */
72 #define ENCODE_FRAME_PORT (Config::instance()->server_port_base())
73 /** Port on which EncodeServer listens for DCPOMATIC_HELLO from masters */
74 #define HELLO_PORT (Config::instance()->server_port_base()+1)
75 /** Port on which EncodeServerFinder in the main DCP-o-matic listens for replies to DCPOMATIC_HELLO from servers */
76 #define MAIN_SERVER_PRESENCE_PORT (Config::instance()->server_port_base()+2)
77 /** Port on which EncodeServerFinder in the batch converter listens for replies to DCPOMATIC_HELLO from servers */
78 #define BATCH_SERVER_PRESENCE_PORT (Config::instance()->server_port_base()+3)
79 /** Port on which batch converter listens for job requests */
80 #define BATCH_JOB_PORT (Config::instance()->server_port_base()+4)
81 /** Port on which player listens for play requests */
82 #define PLAYER_PLAY_PORT (Config::instance()->server_port_base()+5)
83
84 typedef std::vector<std::shared_ptr<Content>> ContentList;
85 typedef std::vector<std::shared_ptr<FFmpegContent>> FFmpegContentList;
86
87 typedef int64_t Frame;
88
89 enum class VideoFrameType
90 {
91         TWO_D,
92         /** `True' 3D content, e.g. 3D DCPs */
93         THREE_D,
94         THREE_D_LEFT_RIGHT,
95         THREE_D_TOP_BOTTOM,
96         THREE_D_ALTERNATE,
97         /** This content is all the left frames of some 3D */
98         THREE_D_LEFT,
99         /** This content is all the right frames of some 3D */
100         THREE_D_RIGHT
101 };
102
103 std::string video_frame_type_to_string (VideoFrameType);
104 VideoFrameType string_to_video_frame_type (std::string);
105
106 enum class Eyes
107 {
108         BOTH,
109         LEFT,
110         RIGHT,
111         COUNT
112 };
113
114 enum class Part
115 {
116         LEFT_HALF,
117         RIGHT_HALF,
118         TOP_HALF,
119         BOTTOM_HALF,
120         WHOLE
121 };
122
123 enum class ReelType
124 {
125         SINGLE,
126         BY_VIDEO_CONTENT,
127         BY_LENGTH
128 };
129
130
131 enum class VideoRange
132 {
133         FULL, ///< full,  or "JPEG" (0-255 for 8-bit)
134         VIDEO ///< video, or "MPEG" (16-235 for 8-bit)
135 };
136
137 extern std::string video_range_to_string (VideoRange r);
138 extern VideoRange string_to_video_range (std::string s);
139
140
141 /** Type of captions.
142  *
143  *  The generally accepted definitions seem to be:
144  *  - subtitles: text for an audience who doesn't speak the film's language
145  *  - captions:  text for a hearing-impaired audience
146  *  - open:      on-screen
147  *  - closed:    only visible by some audience members
148  *
149  *  At the moment DoM supports open subtitles and closed captions.
150  *
151  *  There is some use of the word `subtitle' in the code which may mean
152  *  caption in some contexts.
153  */
154 enum class TextType
155 {
156         UNKNOWN,
157         OPEN_SUBTITLE,
158         CLOSED_CAPTION,
159         COUNT
160 };
161
162 extern std::string text_type_to_string (TextType t);
163 extern std::string text_type_to_name (TextType t);
164 extern TextType string_to_text_type (std::string s);
165
166
167 struct CPLSummary
168 {
169         CPLSummary (boost::filesystem::path p);
170
171         CPLSummary (std::string d, std::string i, std::string a, boost::filesystem::path f, bool e, time_t t)
172                 : dcp_directory (d)
173                 , cpl_id (i)
174                 , cpl_annotation_text (a)
175                 , cpl_file (f)
176                 , encrypted (e)
177                 , last_write_time (t)
178         {}
179
180         std::string dcp_directory;
181         std::string cpl_id;
182         boost::optional<std::string> cpl_annotation_text;
183         boost::filesystem::path cpl_file;
184         /** true if this CPL has any encrypted assets */
185         bool encrypted;
186         time_t last_write_time;
187 };
188
189 enum class FileTransferProtocol {
190         SCP,
191         FTP
192 };
193
194 enum class EmailProtocol {
195         AUTO,
196         PLAIN,
197         STARTTLS,
198         SSL
199 };
200
201
202 #endif