/* gstreamermm - a C++ wrapper for gstreamer * * Copyright 2008-2016 The gstreamermm Development Team * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include _PINCLUDE(gstreamermm/private/element_p.h) #define IGNORE_RESULT(x) { auto release_value = x; (void)release_value; } namespace Gst { const Glib::ustring BaseTransform::SINK_NAME = GST_BASE_TRANSFORM_SINK_NAME; const Glib::ustring BaseTransform::SRC_NAME = GST_BASE_TRANSFORM_SRC_NAME; GstFlowReturn BaseTransform_Class::prepare_output_buffer_vfunc_callback(GstBaseTransform* self, GstBuffer* input, GstBuffer** buffer) { Glib::ObjectBase *const obj_base = static_cast( 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_()) { CppObjectType *const obj = dynamic_cast(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. { Glib::RefPtr cpp_buffer; // Call the virtual member method, which derived classes might override. const GstFlowReturn result = static_cast(obj->prepare_output_buffer_vfunc( Glib::wrap(input, true), cpp_buffer)); *buffer = cpp_buffer ? cpp_buffer->gobj_copy() : 0; return result; } catch(...) { Glib::exception_handlers_invoke(); } } } BaseClassType *const base = static_cast( 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->prepare_output_buffer) return (*base->prepare_output_buffer)(self, input, buffer); typedef GstFlowReturn RType; return RType(); } FlowReturn Gst::BaseTransform::prepare_output_buffer_vfunc(const Glib::RefPtr& input, Glib::RefPtr& buffer) { BaseClassType *const base = static_cast( 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->prepare_output_buffer) { GstBuffer* gst_buffer; const Gst::FlowReturn result = static_cast((*base->prepare_output_buffer)(gobj(), Glib::unwrap(input), &gst_buffer)); buffer = Glib::wrap(gst_buffer, false); // Don't take copy because callback returns a newly created copy. return result; } typedef FlowReturn RType; return RType(); } Glib::RefPtr BaseTransform::get_allocator(AllocationParams& params) { GstAllocator* alloc; gst_base_transform_get_allocator(gobj(), &alloc, params.gobj()); 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::_get_current_wrapper((GObject*)self)); if(obj_base && obj_base->is_derived_()) { CppObjectType *const obj = dynamic_cast(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 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( 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& inbuf, const Glib::RefPtr& outbuf) { BaseClassType *const base = static_cast( 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(); } GstFlowReturn BaseTransform_Class::generate_output_vfunc_callback(GstBaseTransform* self, GstBuffer** outbuf) { Glib::ObjectBase *const obj_base = static_cast( 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_()) { CppObjectType *const obj = dynamic_cast(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. { Glib::RefPtr cpp_buffer; // Call the virtual member method, which derived classes might override. const GstFlowReturn result = static_cast(obj->generate_output_vfunc( cpp_buffer)); *outbuf = cpp_buffer ? cpp_buffer->gobj_copy() : 0; return result; } catch(...) { Glib::exception_handlers_invoke(); } } } BaseClassType *const base = static_cast( 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->generate_output) return (*base->generate_output)(self, outbuf); typedef GstFlowReturn RType; return RType(); } FlowReturn Gst::BaseTransform::generate_output_vfunc(Glib::RefPtr& outbuf) { BaseClassType *const base = static_cast( 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->generate_output) { GstBuffer* gst_buffer = nullptr; const Gst::FlowReturn result = static_cast((*base->generate_output)(gobj(), &gst_buffer)); outbuf = Glib::wrap(gst_buffer, false); // Don't take copy because callback returns a newly created copy. return result; } typedef FlowReturn RType; return RType(); } gboolean BaseTransform_Class::query_vfunc_callback(GstBaseTransform* self, GstPadDirection direction, GstQuery* query) { const auto obj_base = static_cast( 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(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); int ret = static_cast(obj->base_transform_query_vfunc(static_cast(direction), query_cpp)); IGNORE_RESULT(query_cpp.release()); return ret; } catch(...) { Glib::exception_handlers_invoke(); } } } BaseClassType *const base = static_cast( 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->query) { gboolean retval = (*base->query)(self, direction, query); return retval; } typedef gboolean RType; return RType(); } bool Gst::BaseTransform::base_transform_query_vfunc(Gst::PadDirection direction, const Glib::RefPtr& query) { const auto base = static_cast( 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->query) { bool retval((*base->query)(gobj(), static_cast(direction), Glib::unwrap(query))); return retval; } typedef bool RType; return RType(); } bool BaseTransform::propose_allocation_vfunc(const Glib::RefPtr& decide_query, const Glib::RefPtr& query) { const auto base = static_cast( 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::_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(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(obj->propose_allocation_vfunc(decide_query_cpp, query_cpp)); IGNORE_RESULT(query_cpp.release()); IGNORE_RESULT(decide_query_cpp.release()); return ret; } catch(...) { Glib::exception_handlers_invoke(); } } } BaseClassType *const base = static_cast( 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& query) { const auto base = static_cast( 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::_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(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(obj->decide_allocation_vfunc(query_cpp)); IGNORE_RESULT(query_cpp.release()); return ret; } catch(...) { Glib::exception_handlers_invoke(); } } } BaseClassType *const base = static_cast( 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