[gstreamermm] Gst::BaseTransform: fix vfunc methods
- From: Marcin Kolny <mkolny src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm] Gst::BaseTransform: fix vfunc methods
- Date: Sun, 28 Aug 2016 18:51:04 +0000 (UTC)
commit 44b8d279ab1ac0d5f79cc30cb52d5b51a3b8bf76
Author: Marcin Kolny <marcin kolny gmail com>
Date: Sun Aug 28 08:22:19 2016 +0200
Gst::BaseTransform: fix vfunc methods
gstreamer/src/basetransform.ccg | 120 ++++++++++++++++++++++++++++++++++++++-
gstreamer/src/basetransform.hg | 9 ++-
2 files changed, 125 insertions(+), 4 deletions(-)
---
diff --git a/gstreamer/src/basetransform.ccg b/gstreamer/src/basetransform.ccg
index 1cd6a8a..570e4a4 100644
--- a/gstreamer/src/basetransform.ccg
+++ b/gstreamer/src/basetransform.ccg
@@ -214,7 +214,7 @@ FlowReturn Gst::BaseTransform::generate_output_vfunc(Glib::RefPtr<Gst::Buffer>&
if(base && base->generate_output)
{
- GstBuffer* gst_buffer;
+ GstBuffer* gst_buffer = nullptr;
const Gst::FlowReturn result =
static_cast<Gst::FlowReturn>((*base->generate_output)(gobj(), &gst_buffer));
outbuf = Glib::wrap(gst_buffer, false); // Don't take copy because callback returns a newly created copy.
@@ -287,5 +287,123 @@ bool Gst::BaseTransform::base_transform_query_vfunc(Gst::PadDirection direction,
return RType();
}
+bool BaseTransform::propose_allocation_vfunc(const Glib::RefPtr<Gst::Query>& decide_query, const
Glib::RefPtr<Gst::Query>& query)
+{
+ const auto 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->propose_allocation)
+ {
+ bool retval((*base->propose_allocation)(gobj(),Glib::unwrap(decide_query),Glib::unwrap(query)));
+ return retval;
+ }
+
+ typedef bool RType;
+ return RType();
+}
+
+gboolean BaseTransform_Class::propose_allocation_vfunc_callback(GstBaseTransform* self, GstQuery*
decide_query, GstQuery* query)
+{
+ const auto obj_base = static_cast<Glib::ObjectBase*>(
+ Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+ // Non-gtkmmproc-generated custom classes implicitly call the default
+ // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+ // generated classes can use this optimisation, which avoids the unnecessary
+ // parameter conversions if there is no possibility of the virtual function
+ // being overridden:
+ if(obj_base && obj_base->is_derived_())
+ {
+ const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
+ if(obj) // This can be NULL during destruction.
+ {
+ try // Trap C++ exceptions which would normally be lost because this is a C callback.
+ {
+ // Call the virtual member method, which derived classes might override.
+ auto query_cpp = Glib::wrap(query, false);
+ auto decide_query_cpp = Glib::wrap(decide_query, false);
+ auto ret = static_cast<int>(obj->propose_allocation_vfunc(decide_query_cpp, query_cpp));
+ query_cpp.release();
+ decide_query_cpp.release();
+ return ret;
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ }
+ }
+
+ 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->propose_allocation)
+ return (*base->propose_allocation)(self, decide_query, query);
+
+ typedef gboolean RType;
+ return RType();
+}
+
+bool Gst::BaseTransform::decide_allocation_vfunc(const Glib::RefPtr<Gst::Query>& query)
+{
+ const auto 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->decide_allocation)
+ {
+ bool retval((*base->decide_allocation)(gobj(),Glib::unwrap(query)));
+ return retval;
+ }
+
+ typedef bool RType;
+ return RType();
+}
+
+gboolean BaseTransform_Class::decide_allocation_vfunc_callback(GstBaseTransform* self, GstQuery* query)
+{
+ const auto obj_base = static_cast<Glib::ObjectBase*>(
+ Glib::ObjectBase::_get_current_wrapper((GObject*)self));
+
+ // Non-gtkmmproc-generated custom classes implicitly call the default
+ // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc-
+ // generated classes can use this optimisation, which avoids the unnecessary
+ // parameter conversions if there is no possibility of the virtual function
+ // being overridden:
+ if(obj_base && obj_base->is_derived_())
+ {
+ const auto obj = dynamic_cast<CppObjectType* const>(obj_base);
+ if(obj) // This can be NULL during destruction.
+ {
+ try // Trap C++ exceptions which would normally be lost because this is a C callback.
+ {
+ // Call the virtual member method, which derived classes might override.
+ auto query_cpp = Glib::wrap(query, false);
+ auto ret = static_cast<int>(obj->decide_allocation_vfunc(query_cpp));
+ query_cpp.release();
+ return ret;
+ }
+ catch(...)
+ {
+ Glib::exception_handlers_invoke();
+ }
+ }
+ }
+
+ 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->decide_allocation)
+ return (*base->decide_allocation)(self, query);
+
+ typedef gboolean RType;
+ return RType();
+}
+
} //namespace Gst
diff --git a/gstreamer/src/basetransform.hg b/gstreamer/src/basetransform.hg
index aa694dc..f845414 100644
--- a/gstreamer/src/basetransform.hg
+++ b/gstreamer/src/basetransform.hg
@@ -267,7 +267,7 @@ public:
* implementation, it will be called for all metadata API in the downstream query,
* otherwise the metadata API is removed.
*/
- _WRAP_VFUNC(bool decide_allocation(const Glib::RefPtr<Gst::Query>& query), "decide_allocation")
+ virtual bool decide_allocation_vfunc(const Glib::RefPtr<Gst::Query>& query);
/** Return TRUE if the metadata API should be proposed in the upstream allocation query.
* The default implementation is NULL and will cause all metadata to be removed.
@@ -281,7 +281,7 @@ public:
* query downstream when in passthrough mode and will copy all the filtered metadata API
* in non-passthrough mode.
*/
- _WRAP_VFUNC(bool propose_allocation(const Glib::RefPtr<Gst::Query>& decide_query, const
Glib::RefPtr<Gst::Query>& query), "propose_allocation")
+ virtual bool propose_allocation_vfunc(const Glib::RefPtr<Gst::Query>& decide_query, const
Glib::RefPtr<Gst::Query>& query);
#m4 _CONVERSION(`GstBuffer*', `const Glib::RefPtr<Gst::Buffer>&', `Glib::wrap($3, true)')
@@ -322,13 +322,16 @@ protected:
klass->prepare_output_buffer = &prepare_output_buffer_vfunc_callback;
klass->transform = &transform_vfunc_callback;
klass->generate_output = &generate_output_vfunc_callback;
- klass->generate_output = &generate_output_vfunc_callback;
klass->query = &query_vfunc_callback;
+ klass->propose_allocation = &propose_allocation_vfunc_callback;
+ klass->decide_allocation = &decide_allocation_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);
static GstFlowReturn generate_output_vfunc_callback(GstBaseTransform* self, GstBuffer** outbuf);
static gboolean query_vfunc_callback(GstBaseTransform* self, GstPadDirection direction, GstQuery* query);
+ static gboolean propose_allocation_vfunc_callback(GstBaseTransform* self, GstQuery* decide_query,
GstQuery* query);
+ static gboolean decide_allocation_vfunc_callback(GstBaseTransform* self, GstQuery* query);
_POP()
#m4end
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]