gnomemm r1436 - in gstreamermm/trunk: . gstreamer/src gstreamerbase tests



Author: jaalburqu
Date: Tue Apr  1 22:53:55 2008
New Revision: 1436
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1436&view=rev

Log:
2008-04-01  Josà Alburquerque  <jaalburqu svn gnome org>

	* gstreamer/src/interface.hg: Rewrote cast() to return null
	RefPtr<...> if cast is not possible
	* gstreamer/src/element.hg: Rewrote ElementInterfaced constructor to
	accept possible NULL GstElement*

	* tests/Makefile.am:
	* tests/test-create-element.cc:
	* tests/test-interface.cc: Added test-interface.cc (for testing
	casting) and removed casting test from test-create-element.cc

	* gstreamerbase/gstreamerbasemm.h: Added xoverlay.h to includes;
	Removed unused version.h include

Added:
   gstreamermm/trunk/tests/test-interface.cc
Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/gstreamer/src/element.hg
   gstreamermm/trunk/gstreamer/src/interface.hg
   gstreamermm/trunk/gstreamerbase/gstreamerbasemm.h
   gstreamermm/trunk/tests/Makefile.am
   gstreamermm/trunk/tests/test-create-element.cc

Modified: gstreamermm/trunk/gstreamer/src/element.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/element.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/element.hg	Tue Apr  1 22:53:55 2008
@@ -221,9 +221,11 @@
 ElementInterfaced<T_Interface>::ElementInterfaced(GstElement* castitem)
 {
   gobject_ = (GObject*)castitem;
-  gst_object_ref(Element::gobj());
-  g_object_weak_ref(gobject_,
-    &ElementInterfaced_WeakNotify_gstreamermm_callback, this);
+  if (gobject_) {
+    gst_object_ref(Element::gobj());
+    g_object_weak_ref(gobject_,
+      &ElementInterfaced_WeakNotify_gstreamermm_callback, this);
+  }
 }
 
 template <class T_Interface>

Modified: gstreamermm/trunk/gstreamer/src/interface.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/interface.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/interface.hg	Tue Apr  1 22:53:55 2008
@@ -39,7 +39,7 @@
 public:
   _WRAP_METHOD(static bool element_implements(const Glib::RefPtr<const Element>&element, GType iface_type), gst_element_implements_interface)
 
