summaryrefslogtreecommitdiff
path: root/src/QGst/global.h
blob: b5a886528238f8f151c20b76c5457f8a2cbcc6f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
/*
    Copyright (C) 2010  George Kiagiadakis <kiagiadakis.george@gmail.com>

    This library is free software; you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published
    by the Free Software Foundation; either version 2.1 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef QGST_GLOBAL_H
#define QGST_GLOBAL_H

#include "enums.h"
#include <QtCore/QtGlobal>
#include <QtCore/QSharedPointer>

#define QGST_WRAPPER_GSTCLASS_DECLARATION(Class) \
    typedef struct _Gst##Class Gst##Class;

#define QGST_WRAPPER_REFPOINTER_DECLARATION(Class) \
    namespace QGst { \
        class Class; \
        typedef QGlib::RefPointer<Class> Class##Ptr; \
    }

#define QGST_WRAPPER_DECLARATION(Class) \
    QGST_WRAPPER_GSTCLASS_DECLARATION(Class) \
    QGST_WRAPPER_REFPOINTER_DECLARATION(Class)

#define QGST_SUBCLASS_REGISTER_CONVERTERS(BASECLASS, TYPE) \
    namespace QGlib { \
    namespace Private { \
        template <> \
        struct CanConvertTo<QGst::TYPE##BASECLASS> \
        { \
            static inline bool from(void *instance) \
            { \
                return (Type::fromInstance(instance).isA<QGst::BASECLASS>() && \
                        QGst::BASECLASS##Ptr::wrap(static_cast<Gst##BASECLASS *>(instance))->type() \
                        == QGst::BASECLASS##TYPE); \
            } \
        }; \
    } /* namespace Private */ \
    } /* namespace QGlib */

#define QGST_SUBCLASS_REGISTER_VALUEIMPL(BASECLASS, TYPE) \
    namespace QGlib { \
        template<> \
        struct ValueImpl<QGst::TYPE##BASECLASS##Ptr> \
        { \
            static void set(Value & value, const QGst::TYPE##BASECLASS##Ptr & data) { \
                ValueImpl<QGst::BASECLASS##Ptr>::set(value, data); \
            } \
        }; \
    } /* namespace QGlib */

#define QGST_REGISTER_SUBCLASS(BASECLASS, TYPE) \
    QGST_SUBCLASS_REGISTER_CONVERTERS(BASECLASS, TYPE) \
        QGST_SUBCLASS_REGISTER_VALUEIMPL(BASECLASS, TYPE)

