[gstreamermm] BaseSink: Wrap remaining virtual functions.



commit b8b4edf27bbfdb78e425e039a17aec5994488695
Author: José Alburquerque <jaalburqu svn gnome org>
Date:   Fri Aug 6 18:43:31 2010 -0400

    	BaseSink: Wrap remaining virtual functions.
    
    	* gstreamer/src/basesink.ccg:
    	* gstreamer/src/basesink.hg: Manually wrap the remaining boolean
    	virtual functions making sure that they return true by default.
    	The C API does not set default handlers for the virtual functions (in
    	the init function) causing our virtual functions to return false by
    	default which apparently is considered an error by the underlying API.

 ChangeLog                  |   11 ++
 gstreamer/src/basesink.ccg |  367 ++++++++++++++++++++++++++++++++++++++++++++
 gstreamer/src/basesink.hg  |   90 +++++------
 3 files changed, 420 insertions(+), 48 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 7c044fb..4615b42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2010-08-06  José Alburquerque  <jaalburqu svn gnome org>
 
+	BaseSink: Wrap remaining virtual functions.
+
+	* gstreamer/src/basesink.ccg:
+	* gstreamer/src/basesink.hg: Manually wrap the remaining boolean
+	virtual functions making sure that they return true by default.
+	The C API does not set default handlers for the virtual functions (in
+	the init function) causing our virtual functions to return false by
+	default which apparently is considered an error by the underlying API.
+
+2010-08-06  José Alburquerque  <jaalburqu svn gnome org>
+
 	Fix the build with GCC 4.5.
 
 	* gstreamer/src/message.ccg (wrap): Store the message type as a
diff --git a/gstreamer/src/basesink.ccg b/gstreamer/src/basesink.ccg
index 9b513de..c252746 100644
--- a/gstreamer/src/basesink.ccg
+++ b/gstreamer/src/basesink.ccg
@@ -112,5 +112,372 @@ FlowReturn Gst::BaseSink::buffer_alloc_vfunc(guint64 offset, guint size, const G
   typedef FlowReturn RType;
   return RType();
 }
+gboolean BaseSink_Class::set_caps_vfunc_callback(GstBaseSink* self, GstCaps* caps)
+{
+  Glib::ObjectBase *const 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_())
+  {
+    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
+        // Call the virtual member method, which derived classes might override.
+        return static_cast<int>(obj->set_caps_vfunc(Glib::wrap(caps, true)
+));
+      #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->set_caps)
+    return (*base->set_caps)(self, caps);
+
+  return true;
+}
+bool Gst::BaseSink::set_caps_vfunc(const Glib::RefPtr<Gst::Caps>& caps) 
+{
+  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->set_caps)
+    return (*base->set_caps)(gobj(),Glib::unwrap(caps));
+
+  return true;
+}
+gboolean BaseSink_Class::start_vfunc_callback(GstBaseSink* self)
+{
+  Glib::ObjectBase *const 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_())
+  {
+    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
+        // Call the virtual member method, which derived classes might override.
+        return static_cast<int>(obj->start_vfunc());
+      #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->start)
+    return (*base->start)(self);
+
+  return true;
+}
+bool Gst::BaseSink::start_vfunc() 
+{
+  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->start)
+    return (*base->start)(gobj());
+
+  return true;
+}
+gboolean BaseSink_Class::stop_vfunc_callback(GstBaseSink* self)
+{
+  Glib::ObjectBase *const 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_())
+  {
+    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
+        // Call the virtual member method, which derived classes might override.
+        return static_cast<int>(obj->stop_vfunc());
+      #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->stop)
+    return (*base->stop)(self);
+
+  return true;
+}
+bool Gst::BaseSink::stop_vfunc() 
+{
+  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->stop)
+    return (*base->stop)(gobj());
+
+  return true;
+}
+gboolean BaseSink_Class::unlock_vfunc_callback(GstBaseSink* self)
+{
+  Glib::ObjectBase *const 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_())
+  {
+    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
+        // Call the virtual member method, which derived classes might override.
+        return static_cast<int>(obj->unlock_vfunc());
+      #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->unlock)
+    return (*base->unlock)(self);
+
+  return true;
+}
+bool Gst::BaseSink::unlock_vfunc() 
+{
+  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->unlock)
+    return (*base->unlock)(gobj());
+
+  return true;
+}
+gboolean BaseSink_Class::event_vfunc_callback(GstBaseSink* self, GstEvent* event)
+{
+  Glib::ObjectBase *const 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_())
+  {
+    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
+        // Call the virtual member method, which derived classes might override.
+        return static_cast<int>(obj->event_vfunc(Gst::wrap(event, true)
+));
+      #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->event)
+    return (*base->event)(self, event);
+
+  return true;
+}
+bool Gst::BaseSink::event_vfunc(const Glib::RefPtr<Gst::Event>& event) 
+{
+  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->event)
+    return (*base->event)(gobj(),Gst::unwrap(event));
+
+  return true;
+}
+gboolean BaseSink_Class::activate_pull_vfunc_callback(GstBaseSink* self, gboolean active)
+{
+  Glib::ObjectBase *const 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_())
+  {
+    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
+        // Call the virtual member method, which derived classes might override.
+        return static_cast<int>(obj->activate_pull_vfunc(active
+));
+      #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->activate_pull)
+    return (*base->activate_pull)(self, active);
+
+  return true;
+}
+bool Gst::BaseSink::activate_pull_vfunc(bool active) 
+{
+  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->activate_pull)
+    return (*base->activate_pull)(gobj(),static_cast<int>(active));
+
+  return true;
+}
+gboolean BaseSink_Class::unlock_stop_vfunc_callback(GstBaseSink* self)
+{
+  Glib::ObjectBase *const 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_())
+  {
+    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
+        // Call the virtual member method, which derived classes might override.
+        return static_cast<int>(obj->unlock_stop_vfunc());
+      #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->unlock_stop)
+    return (*base->unlock_stop)(self);
+
+  return true;
+}
+bool Gst::BaseSink::unlock_stop_vfunc() 
+{
+  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->unlock_stop)
+    return (*base->unlock_stop)(gobj());
+
+  return true;
+}
 
 } // namespace Gst
