diff options
Diffstat (limited to 'src/QGst')
-rw-r--r-- | src/QGst/caps.cpp | 43 | ||||
-rw-r--r-- | src/QGst/caps.h | 11 | ||||
-rw-r--r-- | src/QGst/childproxy.h | 1 | ||||
-rw-r--r-- | src/QGst/colorbalance.h | 1 | ||||
-rw-r--r-- | src/QGst/global.cpp | 3 | ||||
-rw-r--r-- | src/QGst/global.h | 2 | ||||
-rw-r--r-- | src/QGst/miniobject.cpp | 43 | ||||
-rw-r--r-- | src/QGst/miniobject.h | 9 | ||||
-rw-r--r-- | src/QGst/propertyprobe.h | 1 | ||||
-rw-r--r-- | src/QGst/streamvolume.h | 1 | ||||
-rw-r--r-- | src/QGst/urihandler.h | 1 | ||||
-rw-r--r-- | src/QGst/videoorientation.h | 1 | ||||
-rw-r--r-- | src/QGst/xoverlay.h | 1 |
13 files changed, 73 insertions, 45 deletions
diff --git a/src/QGst/caps.cpp b/src/QGst/caps.cpp index 08d0e34..d3971c3 100644 --- a/src/QGst/caps.cpp +++ b/src/QGst/caps.cpp @@ -185,7 +185,7 @@ CapsPtr Caps::copyNth(uint index) const void Caps::ref(bool increaseRef) { - if (Private::ObjectStore::put(m_object)) { + if (Private::ObjectStore::put(this)) { if (increaseRef) { gst_caps_ref(GST_CAPS(m_object)); } @@ -194,32 +194,24 @@ void Caps::ref(bool increaseRef) void Caps::unref() { - if (Private::ObjectStore::take(m_object)) { + if (Private::ObjectStore::take(this)) { gst_caps_unref(GST_CAPS(m_object)); + delete this; } } -void Caps::makeWritable() +CapsPtr Caps::makeWritable() const { + /* + * Calling gst_*_make_writable() below is tempting but wrong. + * Since MiniObjects and Caps do not share the same C++ instance in various wrappings, calling + * gst_*_make_writable() on an already writable object and wrapping the result is wrong, + * since it would just return the same pointer and we would wrap it in a new C++ instance. + */ if (!isWritable()) { - //m_object will change, need to deal with the reference count properly - unref(); - - /* - * Calling gst_*_make_writable() below is tempting but wrong, as the above unref() might have - * dropped the gst refcount from 2 to 1 temporarily. When this happens gst_*_make_writable() - * will do nothing, return the same object, and the refcount will go back to 2 when we ref() - * it again below. - * So the right thing to do is to copy() here to make sure we get a new object in this case. - * - * Note that if the external refCount is 1 then the gst_*_make_writable() semantics is - * preserved (nothing is copied, same object is used) as we tested for this condition - * before entering this code path. - */ - m_object = gst_caps_copy(GST_CAPS(m_object)); - - //Manage our reference count for the new m_object - ref(false); + return copy(); + } else { + return CapsPtr(const_cast<Caps*>(this)); } } @@ -229,4 +221,13 @@ QDebug operator<<(QDebug debug, const CapsPtr & caps) return debug.space(); } + +namespace Private { + +QGlib::RefCountedObject *wrapCaps(void *caps) +{ + return QGlib::constructWrapper(GST_CAPS(caps)->type, caps); +} + +} //namespace Private } //namespace QGst diff --git a/src/QGst/caps.h b/src/QGst/caps.h index a83b6e1..4a11f38 100644 --- a/src/QGst/caps.h +++ b/src/QGst/caps.h @@ -69,7 +69,7 @@ public: CapsPtr copyNth(uint index) const; bool isWritable() const; - void makeWritable(); + CapsPtr makeWritable() const; protected: virtual void ref(bool increaseRef); @@ -79,8 +79,15 @@ protected: /*! \relates QGst::Caps */ QDebug operator<<(QDebug debug, const CapsPtr & caps); -} + +namespace Private { + +QGlib::RefCountedObject *wrapCaps(void *caps); + +} //namespace Private +} //namespace QGst QGLIB_REGISTER_TYPE(QGst::Caps) +QGLIB_REGISTER_WRAPIMPL_FOR_SUBCLASSES_OF(QGst::Caps, QGst::Private::wrapCaps) #endif diff --git a/src/QGst/childproxy.h b/src/QGst/childproxy.h index 107f3f0..91d43b3 100644 --- a/src/QGst/childproxy.h +++ b/src/QGst/childproxy.h @@ -53,5 +53,6 @@ void ChildProxy::setChildProperty(const char *name, const T & value) } QGLIB_REGISTER_TYPE(QGst::ChildProxy) +QGLIB_REGISTER_INTERFACE(QGst::ChildProxy) #endif // QGST_CHILDPROXY_H diff --git a/src/QGst/colorbalance.h b/src/QGst/colorbalance.h index c8bf262..7e54099 100644 --- a/src/QGst/colorbalance.h +++ b/src/QGst/colorbalance.h @@ -51,5 +51,6 @@ public: QGLIB_REGISTER_TYPE(QGst::ColorBalanceChannel) QGLIB_REGISTER_TYPE(QGst::ColorBalance) +QGLIB_REGISTER_INTERFACE(QGst::ColorBalance) #endif // QGST_COLORBALANCE_H diff --git a/src/QGst/global.cpp b/src/QGst/global.cpp index 0f5fcf2..9299db0 100644 --- a/src/QGst/global.cpp +++ b/src/QGst/global.cpp @@ -22,6 +22,7 @@ namespace QGst { namespace Private { void registerValueVTables(); + void registerWrapperConstructors(); //generated by codegen } void init() @@ -31,11 +32,13 @@ void init() void init(int *argc, char **argv[]) { + QGlib::init(); GError *error; if (!gst_init_check(argc, argv, &error)) { throw QGlib::Error(error); } Private::registerValueVTables(); + Private::registerWrapperConstructors(); } void cleanup() diff --git a/src/QGst/global.h b/src/QGst/global.h index b5a8865..5c74c35 100644 --- a/src/QGst/global.h +++ b/src/QGst/global.h @@ -164,6 +164,8 @@ namespace QGst { /*! Initializes the GStreamer library, setting up internal path lists, * registering built-in elements, and loading standard plugins. + * \note This function also calls QGlib::init(), + * so there is no need to call it explicitly. * \param argc pointer to the application's argc * \param argv pointer to the application's argv * \throws QGlib::Error when initialization fails diff --git a/src/QGst/miniobject.cpp b/src/QGst/miniobject.cpp index 4a063d9..9f5c461 100644 --- a/src/QGst/miniobject.cpp +++ b/src/QGst/miniobject.cpp @@ -52,7 +52,7 @@ void MiniObject::unsetFlag(MiniObjectFlag flag) void MiniObject::ref(bool increaseRef) { - if (Private::ObjectStore::put(m_object)) { + if (Private::ObjectStore::put(this)) { if (increaseRef) { gst_mini_object_ref(GST_MINI_OBJECT(m_object)); } @@ -61,33 +61,34 @@ void MiniObject::ref(bool increaseRef) void MiniObject::unref() { - if (Private::ObjectStore::take(m_object)) { + if (Private::ObjectStore::take(this)) { gst_mini_object_unref(GST_MINI_OBJECT(m_object)); + delete this; } } -void MiniObject::makeWritable() +MiniObjectPtr MiniObject::makeWritable() const { + /* + * Calling gst_*_make_writable() below is tempting but wrong. + * Since MiniObjects and Caps do not share the same C++ instance in various wrappings, calling + * gst_*_make_writable() on an already writable object and wrapping the result is wrong, + * since it would just return the same pointer and we would wrap it in a new C++ instance. + */ if (!isWritable()) { - //m_object will change, need to deal with the reference count properly - unref(); - - /* - * Calling gst_*_make_writable() below is tempting but wrong, as the above unref() might have - * dropped the gst refcount from 2 to 1 temporarily. When this happens gst_*_make_writable() - * will do nothing, return the same object, and the refcount will go back to 2 when we ref() - * it again below. - * So the right thing to do is to copy() here to make sure we get a new object in this case. - * - * Note that if the external refCount is 1 then the gst_*_make_writable() semantics is - * preserved (nothing is copied, same object is used) as we tested for this condition - * before entering this code path. - */ - m_object = gst_mini_object_copy(GST_MINI_OBJECT(m_object)); - - //Manage our reference count for the new m_object - ref(false); + return copy(); + } else { + return MiniObjectPtr(const_cast<MiniObject*>(this)); } } + +namespace Private { + +QGlib::RefCountedObject *wrapMiniObject(void *miniObject) +{ + return QGlib::constructWrapper(QGlib::Type::fromInstance(miniObject), miniObject); +} + +} //namespace Private } //namespace QGst diff --git a/src/QGst/miniobject.h b/src/QGst/miniobject.h index feb8ae6..61690c7 100644 --- a/src/QGst/miniobject.h +++ b/src/QGst/miniobject.h @@ -32,7 +32,7 @@ class MiniObject : public QGlib::RefCountedObject public: MiniObjectPtr copy() const; bool isWritable() const; - void makeWritable(); + MiniObjectPtr makeWritable() const; MiniObjectFlags flags() const; bool flagIsSet(MiniObjectFlag flag) const; @@ -44,8 +44,15 @@ protected: virtual void unref(); }; + +namespace Private { + +QGlib::RefCountedObject *wrapMiniObject(void *miniObject); + +} //namespace Private } //namespace QGst QGLIB_REGISTER_TYPE(QGst::MiniObject) +QGLIB_REGISTER_WRAPIMPL_FOR_SUBCLASSES_OF(QGst::MiniObject, QGst::Private::wrapMiniObject) #endif diff --git a/src/QGst/propertyprobe.h b/src/QGst/propertyprobe.h index 75714e6..1385add 100644 --- a/src/QGst/propertyprobe.h +++ b/src/QGst/propertyprobe.h @@ -50,5 +50,6 @@ public: } QGLIB_REGISTER_TYPE(QGst::PropertyProbe) +QGLIB_REGISTER_INTERFACE(QGst::PropertyProbe) #endif // QGST_PROPERTYPROBE_H diff --git a/src/QGst/streamvolume.h b/src/QGst/streamvolume.h index b908f66..e646eca 100644 --- a/src/QGst/streamvolume.h +++ b/src/QGst/streamvolume.h @@ -41,5 +41,6 @@ public: } //namespace QGst QGLIB_REGISTER_TYPE(QGst::StreamVolume) +QGLIB_REGISTER_INTERFACE(QGst::StreamVolume) #endif // QGST_STREAMVOLUME_H diff --git a/src/QGst/urihandler.h b/src/QGst/urihandler.h index eeb2538..eafd3a5 100644 --- a/src/QGst/urihandler.h +++ b/src/QGst/urihandler.h @@ -42,5 +42,6 @@ public: } //namespace QGst QGLIB_REGISTER_TYPE(QGst::UriHandler) +QGLIB_REGISTER_INTERFACE(QGst::UriHandler) #endif // QGST_URIHANDLER_H diff --git a/src/QGst/videoorientation.h b/src/QGst/videoorientation.h index 4764ee1..60c5ff1 100644 --- a/src/QGst/videoorientation.h +++ b/src/QGst/videoorientation.h @@ -44,5 +44,6 @@ public: } //namespace QGst QGLIB_REGISTER_TYPE(QGst::VideoOrientation) +QGLIB_REGISTER_INTERFACE(QGst::VideoOrientation) #endif // QGST_VIDEOORIENTATION_H diff --git a/src/QGst/xoverlay.h b/src/QGst/xoverlay.h index f8d665b..2db89f9 100644 --- a/src/QGst/xoverlay.h +++ b/src/QGst/xoverlay.h @@ -42,5 +42,6 @@ public: } //namespace QGst QGLIB_REGISTER_TYPE(QGst::XOverlay) +QGLIB_REGISTER_INTERFACE(QGst::XOverlay) #endif // QGST_XOVERLAY_H |