00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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
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
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 }
00160
00161 QGST_REGISTER_TYPE(QGst::Structure)
00162
00163 #endif