[gstreamermm: 117/167] wrapped gstpadprobeinfo
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm: 117/167] wrapped gstpadprobeinfo
- Date: Tue, 3 Sep 2013 19:28:54 +0000 (UTC)
commit a302c32d1e714788f21894423b78d9e129852427
Author: Marcin Kolny [loganek] <marcin kolny gmail com>
Date: Thu Aug 1 21:07:30 2013 +0200
wrapped gstpadprobeinfo
examples/ogg_player/main.cc | 2 +-
gstreamer/src/pad.ccg | 71 ++++++++++++++++++++++++++++++++++++++++++-
gstreamer/src/pad.hg | 39 +++++++++++++++++++++++-
tools/m4/convert_gst.m4 | 4 ++-
4 files changed, 112 insertions(+), 4 deletions(-)
---
diff --git a/examples/ogg_player/main.cc b/examples/ogg_player/main.cc
index e217dc1..c709c9b 100644
--- a/examples/ogg_player/main.cc
+++ b/examples/ogg_player/main.cc
@@ -111,7 +111,7 @@ void on_parser_pad_added(const Glib::RefPtr<Gst::Pad>& newPad)
}
}
-Gst::PadProbeReturn on_sink_pad_have_data(const Glib::RefPtr<Gst::Pad>& pad, GstPadProbeInfo* info)
+Gst::PadProbeReturn on_sink_pad_have_data(const Glib::RefPtr<Gst::Pad>& pad, const Gst::PadProbeInfo& info)
{
std::cout << "Sink pad '" << pad->get_name() << "' has received data;";
std::cout << " will now remove sink data probe id: " << data_probe_id << std::endl;
diff --git a/gstreamer/src/pad.ccg b/gstreamer/src/pad.ccg
index a318acc..f1d1a88 100644
--- a/gstreamer/src/pad.ccg
+++ b/gstreamer/src/pad.ccg
@@ -39,7 +39,7 @@ static GstPadProbeReturn Pad_Probe_gstreamermm_callback(GstPad* pad, GstPadProbe
try
{
- return static_cast<GstPadProbeReturn>((*the_slot)(Glib::wrap(pad, true), probe_info));
+ return static_cast<GstPadProbeReturn>((*the_slot)(Glib::wrap(pad, true), Glib::wrap(probe_info,
true)));
}
catch(...)
{
@@ -199,4 +199,73 @@ void Pad::set_chain_function(const SlotChain& slot)
gst_pad_set_chain_function(GST_PAD(gobj()), &Pad_Chain_gstreamermm_callback);
}
+PadProbeInfo::PadProbeInfo()
+: gobj_(g_try_new(GstPadProbeInfo, 1)),
+ take_ownership(true)
+{
+ // Handle possible memory allocation failure.
+ if(!gobj_)
+ {
+ gstreamermm_handle_error(
+ "Failed to allocate a new Gst::PadProbeInfo.");
+ }
+}
+
+PadProbeInfo::PadProbeInfo(GstPadProbeInfo& castitem, bool take_ownership)
+: gobj_(&castitem),
+ take_ownership(take_ownership)
+{
+}
+
+PadProbeInfo::PadProbeInfo(GstPadProbeInfo* castitem, bool take_copy)
+: take_ownership(take_copy)
+{
+ if(take_copy)
+ {
+ gobj_ = (g_try_new(GstPadProbeInfo, 1));
+
+ if(!gobj_)
+ {
+ gstreamermm_handle_error(
+ "Failed to allocate a new Gst::PadProbeInfo.");
+ return;
+ }
+
+ if(castitem)
+ *gobj_ = *castitem;
+ }
+ else
+ {
+ gobj_ = castitem;
+ }
+}
+
+PadProbeInfo::PadProbeInfo(const PadProbeInfo& other)
+: gobj_(g_try_new(GstPadProbeInfo, 1)),
+ take_ownership(true)
+{
+ if(!gobj_)
+ {
+ gstreamermm_handle_error("Failed to allocate a new Gst::PadProbeInfo.");
+ return;
+ }
+
+ // I can do it, because there is no dynamic allocated memory in pad
+ *gobj_ = *other.gobj_;
+}
+
+PadProbeInfo::~PadProbeInfo()
+{
+ if(take_ownership)
+ g_free(gobj_);
+}
+
} //namespace Gst
+
+namespace Glib
+{
+Gst::PadProbeInfo wrap(GstPadProbeInfo* probe_info, bool take_copy)
+{
+ return Gst::PadProbeInfo(probe_info, take_copy);
+}
+}
diff --git a/gstreamer/src/pad.hg b/gstreamer/src/pad.hg
index 3db833f..40c6d30 100644
--- a/gstreamer/src/pad.hg
+++ b/gstreamer/src/pad.hg
@@ -22,6 +22,7 @@
#include <gstreamermm/miniobject.h>
#include <gstreamermm/format.h>
#include <gstreamermm/query.h>
+#include <gstreamermm/bufferlist.h>
#include <glibmm/arrayhandle.h>
_DEFS(gstreamermm,gst)
@@ -35,6 +36,7 @@ class Element;
class Event;
class PadTemplate;
class Query;
+class PadProbeInfo;
//Gst::Iterator<> forward declaration.
template <class CppType>
@@ -116,7 +118,7 @@ public:
* bool on_have_data(const Glib::RefPtr<Gst::Pad>& pad, const
* Glib::RefPtr<Gst::MiniObjec>& data);.
*/
- typedef sigc::slot< PadProbeReturn, const Glib::RefPtr<Gst::Pad>&, GstPadProbeInfo* > SlotProbe;
+ typedef sigc::slot< PadProbeReturn, const Glib::RefPtr<Gst::Pad>&, const Gst::PadProbeInfo& > SlotProbe;
typedef sigc::slot< Gst::FlowReturn, const Glib::RefPtr<Gst::Pad>&, Glib::RefPtr<Gst::Buffer>& > SlotChain;
@@ -420,4 +422,39 @@ private:
SlotChain slot_chain;
};
+class PadProbeInfo
+{
+ _CLASS_GENERIC(PadProbeInfo, GstPadProbeInfo)
+
+public:
+ PadProbeInfo();
+ explicit PadProbeInfo(GstPadProbeInfo& castitem,
+ bool take_ownership = false);
+ explicit PadProbeInfo(GstPadProbeInfo* castitem,
+ bool take_copy = false);
+ PadProbeInfo(const PadProbeInfo& other);
+ virtual ~PadProbeInfo();
+
+ GstPadProbeInfo* gobj() { return gobj_; };
+
+ const GstPadProbeInfo* gobj() const { return gobj_; };
+
+ _WRAP_METHOD(Glib::RefPtr<Gst::Event> get_event(), gst_pad_probe_info_get_event)
+ _WRAP_METHOD(Glib::RefPtr<Gst::Query> get_query(), gst_pad_probe_info_get_query)
+ _WRAP_METHOD(Glib::RefPtr<Gst::Buffer> get_buffer(), gst_pad_probe_info_get_buffer)
+ _WRAP_METHOD(Glib::RefPtr<Gst::BufferList> get_buffer_list(), gst_pad_probe_info_get_buffer_list)
+protected:
+#ifndef DOXYGEN_SHOULD_SKIP_THIS
+ GstPadProbeInfo* gobj_;
+ bool take_ownership;
+#endif /* DOXYGEN_SHOULD_SKIP_THIS */
+};
+
} // namespace Gst
+
+namespace Glib
+{
+Gst::PadProbeInfo wrap(GstPadProbeInfo* probe_info, bool take_copy);
+
+} // namespace Glib
+
diff --git a/tools/m4/convert_gst.m4 b/tools/m4/convert_gst.m4
index 1a89df6..36cf0ae 100644
--- a/tools/m4/convert_gst.m4
+++ b/tools/m4/convert_gst.m4
@@ -66,7 +66,7 @@ _CONVERSION(`Glib::RefPtr<Gst::Buffer>',`GstBuffer*', `Glib::unwrap($3)')
dnl BufferList
_CONVERSION(`Glib::RefPtr<Gst::BufferList>',`GstBufferList*', `Glib::unwrap($3)')
-_CONVERSION(`GstBufferList*', `Glib::RefPtr<BufferList>', `Glib::wrap($3)')
+_CONVERSION(`GstBufferList*', `Glib::RefPtr<Gst::BufferList>', `Glib::wrap($3)')
_CONVERSION(`const Glib::RefPtr<Gst::BufferList>&', `GstBufferList*', `Glib::unwrap($3)')
dnl Bus
@@ -120,6 +120,7 @@ _CONVERSION(`const Glib::RefPtr<Gst::ElementFactory>&',`GstElementFactory*', `Gl
dnl Event
_CONVERSION(`const Glib::RefPtr<Gst::Event>&',`GstEvent*', `Glib::unwrap($3)')
_CONVERSION(`GstEvent*',`const Glib::RefPtr<Gst::Event>&', `Glib::wrap($3)')
+_CONVERSION(`GstEvent*',`Glib::RefPtr<Gst::Event>', `Glib::wrap($3)')
dnl Index
_CONVERSION(`GstIndex*',`Glib::RefPtr<Gst::Index>',`Glib::wrap($3)')
@@ -184,6 +185,7 @@ _CONVERSION(`const Glib::RefPtr<Gst::PluginFeature>&',`GstPluginFeature*',`Glib:
dnl Query
_CONVERSION(`const Glib::RefPtr<Gst::Query>&',`GstQuery*', `Glib::unwrap($3)')
+_CONVERSION(`GstQuery*', `Glib::RefPtr<Gst::Query>',`Glib::wrap($3)')
dnl Registry
_CONVERSION(`GstRegistry*',`Glib::RefPtr<Gst::Registry>', `Glib::wrap($3)')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]