QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
structs.h
00001 /*
00002     Copyright (C) 2010  George Kiagiadakis <kiagiadakis.george@gmail.com>
00003 
00004     This library is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU Lesser General Public License as published
00006     by the Free Software Foundation; either version 2.1 of the License, or
00007     (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU Lesser General Public License for more details.
00013 
00014     You should have received a copy of the GNU Lesser General Public License
00015     along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016 */
00017 #ifndef QGST_STRUCTS_H
00018 #define QGST_STRUCTS_H
00019 
00020 #include "global.h"
00021 
00022 namespace QGst {
00023 
00027     struct QTGSTREAMER_EXPORT Fourcc
00028     {
00029         inline Fourcc() { value.as_integer = 0; }
00030 
00031         inline Fourcc (char first, char second, char third, char fourth)
00032         {
00033             value.as_integer = first | second << 8 | third << 16 | fourth << 24;
00034         }
00035 
00036         inline Fourcc(const char str[4])
00037         {
00038             value.as_integer = str[0] | str[1] << 8 | str[2] << 16 | str[3] << 24;
00039         }
00040 
00041         inline Fourcc(quint32 fourcc)
00042         {
00043             value.as_integer = fourcc;
00044         }
00045 
00046         union {
00047 #if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
00048             struct {
00049                 char first;
00050                 char second;
00051                 char third;
00052                 char fourth;
00053             } as_bytes;
00054 #else
00055             struct {
00056                 char fourth;
00057                 char third;
00058                 char second;
00059                 char first;
00060             } as_bytes;
00061 #endif
00062             quint32 as_integer;
00063         } value;
00064     };
00065 }
00066 QGST_REGISTER_TYPE(QGst::Fourcc)
00067 
00068 namespace QGst {
00072     struct QTGSTREAMER_EXPORT Fraction
00073     {
00074         inline Fraction() {}
00075         inline Fraction(int numerator, int denominator)
00076             : numerator(numerator), denominator(denominator) {}
00077 
00078         int numerator;
00079         int denominator;
00080     };
00081 }
00082 QGST_REGISTER_TYPE(QGst::Fraction)
00083 
00084 namespace QGst {
00085     namespace Private {
00090         template <typename T>
00091         struct Range
00092         {
00093             inline Range()
00094                 : start(T()), end(T()) {}
00095             inline Range(const T & start, const T & end)
00096                 : start(start), end(end) {}
00097 
00098             T start;
00099             T end;
00100         };
00101     }
00102 
00106     typedef Private::Range<int> IntRange;
00107 
00111     typedef Private::Range<qint64> Int64Range;
00112 
00116     typedef Private::Range<double> DoubleRange;
00117 
00121     typedef Private::Range<Fraction> FractionRange;
00122 }
00123 QGST_REGISTER_TYPE(QGst::IntRange)
00124 QGST_REGISTER_TYPE(QGst::Int64Range)
00125 QGST_REGISTER_TYPE(QGst::DoubleRange)
00126 QGST_REGISTER_TYPE(QGst::FractionRange)
00127 
00128 #endif // QGST_STRUCTS_H