gnomemm r1375 - in gstreamermm/trunk: . examples/element_link examples/ogg_player examples/ogg_player_gtkmm gstreamer/src tests



Author: jaalburqu
Date: Fri Feb 29 20:16:36 2008
New Revision: 1375
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1375&view=rev

Log:
2008-02-29  Josà Alburquerque  <jaalburqu svn gnome org>

	* gstreamer/src/element.ccg:
	* gstreamer/src/element.hg: Made Element derive also from
	Gst::Interface (newly added 2008-02-27); Removed create() method and
	use Gst::ElementFactory to create elements (as C API does); Added
	class docs

	* examples/element_link/element_link.cc:
	* examples/ogg_player/main.cc:
	* examples/ogg_player_gtkmm/main.cc:
	* tests/test-link-elements.cc:
	* tests/test-pipeline-add-element.cc: Modified to create elements
	using Gst::ElementFactory::create()

	* tests/test-create-bin.cc: Added lines to test derived interface
	ChildProxy

	* tests/test-create-element.cc: Added lines to test the
	Gst::Interface::implements() method; Filed bug #519584 due to
	segfault.  May have to rethink Gst::Element's derivation of
	Gst::Interface because as bug report says, not all elements implement
	GstImplementsInterface

	* gstreamer/src/urihandler.hg: Added accidental remove of new_uri()
	method in last commit

Modified:
   gstreamermm/trunk/ChangeLog
   gstreamermm/trunk/examples/element_link/element_link.cc
   gstreamermm/trunk/examples/ogg_player/main.cc
   gstreamermm/trunk/examples/ogg_player_gtkmm/main.cc
   gstreamermm/trunk/gstreamer/src/element.ccg
   gstreamermm/trunk/gstreamer/src/element.hg
   gstreamermm/trunk/gstreamer/src/urihandler.hg
   gstreamermm/trunk/tests/test-create-bin.cc
   gstreamermm/trunk/tests/test-create-element.cc
   gstreamermm/trunk/tests/test-link-elements.cc
   gstreamermm/trunk/tests/test-pipeline-add-element.cc

