QtGStreamer  1.2.0
 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 #include <QtCore/QDebug>
22 
23 namespace QGst {
24 
28  struct QTGSTREAMER_EXPORT Fourcc
29  {
30  inline Fourcc() { value.as_integer = 0; }
31 
32  inline Fourcc (char first, char second, char third, char fourth)
33  {
34  value.as_integer = first | second << 8 | third << 16 | fourth << 24;
35  }
36 
37  inline Fourcc(const char str[4])
38  {
39  value.as_integer = str[0] | str[1] << 8 | str[2] << 16 | str[3] << 24;
40  }
41 
42  inline Fourcc(quint32 fourcc)
43  {
44  value.as_integer = fourcc;
45  }
46 
47  union {
48 #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
49  struct {
50  char first;
51  char second;
52  char third;
53  char fourth;
54  } as_bytes;
55 #else
56  struct {
57  char fourth;
58  char third;
59  char second;
60  char first;
61  } as_bytes;
62 #endif
63  quint32 as_integer;
64  } value;
65  };
66 }
67 QGST_REGISTER_TYPE(QGst::Fourcc) //codegen: GType=G_TYPE_UINT
68 
69 namespace QGst {
73  struct QTGSTREAMER_EXPORT Fraction
74  {
75  inline Fraction() {}
76  inline Fraction(int numerator, int denominator)
77  : numerator(numerator), denominator(denominator) {}
78 
79  inline bool operator==(const Fraction & other) const
80  { return numerator == other.numerator && denominator == other.denominator; }
81  inline bool operator!=(const Fraction & other) const
82  { return !operator==(other); }
83 
84  int numerator;
85  int denominator;
86  };
87 
88  inline QDebug operator<<(QDebug debug, const Fraction &f)
89  {
90  return (debug.nospace() << f.numerator << "/" << f.denominator).maybeSpace();
91  }
92 }
93 QGST_REGISTER_TYPE(QGst::Fraction)
94 
95 namespace QGst {
96  namespace Private {
101  template <typename T>
102  struct Range
103  {
104  inline Range()
105  : start(T()), end(T()) {}
106  inline Range(const T & start, const T & end)
107  : start(start), end(end) {}
108 
109  T start;
110  T end;
111  };
112  }
113 
118 
123 
128 
133 }
134 QGST_REGISTER_TYPE(QGst::IntRange)
135 QGST_REGISTER_TYPE(QGst::Int64Range)
136 QGST_REGISTER_TYPE(QGst::DoubleRange)
137 QGST_REGISTER_TYPE(QGst::FractionRange)
138 
139 #endif // QGST_STRUCTS_H
Common template for IntRange, Int64Range, DoubleRange and FractionRange.
Definition: structs.h:102
Helper structure for accessing Fourcc values.
Definition: structs.h:28
QDebug operator<<(QDebug dbg, const Error &error)
Definition: error.cpp:95