QtGStreamer 0.10.1
|
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 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_ELEMENT_H 00018 #define QGST_ELEMENT_H 00019 00020 #include "object.h" 00021 #include "caps.h" 00022 #include "clocktime.h" 00023 00024 #if !QGLIB_HAVE_CXX0X 00025 # include <boost/preprocessor.hpp> 00026 #endif 00027 00028 namespace QGst { 00029 00033 class QTGSTREAMER_EXPORT Element : public Object 00034 { 00035 QGST_WRAPPER(Element) 00036 public: 00037 State currentState() const; 00038 State pendingState() const; 00039 StateChangeReturn getState(State *state, State *pending, ClockTime timeout) const; 00040 StateChangeReturn setState(State state); 00041 bool syncStateWithParent(); 00042 00043 bool stateIsLocked() const; 00044 bool setStateLocked(bool locked); 00045 00046 bool addPad(const PadPtr & pad); 00047 PadPtr getStaticPad(const char *name); 00048 PadPtr getRequestPad(const char *name); 00049 void releaseRequestPad(const PadPtr & pad); 00050 00051 ClockPtr clock() const; 00052 bool setClock(const ClockPtr & clock); 00053 00054 bool link(const char *srcPadName, const ElementPtr & dest, 00055 const char *sinkPadName, const CapsPtr & filter = CapsPtr()); 00056 bool link(const char *srcPadName, const ElementPtr & dest, 00057 const CapsPtr & filter = CapsPtr()); 00058 bool link(const ElementPtr & dest, const char *sinkPadName, 00059 const CapsPtr & filter = CapsPtr()); 00060 bool link(const ElementPtr & dest, const CapsPtr & filter = CapsPtr()); 00061 00062 void unlink(const char *srcPadName, const ElementPtr & dest, 00063 const char *sinkPadName = NULL); 00064 void unlink(const ElementPtr & dest, const char *sinkPadName = NULL); 00065 00066 #ifndef DOXYGEN_RUN 00067 private: 00068 static inline bool linkMany(const ElementPtr & first, const ElementPtr & second) 00069 { 00070 return first->link(second); 00071 } 00072 00073 static inline void unlinkMany(const ElementPtr & first, const ElementPtr & second) 00074 { 00075 first->unlink(second); 00076 } 00077 public: 00078 #endif 00079 00080 #if QGLIB_HAVE_CXX0X 00081 00087 template <typename First, typename Second, typename Third, typename... Rest> 00088 static inline bool linkMany(const First & first, const Second & second, 00089 const Third & third, const Rest & ... rest) 00090 { 00091 if (!first->link(second)) return false; 00092 return linkMany(second, third, rest...); 00093 } 00094 00101 template <typename First, typename Second, typename Third, typename... Rest> 00102 static inline void unlinkMany(const First & first, const Second & second, 00103 const Third & third, const Rest & ... rest) 00104 { 00105 first->unlink(second); 00106 unlinkMany(second, third, rest...); 00107 } 00108 #else //QGLIB_HAVE_CXX0X 00109 00110 # ifndef QGST_ELEMENT_LINK_MANY_MAX_ARGS 00111 # define QGST_ELEMENT_LINK_MANY_MAX_ARGS 10 00112 # endif 00113 00114 # ifndef QGST_ELEMENT_UNLINK_MANY_MAX_ARGS 00115 # define QGST_ELEMENT_UNLINK_MANY_MAX_ARGS 10 00116 # endif 00117 00118 # define QGST_ELEMENT_LINK_MANY_DECLARATION(z, n, data) \ 00119 static inline bool linkMany(BOOST_PP_ENUM_PARAMS(n, const ElementPtr & e)) \ 00120 { \ 00121 if (!e0->link(e1)) return false; \ 00122 return linkMany(BOOST_PP_ENUM_SHIFTED_PARAMS(n, e)); \ 00123 }; 00124 00125 # define QGST_ELEMENT_UNLINK_MANY_DECLARATION(z, n, data) \ 00126 static inline void unlinkMany(BOOST_PP_ENUM_PARAMS(n, const ElementPtr & e)) \ 00127 { \ 00128 e0->unlink(e1); \ 00129 unlinkMany(BOOST_PP_ENUM_SHIFTED_PARAMS(n, e)); \ 00130 }; 00131 00132 BOOST_PP_REPEAT_FROM_TO(3, BOOST_PP_INC(QGST_ELEMENT_LINK_MANY_MAX_ARGS), 00133 QGST_ELEMENT_LINK_MANY_DECLARATION, dummy) 00134 BOOST_PP_REPEAT_FROM_TO(3, BOOST_PP_INC(QGST_ELEMENT_UNLINK_MANY_MAX_ARGS), 00135 QGST_ELEMENT_UNLINK_MANY_DECLARATION, dummy) 00136 00137 # undef QGST_ELEMENT_LINK_MANY_DECLARATION 00138 # undef QGST_ELEMENT_UNLINK_MANY_DECLARATION 00139 00140 #endif //QGLIB_HAVE_CXX0X 00141 00142 bool query(const QueryPtr & query); 00143 bool sendEvent(const EventPtr & event); 00144 bool seek(Format format, SeekFlags flags, quint64 position); 00145 }; 00146 00147 } 00148 00149 QGST_REGISTER_TYPE(QGst::Element) 00150 00151 #endif // QGST_ELEMENT_H