QtGStreamer  0.10.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
caps.h
1 /*
2  Copyright (C) 2009-2010 George Kiagiadakis <kiagiadakis.george@gmail.com>
3 
4  This library is free software; you can redistribute it and/or modify
5  it under the terms of the GNU Lesser General Public License as published
6  by the Free Software Foundation; either version 2.1 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public License
15  along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #ifndef QGST_CAPS_H
18 #define QGST_CAPS_H
19 
20 #include "global.h"
21 #include "../QGlib/value.h"
22 #include "../QGlib/refpointer.h"
23 #include "../QGlib/type.h"
24 
25 namespace QGst {
26 
30 class QTGSTREAMER_EXPORT Caps : public QGlib::RefCountedObject
31 {
32  QGST_WRAPPER(Caps)
33 public:
34  static CapsPtr createSimple(const char *mediaType);
35  static CapsPtr createAny();
36  static CapsPtr createEmpty();
37 
38  static CapsPtr fromString(const char *string);
39  static inline CapsPtr fromString(const QString & string);
40  QString toString() const;
41 
42  void append(const CapsPtr & caps2);
43  void merge(const CapsPtr & caps2);
44  template <typename T>
45  inline void setValue(const char *field, const T & value);
46  void setValue(const char *field, const QGlib::Value & value);
47  bool simplify();
48  void truncate();
49 
50  StructurePtr internalStructure(uint index);
51 
52  void appendStructure(const Structure & structure);
53  void mergeStructure(const Structure & structure);
54  void removeStructure(uint index);
55 
56  uint size() const;
57  bool isSimple() const;
58  bool isAny() const;
59  bool isEmpty() const;
60  bool isFixed() const;
61  bool equals(const CapsPtr & caps2) const;
62  bool isAlwaysCompatibleWith(const CapsPtr & caps2) const;
63  bool isSubsetOf(const CapsPtr & superset) const;
64  bool canIntersect(const CapsPtr & caps2) const;
65  CapsPtr getIntersection(const CapsPtr & caps2) const;
66  CapsPtr getUnion(const CapsPtr & caps2) const;
67  CapsPtr getNormal() const;
68  CapsPtr subtract(const CapsPtr & subtrahend) const;
69 
70  CapsPtr copy() const;
71  CapsPtr copyNth(uint index) const;
72 
73  bool isWritable() const;
74  CapsPtr makeWritable() const;
75 
76 protected:
77  virtual void ref(bool increaseRef);
78  virtual void unref();
79 };
80 
81 template <typename T>
82 inline void Caps::setValue(const char *field, const T & value)
83 {
84  setValue(field, QGlib::Value::create(value));
85 }
86 
87 //static
88 inline CapsPtr Caps::fromString(const QString & string)
89 {
90  return fromString(string.toUtf8().constData());
91 }
92 
94 QTGSTREAMER_EXPORT QDebug operator<<(QDebug debug, const CapsPtr & caps);
95 
96 
97 namespace Private {
98 
99 QTGSTREAMER_EXPORT QGlib::RefCountedObject *wrapCaps(void *caps);
100 
101 } //namespace Private
102 } //namespace QGst
103 
104 QGST_REGISTER_TYPE(QGst::Caps)
105 QGLIB_REGISTER_WRAPIMPL_FOR_SUBCLASSES_OF(QGst::Caps, QGst::Private::wrapCaps)
106 
107 #endif