gnomemm r2077 - in gstreamermm/trunk: . build_shared gstreamer gstreamer/gstreamermm gstreamer/src



Author: jaalburqu
Date: Tue Mar  3 04:30:43 2009
New Revision: 2077
URL: http://svn.gnome.org/viewvc/gnomemm?rev=2077&view=rev

Log:
2009-03-02  Josà Alburquerque  <jaalburqu svn gnome org>

	* gstreamer/gstreamermm.h:
	* gstreamer/src/Makefile_list_of_hg.am_fragment:
	* gstreamer/src/typefind.hg:
	* gstreamer/src/typefindfactory.hg: Remove typefind until it is clear
	how it might be used in C++.  Added comment in docs saying that it is
	not possible to write typefinds yet because the C API uses members in
	the C struct sort of like virtual methods which is odd.

	* gstreamer/src/clock.hg:
	* gstreamer/src/gst_vfuncs.defs: Added wait_vfunc() to wrap all of
	Gst::Clock's vfuncs.
	* gstreamer/src/element.ccg:
	* gstreamer/src/element.hg: Added set_clock_vfunc() and
	get_query_types_vfunc() to wrap all of Gst::Element's vfuncs.

	* gstreamer/src/mixer.hg: Indentation.

	* build_shared/Makefile_build_gensrc.am_fragment:
	* gstreamer/gstreamermm/Makefile.am: Move gst_wrap_init.{h,cc} with
	wrap_init.{h,cc} in build process.

Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/build_shared/Makefile_build_gensrc.am_fragment
   gstreamermm/trunk/gstreamer/gstreamermm/   (props changed)
   gstreamermm/trunk/gstreamer/gstreamermm.h
   gstreamermm/trunk/gstreamer/gstreamermm/Makefile.am
   gstreamermm/trunk/gstreamer/src/   (props changed)
   gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment
   gstreamermm/trunk/gstreamer/src/clock.hg
   gstreamermm/trunk/gstreamer/src/element.ccg
   gstreamermm/trunk/gstreamer/src/element.hg
   gstreamermm/trunk/gstreamer/src/gst_vfuncs.defs
   gstreamermm/trunk/gstreamer/src/mixer.hg
   gstreamermm/trunk/gstreamer/src/typefind.hg
   gstreamermm/trunk/gstreamer/src/typefindfactory.hg

Modified: gstreamermm/trunk/build_shared/Makefile_build_gensrc.am_fragment
==============================================================================
--- gstreamermm/trunk/build_shared/Makefile_build_gensrc.am_fragment	(original)
+++ gstreamermm/trunk/build_shared/Makefile_build_gensrc.am_fragment	Tue Mar  3 04:30:43 2009
@@ -47,12 +47,12 @@
 files_hg = $(files_general_hg) $(files_posix_hg) $(files_general_deprecated_hg)
 endif
 
-files_built_cc = $(files_hg:.hg=.cc) wrap_init.cc
+files_built_cc = $(files_hg:.hg=.cc) wrap_init.cc gst_wrap_init.cc
 files_built_h = $(files_hg:.hg=.h)
 
 files_patched_h = $(files_patched_hg:.hg=.h)
 
-files_all_built_cc = $(files_all_hg:.hg=.cc) wrap_init.cc
+files_all_built_cc = $(files_all_hg:.hg=.cc) wrap_init.cc gst_wrap_init.cc
 files_all_built_h = $(files_all_hg:.hg=.h)
 
 files_all_plugin_built_cc = $(files_all_plugin_hg:.hg=.cc)
@@ -74,7 +74,7 @@
 	$(sublib_files_extra_win32_h) \
 	$(sublib_files_extra_general_h) \
 	$(sublib_files_extra_general_deprecated_h)
-files_all_extra_h += wrap_init.h
+files_all_extra_h += wrap_init.h gst_wrap_init.h
 
 if OS_WIN32
 files_extra_cc = \
@@ -91,4 +91,4 @@
 	$(sublib_files_extra_posix_h) \
 	$(sublib_files_extra_general_h)
 endif
