[gstreamermm] C++11: restore some overload methods



commit d4d0140504bfee1baf9d075074ebd2e5759ab1fa
Author: Marcin Kolny <marcin kolny gmail com>
Date:   Mon Aug 24 18:14:27 2015 +0000

    C++11: restore some overload methods
    
    Sometimes it might be convinient to have valid object after function call,
    so I restored some methods, which has been replaced by methods with
    r-value arguments.
    
        * gstreamer/src/bufferlist.ccg:
        * gstreamer/src/bufferlist.hg:
        * gstreamer/src/element.ccg:
        * gstreamer/src/element.hg:
        * gstreamer/src/pad.ccg:
        * gstreamer/src/pad.hg:
        * gstreamer/src/registry.ccg:
        * gstreamer/src/registry.hg: restore some methods with const reference
          arguments.

 gstreamer/src/bufferlist.ccg |   11 +++--------
 gstreamer/src/bufferlist.hg  |   17 ++---------------
 gstreamer/src/element.ccg    |    6 ++++++
 gstreamer/src/element.hg     |    3 +++
 gstreamer/src/pad.ccg        |   14 ++++++++++++++
 gstreamer/src/pad.hg         |   10 +++++++++-
 gstreamer/src/registry.ccg   |   13 +++++++++++++
 gstreamer/src/registry.hg    |   11 +++++++++--
 8 files changed, 59 insertions(+), 26 deletions(-)
