[gstreamermm/devel-other-plugins] Gst::BaseTransform: fix transform_vfunc method
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm/devel-other-plugins] Gst::BaseTransform: fix transform_vfunc method
- Date: Mon, 13 Jul 2015 09:19:33 +0000 (UTC)
commit 7730fb3bde9a9dd32b0d2db41ee1e2acc353e1c8
Author: Marcin Kolny <marcin kolny flytronic pl>
Date: Mon Jul 13 11:07:46 2015 +0200
Gst::BaseTransform: fix transform_vfunc method
* gstreamer/src/basetransform.{ccg|hg}: transform_vfunc_callback
increases buffer refcount before passing it to transform_vfunc, but
some transform* methods require writable buffer.
transform_vfunc_callback has to be handcrafted, because refcount
managment isn't trivial in this case.
It should be done by using std::move and RefPtr move constructor.
gstreamer/src/basetransform.ccg | 61 +++++++++++++++++++++++++++++++++++++++
gstreamer/src/basetransform.hg | 4 ++-
2 files changed, 64 insertions(+), 1 deletions(-)
---
diff --git a/gstreamer/src/basetransform.ccg b/gstreamer/src/basetransform.ccg
index 9222b41..8d9cdc2 100644
--- a/gstreamer/src/basetransform.ccg
+++ b/gstreamer/src/basetransform.ccg
@@ -100,4 +100,65 @@ Glib::RefPtr<Allocator> BaseTransform::get_allocator(AllocationParams& params)
return Glib::wrap(alloc, false);
}
+GstFlowReturn BaseTransform_Class::transform_vfunc_callback(GstBaseTransform* self, GstBuffer* inbuf,
GstBuffer* outbuf)
+{
+ Glib::ObjectBase *const obj_base = static_cast<Glib::ObjectBase*>(
+ Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+ if(obj_base && obj_base->is_derived_())
+ {
+ CppObjectType *const obj = dynamic_cast<CppObjectType* const>(obj_base);
+ if(obj) // This can be NULL during destruction.
+ {
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ try // Trap C++ exceptions which would normally be lost because this is a C callback.
+ {
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ Glib::RefPtr<Gst::Buffer> w_inbuf = Glib::wrap(inbuf, false),
+ w_outbuf = Glib::wrap(outbuf, false);
+ // Call the virtual member method, which derived classes might override.
+ GstFlowReturn ret = ((GstFlowReturn)(obj->transform_vfunc(w_inbuf, w_outbuf)));
+ w_inbuf->reference(); w_outbuf->reference();
+ return ret;
+ #ifdef GLIBMM_EXCEPTIONS_ENABLED
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ #endif //GLIBMM_EXCEPTIONS_ENABLED
+ }
+ }
+
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_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 && base->transform)
+ {
+ GstFlowReturn retval = (*base->transform)(self, inbuf, outbuf);
+ return retval;
+ }
+
+ typedef GstFlowReturn RType;
+ return RType();
+}
+
+FlowReturn Gst::BaseTransform::transform_vfunc(const Glib::RefPtr<Gst::Buffer>& inbuf, const
Glib::RefPtr<Gst::Buffer>& outbuf)
+{
+ BaseClassType *const base = static_cast<BaseClassType*>(
+ g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class
(The original underlying C class).
+ );
+
+ if(base && base->transform)
+ {
+ FlowReturn retval(((FlowReturn)((*base->transform)(gobj(),Glib::unwrap(inbuf),Glib::unwrap(outbuf)))));
+ return retval;
+ }
+
+ typedef FlowReturn RType;
+ return RType();
+}
+
} //namespace Gst
diff --git a/gstreamer/src/basetransform.hg b/gstreamer/src/basetransform.hg
index 7a31f7f..1bb0426 100644
--- a/gstreamer/src/basetransform.hg
+++ b/gstreamer/src/basetransform.hg
@@ -200,7 +200,7 @@ public:
* incoming buffer to one outgoing buffer. The function is allowed to change
* size/timestamp/duration of the outgoing buffer.
*/
- _WRAP_VFUNC(FlowReturn transform(const Glib::RefPtr<Gst::Buffer>& inbuf, const Glib::RefPtr<Gst::Buffer>&
outbuf), "transform")
+ virtual FlowReturn transform_vfunc(const Glib::RefPtr<Gst::Buffer>& inbuf, const
Glib::RefPtr<Gst::Buffer>& outbuf);
/** Required if the element operates in-place. Transform the incoming buffer
* in-place.
@@ -245,8 +245,10 @@ protected:
klass->start = &start_vfunc_callback;
klass->stop = &stop_vfunc_callback;
klass->prepare_output_buffer = &prepare_output_buffer_vfunc_callback;
+ klass->transform = &transform_vfunc_callback;
_SECTION(SECTION_PH_VFUNCS)
static GstFlowReturn prepare_output_buffer_vfunc_callback(GstBaseTransform* self, GstBuffer* input,
GstBuffer** buf);
+ static GstFlowReturn transform_vfunc_callback(GstBaseTransform* self, GstBuffer* inbuf, GstBuffer* outbuf);
_POP()
#m4end
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]