QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
structs.h
1 /*
2  Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
3 
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as published
6  by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #ifndef QGST_STRUCTS_H
18 #define QGST_STRUCTS_H
19 
20 #include "global.h"
21 
22 namespace QGst {
23 
27  struct QTGSTREAMER_EXPORT Fourcc
28  {
29  inline Fourcc() { value.as_integer = 0; }
30 
31  inline Fourcc (char first, char second, char third, char fourth)
32  {
33  value.as_integer = first | second << 8 | third << 16 | fourth << 24;
34  }
35 
36  inline Fourcc(const char str[4])
37  {
38  value.as_integer = str[0] | str[1] << 8 | str[2] << 16 | str[3] << 24;
39  }
40 
41  inline Fourcc(quint32 fourcc)
42  {
43  value.as_integer = fourcc;
44  }
45 
46  union {
47 #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
48  struct {
49  char first;
50  char second;
51  char third;
52  char fourth;
53  } as_bytes;
54 #else
55  struct {
56  char fourth;
57  char third;
58  char second;
59  char first;
60  } as_bytes;
61 #endif
62  quint32 as_integer;
63  } value;
64  };
65 }
66 QGST_REGISTER_TYPE(QGst::Fourcc)
67 
68 namespace QGst {
72  struct QTGSTREAMER_EXPORT Fraction
73  {
74  inline Fraction() {}
75  inline Fraction(int numerator, int denominator)
76  : numerator(numerator), denominator(denominator) {}
77 
78  int numerator;
79  int denominator;
80  };
81 }
82 QGST_REGISTER_TYPE(QGst::Fraction)
83 
84 namespace QGst {
85  namespace Private {
90  template <typename T>
91  struct Range
92  {
93  inline Range()
94  : start(T()), end(T()) {}
95  inline Range(const T & start, const T & end)
96  : start(start), end(end) {}
97 
98  T start;
99  T end;
100  };
101  }
102 
107 
112 
117 
122 }
123 QGST_REGISTER_TYPE(QGst::IntRange)
124 QGST_REGISTER_TYPE(QGst::Int64Range)
125 QGST_REGISTER_TYPE(QGst::DoubleRange)
126 QGST_REGISTER_TYPE(QGst::FractionRange)
127 
128 #endif // QGST_STRUCTS_H