Split audio; builds.
[dcpomatic.git] / src / lib / types.h
1 /*
2     Copyright (C) 2013-2016 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef DCPOMATIC_TYPES_H
21 #define DCPOMATIC_TYPES_H
22
23 #include "position.h"
24 #include "rect.h"
25 #include <dcp/util.h>
26 #include <boost/shared_ptr.hpp>
27 #include <vector>
28 #include <stdint.h>
29
30 class Content;
31 class VideoContent;
32 class AudioContent;
33 class SubtitleContent;
34 class FFmpegContent;
35
36 namespace cxml {
37         class Node;
38 }
39
40 namespace xmlpp {
41         class Node;
42 }
43
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
47  */
48 #define SERVER_LINK_VERSION (64+0)
49
50 typedef std::vector<boost::shared_ptr<Content> > ContentList;
51 typedef std::vector<boost::shared_ptr<FFmpegContent> > FFmpegContentList;
52
53 typedef int64_t Frame;
54
55 enum VideoFrameType
56 {
57         VIDEO_FRAME_TYPE_2D,
58         VIDEO_FRAME_TYPE_3D_LEFT_RIGHT,
59         VIDEO_FRAME_TYPE_3D_TOP_BOTTOM,
60         VIDEO_FRAME_TYPE_3D_ALTERNATE,
61         /** This content is all the left frames of some 3D */
62         VIDEO_FRAME_TYPE_3D_LEFT,
63         /** This content is all the right frames of some 3D */
64         VIDEO_FRAME_TYPE_3D_RIGHT
65 };
66
67 enum Eyes
68 {
69         EYES_BOTH,
70         EYES_LEFT,
71         EYES_RIGHT,
72         EYES_COUNT
73 };
74
75 enum Part
76 {
77         PART_LEFT_HALF,
78         PART_RIGHT_HALF,
79         PART_TOP_HALF,
80         PART_BOTTOM_HALF,
81         PART_WHOLE
82 };
83
84 enum ReelType
85 {
86         REELTYPE_SINGLE,
87         REELTYPE_BY_VIDEO_CONTENT,
88         REELTYPE_BY_LENGTH
89 };
90
91 /** @struct Crop
92  *  @brief A description of the crop of an image or video.
93  */
94 struct Crop
95 {
96         Crop () : left (0), right (0), top (0), bottom (0) {}
97         Crop (int l, int r, int t, int b) : left (l), right (r), top (t), bottom (b) {}
98         Crop (boost::shared_ptr<cxml::Node>);
99
100         /** Number of pixels to remove from the left-hand side */
101         int left;
102         /** Number of pixels to remove from the right-hand side */
103         int right;
104         /** Number of pixels to remove from the top */
105         int top;
106         /** Number of pixels to remove from the bottom */
107         int bottom;
108
109         dcp::Size apply (dcp::Size s, int minimum = 4) const {
110                 s.width -= left + right;
111                 s.height -= top + bottom;
112
113                 if (s.width < minimum) {
114                         s.width = minimum;
115                 }
116
117                 if (s.height < minimum) {
118                         s.height = minimum;
119                 }
120
121                 return s;
122         }
123
124         void as_xml (xmlpp::Node *) const;
125 };
126
127 struct CPLSummary
128 {
129         CPLSummary (std::string d, std::string i, std::string a, boost::filesystem::path f)
130                 : dcp_directory (d)
131                 , cpl_id (i)
132                 , cpl_annotation_text (a)
133                 , cpl_file (f)
134         {}
135
136         std::string dcp_directory;
137         std::string cpl_id;
138         std::string cpl_annotation_text;
139         boost::filesystem::path cpl_file;
140 };
141
142 extern bool operator== (Crop const & a, Crop const & b);
143 extern bool operator!= (Crop const & a, Crop const & b);
144
145 enum Resolution {
146         RESOLUTION_2K,
147         RESOLUTION_4K
148 };
149
150 std::string resolution_to_string (Resolution);
151 Resolution string_to_resolution (std::string);
152
153 enum Protocol {
154         PROTOCOL_SCP,
155         PROTOCOL_FTP
156 };
157
158 #endif