[gstreamermm] Gst::Element: minors



commit ecb17a6929388d04defdea987f5400b9b286446a
Author: Marcin Kolny <marcin kolny gmail com>
Date:   Fri Aug 28 15:01:14 2015 +0000

    Gst::Element: minors
    
        * gstreamer/src/element.{ccg|hg}: remove handcoded methods, update
          documentation.
        * gstreamer/src/gst_extra_objects.defs: add Event to extra-object
          defs.

 gstreamer/src/element.ccg            |   66 +------------------
 gstreamer/src/element.hg             |  120 ++++++++++++---------------------
 gstreamer/src/gst_extra_objects.defs |    5 ++
 3 files changed, 50 insertions(+), 141 deletions(-)
---
diff --git a/gstreamer/src/element.ccg b/gstreamer/src/element.ccg
index 1a6525d..d88b17a 100644
--- a/gstreamer/src/element.ccg
+++ b/gstreamer/src/element.ccg
@@ -1,6 +1,6 @@
 /* gstreamermm - a C++ wrapper for gstreamer
  *
- * Copyright 2008 The gstreamermm Development Team
+ * Copyright 2008-2015 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
@@ -25,7 +25,6 @@
 #include <gstreamermm/pad.h>
 #include <gstreamermm/padtemplate.h>
 #include <gstreamermm/query.h>
-#include <gstreamermm/taglist.h>
 #include <gstreamermm/iterator.h>
 #include <gstreamermm/handle_error.h>
 
@@ -96,69 +95,6 @@ void Element::post_message(int code, int line, MessageType type,
     domain, code, gst_text, gst_debug, file.c_str(), function.c_str(), line);
 }
 
-bool Element::query_position(Gst::Format format) const
-{
-  return gst_element_query_position(const_cast<GstElement*>(gobj()), (GstFormat)format, nullptr);
-}
-
-bool Element::query_duration(Format format) const
-{
-  return gst_element_query_duration(const_cast<GstElement*>(gobj()), (GstFormat)format, nullptr);
-}
-
-gboolean Element_Class::set_clock_vfunc_callback(GstElement* self, GstClock* clock)
-{
-  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.
-    {
-      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.
-        return static_cast<int>(obj->set_clock_vfunc(Glib::wrap(clock, true)
-));
-      }
-      catch(...)
-      {
-        Glib::exception_handlers_invoke();
-      }
-    }
-  }
-  
-  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_clock)
-    return (*base->set_clock)(self, clock);
-
-
-  // Return the value that would be assumed as retval if element->set_clock was not set (see 
gst_element_set_clock() in gstelement.c)
-  return true;
-}
-bool Gst::Element::set_clock_vfunc(const Glib::RefPtr<Gst::Clock>& clock)
-{
-  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_clock)
-    return (*base->set_clock)(gobj(),Glib::unwrap(clock));
-
-  // Return the value that would be assumed as retval if element->set_clock was not set (see 
gst_element_set_clock() in gstelement.c)
-  return true;
-}
-
 bool Element::send_event(const Glib::RefPtr<Gst::Event>& event)
 {
   event->reference();
diff --git a/gstreamer/src/element.hg b/gstreamer/src/element.hg
index 2d2c564..918da4c 100644
--- a/gstreamer/src/element.hg
+++ b/gstreamer/src/element.hg
@@ -1,6 +1,6 @@
 /* gstreamermm - a C++ wrapper for gstreamer
  *
- * Copyright 2008 The gstreamermm Development Team
+ * Copyright 2008-2015 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
@@ -17,17 +17,12 @@
  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
-#include <gst/gst.h>
+#include <gst/gstelement.h>
 #include <gstreamermm/object.h>
 #include <gstreamermm/clock.h>
 #include <gstreamermm/enums.h>
 #include <gstreamermm/error.h>
-#include <gstreamermm/event.h>
 #include <gstreamermm/message.h>
-#include <gstreamermm/pad.h>
-#include <gstreamermm/query.h>
-#include <gstreamermm/context.h>
-#include <glibmm/arrayhandle.h>
 
 _DEFS(gstreamermm,gst)
 
@@ -48,33 +43,19 @@ namespace Gst
 
 class Bus;
 class Caps;
-class Clock;
+class Context;
 class ElementFactory;
 class Event;
-class Message;
 class Pad;
 class PadTemplate;
 class Query;
-class TagList;
 
 //Gst::Iterator<> forward declaration.
 template <class CppType>
 class Iterator;
 
 _WRAP_ENUM(ElementFlags, GstElementFlags)
-
-//TODO: Fix gmmproc so that definition in gst_enums.defs does not cause errors
-//and this can be wrapped with _WRAP_ENUM.
-enum StateChange
-{
-  STATE_CHANGE_NULL_TO_READY = GST_STATE_CHANGE_NULL_TO_READY,
-  STATE_CHANGE_READY_TO_PAUSED = GST_STATE_CHANGE_READY_TO_PAUSED,
-  STATE_CHANGE_PAUSED_TO_PLAYING = GST_STATE_CHANGE_PAUSED_TO_PLAYING,
-  STATE_CHANGE_PLAYING_TO_PAUSED = GST_STATE_CHANGE_PLAYING_TO_PAUSED,
-  STATE_CHANGE_PAUSED_TO_READY = GST_STATE_CHANGE_PAUSED_TO_READY,
-  STATE_CHANGE_READY_TO_NULL = GST_STATE_CHANGE_READY_TO_NULL 
-};
-
+_WRAP_ENUM(StateChange, GstStateChange)
 _WRAP_ENUM(StateChangeReturn, GstStateChangeReturn)
 
 namespace Enums
@@ -96,7 +77,8 @@ Glib::ustring get_name(StateChangeReturn state_ret);
 
 } //namespace Enums
 
-/** The abstract base class for all pipeline elements.
+/** Abstract base class for all pipeline elements
+ *
  * Gst::Element is the abstract base class needed to construct an element that
  * can be used in a GStreamer pipeline. Please refer to the plugin writers
  * guide for more information on creating Gst::Element subclasses.
@@ -104,30 +86,47 @@ Glib::ustring get_name(StateChangeReturn state_ret);
  * The name of a Gst::Element can be get with get_name() and set with
  * set_name().
  *
- * All elements have pads (of the type Gst::Pad). These pads link to pads on
- * other elements. Gst::Buffer flow between these linked pads. An Element has a
- * GList of Gst::Pad structures for all their input (or sink) and output (or
- * source) pads.  Core and plug-in writers can add and remove pads with
- * add_pad() and remove_pad().
+ * Elements can have pads (of the type Gst::Pad).  These pads link to pads on
+ * other elements.  Gst::Buffer flow between these linked pads.
+ * A Gst::Element has a GList of Gst::Pad structures for all their input (or sink)
+ * and output (or source) pads.
+ * Core and plug-in writers can add and remove pads with add_pad()
+ * and remove_pad().
+ *
+ * An existing pad of an element can be retrieved by name with
+ * get_static_pad(). A new dynamic pad can be created using
+ * request_pad() with a Gst::PadTemplate.
+ * An iterator of all pads can be retrieved with iterate_pads().
  *
- * A pad of an element can be retrieved by name with get_request_pad() or
- * get_static_pad(). An iterator of all pads can be retrieved with
- * iterate_pads().
+ * Elements can be linked through their pads.
+ * If the link is straightforward, use the link()
+ * convenience function to link two elements.
+ * Use link_filtered() to link two elements constrained by
+ * a specified set of Gst::Caps.
+ * For finer control, use link_pads() and
+ * link_pads_filtered() to specify the pads to link on
+ * each element by name.
  *
- * Gst::Elements can be linked through their pads. Use the link() function to
- * link elements. Use link_filtered() to link two elements constrained by a
- * specified set of Gst::Caps. For finer control, use link_pads() and
- * link_pads_filtered() to specify the pads to link on each element by name.
+ * Each element has a state (see Gst::State).  You can get and set the state
+ * of an element with get_state() and set_state().
+ * Setting a state triggers a Gst::StateChange. To get a string representation
+ * of a Gst::State, use Gst::Enums::get_name().
  *
- * Each element has a state (see State). You can get and set the state of an
- * element with get_state() and set_state(). To get a string representation of
- * a State, use Gst::Enums::get_name().
+ * You can get and set a Gst::Clock on an element using get_clock()
+ * and set_clock().
+ * Some elements can provide a clock for the pipeline if
+ * the Gst::ELEMENT_FLAG_PROVIDE_CLOCK flag is set. With the
+ * provide_clock() method one can retrieve the clock provided by
+ * such an element.
+ * Not all elements require a clock to operate correctly. If the
+ * Gst::ELEMENT_FLAG_REQUIRE_CLOCK flag is set, a clock should be set on the
+ * element with set_clock().
  *
- * Note that clock slection and distribution is normally handled by the
+ * Note that clock selection and distribution is normally handled by the
  * toplevel Gst::Pipeline so the clock functions are only to be used in very
  * specific situations.
  *
- * Last reviewed on 2006-03-12 (0.10.5).
+ * Last reviewed on 2015-08-28 (1.5.2).
  * @ingroup GstBaseClasses
  */
 class Element : public Gst::Object