diff --git a/gstreamer/src/basesink.hg b/gstreamer/src/basesink.hg
index e228958..40ed15f 100644
--- a/gstreamer/src/basesink.hg
+++ b/gstreamer/src/basesink.hg
@@ -222,12 +222,9 @@ public:
   _WRAP_VFUNC(Glib::RefPtr<Gst::Caps> get_caps() const, "get_caps")
 
 #m4 _CONVERSION(`GstCaps*', `const Glib::RefPtr<Gst::Caps>&', `Glib::wrap($3, true)')
-  //TODO: Some boolean vfuncs cause strange incorrect functionality when their
-  //callbacks return false with the last "return RType()" line.  Make sure this
-  //one doesn't cause problems and implement later.
-  ///** Notify subclass of changed caps.
-   //*/
-  //_WRAP_VFUNC(bool set_caps(const Glib::RefPtr<Gst::Caps>& caps), "set_caps")
+  /** Notify subclass of changed caps.
+   */
+   virtual bool set_caps_vfunc(const Glib::RefPtr<Gst::Caps>& caps);
 
   /** Allocate a new buffer with given caps. */
   virtual FlowReturn buffer_alloc_vfunc(guint64 offset, guint size, const Glib::RefPtr<Gst::Caps>& caps, Glib::RefPtr<Gst::Buffer>& buffer);
@@ -239,35 +236,23 @@ public:
    */
   _WRAP_VFUNC(void get_times(const Glib::RefPtr<Gst::Buffer>& buffer, ClockTime& start, ClockTime& end) const, "get_times")
 
-  //TODO: Some boolean vfuncs cause strange incorrect functionality when their
-  //callbacks return false with the last "return RType()" line.  Make sure this
-  //one doesn't cause problems and implement later.
-  ///** Start processing. Ideal for opening resources in the subclass.
-   //*/
-  //_WRAP_VFUNC(bool start(), "start")
+  /** Start processing. Ideal for opening resources in the subclass.
+   */
+    virtual bool start_vfunc();
 
-  //TODO: Some boolean vfuncs cause strange incorrect functionality when their
-  //callbacks return false with the last "return RType()" line.  Make sure this
-  //one doesn't cause problems and implement later.
-  ///** Stop processing. Subclasses should use this to close resources.
-   //*/
-  //_WRAP_VFUNC(bool stop(), "stop")
+  /** Stop processing. Subclasses should use this to close resources.
+   */
+    virtual bool stop_vfunc();
 
