QtGStreamer 1.2.0
Loading...
Searching...
No Matches
element.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_ELEMENT_H
18#define QGST_ELEMENT_H
19
20#include "object.h"
21#include "caps.h"
22#include "clocktime.h"
23
24#if !QGLIB_HAVE_CXX0X
25# include <boost/preprocessor.hpp>
26#endif
27
28namespace QGst {
29
33class QTGSTREAMER_EXPORT Element : public Object
34{
35 QGST_WRAPPER(Element)
36public:
37 State currentState() const;
38 State pendingState() const;
39 StateChangeReturn getState(State *state, State *pending, ClockTime timeout) const;
40 StateChangeReturn setState(State state);
41 bool syncStateWithParent();
42
43 bool stateIsLocked() const;
44 bool setStateLocked(bool locked);
45
46 bool addPad(const PadPtr & pad);
47 bool removePad(const PadPtr & pad);
48
49 PadPtr getStaticPad(const char *name);
50 PadPtr getRequestPad(const char *name);
51 void releaseRequestPad(const PadPtr & pad);
52
53 ClockPtr clock() const;
54 bool setClock(const ClockPtr & clock);
55
56 bool link(const char *srcPadName, const ElementPtr & dest,
57 const char *sinkPadName, const CapsPtr & filter = CapsPtr());
58 bool link(const char *srcPadName, const ElementPtr & dest,
59 const CapsPtr & filter = CapsPtr());
60 bool link(const ElementPtr & dest, const char *sinkPadName,
61 const CapsPtr & filter = CapsPtr());
62 bool link(const ElementPtr & dest, const CapsPtr & filter = CapsPtr());
63
64#ifndef DOXYGEN_RUN
65 //FIXME-0.11 Remove the default NULL parameter from the first version
66 //and remove entirely sinkPadName from the second version
67 void unlink(const char *srcPadName, const ElementPtr & dest,
68 const char *sinkPadName = NULL);
69 void unlink(const ElementPtr & dest, const char *sinkPadName = NULL);
70#else
71 //documentation should show those functions as they are meant to be used.
74 void unlink(const char *srcPadName, const ElementPtr & dest, const char *sinkPadName);
75
77 void unlink(const ElementPtr & dest);
78#endif
79
80#ifndef DOXYGEN_RUN
81private:
82 static inline bool linkMany(const ElementPtr & first, const ElementPtr & second)
83 {
84 return first->link(second);
85 }
86
87 static inline void unlinkMany(const ElementPtr & first, const ElementPtr & second)
88 {
89 first->unlink(second);
90 }
91public:
92#endif
93
94#if QGLIB_HAVE_CXX0X
101 template <typename First, typename Second, typename Third, typename... Rest>
102 static inline bool linkMany(const First & first, const Second & second,
103 const Third & third, const Rest & ... rest)
104 {
105 if (!first->link(second)) return false;
106 return linkMany(second, third, rest...);
107 }
108
115 template <typename First, typename Second, typename Third, typename... Rest>
116 static inline void unlinkMany(const First & first, const Second & second,
117 const Third & third, const Rest & ... rest)
118 {
119 first->unlink(second);
120 unlinkMany(second, third, rest...);
121 }
122#else //QGLIB_HAVE_CXX0X
123
124# ifndef QGST_ELEMENT_LINK_MANY_MAX_ARGS
125# define QGST_ELEMENT_LINK_MANY_MAX_ARGS 10
126# endif
127
128# ifndef QGST_ELEMENT_UNLINK_MANY_MAX_ARGS
129# define QGST_ELEMENT_UNLINK_MANY_MAX_ARGS 10
130# endif
131
132# define QGST_ELEMENT_LINK_MANY_DECLARATION(z, n, data) \
133 static inline bool linkMany(BOOST_PP_ENUM_PARAMS(n, const ElementPtr & e)) \
134 { \
135 if (!e0->link(e1)) return false; \
136 return linkMany(BOOST_PP_ENUM_SHIFTED_PARAMS(n, e)); \
137 };
138
139# define QGST_ELEMENT_UNLINK_MANY_DECLARATION(z, n, data) \
140 static inline void unlinkMany(BOOST_PP_ENUM_PARAMS(n, const ElementPtr & e)) \
141 { \
142 e0->unlink(e1); \
143 unlinkMany(BOOST_PP_ENUM_SHIFTED_PARAMS(n, e)); \
144 };
145
146 BOOST_PP_REPEAT_FROM_TO(3, BOOST_PP_INC(QGST_ELEMENT_LINK_MANY_MAX_ARGS),
147 QGST_ELEMENT_LINK_MANY_DECLARATION, dummy)
148 BOOST_PP_REPEAT_FROM_TO(3, BOOST_PP_INC(QGST_ELEMENT_UNLINK_MANY_MAX_ARGS),
149 QGST_ELEMENT_UNLINK_MANY_DECLARATION, dummy)
150
151# undef QGST_ELEMENT_LINK_MANY_DECLARATION
152# undef QGST_ELEMENT_UNLINK_MANY_DECLARATION
153
154#endif //QGLIB_HAVE_CXX0X
155
156 bool query(const QueryPtr & query);
157 bool sendEvent(const EventPtr & event);
158 bool seek(Format format, SeekFlags flags, quint64 position);
159};
160
161}
162
163QGST_REGISTER_TYPE(QGst::Element)
164
165#endif // QGST_ELEMENT_H
Smart pointer class for working with wrapper classes that support reference counting.
Definition refpointer.h:91
A datatype to hold a time, measured in nanoseconds.
Definition clocktime.h:38
Wrapper class for GstElement.
Definition element.h:34
static bool linkMany(const First &first, const Second &second, const Third &third, const Rest &... rest)
Definition element.h:102
static void unlinkMany(const First &first, const Second &second, const Third &third, const Rest &... rest)
Definition element.h:116
void unlink(const ElementPtr &dest)
Wrapper class for GstObject.
Definition object.h:29
Wrappers for GStreamer classes.