-files_extra_h += wrap_init.h
+files_extra_h += wrap_init.h gst_wrap_init.h

Modified: gstreamermm/trunk/gstreamer/gstreamermm.h
==============================================================================
--- gstreamermm/trunk/gstreamer/gstreamermm.h	(original)
+++ gstreamermm/trunk/gstreamer/gstreamermm.h	Tue Mar  3 04:30:43 2009
@@ -40,6 +40,8 @@
 #include <gstreamermm/taglist.h>
 #include <gstreamermm/tagsetter.h>
 #include <gstreamermm/task.h>
+//TODO: #include <gstreamermm/typefind.h>
+//TODO: #include <gstreamermm/typefindfactory.h>
 #include <gstreamermm/urihandler.h>
 #include <gstreamermm/value.h>
 #include <gstreamermm/xml.h>

Modified: gstreamermm/trunk/gstreamer/gstreamermm/Makefile.am
==============================================================================
--- gstreamermm/trunk/gstreamer/gstreamermm/Makefile.am	(original)
+++ gstreamermm/trunk/gstreamer/gstreamermm/Makefile.am	Tue Mar  3 04:30:43 2009
@@ -13,12 +13,12 @@
 
 sublib_files_extra_posix_cc = 
 sublib_files_extra_win32_cc =
-sublib_files_extra_general_cc = init.cc miniobject.cc object.cc version.cc wrap.cc gst_wrap_init.cc
+sublib_files_extra_general_cc = init.cc miniobject.cc object.cc version.cc wrap.cc
 sublib_files_extra_general_deprecated_cc = 
 
 sublib_files_extra_posix_h = 
 sublib_files_extra_win32_h =
-sublib_files_extra_general_h = init.h miniobject.h object.h version.h wrap.h gst_wrap_init.h
+sublib_files_extra_general_h = init.h miniobject.h object.h version.h wrap.h
 sublib_files_extra_general_deprecated_h = 
 
 include $(top_srcdir)/build_shared/Makefile_build.am_fragment

Modified: gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment
==============================================================================
--- gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment	(original)
+++ gstreamermm/trunk/gstreamer/src/Makefile_list_of_hg.am_fragment	Tue Mar  3 04:30:43 2009
@@ -10,7 +10,7 @@
 	iterator.hg message.hg pad.hg padtemplate.hg parse.hg pipeline.hg \
 	plugin.hg pluginfeature.hg preset.hg query.hg registry.hg segment.hg \
 	structure.hg systemclock.hg taglist.hg tagsetter.hg task.hg \
-	typefind.hg typefindfactory.hg urihandler.hg value.hg xml.hg \
+	urihandler.hg value.hg xml.hg \
 	basesrc.hg basesink.hg basetransform.hg pushsrc.hg audioclock.hg \
 	audiofilter.hg audiosink.hg audiosrc.hg baseaudiosink.hg \
 	baseaudiosrc.hg cddabasesrc.hg videosink.hg \
@@ -18,6 +18,9 @@
 	mixertrack.hg navigation.hg propertyprobe.hg tuner.hg \
 	tunerchannel.hg tunernorm.hg videoorientation.hg xoverlay.hg
 
+#TODO: Add typefind.hg and typefindfactory.hg to list above when C++ use is
+# understood.
+
 files_general_deprecated_hg =
 
 # To add a plugin, add the plugin definition, in the form of

Modified: gstreamermm/trunk/gstreamer/src/clock.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/clock.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/clock.hg	Tue Mar  3 04:30:43 2009
@@ -260,6 +260,11 @@
 
 #m4 _CONVERSION(`GstClockEntry*',`const Glib::RefPtr<Gst::ClockID>&',`Glib::wrap($3, true)')
 
+  /** Perform a blocking wait for the given Gst::ClockID. Deprecated,
+   * implement wait_jitter_vfunc() instead.
+   */
+  _WRAP_VFUNC(ClockReturn wait(const Glib::RefPtr<Gst::ClockID>& id), "wait")
+
   /** Perform an asynchronous wait for the given Gst::ClockID.
    */
   _WRAP_VFUNC(ClockReturn wait_async(const Glib::RefPtr<Gst::ClockID>& id), "wait_async")