@@ -281,25 +280,8 @@ public:
 
   _WRAP_METHOD(bool query(const Glib::RefPtr<Gst::Query>& query) const, gst_element_query)
   _WRAP_METHOD(bool query_convert(Gst::Format src_format, gint64 src_val, Format dest_format, gint64& 
dest_val) const, gst_element_query_convert)
-  _WRAP_METHOD(bool query_position(Gst::Format format, gint64& cur) const, gst_element_query_position)
-
-  /** Queries an element for the stream position.
-   *
-   * @param format On return will
-   * contain the Gst::Format used.
-   * @return true if the query could be performed.
-   */
-  bool query_position(Gst::Format format) const;
-
-  _WRAP_METHOD(bool query_duration(Gst::Format format, gint64& duration) const, gst_element_query_duration)
-
-  /** Queries an element for the total stream duration.
-   *
-   * @param format On return contains
-   * the Gst::Format used.
-   * @return true if the query could be performed.
-   */
-  bool query_duration(Gst::Format format) const;
+  _WRAP_METHOD(bool query_position(Gst::Format format, gint64& cur{?}) const, gst_element_query_position)
+  _WRAP_METHOD(bool query_duration(Gst::Format format, gint64& duration{?}) const, 
gst_element_query_duration)
 
   _WRAP_METHOD(bool seek(Format format, SeekFlags seek_flags, gint64 seek_pos), gst_element_seek_simple)
   _WRAP_METHOD(bool seek(double rate, Format format, SeekFlags flags, SeekType cur_type, gint64 cur, 
SeekType stop_type, gint64 stop), gst_element_seek)
@@ -345,15 +327,10 @@ public:
    */
   _WRAP_VFUNC(Glib::RefPtr<Gst::Clock> provide_clock(), "provide_clock")
 
