[gstreamermm] Message: Use a custom wrap_new() to generate correct Message class.
- From: José Alburquerque <jaalburqu src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gstreamermm] Message: Use a custom wrap_new() to generate correct Message class.
- Date: Fri, 12 Feb 2010 00:32:58 +0000 (UTC)
commit f4a31c8f2893adca0cb5741d64539ea1a4dfcba5
Author: José Alburquerque <jaalburqu svn gnome org>
Date: Mon Feb 8 19:13:44 2010 -0500
Message: Use a custom wrap_new() to generate correct Message class.
* gstreamer/src/message.ccg:
* gstreamer/src/message.hg: Used a custom wrap_new() method which uses
the Gst::Message::wrap() method to generate the correct Message class
wrapper. Wrapped the copy_vfunc() virtual function.
ChangeLog | 9 +++++++++
gstreamer/src/message.ccg | 42 +++++++++++++++++++++++++++++++++++++-----
gstreamer/src/message.hg | 9 +++++++++
3 files changed, 55 insertions(+), 5 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index de06ead..7e78254 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-02-08 José Alburquerque <jaalburqu svn gnome org>
+
+ Message: Use a custom wrap_new() to generate correct Message class.
+
+ * gstreamer/src/message.ccg:
+ * gstreamer/src/message.hg: Used a custom wrap_new() method which uses
+ the Gst::Message::wrap() method to generate the correct Message class
+ wrapper. Wrapped the copy_vfunc() virtual function.
+
2010-02-07 José Alburquerque <jaalburqu svn gnome org>
Message: Modify create() method so that wrappers are not leaked.
diff --git a/gstreamer/src/message.ccg b/gstreamer/src/message.ccg
index 6a03940..ef09ca3 100644
--- a/gstreamer/src/message.ccg
+++ b/gstreamer/src/message.ccg
@@ -46,7 +46,7 @@ Glib::QueryQuark get_quark(MessageType t)
Glib::RefPtr<Gst::Message> Message::create_writable()
{
- return Gst::wrap(gst_message_make_writable(gobj()));
+ return wrap(gst_message_make_writable(gobj()));
}
MessageEos::MessageEos(GstMessage* castitem)
@@ -1140,7 +1140,7 @@ Glib::RefPtr<Gst::Message> Message::wrap(GstMessage* message, bool take_copy)
result = Glib::RefPtr<Gst::Message>(wrapper);
- if(result && take_copy)
+ if(take_copy)
result->reference();
// Hook into the GstMessage finalize function.
@@ -1156,7 +1156,41 @@ Glib::RefPtr<Gst::Message> Message::wrap(GstMessage* message, bool take_copy)
return result;
}
+Gst::MiniObject* Message_Class::wrap_new(GstMiniObject* object)
+{
+ // Use the Gst::Message wrap() method to get the right type of Message class
+ // and return the underlying object in the refptr.
+ return Gst::Message::wrap((GstMessage*)object, true).operator->();
+}
+
#ifdef GLIBMM_VFUNCS_ENABLED
+GstMiniObject* Message_Class::copy_vfunc_callback(const GstMiniObject* self)
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(GST_MINI_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ // Call the original underlying C function:
+ if(base && GST_MINI_OBJECT_CLASS(base)->copy)
+ return (*GST_MINI_OBJECT_CLASS(base)->copy)(self);
+
+ return 0;
+}
+Glib::RefPtr<Gst::MiniObject> Message::copy_vfunc() const
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobj())) // Get the parent class of the object class (The original underlying C class).
+ );
+
+ if(base && GST_MINI_OBJECT_CLASS(base)->copy)
+ {
+ return Gst::Message::wrap(
+ GST_MESSAGE((*GST_MINI_OBJECT_CLASS(base)->copy)(
+ GST_MINI_OBJECT(gobj()))));
+ }
+
+ return Glib::RefPtr<Gst::MiniObject>(0);
+}
void Message_Class::finalize_vfunc_callback(GstMiniObject* self)
{
BaseClassType *const base = static_cast<BaseClassType*>(
@@ -1166,9 +1200,8 @@ void Message_Class::finalize_vfunc_callback(GstMiniObject* self)
// Call the original underlying C function:
if(base && GST_MINI_OBJECT_CLASS(base)->finalize)
(*GST_MINI_OBJECT_CLASS(base)->finalize)(self);
-
}
-void Message::finalize_vfunc()
+void Message::finalize_vfunc()
{
BaseClassType *const base = static_cast<BaseClassType*>(
g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobj())) // Get the parent class of the object class (The original underlying C class).
@@ -1179,5 +1212,4 @@ void Message::finalize_vfunc()
}
#endif //GLIBMM_VFUNCS_ENABLED
-
} //namespace Gst
diff --git a/gstreamer/src/message.hg b/gstreamer/src/message.hg
index 64d2a06..08fdda7 100644
--- a/gstreamer/src/message.hg
+++ b/gstreamer/src/message.hg
@@ -75,6 +75,7 @@ class Message : public Gst::MiniObject
{
_CLASS_GSTMINIOBJECT(Message, GstMessage, GST_MESSAGE, Gst::MiniObject, GstMiniObject)
_IGNORE(gst_message_ref, gst_message_unref)
+ _CUSTOM_WRAP_NEW
public:
/** Wrap a GstMessage* in a C++ instance, creating an instance of a
@@ -111,6 +112,12 @@ public:
_MEMBER_GET_GOBJECT(source, src, Gst::Object, GstObject*)
#ifdef GLIBMM_VFUNCS_ENABLED
+ /** Virtual function called when the Gst::Message needs to be copied.
+ */
+ virtual Glib::RefPtr<Gst::MiniObject> copy_vfunc() const;
+#endif //GLIBMM_VFUNCS_ENABLED
+
+#ifdef GLIBMM_VFUNCS_ENABLED
/** Virtual function called when the Gst::Message is about to be finalized.
*/
virtual void finalize_vfunc();
@@ -119,8 +126,10 @@ public:
protected:
#m4begin
_PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
+ GST_MINI_OBJECT_CLASS(klass)->copy = ©_vfunc_callback;
GST_MINI_OBJECT_CLASS(klass)->finalize = &finalize_vfunc_callback;
_SECTION(SECTION_PH_VFUNCS)
+ static GstMiniObject* copy_vfunc_callback(const GstMiniObject* self);
static void finalize_vfunc_callback(GstMiniObject* self);
_POP()
#m4end
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]