-  //TODO: Some boolean vfuncs cause strange incorrect functionality when their
-  //callbacks return false with the last "return RType()" line.  Make sure this
-  //one doesn't cause problems and implement later.
-  ///** Unlock any pending access to the resource. Subclasses should unblock any
-   //* blocked function ASAP.
-   //*/
-  //_WRAP_VFUNC(bool unlock(), "unlock")
+  /** Unlock any pending access to the resource. Subclasses should unblock any
+   * blocked function ASAP.
+   */
+    virtual bool unlock_vfunc();
 
 #m4 _CONVERSION(`GstEvent*', `const Glib::RefPtr<Gst::Event>&', `Gst::wrap($3, true)')
-  //TODO: Some boolean vfuncs cause strange incorrect functionality when their
-  //callbacks return false with the last "return RType()" line.  Make sure this
-  //one doesn't cause problems and implement later.
-  ///** Override this to handle events arriving on the sink pad.
-   //*/
-  //_WRAP_VFUNC(bool event(const Glib::RefPtr<Gst::Event>& event), "event")
+  /** Override this to handle events arriving on the sink pad.
+   */
+    virtual bool event_vfunc(const Glib::RefPtr<Gst::Event>& event);
 
   /** Called to present the preroll buffer if desired.
    */
@@ -284,16 +269,13 @@ public:
    */
   _WRAP_VFUNC(StateChangeReturn async_play(), "async_play")
 
-  //TODO: Some boolean vfuncs cause strange incorrect functionality when their
-  //callbacks return false with the last "return RType()" line.  Make sure this
-  //one doesn't cause problems and implement later.
-  ///** Subclasses should override this when they can provide an alternate method
-   //* of spawning a thread to drive the pipeline in pull mode. Should start or
-   //* stop the pulling thread, depending on the value of the "active" argument.
-   //* Called after actually activating the sink pad in pull mode. The default
-   //* implementation starts a task on the sink pad. 
-   //*/
-  //_WRAP_VFUNC(bool activate_pull(bool active), "activate_pull")
+  /** Subclasses should override this when they can provide an alternate method
+   * of spawning a thread to drive the pipeline in pull mode. Should start or
+   * stop the pulling thread, depending on the value of the "active" argument.
+   * Called after actually activating the sink pad in pull mode. The default
+   * implementation starts a task on the sink pad. 
+   */
+    virtual bool activate_pull_vfunc(bool active);
 
   /** Only useful in pull mode, this vmethod will be called in response to
    * Gst::Pad::fixate_caps() being called on the sink pad. Implement if you
@@ -302,20 +284,32 @@ public:
    */
   _WRAP_VFUNC(void fixate(const Glib::RefPtr<Gst::Caps>& caps), "fixate")
 
-  //TODO: Some boolean vfuncs cause strange incorrect functionality when their
-  //callbacks return false with the last "return RType()" line.  Make sure this
-  //one doesn't cause problems and implement later.
-  ///** Clear the previous unlock request. Subclasses should clear any state they
-   //* set during unlock_vfunc(), such as clearing command queues.
-   //*/
-  //_WRAP_VFUNC(bool unlock_stop(), "unlock_stop")
+  /** Clear the previous unlock request. Subclasses should clear any state they
+   * set during unlock_vfunc(), such as clearing command queues.
+   */
+    virtual bool unlock_stop_vfunc();
+
 protected:
 #m4begin
   _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
   klass->buffer_alloc = &buffer_alloc_vfunc_callback;
+  klass->set_caps = &set_caps_vfunc_callback;
+  klass->start = &start_vfunc_callback;
+  klass->stop = &stop_vfunc_callback;
+  klass->unlock = &unlock_vfunc_callback;
+  klass->event = &event_vfunc_callback;
+  klass->activate_pull = &activate_pull_vfunc_callback;
+  klass->unlock_stop = &unlock_stop_vfunc_callback;
   _SECTION(SECTION_PH_VFUNCS)
   static GstFlowReturn buffer_alloc_vfunc_callback(GstBaseSink* self,
     guint64 offset, guint size, GstCaps* caps, GstBuffer** buf);
+  static gboolean set_caps_vfunc_callback(GstBaseSink* self, GstCaps* caps);
+  static gboolean start_vfunc_callback(GstBaseSink* self);
+  static gboolean stop_vfunc_callback(GstBaseSink* self);
+  static gboolean unlock_vfunc_callback(GstBaseSink* self);
+  static gboolean event_vfunc_callback(GstBaseSink* self, GstEvent* event);
+  static gboolean activate_pull_vfunc_callback(GstBaseSink* self, gboolean active);
+  static gboolean unlock_stop_vfunc_callback(GstBaseSink* self);
   _POP()
 #m4end
 };



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]