-  // This vfunc is hand-coded because it is necessary for the callback to
-  // return true instead of false (as would happen with the default gmmproc
-  // callback) because GstElement does not set its set_clock() vfunc
-  // by default and yet gst_element_set_clock() returns true when GstElement's
-  // set_clock() vfunc is not set (it's a strange thing, but look at
-  // gst_element_class_init() and gst_element_set_clock() for insight).
+#m4 _CONVERSION(`GstClock*', `const Glib::RefPtr<Gst::Clock>&', `Glib::wrap($3, true)')
   /** Set the Gst::Clock on the element.
    */
-  virtual bool set_clock_vfunc(const Glib::RefPtr<Gst::Clock>& clock);
+  _WRAP_VFUNC(bool set_clock(const Glib::RefPtr<Gst::Clock>& clock), "set_clock", return_value true)
 
 #m4 _CONVERSION(`GstEvent*',`const Glib::RefPtr<Gst::Event>&', `Glib::wrap($3, true)')
   /** Send a Gst::Event to the element.
@@ -381,15 +358,6 @@ public:
        set_property(name, value);
        return Glib::RefPtr<Gst::Element>( dynamic_cast<Gst::Element*> (Glib::wrap_auto ((GObject*)(gobj()), 
true)) );
    }
-
-protected:
-#m4begin
-  _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
-  klass->set_clock = &set_clock_vfunc_callback;
-  _SECTION(SECTION_PH_VFUNCS)
-  static gboolean set_clock_vfunc_callback(GstElement* self, GstClock* clock);
-  _POP()
-#m4end
 };
 
 } // namespace Gst
diff --git a/gstreamer/src/gst_extra_objects.defs b/gstreamer/src/gst_extra_objects.defs
index 667c35c..9e59c9f 100644
--- a/gstreamer/src/gst_extra_objects.defs
+++ b/gstreamer/src/gst_extra_objects.defs
@@ -35,6 +35,11 @@
   (gtype-id "GST_TYPE_CAPS_FEATURES")
 )
 
+(define-object Event
+  (in-module "Gst")
+  (c-name "GstEvent")
+)
+
 (define-object Iterator
   (in-module "Gst")
   (c-name "GstIterator")


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