QGST_WRAPPER_DECLARATION(Bin)
QGST_WRAPPER_DECLARATION(Bus)
QGST_WRAPPER_DECLARATION(Caps)
QGST_WRAPPER_DECLARATION(ChildProxy)
QGST_WRAPPER_DECLARATION(Clock)
QGST_WRAPPER_DECLARATION(ColorBalanceChannel)
QGST_WRAPPER_DECLARATION(ColorBalance)
QGST_WRAPPER_DECLARATION(Element)
QGST_WRAPPER_DECLARATION(ElementFactory)
QGST_WRAPPER_DECLARATION(GhostPad)
QGST_WRAPPER_DECLARATION(Message)
QGST_WRAPPER_REFPOINTER_DECLARATION(EosMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(ErrorMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(WarningMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(InfoMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(BufferingMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(StateChangedMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(StepDoneMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(StreamStatusMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(ApplicationMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(ElementMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(SegmentDoneMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(DurationMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(LatencyMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(AsyncDoneMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(RequestStateMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(StepStartMessage)
QGST_WRAPPER_REFPOINTER_DECLARATION(QosMessage)
QGST_WRAPPER_DECLARATION(MiniObject)
QGST_WRAPPER_DECLARATION(Object)
QGST_WRAPPER_DECLARATION(Pad)
QGST_WRAPPER_DECLARATION(Pipeline)
QGST_WRAPPER_DECLARATION(PluginFeature)
QGST_WRAPPER_DECLARATION(PropertyProbe)
QGST_WRAPPER_DECLARATION(Query)
QGST_WRAPPER_REFPOINTER_DECLARATION(PositionQuery)
QGST_WRAPPER_REFPOINTER_DECLARATION(DurationQuery)
QGST_WRAPPER_REFPOINTER_DECLARATION(LatencyQuery)
QGST_WRAPPER_REFPOINTER_DECLARATION(SeekingQuery)
QGST_WRAPPER_REFPOINTER_DECLARATION(SegmentQuery)
QGST_WRAPPER_REFPOINTER_DECLARATION(ConvertQuery)
QGST_WRAPPER_REFPOINTER_DECLARATION(FormatsQuery)
QGST_WRAPPER_REFPOINTER_DECLARATION(BufferingQuery)
QGST_WRAPPER_REFPOINTER_DECLARATION(UriQuery)
QGST_WRAPPER_DECLARATION(Buffer)
QGST_WRAPPER_DECLARATION(Event)
QGST_WRAPPER_REFPOINTER_DECLARATION(FlushStartEvent)
QGST_WRAPPER_REFPOINTER_DECLARATION(FlushStopEvent)
QGST_WRAPPER_REFPOINTER_DECLARATION(EosEvent)
QGST_WRAPPER_REFPOINTER_DECLARATION(NewSegmentEvent)
//TODO QGST_REGISTER_EVENT_SUBCLASS(TagEvent)
QGST_WRAPPER_REFPOINTER_DECLARATION(BufferSizeEvent)
QGST_WRAPPER_REFPOINTER_DECLARATION(SinkMessageEvent)
QGST_WRAPPER_REFPOINTER_DECLARATION(QosEvent)
QGST_WRAPPER_REFPOINTER_DECLARATION(SeekEvent)
QGST_WRAPPER_REFPOINTER_DECLARATION(NavigationEvent)
QGST_WRAPPER_REFPOINTER_DECLARATION(LatencyEvent)
QGST_WRAPPER_REFPOINTER_DECLARATION(StepEvent)
QGST_WRAPPER_DECLARATION(StreamVolume)
QGST_WRAPPER_GSTCLASS_DECLARATION(Structure)
namespace QGst {
    class Structure;
    class SharedStructure;
    typedef QSharedPointer<SharedStructure> StructurePtr;
}
QGST_WRAPPER_GSTCLASS_DECLARATION(URIHandler)
QGST_WRAPPER_REFPOINTER_DECLARATION(UriHandler)
QGST_WRAPPER_DECLARATION(VideoOrientation)
QGST_WRAPPER_DECLARATION(XOverlay)

#undef QGST_WRAPPER_DECLARATION
#undef QGST_WRAPPER_REFPOINTER_DECLARATION
#undef QGST_WRAPPER_GSTCLASS_DECLARATION


#define QGST_WRAPPER(Class) \
    QGLIB_WRAPPER_DECLARATION_MACRO(Class, Class, Gst, Class)

#define QGST_WRAPPER_DIFFERENT_C_CLASS(Class, CClass) \
    QGLIB_WRAPPER_DECLARATION_MACRO(Class, CClass, Gst, Class)

#define QGST_WRAPPER_FAKE_SUBCLASS(Sub, Class) \
    QGLIB_WRAPPER_DECLARATION_MACRO(Sub##Class, Class, Gst, Class)


namespace QGst {
    /*! A datatype to hold a time, measured in nanoseconds */
    typedef quint64 ClockTime;

    /*! A datatype to hold a time difference, measured in nanoseconds */
    typedef qint64 ClockTimeDiff;
}

namespace QGst {
    /*! \overload */
    void init();

    /*! Initializes the GStreamer library, setting up internal path lists,
     * registering built-in elements, and loading standard plugins.
     * \param argc pointer to the application's argc
     * \param argv pointer to the application's argv
     * \throws QGlib::Error when initialization fails
     */
    void init(int *argc, char **argv[]);

    /*! Clean up any resources created by GStreamer in init().
     *
     * It is normally not needed to call this function in a normal application as the resources
     * will automatically be freed when the program terminates. This function is therefore mostly
     * used by testsuites and other memory profiling tools.
     *
     * After this call GStreamer (including this method) should not be used anymore.
     */
    void cleanup();
}

#endif