---
diff --git a/gstreamer/src/bufferlist.ccg b/gstreamer/src/bufferlist.ccg
index d27be53..c887def 100644
--- a/gstreamer/src/bufferlist.ccg
+++ b/gstreamer/src/bufferlist.ccg
@@ -69,15 +69,10 @@ static gboolean BufferList_Foreach_gstreamermm_callback(GstBuffer** buffer, guin
 
 namespace Gst
 {
-
-bool BufferList::is_writable() const
-{
-  return static_cast<bool>(gst_buffer_list_is_writable(gobj()));
-}
-
-Glib::RefPtr<BufferList> BufferList::create_writable()
+void BufferList::insert(gint idx, const Glib::RefPtr<Gst::Buffer>& buffer)
 {
-  return Glib::RefPtr<BufferList>::cast_static(MiniObject::create_writable());
+  buffer->reference();
+  gst_buffer_list_insert(gobj(), idx, buffer->gobj());
 }
 
 void BufferList::foreach(const SlotForeach& slot)
diff --git a/gstreamer/src/bufferlist.hg b/gstreamer/src/bufferlist.hg
index 9ce2974..d52ccc6 100644
--- a/gstreamer/src/bufferlist.hg
+++ b/gstreamer/src/bufferlist.hg
@@ -75,21 +75,8 @@ public:
 
   _WRAP_METHOD(void insert(gint idx, Glib::RefPtr<Gst::Buffer>&& buffer), gst_buffer_list_insert)
 
-  /** Tests if you can safely add buffers and groups into a buffer list.
-   * @return <tt>true</tt> if the buffer list is writable, <tt>false</tt>
-   * otherwise.
-   *
-   * Since 0.10.24
-   */
-  bool is_writable() const;
-
-  /** Makes a writable buffer list from the given buffer list. If the source buffer
-   * list is already writable, this will simply return the same buffer list. A copy
-   * will otherwise be made.
-   *
-   * @return A buffer list (possibly the same pointer) that is writable.
-   */
-  Glib::RefPtr<BufferList> create_writable();
+  /// A insert() convenience overload. Allows to re-use @buffer parameter after function call.
+  void insert(gint idx, const Glib::RefPtr<Gst::Buffer>& buffer);
 
   /** Call @a slot for each buffer in @a list.
    *
diff --git a/gstreamer/src/element.ccg b/gstreamer/src/element.ccg
index 4a1e4fb..1a6525d 100644
--- a/gstreamer/src/element.ccg
+++ b/gstreamer/src/element.ccg
@@ -159,6 +159,12 @@ bool Gst::Element::set_clock_vfunc(const Glib::RefPtr<Gst::Clock>& clock)
   return true;
 }
 
+bool Element::send_event(const Glib::RefPtr<Gst::Event>& event)
+{
+  event->reference();
+  return gst_element_send_event(gobj(), Glib::unwrap(event));
+}
+
 Glib::RefPtr<Gst::PadTemplate> Gst::Element::get_pad_template(const Glib::ustring &factory_name) const
 {
   return Glib::wrap(gst_element_class_get_pad_template(GST_ELEMENT_GET_CLASS(gobject_), 
factory_name.c_str()), true);
diff --git a/gstreamer/src/element.hg b/gstreamer/src/element.hg
index 96351ef..02de4fc 100644
--- a/gstreamer/src/element.hg
+++ b/gstreamer/src/element.hg
@@ -307,6 +307,9 @@ public:
 
   _WRAP_METHOD(bool send_event(Glib::RefPtr<Gst::Event>&& event), gst_element_send_event)
 
+  /// A send_event() convenience overload. Allows to re-use @event parameter after function call.
+  bool send_event(const Glib::RefPtr<Gst::Event>& event);
+
   _WRAP_SIGNAL(void no_more_pads(), "no-more-pads")
 
 #m4 _CONVERSION(`GstPad*',`const Glib::RefPtr<Gst::Pad>&',`Glib::wrap($3, true)')
diff --git a/gstreamer/src/pad.ccg b/gstreamer/src/pad.ccg
index 245e9b3..ac1dccb 100644
--- a/gstreamer/src/pad.ccg
+++ b/gstreamer/src/pad.ccg
@@ -326,6 +326,12 @@ void Pad::set_event_function(const SlotEvent& slot)
        gst_pad_set_event_function(GST_PAD(gobj()), &Pad_Event_gstreamermm_callback);
 }
 
+bool Pad::push_event(const Glib::RefPtr<Gst::Event>& event)
+{
+  event->reference();
+  return gst_pad_push_event(gobj(), event->gobj());
+}
+
 void Pad::set_activate_function(const SlotActivate& slot)
 {
   slot_activate = slot;
@@ -354,6 +360,14 @@ bool Pad::is_proxy_pad() const
        return GST_IS_PROXY_PAD(gobj());
 }
 
+bool Pad::send_event(const Glib::RefPtr<Gst::Event>& event)
+{
+  event->reference();
+  return gst_pad_send_event(gobj(), event->gobj());
+}
+
+
+
 PadProbeInfo::PadProbeInfo()
 : gobj_(g_try_new(GstPadProbeInfo, 1)),
   take_ownership(true)
diff --git a/gstreamer/src/pad.hg b/gstreamer/src/pad.hg
index e8d7c22..d2d7859 100644
--- a/gstreamer/src/pad.hg
+++ b/gstreamer/src/pad.hg
@@ -219,8 +219,12 @@ public:
   _WRAP_METHOD(bool proxy_query_caps(const Glib::RefPtr<Gst::Query>& query) const, gst_pad_proxy_query_caps, 
constversion)
   _WRAP_METHOD(bool peer_query_accept_caps(const Glib::RefPtr<const Gst::Caps>& caps) const, 
gst_pad_peer_query_accept_caps)
   _WRAP_METHOD(FlowReturn push(Glib::RefPtr<Gst::Buffer>&& buffer), gst_pad_push)
+
   _WRAP_METHOD(bool push_event(Glib::RefPtr<Gst::Event>&& event), gst_pad_push_event)
 
+  /// A push_event() convenience overload. Allows to re-use @event parameter after function call.
+  bool push_event(const Glib::RefPtr<Gst::Event>& event);
+
   /** Pulls a buffer from the peer pad.  This function will first trigger the
    * pad block signal if it was installed.  This method works only on sink
    * pads.
@@ -244,9 +248,13 @@ public:
   FlowReturn pull_range(guint64 offset, guint size, Glib::RefPtr<Gst::Buffer>& buffer);
   _IGNORE(gst_pad_pull_range)
 
-  _WRAP_METHOD(bool activate_mode(Gst::PadMode mode, bool active = true), gst_pad_activate_mode)
+
   _WRAP_METHOD(bool send_event(Glib::RefPtr<Gst::Event>&& event), gst_pad_send_event)
 
+  /// A send_event() convenience overload. Allows to re-use @event parameter after function call.
+  bool send_event(const Glib::RefPtr<Gst::Event>& event);
+
+  _WRAP_METHOD(bool activate_mode(Gst::PadMode mode, bool active = true), gst_pad_activate_mode)
   _WRAP_METHOD(bool event_default(const Glib::RefPtr<Gst::Object>& parent{?}, Glib::RefPtr<Gst::Event>&& 
event), gst_pad_event_default)
   _WRAP_METHOD(bool query(const Glib::RefPtr<Gst::Query>& query) const, gst_pad_query)
   _WRAP_METHOD(bool peer_query(const Glib::RefPtr<Gst::Query>& query) const, gst_pad_peer_query)
diff --git a/gstreamer/src/registry.ccg b/gstreamer/src/registry.ccg
index 4fcc79f..1172211 100644
--- a/gstreamer/src/registry.ccg
+++ b/gstreamer/src/registry.ccg
@@ -120,4 +120,17 @@ Registry::get()
   return Glib::wrap(gst_registry_get(), true);
 }
 
+void Registry::add_feature(const Glib::RefPtr<Gst::PluginFeature>& feature)
+{
+  feature->reference();
+  gst_registry_add_feature(gobj(), feature->gobj());
+}
+
+void Registry::add_plugin(const Glib::RefPtr<Gst::Plugin>& plugin)
+{
+  plugin->reference();
+  gst_registry_add_plugin(gobj(), plugin->gobj());
+}
+
+
 } //namespace Gst
diff --git a/gstreamer/src/registry.hg b/gstreamer/src/registry.hg
index 19652ba..7cc8362 100644
--- a/gstreamer/src/registry.hg
+++ b/gstreamer/src/registry.hg
@@ -110,9 +110,12 @@ public:
 #m4 _CONVERSION(`GList*',`Glib::ListHandle< Glib::RefPtr<const Gst::Plugin> >',`$2($3, 
Glib::OWNERSHIP_DEEP)')
   _WRAP_METHOD(Glib::ListHandle< Glib::RefPtr<const Gst::Plugin> > get_plugin_list() const, 
gst_registry_get_plugin_list)
 
-  _WRAP_METHOD(bool add_plugin(Glib::RefPtr<Gst::Plugin>&& plugin), gst_registry_add_plugin)
   _WRAP_METHOD(void remove_plugin(const Glib::RefPtr<Gst::Plugin>& plugin), gst_registry_remove_plugin)
 
+  _WRAP_METHOD(bool add_plugin(Glib::RefPtr<Gst::Plugin>&& plugin), gst_registry_add_plugin)
+
+  /// A add_plugin() convenience overload. Allows to re-use @plugin parameter after function call.
+  void add_plugin(const Glib::RefPtr<Gst::Plugin>& plugin);
   /** Runs a filter against all plugins in the registry and returns a List with
    * the results. If the first flag is set, only the first match is returned
    * (as a list with a single object).
@@ -170,9 +173,13 @@ public:
   _WRAP_METHOD(Glib::RefPtr<Gst::Plugin> lookup(const Glib::ustring& filename), gst_registry_lookup)
   _WRAP_METHOD(Glib::RefPtr<const Gst::Plugin> lookup(const Glib::ustring& filename) const, 
gst_registry_lookup, constversion)
   _WRAP_METHOD(void remove_feature(const Glib::RefPtr<Gst::PluginFeature>& feature), 
gst_registry_remove_feature)
-  _WRAP_METHOD(void add_feature(Glib::RefPtr<Gst::PluginFeature>&& feature), gst_registry_add_feature)
   _WRAP_METHOD(static bool check_feature_version(const Glib::ustring& feature_name, guint min_major, guint 
min_minor, guint min_micro), gst_default_registry_check_feature_version)
+
+  _WRAP_METHOD(void add_feature(Glib::RefPtr<Gst::PluginFeature>&& feature), gst_registry_add_feature)
   
+  /// A add_feature() convenience overload. Allows to re-use @feature parameter after function call.
+  void add_feature(const Glib::RefPtr<Gst::PluginFeature>& feature);
+
   static Glib::RefPtr<Gst::Registry> get();
 };
 


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