QtGStreamer  1.2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
structure.h
1 /*
2  Copyright (C) 2009-2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
3  Copyright (C) 2010 Collabora Multimedia.
4  @author Mauricio Piacentini <mauricio.piacentini@collabora.co.uk>
5  Copyright (C) 2011 Collabora Ltd.
6  @author George Kiagiadakis <george.kiagiadakis@collabora.co.uk>
7 
8  This library is free software; you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published
10  by the Free Software Foundation; either version 2.1 of the License, or
11  (at your option) any later version.
12 
13  This program is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Lesser General Public License for more details.
17 
18  You should have received a copy of the GNU Lesser General Public License
19  along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21 #ifndef QGST_STRUCTURE_H
22 #define QGST_STRUCTURE_H
23 
24 #include "global.h"
25 #include "../QGlib/type.h"
26 #include "../QGlib/value.h"
27 #include <QtCore/QString>
28 
29 namespace QGst {
30 
49 class QTGSTREAMER_EXPORT Structure
50 {
51 public:
52  Structure();
53  explicit Structure(const char *name);
54  explicit Structure(const GstStructure *structure);
55  Structure(const Structure & other);
56  virtual ~Structure();
57 
58  Structure & operator=(const Structure & other);
59 
60  bool isValid() const;
61 
62  QString name() const;
63  void setName(const char *name);
64 
65  QGlib::Value value(const char *fieldName) const;
66  template <typename T>
67  inline void setValue(const char *fieldName, const T & value);
68  void setValue(const char *fieldName, const QGlib::Value & value);
69 
70  unsigned int numberOfFields() const;
71  QString fieldName(unsigned int fieldNumber) const;
72  QGlib::Type fieldType(const char *fieldName) const;
73  bool hasField(const char *fieldName) const;
74  bool hasFieldTyped(const char *fieldName, QGlib::Type type) const;
75 
76  void removeField(const char *fieldName);
77  void removeAllFields();
78 
79  QString toString() const;
80  static Structure fromString(const char *str);
81  static inline Structure fromString(const QString & str);
82 
83  operator GstStructure*();
84  operator const GstStructure*() const;
85 
86 private:
87  friend class SharedStructure;
88 
89  struct Data;
90 
91  QTGSTREAMER_NO_EXPORT
92  Structure(Data *data);
93 
94  QSharedDataPointer<Data> d;
95 };
96 
97 template <typename T>
98 inline void Structure::setValue(const char *fieldName, const T & value)
99 {
100  setValue(fieldName, QGlib::Value::create(value));
101 }
102 
103 //static
104 inline Structure Structure::fromString(const QString & str)
105 {
106  return fromString(str.toUtf8().constData());
107 }
108 
109 
129 class QTGSTREAMER_EXPORT SharedStructure : public Structure
130 {
131 public:
132  virtual ~SharedStructure();
133 
135  Structure copy() const;
136 
137 private:
138  //Only these classes can call our constructor, others should use a StructurePtr passed to them
139  friend class Caps;
140  friend class Message;
141  friend class Event;
142  friend class Query;
143 
144  struct Data;
145 
146  QTGSTREAMER_NO_EXPORT
147  SharedStructure(Data *data);
148  QTGSTREAMER_NO_EXPORT
149  static StructurePtr fromMiniObject(GstStructure *structure, const MiniObjectPtr & parent);
150  QTGSTREAMER_NO_EXPORT
151  static StructurePtr fromCaps(GstStructure *structure, const CapsPtr & parent);
152 
153  Q_DISABLE_COPY(SharedStructure);
154 };
155 
157 QTGSTREAMER_EXPORT QDebug operator<<(QDebug debug, const Structure & structure);
158 
159 } //namespace QGst
160 
161 QGST_REGISTER_TYPE(QGst::Structure)
162 
163 #endif
static Value create(const T &data)
Definition: value.h:293
Smart pointer class for working with wrapper classes that support reference counting.
Definition: global.h:56
Wrapper class for GValue.
Definition: value.h:74
Wrapper for GstStructure.
Definition: structure.h:49
Wrapper class for GstEvent.
Definition: event.h:55
Wrapper class for GstMessage.
Definition: message.h:48
Helper for shared GstStructure instances.
Definition: structure.h:129
Wrapper class for GstCaps.
Definition: caps.h:31
Wrapper class for GType.
Definition: type.h:63
Wrapper class for GstQuery.
Definition: query.h:53