QtGStreamer 0.10.1
|
00001 /* 00002 Copyright (C) 2009-2010 George Kiagiadakis <kiagiadakis.george@gmail.com> 00003 Copyright (C) 2010 Collabora Multimedia. 00004 @author Mauricio Piacentini <mauricio.piacentini@collabora.co.uk> 00005 Copyright (C) 2011 Collabora Ltd. 00006 @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk> 00007 00008 This library is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU Lesser General Public License as published 00010 by the Free Software Foundation; either version 2.1 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU Lesser General Public License 00019 along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 #ifndef QGST_STRUCTURE_H 00022 #define QGST_STRUCTURE_H 00023 00024 #include "global.h" 00025 #include "../QGlib/type.h" 00026 #include "../QGlib/value.h" 00027 #include <QtCore/QString> 00028 00029 namespace QGst { 00030 00049 class QTGSTREAMER_EXPORT Structure 00050 { 00051 public: 00052 Structure(); 00053 explicit Structure(const char *name); 00054 explicit Structure(const GstStructure *structure); 00055 Structure(const Structure & other); 00056 virtual ~Structure(); 00057 00058 Structure & operator=(const Structure & other); 00059 00060 bool isValid() const; 00061 00062 QString name() const; 00063 void setName(const char *name); 00064 00065 QGlib::Value value(const char *fieldName) const; 00066 template <typename T> 00067 inline void setValue(const char *fieldName, const T & value); 00068 void setValue(const char *fieldName, const QGlib::Value & value); 00069 00070 unsigned int numberOfFields() const; 00071 QString fieldName(unsigned int fieldNumber) const; 00072 QGlib::Type fieldType(const char *fieldName) const; 00073 bool hasField(const char *fieldName) const; 00074 bool hasFieldTyped(const char *fieldName, QGlib::Type type) const; 00075 00076 void removeField(const char *fieldName); 00077 void removeAllFields(); 00078 00079 QString toString() const; 00080 static Structure fromString(const char *str); 00081 static inline Structure fromString(const QString & str); 00082 00083 operator GstStructure*(); 00084 operator const GstStructure*() const; 00085 00086 private: 00087 friend class SharedStructure; 00088 00089 struct Data; 00090 00091 QTGSTREAMER_NO_EXPORT 00092 Structure(Data *data); 00093 00094 QSharedDataPointer<Data> d; 00095 }; 00096 00097 template <typename T> 00098 inline void Structure::setValue(const char *fieldName, const T & value) 00099 { 00100 setValue(fieldName, QGlib::Value::create(value)); 00101 } 00102 00103 //static 00104 inline Structure fromString(const QString & str) 00105 { 00106 return fromString(str.toUtf8().constData()); 00107 } 00108 00109 00129 class QTGSTREAMER_EXPORT SharedStructure : public Structure 00130 { 00131 public: 00132 virtual ~SharedStructure(); 00133 00135 Structure copy() const; 00136 00137 private: 00138 //Only these classes can call our constructor, others should use a StructurePtr passed to them 00139 friend class Caps; 00140 friend class Message; 00141 friend class Event; 00142 friend class Query; 00143 00144 struct Data; 00145 00146 QTGSTREAMER_NO_EXPORT 00147 SharedStructure(Data *data); 00148 QTGSTREAMER_NO_EXPORT 00149 static StructurePtr fromMiniObject(GstStructure *structure, const MiniObjectPtr & parent); 00150 QTGSTREAMER_NO_EXPORT 00151 static StructurePtr fromCaps(GstStructure *structure, const CapsPtr & parent); 00152 00153 Q_DISABLE_COPY(SharedStructure); 00154 }; 00155 00157 QTGSTREAMER_EXPORT QDebug operator<<(QDebug debug, const Structure & structure); 00158 00159 } //namespace QGst 00160 00161 QGST_REGISTER_TYPE(QGst::Structure) 00162 00163 #endif