00001 #pragma once 00002 00003 // QStreamer 00004 // A GStreamer replacement for Qt. 00005 // 00006 // Authors : 00007 // Darren R. Starr <submux at gmail dot com> 00008 // 00009 // Copyright : 2010 The QStreamer Project 00010 // License : BSD (until we're informed that we're in violation of some other license) 00011 // Donations : Appreciated and possible through SourceForge donation page. 00012 // 00013 // All code included in this project can be used freely in whatever way the user feels fit. 00014 // If you want to take it, close it and be a weasel that doesn't even contribute back patches, 00015 // so be it. Patches are however appreciated. Wrappers for other open source components are 00016 // also appreciated. 00017 // 00018 // If you wish to be nice to us so we can see how our code is being used. Drop us a mail and let us 00019 // know you're using it in your project. 00020 // 00021 // Support : By default the support is "you get what you pay for". Paid nothing, there's no implied 00022 // requirement to support you. On the other hand, some project developers are likely to 00023 // make fixes, changes, features on request or contract. 00024 // 00025 // Enjoy 00026 00027 #include "qelementlist.h" 00028 #include "qpinlist.h" 00029 00030 namespace QStreamer 00031 { 00071 class QElement 00072 { 00073 public: 00078 virtual ~QElement(); 00079 00083 class QPipeline *pipeline(); 00084 00088 const class QPipeline *pipeline() const; 00089 00091 const QString &name() const; 00092 00094 QElement *parent(); 00095 00097 const QElement *parent() const; 00098 00100 class QMediaError &error(); 00101 00103 QElementList &children(); 00104 00106 const QElementList &children() const; 00107 00109 const QPinList &pins() const; 00110 00120 class QMediaClock *clock(); 00121 00126 void setClock(class QMediaClock *clock); 00127 00129 bool connectSourceTo(QElement *destinationElement, const QString &destinationPinName="sink"); 00130 00140 bool connectSourceTo(const QString &sourcePinName, QElement *destinationElement, const QString &destinationPinName="sink"); 00141 00145 class QSourcePin *sourcePin(const QString &name); 00146 00150 class QSinkPin *sinkPin(const QString &name); 00151 00152 protected: 00159 QElement(const QString &name, class QPipeline *parent); 00160 00167 QElement(const QString &name, QElement *parent); 00168 00174 bool addChild(QElement *child); 00175 00180 bool removeChild(QElement *child); 00181 00190 bool addPin(QPin *pin); 00191 00196 bool removePin(QPin *pin); 00197 00199 QPinList &pins(); 00200 00205 class QSourcePin *constructSourcePin(const QString &name); 00206 00210 void deleteSourcePin(class QSourcePin *pin); 00211 00216 void setParentElement(QElement *parent); 00217 00218 private: 00219 QString m_name; 00220 00221 class QPipeline *m_parentPipeline; 00222 QElement *m_parentElement; 00223 00224 QElementList m_children; 00225 QPinList m_pins; 00226 00227 class QMediaClock *m_clock; 00228 }; 00229 00230 inline class QPipeline *QElement::pipeline() 00231 { 00232 if(m_parentPipeline) 00233 return m_parentPipeline; 00234 if(m_parentElement) 00235 return m_parentElement->pipeline(); 00236 return 0; 00237 } 00238 00239 inline const class QPipeline *QElement::pipeline() const 00240 { 00241 if(m_parentPipeline) 00242 return m_parentPipeline; 00243 if(m_parentElement) 00244 return m_parentElement->pipeline(); 00245 return 0; 00246 } 00247 00248 inline const QString &QElement::name() const 00249 { 00250 return m_name; 00251 } 00252 00253 inline QElement *QElement::parent() 00254 { 00255 return m_parentElement; 00256 } 00257 00258 inline const QElement *QElement::parent() const 00259 { 00260 return m_parentElement; 00261 } 00262 00263 inline void setParentElement(QElement *parent) 00264 { 00265 m_parentElement = parent; 00266 } 00267 }