Add video_{range,frame_type}.{cc,h} and remove some types.h includes.
[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 Eyes
90 {
91         BOTH,
92         LEFT,
93         RIGHT,
94         COUNT
95 };
96
97 enum class Part
98 {
99         LEFT_HALF,
100         RIGHT_HALF,
101         TOP_HALF,
102         BOTTOM_HALF,
103         WHOLE
104 };
105
106 enum class ReelType
107 {
108         SINGLE,
109         BY_VIDEO_CONTENT,
110         BY_LENGTH
111 };
112
113
114 /** Type of captions.
115  *
116  *  The generally accepted definitions seem to be:
117  *  - subtitles: text for an audience who doesn't speak the film's language
118  *  - captions:  text for a hearing-impaired audience
119  *  - open:      on-screen
120  *  - closed:    only visible by some audience members
121  *
122  *  At the moment DoM supports open subtitles and closed captions.
123  *
124  *  There is some use of the word `subtitle' in the code which may mean
125  *  caption in some contexts.
126  */
127 enum class TextType
128 {
129         UNKNOWN,
130         OPEN_SUBTITLE,
131         CLOSED_CAPTION,
132         COUNT
133 };
134
135 extern std::string text_type_to_string (TextType t);
136 extern std::string text_type_to_name (TextType t);
137 extern TextType string_to_text_type (std::string s);
138
139
140 struct CPLSummary
141 {
142         CPLSummary (boost::filesystem::path p);
143
144         CPLSummary (std::string d, std::string i, std::string a, boost::filesystem::path f, bool e, time_t t)
145                 : dcp_directory (d)
146                 , cpl_id (i)
147                 , cpl_annotation_text (a)
148                 , cpl_file (f)
149                 , encrypted (e)
150                 , last_write_time (t)
151         {}
152
153         std::string dcp_directory;
154         std::string cpl_id;
155         boost::optional<std::string> cpl_annotation_text;
156         boost::filesystem::path cpl_file;
157         /** true if this CPL has any encrypted assets */
158         bool encrypted;
159         time_t last_write_time;
160 };
161
162 enum class FileTransferProtocol {
163         SCP,
164         FTP
165 };
166
167 enum class EmailProtocol {
168         AUTO,
169         PLAIN,
170         STARTTLS,
171         SSL
172 };
173
174
175 #endif