QtGStreamer  1.2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
caps.cpp
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 #include "caps.h"
18 #include "structure.h"
19 #include "../QGlib/string_p.h"
20 #include "objectstore_p.h"
21 #include <QtCore/QDebug>
22 #include <gst/gst.h>
23 
24 namespace QGst {
25 
26 //static
27 CapsPtr Caps::createSimple(const char *mediaType)
28 {
29  return CapsPtr::wrap(gst_caps_new_empty_simple(mediaType), false);
30 }
31 
32 //static
33 CapsPtr Caps::createAny()
34 {
35  return CapsPtr::wrap(gst_caps_new_any(), false);
36 }
37 
38 //static
39 CapsPtr Caps::createEmpty()
40 {
41  return CapsPtr::wrap(gst_caps_new_empty(), false);
42 }
43 
44 //static
45 CapsPtr Caps::fromString(const char *string)
46 {
47  return CapsPtr::wrap(gst_caps_from_string(string), false);
48 }
49 
50 QString Caps::toString() const
51 {
52  return QGlib::Private::stringFromGCharPtr(gst_caps_to_string(object<GstCaps>()));
53 }
54 
55 void Caps::append(const CapsPtr & caps2)
56 {
57  gst_caps_append(object<GstCaps>(), gst_caps_copy(caps2));
58 }
59 
60 CapsPtr Caps::merge(CapsPtr & caps2)
61 {
62  return CapsPtr::wrap(gst_caps_merge(object<GstCaps>(), caps2), false);
63 }
64 
65 void Caps::setValue(const char *field, const QGlib::Value & value)
66 {
67  gst_caps_set_value(object<GstCaps>(), field, value);
68 }
69 
70 bool Caps::simplify()
71 {
72  return gst_caps_simplify(object<GstCaps>());
73 }
74 
75 CapsPtr Caps::truncate()
76 {
77  return CapsPtr::wrap(gst_caps_truncate(object<GstCaps>()), false);
78 }
79 
80 StructurePtr Caps::internalStructure(uint index)
81 {
82  GstStructure *structure = gst_caps_get_structure(object<GstCaps>(), index);
83  return SharedStructure::fromCaps(structure, CapsPtr(this));
84 }
85 
86 void Caps::appendStructure(const Structure & structure)
87 {
88  gst_caps_append_structure(object<GstCaps>(), gst_structure_copy(structure));
89 }
90 
91 CapsPtr Caps::mergeStructure(Structure & structure)
92 {
93  return CapsPtr::wrap(gst_caps_merge_structure(object<GstCaps>(), structure), false);
94 }
95 
96 void Caps::removeStructure(uint index)
97 {
98  gst_caps_remove_structure(object<GstCaps>(), index);
99 }
100 
101 uint Caps::size() const
102 {
103  return gst_caps_get_size(object<GstCaps>());
104 }
105 
106 bool Caps::isSimple() const
107 {
108  return GST_CAPS_IS_SIMPLE(object<GstCaps>());
109 }
110 
111 bool Caps::isAny() const
112 {
113  return gst_caps_is_any(object<GstCaps>());
114 }
115 
116 bool Caps::isEmpty() const
117 {
118  return gst_caps_is_empty(object<GstCaps>());
119 }
120 
121 bool Caps::isFixed() const
122 {
123  return gst_caps_is_fixed(object<GstCaps>());
124 }
125 
126 bool Caps::equals(const CapsPtr & caps2) const
127 {
128  return gst_caps_is_equal(object<GstCaps>(), caps2);
129 }
130 
131 bool Caps::isAlwaysCompatibleWith(const CapsPtr & caps2) const
132 {
133  return gst_caps_is_always_compatible(object<GstCaps>(), caps2);
134 }
135 
136 bool Caps::isSubsetOf(const CapsPtr & superset) const
137 {
138  return gst_caps_is_subset(object<GstCaps>(), superset);
139 }
140 
141 bool Caps::canIntersect(const CapsPtr & caps2) const
142 {
143  return gst_caps_can_intersect(object<GstCaps>(), caps2);
144 }
145 
146 CapsPtr Caps::getIntersection(const CapsPtr & caps2) const
147 {
148  return CapsPtr::wrap(gst_caps_intersect(object<GstCaps>(), caps2), false);
149 }
150 
151 CapsPtr Caps::getNormal()
152 {
153  return CapsPtr::wrap(gst_caps_normalize(object<GstCaps>()), false);
154 }
155 
156 CapsPtr Caps::subtract(const CapsPtr & subtrahend) const
157 {
158  return CapsPtr::wrap(gst_caps_subtract(object<GstCaps>(), subtrahend), false);
159 }
160 
161 CapsPtr Caps::copy() const
162 {
163  return CapsPtr::wrap(gst_caps_copy(object<GstCaps>()), false);
164 }
165 
166 CapsPtr Caps::copyNth(uint index) const
167 {
168  return CapsPtr::wrap(gst_caps_copy_nth(object<GstCaps>(), index), false);
169 }
170 
171 QDebug operator<<(QDebug debug, const CapsPtr & caps)
172 {
173  debug.nospace() << "QGst::Caps(" << caps->toString() << ")";
174  return debug.space();
175 }
176 
177 } //namespace QGst
static RefPointer< T > wrap(typename T::CType *nativePtr, bool increaseRef=true)
Definition: refpointer.h:326
Smart pointer class for working with wrapper classes that support reference counting.
Definition: global.h:56
Wrapper class for GValue.
Definition: value.h:74