Modified: gstreamermm/trunk/gstreamer/src/element.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/element.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/element.ccg	Tue Mar  3 04:30:43 2009
@@ -85,4 +85,119 @@
   return gst_element_send_event(gobj(), event->gobj());
 }
 
+#ifdef GLIBMM_VFUNCS_ENABLED
+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.
+    {
+      #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_clock_vfunc(Glib::wrap(clock, 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_clock)
+    return (*base->set_clock)(self, clock);
+
+
+  //typedef gboolean RType;
+  //return RType();
+  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));
+
+  typedef bool RType;
+  return RType();
+}
+const GstQueryType* Element_Class::get_query_types_vfunc_callback(GstElement* 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 (GstQueryType*)((obj->get_query_types_vfunc()).data());
+      #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->get_query_types)
+    return (*base->get_query_types)(self);
+
+
+  typedef const GstQueryType* RType;
+  return RType();
+}
+Glib::ArrayHandle<QueryType> Gst::Element::get_query_types_vfunc() const
+{
+  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->get_query_types)
+    return Glib::ArrayHandle<QueryType>((QueryType*)((*base->get_query_types)(const_cast<GstElement*>(gobj()))), Glib::OWNERSHIP_SHALLOW);
+
+  typedef Glib::ArrayHandle<QueryType> RType;
+  return RType(0, 0, Glib::OWNERSHIP_NONE);
+}
+#endif //GLIBMM_VFUNCS_ENABLED
+
 } //namespace Gst

Modified: gstreamermm/trunk/gstreamer/src/element.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/element.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/element.hg	Tue Mar  3 04:30:43 2009
@@ -320,25 +320,25 @@
    */
   _WRAP_VFUNC(Glib::RefPtr<Gst::Clock> provide_clock(), "provide_clock")
 
-  //TODO: Wrapping this vfunc causes problems for generated plug-ins because
-  //the underlying C base class (GstElement) does not have a default set_clock
-  //(gst_element_set_clock_func) implementation and when a pipeline tries to
-  //set a clock for our derived gtkmm wrapper (in gst_bin_set_clock_func by
-  //calling gst_element_set_clock on all its children),
-  //set_clock_vfunc_callback returns false because when it tries to call the
-  //(*base->set_clock)() function, there is none (for a GstElement) and the
-  //callback winds up typedefing RType to gboolean and returning RType() which
-  //is false thus triggering a failure when setting the clock for one of our
-  //gtkmm plug-in wrappers. I think the reason that there is no default
-  //set_clock() implementation in GStreamer is that it depends on if an element
-  //requires a clock (see gst_element_requires_clock) so a possible fix would
-  //be to add an optional parameter to _WRAP_VFUNC parameter specifying what to
-  //return in that last vfunc callback return statement.  This would also fix
-  //bug #530416 so I may submit a patch for this in hopes that it fixes both
-  //problems.
-  // /** Set the Gst::Clock on the element.
-  //  */
-  //_WRAP_VFUNC(bool set_clock(const Glib::RefPtr<Gst::Clock>& clock), "set_clock")
+#ifdef GLIBMM_VFUNCS_ENABLED
+  // 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).
+  /** Set the Gst::Clock on the element.
+   */
+  virtual bool set_clock_vfunc(const Glib::RefPtr<Gst::Clock>& clock);
+
+  // This vfunc is handwritten because the default gmmproc code produces a
+  // compile error related to tyring to use Glib::ArrayHandle<>'s default
+  // constructor when returning a default value at the end of both the callback
+  // and the vfunc.
+  /** Get the supported Gst::QueryType of this element.
+   */
+   virtual Glib::ArrayHandle<QueryType> get_query_types_vfunc() const;
+#endif //GLIBMM_VFUNCS_ENABLED
 
   /** Get a Gst::Index on the element.
    */
