Merge branch 'master' of /home/carl/git/libdcp
[libdcp.git] / src / types.h
1 /*
2     Copyright (C) 2012 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 /** @file  src/types.h
21  *  @brief Miscellaneous types.
22  */
23
24 #ifndef LIBDCP_TYPES_H
25 #define LIBDCP_TYPES_H
26
27 #include <string>
28
29 namespace libdcp
30 {
31
32 /** Identifier for a sound channel */
33 enum Channel {
34         LEFT = 0,      ///< left
35         RIGHT = 1,     ///< right
36         CENTRE = 2,    ///< centre
37         LFE = 3,       ///< low-frequency effects (sub)
38         LS = 4,        ///< left surround
39         RS = 5,        ///< right surround
40         CHANNEL_7 = 6, ///< channel 7; not sure what this should be called
41         CHANNEL_8 = 7  ///< channel 8; not sure what this should be called
42 };
43
44 enum ContentKind
45 {
46         FEATURE,
47         SHORT,
48         TRAILER,
49         TEST,
50         TRANSITIONAL,
51         RATING,
52         TEASER,
53         POLICY,
54         PUBLIC_SERVICE_ANNOUNCEMENT,
55         ADVERTISEMENT
56 };
57
58 enum Effect
59 {
60         NONE,
61         BORDER,
62         SHADOW
63 };
64
65 extern std::string effect_to_string (Effect e);
66 extern Effect string_to_effect (std::string s);
67
68 enum VAlign
69 {
70         TOP,
71         CENTER,
72         BOTTOM
73 };
74
75 extern std::string valign_to_string (VAlign a);
76 extern VAlign string_to_valign (std::string s);
77
78 enum Eye
79 {
80         EYE_LEFT,
81         EYE_RIGHT
82 };
83         
84 class Fraction
85 {
86 public:
87         Fraction () : numerator (0), denominator (0) {}
88         Fraction (std::string s);
89         Fraction (int n, int d) : numerator (n), denominator (d) {}
90
91         int numerator;
92         int denominator;
93 };
94
95 extern bool operator== (Fraction const & a, Fraction const & b);
96 extern bool operator!= (Fraction const & a, Fraction const & b);
97         
98 struct EqualityOptions {
99         EqualityOptions () 
100                 : max_mean_pixel_error (0)
101                 , max_std_dev_pixel_error (0)
102                 , max_audio_sample_error (0)
103                 , mxf_names_can_differ (false)
104         {}
105
106         double max_mean_pixel_error;
107         double max_std_dev_pixel_error;
108         int max_audio_sample_error;
109         bool mxf_names_can_differ;
110 };
111
112 enum NoteType {
113         PROGRESS,
114         ERROR,
115         NOTE
116 };
117
118 /** @class Color
119  *  @brief An RGB color (aka colour).
120  */
121 class Color
122 {
123 public:
124         Color ();
125         Color (int r_, int g_, int b_);
126         Color (std::string argb_hex);
127
128         int r; ///< red component, from 0 to 255
129         int g; ///< green component, from 0 to 255
130         int b; ///< blue component, from 0 to 255
131
132         std::string to_argb_string () const;
133 };
134
135 extern bool operator== (Color const & a, Color const & b);
136 extern bool operator!= (Color const & a, Color const & b);
137 extern std::ostream & operator<< (std::ostream & s, Color const & c);
138
139 }
140
141 #endif