Modified: gstreamermm/trunk/examples/element_link/element_link.cc
==============================================================================
--- gstreamermm/trunk/examples/element_link/element_link.cc	(original)
+++ gstreamermm/trunk/examples/element_link/element_link.cc	Fri Feb 29 20:16:36 2008
@@ -37,9 +37,9 @@
   // create elements
   try
   {
-    m_Element_Source = Gst::Element::create("fakesrc", "source");
-    m_Element_Filter = Gst::Element::create("identity", "filter");
-    m_Element_Sink = Gst::Element::create("fakesink", "sink");
+    m_Element_Source = Gst::ElementFactory::create("fakesrc", "source");
+    m_Element_Filter = Gst::ElementFactory::create("identity", "filter");
+    m_Element_Sink = Gst::ElementFactory::create("fakesink", "sink");
   }
   catch(std::runtime_error& error)
   {

Modified: gstreamermm/trunk/examples/ogg_player/main.cc
==============================================================================
--- gstreamermm/trunk/examples/ogg_player/main.cc	(original)
+++ gstreamermm/trunk/examples/ogg_player/main.cc	Fri Feb 29 20:16:36 2008
@@ -123,23 +123,23 @@
 
   // Create the elements
   // Reads file from disk
-  Glib::RefPtr<Gst::Element> source = Gst::Element::create("filesrc", "file-source");
+  Glib::RefPtr<Gst::Element> source = Gst::ElementFactory::create("filesrc", "file-source");
   std::cout << "source=" << source << std::endl;
 
   // Parses the ogg streams into elementary streams (note that an ogg file may contain a video stream too)
-  Glib::RefPtr<Gst::Element> parser = Gst::Element::create("oggdemux", "ogg-parser");
+  Glib::RefPtr<Gst::Element> parser = Gst::ElementFactory::create("oggdemux", "ogg-parser");
   std::cout << "parser=" << parser << std::endl;
 
   // Decodes a vorbis stream
-  decoder = Gst::Element::create("vorbisdec", "vorbis-decoder");
+  decoder = Gst::ElementFactory::create("vorbisdec", "vorbis-decoder");
   std::cout << "decoder=" << decoder << std::endl;
 
   // Converts audio() to a format which can be used by the next element
-  Glib::RefPtr<Gst::Element> conv = Gst::Element::create("audioconvert", "converter");
+  Glib::RefPtr<Gst::Element> conv = Gst::ElementFactory::create("audioconvert", "converter");
   std::cout << "conv=" << conv << std::endl;
 
   // Outputs sound to an ALSA audio device
-  Glib::RefPtr<Gst::Element> sink = Gst::Element::create("alsasink", "alsa-output");
+  Glib::RefPtr<Gst::Element> sink = Gst::ElementFactory::create("alsasink", "alsa-output");
   std::cout << "sink=" << sink << std::endl;
 
   if (!pipeline || !source || !parser || !decoder || !conv || !sink)

Modified: gstreamermm/trunk/examples/ogg_player_gtkmm/main.cc
==============================================================================
--- gstreamermm/trunk/examples/ogg_player_gtkmm/main.cc	(original)
+++ gstreamermm/trunk/examples/ogg_player_gtkmm/main.cc	Fri Feb 29 20:16:36 2008
@@ -22,6 +22,7 @@
 #include <gtkmm/main.h>
 #include <gstreamermm/init.h>
 #include <gstreamermm/element.h>
+#include <gstreamermm/elementfactory.h>
 #include <gstreamermm/pad.h>
 #include <gstreamermm/pipeline.h>
 #include <iostream>
@@ -48,19 +49,19 @@
 
     // Create the elements
     // Reads file from disk
-    Glib::RefPtr<Gst::Element> source = Gst::Element::create("filesrc", "file-source");
+    Glib::RefPtr<Gst::Element> source = Gst::ElementFactory::create("filesrc", "file-source");
 
     // Parses the ogg streams into elementary streams (note that an ogg file may contain a video stream too)
-    Glib::RefPtr<Gst::Element> parser = Gst::Element::create("oggdemux", "ogg-parser");
+    Glib::RefPtr<Gst::Element> parser = Gst::ElementFactory::create("oggdemux", "ogg-parser");
 
     // Decodes a vorbis stream
-    decoder = Gst::Element::create("vorbisdec", "vorbis-decoder");
+    decoder = Gst::ElementFactory::create("vorbisdec", "vorbis-decoder");
 
     // Converts audio() to a format which can be used by the next element
-    Glib::RefPtr<Gst::Element> conv = Gst::Element::create("audioconvert", "converter");
+    Glib::RefPtr<Gst::Element> conv = Gst::ElementFactory::create("audioconvert", "converter");
 
     // Outputs sound to an ALSA audio device
-    Glib::RefPtr<Gst::Element> sink = Gst::Element::create("alsasink", "alsa-output");
+    Glib::RefPtr<Gst::Element> sink = Gst::ElementFactory::create("alsasink", "alsa-output");
 
     if (!pipeline || !source || !parser || !decoder || !conv || !sink)
     {

Modified: gstreamermm/trunk/gstreamer/src/element.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/element.ccg	(original)
+++ gstreamermm/trunk/gstreamer/src/element.ccg	Fri Feb 29 20:16:36 2008
@@ -37,13 +37,6 @@
 {
 
 Glib::RefPtr<Element>
-Element::create(const Glib::ustring& factoryname, const Glib::ustring& name)
-{
-  GstElement* element = gst_element_factory_make(factoryname.c_str(), name.c_str());
-  return Glib::wrap(element);
-}
-
-Glib::RefPtr<Element>
 Element::link(const Glib::RefPtr<Element>& other_element)
 {
   bool result = gst_element_link(gobj(), other_element->gobj());

Modified: gstreamermm/trunk/gstreamer/src/element.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/element.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/element.hg	Fri Feb 29 20:16:36 2008
@@ -20,6 +20,7 @@
  */
 
 #include <gstreamermm/object.h>
+#include <gstreamermm/interface.h>
 #include <gstreamermm/clock.h>
 #include <gstreamermm/enums.h>
 
@@ -40,16 +41,52 @@
 class PadTemplate;
 class Query;
 
-class Element : public Object 
+/** Element â Abstract base class for all pipeline elements.
+ * 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 Element subclasses.
+ *
+ * The name of a Element can be get with get_name() and set with set_name().
+ *
+ * All elements have pads (of the type Pad). These pads link to pads on other
+ * elements. Buffer flow between these linked pads. A Element has a GList of
+ * 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().
+ *
+ * A pad of an element can be retrieved by name with get_pad(). An iterator of
+ * all pads can be retrieved with gst_element_iterate_pads().
+ *
+ * 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 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 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 state_get_name().
+ *
+ * You can get and set a Clock on an element using get_clock() and set_clock().
+ * Some elements can provide a clock for the pipeline if provides_clock()
+ * returns TRUE. 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 requires_clock() returns TRUE, a clock should be set on the
+ * element with set_clock().
+ *
+ * Note that clock slection and distribution is normally handled by the
+ * toplevel Pipeline so the clock functions are only to be used in very
+ * specific situations.
+ *
+ * Last reviewed on 2006-03-12 (0.10.5)
+ */
+class Element
+: public Gst::Object,
+  public Gst::Interface
 {
-  _CLASS_GOBJECT(Element, GstElement, GST_ELEMENT, Object, GstObject)
-
-protected:
-  //TODO: What C function does this correspond to?
-  _CTOR_DEFAULT
+  _CLASS_GOBJECT(Element, GstElement, GST_ELEMENT, Gst::Object, GstObject)
+  _IMPLEMENTS_INTERFACE(Gst::Interface)
 
 public:
-  static Glib::RefPtr<Element> create(const Glib::ustring& factoryname, const Glib::ustring& name);
   Glib::RefPtr<Element> link(const Glib::RefPtr<Element>& other_element);
   _WRAP_METHOD(bool add_pad(const Glib::RefPtr<Pad>& pad), gst_element_add_pad)
   _WRAP_METHOD(Glib::RefPtr<Pad> get_pad(const Glib::ustring& name), gst_element_get_pad)

Modified: gstreamermm/trunk/gstreamer/src/urihandler.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/urihandler.hg	(original)
+++ gstreamermm/trunk/gstreamer/src/urihandler.hg	Fri Feb 29 20:16:36 2008
@@ -58,6 +58,7 @@
   _WRAP_METHOD(Glib::StringArrayHandle get_protocols(), gst_uri_handler_get_protocols)
   _WRAP_METHOD(Glib::ustring get_uri(), gst_uri_handler_get_uri)
   _WRAP_METHOD(bool set_uri(const Glib::ustring& uri), gst_uri_handler_set_uri)
+  _WRAP_METHOD(void new_uri(const Glib::ustring& uri), gst_uri_handler_new_uri)
 
   _WRAP_SIGNAL(void new_uri(const Glib::ustring& uri), "new-uri")
 

Modified: gstreamermm/trunk/tests/test-create-bin.cc
==============================================================================
--- gstreamermm/trunk/tests/test-create-bin.cc	(original)
+++ gstreamermm/trunk/tests/test-create-bin.cc	Fri Feb 29 20:16:36 2008
@@ -33,8 +33,8 @@
   pipeline = Gst::Pipeline::create("my-pipeline");
   bin = Gst::Bin::create("my-bin");
 
-  source = Gst::Element::create("fakesrc", "source");
-  sink = Gst::Element::create("fakesink", "sink");
+  source = Gst::ElementFactory::create("fakesrc", "source");
+  sink = Gst::ElementFactory::create("fakesink", "sink");
 
   bin->add(source)->add(sink);
 
@@ -44,4 +44,13 @@
   std::cout << "Successfully added elements '" << source->get_name() <<
     "' and '" << sink->get_name() << "' to bin '" <<
       bin->get_name() << "'." << std::endl;
+
+  // use childproxy interface to get bin children count
+  std::cout << "'" << bin->get_name() << "' children count  = " << bin->get_children_count() << "." << std::endl;
+
+  // use childproxy interface to get bin's first child
+  Glib::RefPtr<Gst::Element> element = Glib::RefPtr<Gst::Element>::cast_dynamic(bin->get_child(0));
+  std::cout << "'" << bin->get_name() << "' first child is '" << element->get_name() << "'." << std::endl;
+
+  return 0;
 }

Modified: gstreamermm/trunk/tests/test-create-element.cc
==============================================================================
--- gstreamermm/trunk/tests/test-create-element.cc	(original)
+++ gstreamermm/trunk/tests/test-create-element.cc	Fri Feb 29 20:16:36 2008
@@ -26,9 +26,12 @@
 {
   Gst::init(argc, argv);
 
-  Glib::RefPtr<Gst::Element> element = Gst::Element::create("fakesrc", "source");
+  Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create("filesrc", "source");
 
   if(element)
     std::cout << "Successfully created gst element '" <<
       element->get_name() << "'." << std::endl;
+
+  if(element->implements(Gst::URIHandler::get_type()))
+    std::cout << "element '" << element->get_name() << "' implements URIHandler interface." << std::endl;
 }

Modified: gstreamermm/trunk/tests/test-link-elements.cc
==============================================================================
--- gstreamermm/trunk/tests/test-link-elements.cc	(original)
+++ gstreamermm/trunk/tests/test-link-elements.cc	Fri Feb 29 20:16:36 2008
@@ -31,9 +31,9 @@
 
   pipeline = Gst::Pipeline::create("my-pipeline");
 
-  source = Gst::Element::create("fakesrc", "source");
-  filter = Gst::Element::create("identity", "filter");
-  sink = Gst::Element::create("fakesink", "sink");
+  source = Gst::ElementFactory::create("fakesrc", "source");
+  filter = Gst::ElementFactory::create("identity", "filter");
+  sink = Gst::ElementFactory::create("fakesink", "sink");
 
   pipeline->add(source)->add(filter)->add(sink);
   source->link(filter)->link(sink);

Modified: gstreamermm/trunk/tests/test-pipeline-add-element.cc
==============================================================================
--- gstreamermm/trunk/tests/test-pipeline-add-element.cc	(original)
+++ gstreamermm/trunk/tests/test-pipeline-add-element.cc	Fri Feb 29 20:16:36 2008
@@ -27,7 +27,7 @@
   Gst::init(argc, argv);
 
   Glib::RefPtr<Gst::Pipeline> pipeline = Gst::Pipeline::create("my-pipeline");
-  Glib::RefPtr<Gst::Element> source = Gst::Element::create("fakesrc", "source");
+  Glib::RefPtr<Gst::Element> source = Gst::ElementFactory::create("fakesrc", "source");
 
   pipeline->add(source);
 



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