@@ -354,20 +354,21 @@
    */
   _WRAP_VFUNC(bool send_event(const Glib::RefPtr<Gst::Event>& event), "send_event")
 
-  //TODO: This vfunc can't be wrapped without getting a compile error in the
-  //generated code.  The compile error comes about because the code assumes
-  //that Glib::ArrayHandle<> has a default constructor but it does not.  The
-  //way the code is generated will have to be tweaked.
-  //
-//#m4 _CONVERSION(`Glib::ArrayHandle<QueryType>',`const GstQueryType*',`(GstQueryType*)(($3).data())')
-  // /** Get the supported Gst::QueryType of this element.
-  //  */
-  // _WRAP_VFUNC(Glib::ArrayHandle<QueryType> get_query_types() const, "get_query_types")
-
 #m4 _CONVERSION(`GstQuery*',`const Glib::RefPtr<Gst::Query>&', `Gst::wrap($3, true)')
   /** Perform a Gst::Query on the element.
    */
   _WRAP_VFUNC(bool query(const Glib::RefPtr<Gst::Query>& query) const, "query")
+
+protected:
+#m4begin
+  _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
+    klass->set_clock = &set_clock_vfunc_callback;
+    klass->get_query_types = &get_query_types_vfunc_callback;
+  _SECTION(SECTION_PH_VFUNCS)
+    static gboolean set_clock_vfunc_callback(GstElement* self, GstClock* clock);
+    static const GstQueryType* get_query_types_vfunc_callback(GstElement* self);
+  _POP()
+#m4end
 };
 
 /** Templated class used for casting Gst::Element to interfaces that its

Modified: gstreamermm/trunk/gstreamer/src/gst_vfuncs.defs
==============================================================================
--- gstreamermm/trunk/gstreamer/src/gst_vfuncs.defs	(original)
+++ gstreamermm/trunk/gstreamer/src/gst_vfuncs.defs	Tue Mar  3 04:30:43 2009
@@ -65,6 +65,14 @@
   (return-type "GstClockTime")
 )
 
+(define-vfunc wait
+  (of-object "GstClock")
+  (return-type "GstClockReturn")
+  (parameters
+   '("GstClockEntry*" "entry")
+  )
+)
+
 (define-vfunc wait_async
   (of-object "GstClock")
   (return-type "GstClockReturn")

Modified: gstreamermm/trunk/gstreamer/src/mixer.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/mixer.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/mixer.hg	Tue Mar  3 04:30:43 2009
@@ -85,8 +85,9 @@
   //_WRAP_VFUNC(Glib::ListHandle< Glib::RefPtr<Gst::MixerTrack> > list_tracks() const, "list_tracks")
 
 #ifdef GLIBMM_VFUNCS_ENABLED
-// This vfunc is handcoded because we want to have it return the result instead
-// of requiring a pointer parameter in which to put it like the C API does.
+  // This vfunc is handcoded because we want to have it return the result
+  // instead of requiring a pointer parameter in which to put it like the C API
+  // does.
   virtual Glib::ArrayHandle<int> get_volume_vfunc(const Glib::RefPtr<const Gst::MixerTrack>& track) const;
 #endif //GLIBMM_VFUNCS_ENABLED
 

Modified: gstreamermm/trunk/gstreamer/src/typefind.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/typefind.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/typefind.hg	Tue Mar  3 04:30:43 2009
@@ -169,7 +169,6 @@
    * @return true on success, false otherwise.
    */
   static bool register_slot(const Glib::ustring& name, guint rank, const SlotFind& find_slot);
-
 };
 
 } // namespace Gst

Modified: gstreamermm/trunk/gstreamer/src/typefindfactory.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/typefindfactory.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/typefindfactory.hg	Tue Mar  3 04:30:43 2009
@@ -32,8 +32,7 @@
  * These functions allow querying informations about registered typefind
  * functions.
  *
- * TODO: Maybe include an example of writing a simple typefinder like the one
- * in the C API docs.
+ * Writing typefinders in C++ is not possible presently.
  *
  * Last reviewed on 2005-11-09 (0.9.4).
  */



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