[gstreamermm: 79/167] [peper0]Pad::set_chain_function support prototype.



commit e1a207e8d0a287f69dfafabe552ddca0c250bc01
Author: Marcin Kolny at Flytronic <marcin kolny flytronic pl>
Date:   Tue Jul 30 13:14:27 2013 +0200

    [peper0]Pad::set_chain_function support prototype.

 gstreamer/src/pad.ccg |   30 ++++++++++++++++++++++++++++++
 gstreamer/src/pad.hg  |    8 ++++++++
 2 files changed, 38 insertions(+), 0 deletions(-)
---
diff --git a/gstreamer/src/pad.ccg b/gstreamer/src/pad.ccg
index 7bd575f..b1d881a 100644
--- a/gstreamer/src/pad.ccg
+++ b/gstreamer/src/pad.ccg
@@ -175,5 +175,35 @@ FlowReturn Pad::chain(const Glib::RefPtr<Gst::Buffer>& buffer)
   return FlowReturn(gst_pad_chain(gobj(), buffer->gobj()));
 }
 
+GstFlowReturn Pad_Chain_gstreamermm_callback(GstPad* pad, GstObject* parent, GstBuffer *buffer)
+{
+  //FIXME: It's made like vfunc wrappers, but why there is no reffing of pad?
+  Gst::Pad *pad_wrapper = dynamic_cast<Gst::Pad*>
+    (static_cast<Glib::ObjectBase*>(
+      Glib::ObjectBase::_get_current_wrapper((GObject*)pad)
+      )
+    );
+  g_assert(pad);
+
+  try
+  {
+    return static_cast<GstFlowReturn>(
+      pad_wrapper->slot_chain(Glib::wrap(pad, true),  //take copy
+                              Glib::wrap(buffer, false)  //manage object
+                           ));
+  }
+  catch(...)
+  {
+    Glib::exception_handlers_invoke();
+  }
+
+  return GST_FLOW_ERROR;
+}
+
+void Pad::set_chain_function(const SlotChain& slot)
+{
+  slot_chain = slot;
+  gst_pad_set_chain_function(GST_PAD(gobj()), &Pad_Chain_gstreamermm_callback);
+}
 
 } //namespace Gst
diff --git a/gstreamer/src/pad.hg b/gstreamer/src/pad.hg
index 33a2391..caa7b2e 100644
--- a/gstreamer/src/pad.hg
+++ b/gstreamer/src/pad.hg
@@ -123,6 +123,8 @@ public:
    */
   typedef sigc::slot< bool, const Glib::RefPtr<Gst::Pad>&, const Glib::RefPtr<Gst::MiniObject>& > SlotData;
 
+  typedef sigc::slot< Gst::FlowReturn, const Glib::RefPtr<Gst::Pad>&, const Glib::RefPtr<Gst::Buffer>& > 
SlotChain;
+
   /** Creates a new pad with the given name in the given direction.
    *
    * @param name The name of the new pad.
@@ -371,6 +373,9 @@ public:
   _WRAP_METHOD(bool stop_task() , gst_pad_stop_task)
   _WRAP_METHOD(bool set_active(bool active = true), gst_pad_set_active)
 
+  friend GstFlowReturn Pad_Chain_gstreamermm_callback(GstPad* pad, GstObject* parent, GstBuffer *buffer);
+  void set_chain_function(const SlotChain& slot);
+
     //C API specific pad callback setting functions are ignored.
     _IGNORE(
       gst_pad_set_acceptcaps_function,
@@ -411,6 +416,9 @@ public:
   _WRAP_PROPERTY("caps", Glib::RefPtr<Gst::Caps>)
   _WRAP_PROPERTY("direction", PadDirection)
   _WRAP_PROPERTY("template", PadTemplate)
+
+private:
+  SlotChain slot_chain;
 };
 
 } // namespace Gst


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