QtGStreamer  1.2.0
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  const GstCaps * caps2ptr = caps2;
58  gst_caps_append(object<GstCaps>(), gst_caps_copy(caps2ptr));
59 }
60 
61 CapsPtr Caps::merge(CapsPtr & caps2)
62 {
63  return CapsPtr::wrap(gst_caps_merge(object<GstCaps>(), caps2), false);
64 }
65 
66 void Caps::setValue(const char *field, const QGlib::Value & value)
67 {
68  gst_caps_set_value(object<GstCaps>(), field, value);
69 }
70 
71 bool Caps::simplify()
72 {
73  return gst_caps_simplify(object<GstCaps>());
74 }
75 
76 CapsPtr Caps::truncate()
77 {
78  return CapsPtr::wrap(gst_caps_truncate(object<GstCaps>()), false);
79 }
80 
81 StructurePtr Caps::internalStructure(uint index)
82 {
83  GstStructure *structure = gst_caps_get_structure(object<GstCaps>(), index);
84  return SharedStructure::fromCaps(structure, CapsPtr(this));
85 }
86 
87 void Caps::appendStructure(const Structure & structure)
88 {
89  gst_caps_append_structure(object<GstCaps>(), gst_structure_copy(structure));
90 }
91 
92 CapsPtr Caps::mergeStructure(Structure & structure)
93 {
94  return CapsPtr::wrap(gst_caps_merge_structure(object<GstCaps>(), structure), false);
95 }
96 
97 void Caps::removeStructure(uint index)
98 {
99  gst_caps_remove_structure(object<GstCaps>(), index);
100 }
101 
102 uint Caps::size() const
103 {
104  return gst_caps_get_size(object<GstCaps>());
105 }
106 
107 bool Caps::isSimple() const
108 {
109  return GST_CAPS_IS_SIMPLE(object<GstCaps>());
110 }
111 
112 bool Caps::isAny() const
113 {
114  return gst_caps_is_any(object<GstCaps>());
115 }
116 
117 bool Caps::isEmpty() const
118 {
119  return gst_caps_is_empty(object<GstCaps>());
120 }
121 
122 bool Caps::isFixed() const
123 {
124  return gst_caps_is_fixed(object<GstCaps>());
125 }
126 
127 bool Caps::equals(const CapsPtr & caps2) const
128 {
129  return gst_caps_is_equal(object<GstCaps>(), caps2);
130 }
131 
132 bool Caps::isAlwaysCompatibleWith(const CapsPtr & caps2) const
133 {
134  return gst_caps_is_always_compatible(object<GstCaps>(), caps2);
135 }
136 
137 bool Caps::isSubsetOf(const CapsPtr & superset) const
138 {
139  return gst_caps_is_subset(object<GstCaps>(), superset);
140 }
141 
142 bool Caps::canIntersect(const CapsPtr & caps2) const
143 {
144  return gst_caps_can_intersect(object<GstCaps>(), caps2);
145 }
146 
147 CapsPtr Caps::getIntersection(const CapsPtr & caps2) const
148 {
149  return CapsPtr::wrap(gst_caps_intersect(object<GstCaps>(), caps2), false);
150 }
151 
152 CapsPtr Caps::getNormal()
153 {
154  return CapsPtr::wrap(gst_caps_normalize(object<GstCaps>()), false);
155 }
156 
157 CapsPtr Caps::subtract(const CapsPtr & subtrahend) const
158 {
159  return CapsPtr::wrap(gst_caps_subtract(object<GstCaps>(), subtrahend), false);
160 }
161 
162 CapsPtr Caps::copy() const
163 {
164  return CapsPtr::wrap(gst_caps_copy(object<GstCaps>()), false);
165 }
166 
167 CapsPtr Caps::copyNth(uint index) const
168 {
169  return CapsPtr::wrap(gst_caps_copy_nth(object<GstCaps>(), index), false);
170 }
171 
172 QDebug operator<<(QDebug debug, const CapsPtr & caps)
173 {
174  debug.nospace() << "QGst::Caps(" << caps->toString() << ")";
175  return debug.space();
176 }
177 
178 } //namespace QGst
static RefPointer< T > wrap(typename T::CType *nativePtr, bool increaseRef=true)
Definition: refpointer.h:328
Wrapper class for GValue.
Definition: value.h:77
Wrappers for GStreamer classes.