00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "caps.h"
00018 #include "structure.h"
00019 #include "../QGlib/string_p.h"
00020 #include "objectstore_p.h"
00021 #include <QtCore/QDebug>
00022 #include <gst/gstcaps.h>
00023 #include <gst/gstvalue.h>
00024
00025 namespace QGst {
00026
00027
00028 CapsPtr Caps::createSimple(const char *mediaType)
00029 {
00030 return CapsPtr::wrap(gst_caps_new_simple(mediaType, NULL), false);
00031 }
00032
00033
00034 CapsPtr Caps::createAny()
00035 {
00036 return CapsPtr::wrap(gst_caps_new_any(), false);
00037 }
00038
00039
00040 CapsPtr Caps::createEmpty()
00041 {
00042 return CapsPtr::wrap(gst_caps_new_empty(), false);
00043 }
00044
00045
00046 CapsPtr Caps::fromString(const char *string)
00047 {
00048 return CapsPtr::wrap(gst_caps_from_string(string), false);
00049 }
00050
00051 QString Caps::toString() const
00052 {
00053 return QGlib::Private::stringFromGCharPtr(gst_caps_to_string(object<GstCaps>()));
00054 }
00055
00056 void Caps::append(const CapsPtr & caps2)
00057 {
00058 gst_caps_append(object<GstCaps>(), gst_caps_copy(caps2));
00059 }
00060
00061 void Caps::merge(const CapsPtr & caps2)
00062 {
00063 gst_caps_merge(object<GstCaps>(), gst_caps_copy(caps2));
00064 }
00065
00066 void Caps::setValue(const char *field, const QGlib::Value & value)
00067 {
00068 gst_caps_set_value(object<GstCaps>(), field, value);
00069 }
00070
00071 bool Caps::simplify()
00072 {
00073 return gst_caps_do_simplify(object<GstCaps>());
00074 }
00075
00076 void Caps::truncate()
00077 {
00078 gst_caps_truncate(object<GstCaps>());
00079 }
00080
00081 StructurePtr Caps::internalStructure(uint index)
00082 {
00083 GstStructure *structure = gst_caps_get_structure(object<GstCaps>(), index);
00084 return SharedStructure::fromCaps(structure, CapsPtr(this));
00085 }
00086
00087 void Caps::appendStructure(const Structure & structure)
00088 {
00089 gst_caps_append_structure(object<GstCaps>(), gst_structure_copy(structure));
00090 }
00091
00092 void Caps::mergeStructure(const Structure & structure)
00093 {
00094 gst_caps_merge_structure(object<GstCaps>(), gst_structure_copy(structure));
00095 }
00096
00097 void Caps::removeStructure(uint index)
00098 {
00099 gst_caps_remove_structure(object<GstCaps>(), index);
00100 }
00101
00102 uint Caps::size() const
00103 {
00104 return gst_caps_get_size(object<GstCaps>());
00105 }
00106
00107 bool Caps::isSimple() const
00108 {
00109 return GST_CAPS_IS_SIMPLE(object<GstCaps>());
00110 }
00111
00112 bool Caps::isAny() const
00113 {
00114 return gst_caps_is_any(object<GstCaps>());
00115 }
00116
00117 bool Caps::isEmpty() const
00118 {
00119 return gst_caps_is_empty(object<GstCaps>());
00120 }
00121
00122 bool Caps::isFixed() const
00123 {
00124 return gst_caps_is_fixed(object<GstCaps>());
00125 }
00126
00127 bool Caps::isWritable() const
00128 {
00129 return (GST_CAPS_REFCOUNT_VALUE(object<GstCaps>()) == 1);
00130 }
00131
00132 bool Caps::equals(const CapsPtr & caps2) const
00133 {
00134 return gst_caps_is_equal(object<GstCaps>(), caps2);
00135 }
00136
00137 bool Caps::isAlwaysCompatibleWith(const CapsPtr & caps2) const
00138 {
00139 return gst_caps_is_always_compatible(object<GstCaps>(), caps2);
00140 }
00141
00142 bool Caps::isSubsetOf(const CapsPtr & superset) const
00143 {
00144 return gst_caps_is_subset(object<GstCaps>(), superset);
00145 }
00146
00147 bool Caps::canIntersect(const CapsPtr & caps2) const
00148 {
00149 return gst_caps_can_intersect(object<GstCaps>(), caps2);
00150 }
00151
00152 CapsPtr Caps::getIntersection(const CapsPtr & caps2) const
00153 {
00154 return CapsPtr::wrap(gst_caps_intersect(object<GstCaps>(), caps2), false);
00155 }
00156
00157 CapsPtr Caps::getUnion(const CapsPtr & caps2) const
00158 {
00159 return CapsPtr::wrap(gst_caps_union(object<GstCaps>(), caps2), false);
00160 }
00161
00162 CapsPtr Caps::getNormal() const
00163 {
00164 return CapsPtr::wrap(gst_caps_normalize(object<GstCaps>()), false);
00165 }
00166
00167 CapsPtr Caps::subtract(const CapsPtr & subtrahend) const
00168 {
00169 return CapsPtr::wrap(gst_caps_subtract(object<GstCaps>(), subtrahend), false);
00170 }
00171
00172 CapsPtr Caps::copy() const
00173 {
00174 return CapsPtr::wrap(gst_caps_copy(object<GstCaps>()), false);
00175 }
00176
00177 CapsPtr Caps::copyNth(uint index) const
00178 {
00179 return CapsPtr::wrap(gst_caps_copy_nth(object<GstCaps>(), index), false);
00180 }
00181
00182 void Caps::ref(bool increaseRef)
00183 {
00184 if (Private::ObjectStore::put(this)) {
00185 if (increaseRef) {
00186 gst_caps_ref(GST_CAPS(m_object));
00187 }
00188 }
00189 }
00190
00191 void Caps::unref()
00192 {
00193 if (Private::ObjectStore::take(this)) {
00194 gst_caps_unref(GST_CAPS(m_object));
00195 delete this;
00196 }
00197 }
00198
00199 CapsPtr Caps::makeWritable() const
00200 {
00201
00202
00203
00204
00205
00206
00207 if (!isWritable()) {
00208 return copy();
00209 } else {
00210 return CapsPtr(const_cast<Caps*>(this));
00211 }
00212 }
00213
00214 QDebug operator<<(QDebug debug, const CapsPtr & caps)
00215 {
00216 debug.nospace() << "QGst::Caps(" << caps->toString() << ")";
00217 return debug.space();
00218 }
00219
00220
00221 namespace Private {
00222
00223 QGlib::RefCountedObject *wrapCaps(void *caps)
00224 {
00225 return QGlib::constructWrapper(GST_CAPS(caps)->type, caps);
00226 }
00227
00228 }
00229 }