QtGStreamer  1.2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
bin.h
1 /*
2  Copyright (C) 2009-2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
3  Copyright (C) 2011 Collabora Ltd.
4  @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
5 
6  This library is free software; you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation; either version 2.1 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 #ifndef QGST_BIN_H
20 #define QGST_BIN_H
21 
22 #include "element.h"
23 #include "childproxy.h"
24 
25 #ifdef Q_CC_MSVC
26 # pragma warning(push)
27 # pragma warning(disable:4250) //Bin inherits QGst::Object::ref/unref via dominance
28 #endif
29 
30 #if !QGLIB_HAVE_CXX0X
31 # include <boost/preprocessor.hpp>
32 #endif
33 
34 namespace QGst {
35 
45 class QTGSTREAMER_EXPORT Bin : public Element, public ChildProxy
46 {
47  QGST_WRAPPER(Bin)
48 public:
50  static BinPtr create(const char *name = NULL);
51 
53  enum BinFromDescriptionOption { //codegen: skip=true
54  NoGhost = 0,
55  Ghost = 1
56  };
57 
66  static BinPtr fromDescription(const char *description,
67  BinFromDescriptionOption ghostUnlinkedPads = Ghost);
69  static inline BinPtr fromDescription(const QString & description,
70  BinFromDescriptionOption ghostUnlinkedPads = Ghost);
71 
78  bool add(const ElementPtr & element);
79 
80 #if QGLIB_HAVE_CXX0X
81 
82 # ifndef DOXYGEN_RUN
83 private:
84  inline void add() {} //terminate condition for the variadic template recursion
85 public:
86 # endif
87 
95  template <typename First, typename Second, typename... Rest>
96  inline void add(const First & first, const Second & second, const Rest & ... rest)
97  {
98  add(first);
99  add(second);
100  add(rest...);
101  }
102 
103 #else //QGLIB_HAVE_CXX0X
104 
105 # ifndef QGST_BIN_ADD_MAX_ARGS
106 # define QGST_BIN_ADD_MAX_ARGS 10
107 # endif
108 
109 # define QGST_BIN_ADD_DECLARATION(z, n, data) \
110  inline void add(BOOST_PP_ENUM_PARAMS(n, const ElementPtr & e)) \
111  { \
112  add(e0); \
113  add(BOOST_PP_ENUM_SHIFTED_PARAMS(n, e)); \
114  };
115 
116  BOOST_PP_REPEAT_FROM_TO(2, BOOST_PP_INC(QGST_BIN_ADD_MAX_ARGS), QGST_BIN_ADD_DECLARATION, dummy)
117 
118 # undef QGST_BIN_ADD_DECLARATION
119 
120 #endif //QGLIB_HAVE_CXX0X
121 
127  bool remove(const ElementPtr & element);
128 
132  enum RecursionType { //codegen: skip=true
138  RecurseUp
139  };
140 
147  ElementPtr getElementByName(const char *name, RecursionType recursionType = RecurseDown) const;
148 
150  ElementPtr getElementByInterface(QGlib::Type interfaceType) const;
151 
158  template <typename T> QGlib::RefPointer<T> getElementByInterface() const;
159 
163  PadPtr findUnlinkedPad(PadDirection direction) const;
164 
165  bool recalculateLatency();
166 };
167 
168 inline BinPtr Bin::fromDescription(const QString & description,
169  BinFromDescriptionOption ghostUnlinkedPads)
170 {
171  return fromDescription(description.toUtf8().constData(), ghostUnlinkedPads);
172 }
173 
174 template <typename T>
176 {
177  ElementPtr p = getElementByInterface(QGlib::GetType<T>());
178  return p.dynamicCast<T>();
179 }
180 
181 } //namespace QGst
182 
183 QGST_REGISTER_TYPE(QGst::Bin)
184 
185 #ifdef Q_CC_MSVC
186 # pragma warning(pop)
187 #endif
188 
189 #endif
Smart pointer class for working with wrapper classes that support reference counting.
Definition: global.h:56
BinFromDescriptionOption
Definition: bin.h:53
RecursionType
Definition: bin.h:132
Wrapper class for GstElement.
Definition: element.h:33
Wrapper class for GstBin.
Definition: bin.h:45
void add(const First &first, const Second &second, const Rest &...rest)
Definition: bin.h:96
RefPointer< X > dynamicCast() const
Definition: refpointer.h:462
static BinPtr fromDescription(const char *description, BinFromDescriptionOption ghostUnlinkedPads=Ghost)
Definition: bin.cpp:35
Wrapper class for GstChildProxy.
Definition: childproxy.h:27
QGlib::RefPointer< T > getElementByInterface() const
Definition: bin.h:175
Wrapper class for GType.
Definition: type.h:63