Reasonably straightforward stuff; main things are adding
[dcpomatic.git] / src / lib / types.h
1 /*
2     Copyright (C) 2013 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<AudioContent> > AudioContentList;
52 typedef std::vector<boost::shared_ptr<SubtitleContent> > SubtitleContentList;
53 typedef std::vector<boost::shared_ptr<FFmpegContent> > FFmpegContentList;
54
55 typedef int64_t Frame;
56
57 enum VideoFrameType
58 {
59         VIDEO_FRAME_TYPE_2D,
60         VIDEO_FRAME_TYPE_3D_LEFT_RIGHT,
61         VIDEO_FRAME_TYPE_3D_TOP_BOTTOM,
62         VIDEO_FRAME_TYPE_3D_ALTERNATE,
63         /** This content is all the left frames of some 3D */
64         VIDEO_FRAME_TYPE_3D_LEFT,
65         /** This content is all the right frames of some 3D */
66         VIDEO_FRAME_TYPE_3D_RIGHT
67 };
68
69 enum Eyes
70 {
71         EYES_BOTH,
72         EYES_LEFT,
73         EYES_RIGHT,
74         EYES_COUNT
75 };
76
77 enum Part
78 {
79         PART_LEFT_HALF,
80         PART_RIGHT_HALF,
81         PART_TOP_HALF,
82         PART_BOTTOM_HALF,
83         PART_WHOLE
84 };
85
86 enum ReelType
87 {
88         REELTYPE_SINGLE,
89         REELTYPE_BY_VIDEO_CONTENT,
90         REELTYPE_BY_LENGTH
91 };
92
93 /** @struct Crop
94  *  @brief A description of the crop of an image or video.
95  */
96 struct Crop
97 {
98         Crop () : left (0), right (0), top (0), bottom (0) {}
99         Crop (int l, int r, int t, int b) : left (l), right (r), top (t), bottom (b) {}
100         Crop (boost::shared_ptr<cxml::Node>);
101
102         /** Number of pixels to remove from the left-hand side */
103         int left;
104         /** Number of pixels to remove from the right-hand side */
105         int right;
106         /** Number of pixels to remove from the top */
107         int top;
108         /** Number of pixels to remove from the bottom */
109         int bottom;
110
111         dcp::Size apply (dcp::Size s, int minimum = 4) const {
112                 s.width -= left + right;
113                 s.height -= top + bottom;
114
115                 if (s.width < minimum) {
116                         s.width = minimum;
117                 }
118
119                 if (s.height < minimum) {
120                         s.height = minimum;
121                 }
122
123                 return s;
124         }
125
126         void as_xml (xmlpp::Node *) const;
127 };
128
129 struct CPLSummary
130 {
131         CPLSummary (std::string d, std::string i, std::string a, boost::filesystem::path f)
132                 : dcp_directory (d)
133                 , cpl_id (i)
134                 , cpl_annotation_text (a)
135                 , cpl_file (f)
136         {}
137
138         std::string dcp_directory;
139         std::string cpl_id;
140         std::string cpl_annotation_text;
141         boost::filesystem::path cpl_file;
142 };
143
144 extern bool operator== (Crop const & a, Crop const & b);
145 extern bool operator!= (Crop const & a, Crop const & b);
146
147 enum Resolution {
148         RESOLUTION_2K,
149         RESOLUTION_4K
150 };
151
152 std::string resolution_to_string (Resolution);
153 Resolution string_to_resolution (std::string);
154
155 enum Protocol {
156         PROTOCOL_SCP,
157         PROTOCOL_FTP
158 };
159
160 #endif