-  template <class T_CastTo> inline
+  template <class T_CastTo>
   static Glib::RefPtr< ElementInterfaced<T_CastTo> > cast(const Glib::RefPtr<Element>& element);
 
   _IGNORE(gst_element_remove_pad,
@@ -102,12 +102,21 @@
 
 #ifndef DOXYGEN_SHOULD_SKIP_THIS
 
-template <class T_CastTo> inline
+template <class T_CastTo>
 Glib::RefPtr< Gst::ElementInterfaced<T_CastTo> > Interface::cast(const Glib::RefPtr<Element>& element)
 {
-  void* result = gst_implements_interface_cast(element->gobj(), T_CastTo::get_type());
-  Gst::ElementInterfaced<T_CastTo>* element_interfaced = new ElementInterfaced<T_CastTo>((GstElement*) result);
-  return Glib::RefPtr< Gst::ElementInterfaced<T_CastTo> >(element_interfaced);
+  if (gst_element_implements_interface(element->gobj(), T_CastTo::get_type()))
+  {
+    void* result =
+      gst_implements_interface_cast(element->gobj(), T_CastTo::get_type());
+
+    Gst::ElementInterfaced<T_CastTo>* element_interfaced =
+      new ElementInterfaced<T_CastTo>((GstElement*) result);
+
+    return Glib::RefPtr< Gst::ElementInterfaced<T_CastTo> >(element_interfaced);
+  }
+  else
+    return Glib::RefPtr< Gst::ElementInterfaced<T_CastTo> >(0);
 }
 
 #endif /* DOXYGEN_SHOULD_SKIP_THIS */

Modified: gstreamermm/trunk/gstreamerbase/gstreamerbasemm.h
==============================================================================
--- gstreamermm/trunk/gstreamerbase/gstreamerbasemm.h	(original)
+++ gstreamermm/trunk/gstreamerbase/gstreamerbasemm.h	Tue Apr  1 22:53:55 2008
@@ -4,8 +4,8 @@
 //#include <gstreamerbasemm/bin.h>
 
 #include <gstreamerbasemm/init.h>
-#include <gstreamerbasemm/version.h>
 #include <gstreamerbasemm/wrap_init.h>
+#include <gstreamerbasemm/xoverlay.h>
 
 #endif // _GSTREAMERBASEMM_H
 

Modified: gstreamermm/trunk/tests/Makefile.am
==============================================================================
--- gstreamermm/trunk/tests/Makefile.am	(original)
+++ gstreamermm/trunk/tests/Makefile.am	Tue Apr  1 22:53:55 2008
@@ -5,7 +5,7 @@
 noinst_PROGRAMS = test-caps test-create-element test-pipeline-add-element \
                   test-link-elements test-create-bin test-miniobject-wrap \
                   test-message-wrap test-event-wrap test-query-wrap \
-		  test-structure test-caps-structures
+		  test-structure test-caps-structures test-interface
 
 test_caps_SOURCES=test-caps.cc
 test_caps_LDFLAGS= GSTREAMERMM_LIBS@
@@ -40,6 +40,9 @@
 test_caps_structures_SOURCES=test-caps-structures.cc
 test_caps_structures_LDFLAGS= GSTREAMERMM_LIBS@
 
+test_interface_SOURCES=test-interface.cc
+test_interface_LDFLAGS= GSTREAMERMM_LIBS@
+
 #runtestbasic runtestlangs \
 #runtestsearch runtestmimetypes \
 #runtestgetbuffer

Modified: gstreamermm/trunk/tests/test-create-element.cc
==============================================================================
--- gstreamermm/trunk/tests/test-create-element.cc	(original)
+++ gstreamermm/trunk/tests/test-create-element.cc	Tue Apr  1 22:53:55 2008
@@ -26,23 +26,9 @@
 {
   Gst::init(argc, argv);
 
-  Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create("filesrc", "source");
+  Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create("fakesrc", "source");
 
   if(element)
     std::cout << "Successfully created gst element '" <<
       element->get_name() << "'." << std::endl;
-
-  if(Gst::Interface::element_implements(element, Gst::URIHandler::get_type()))
-  {
-    std::cout << "element '" << element->get_name() <<
-      "' implements URIHandler interface." << std::endl;
-
-    Glib::RefPtr< Gst::ElementInterfaced<Gst::URIHandler> > handler =
-      Gst::Interface::cast <Gst::URIHandler>(element);
-
-    handler->set_uri("file:///tmp/media.file");
-
-    std::cout << handler->get_name() << " uri = '" << handler->get_uri() <<
-      "'." << std::endl;
-  }
 }

Added: gstreamermm/trunk/tests/test-interface.cc
==============================================================================
--- (empty file)
+++ gstreamermm/trunk/tests/test-interface.cc	Tue Apr  1 22:53:55 2008
@@ -0,0 +1,60 @@
+// -*- Mode: C++; indent-tabs-mode: nil; c-basic-offset: 2 -*-
+
+/* gstreamermm - a C++ wrapper for gstreamer
+ *
+ * Copyright 2008 The gstreamermm Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <gstreamermm.h>
+#include <gstreamerbasemm.h>
+#include <iostream>
+
+int main (int argc, char* argv[])
+{
+  Gst::init(argc, argv);
+
+  Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create("filesrc", "source");
+
+  if (element)
+    std::cout << "Successfully created gst element '" <<
+      element->get_name() << "'." << std::endl;
+
+  Glib::RefPtr< Gst::ElementInterfaced<Gst::URIHandler> > handler =
+    Gst::Interface::cast <Gst::URIHandler>(element);
+
+  if(handler)
+  {
+    std::cout << "element '" << element->get_name() <<
+      "' implements URIHandler interface." << std::endl;
+
+    handler->set_uri("file:///tmp/media.file");
+
+    std::cout << handler->get_name() << " uri = '" << handler->get_uri() <<
+      "'." << std::endl;
+  }
+
+  Glib::RefPtr< Gst::ElementInterfaced<GstBase::XOverlay> > xoverlay =
+    Gst::Interface::cast <GstBase::XOverlay>(element);
+
+  if(xoverlay)
+  {
+    std::cout << "element '" << element->get_name() <<
+      "' implements XOverlay interface." << std::endl;
+
+    xoverlay->handle_events(false);
+  }
+}



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