gnomemm r1495 - in gstreamermm/trunk: . examples/element_link examples/media_player_gtkmm examples/ogg_player examples/ogg_player_gtkmm gstreamer/src tests
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: gnomemm r1495 - in gstreamermm/trunk: . examples/element_link examples/media_player_gtkmm examples/ogg_player examples/ogg_player_gtkmm gstreamer/src tests
- Date: Fri, 16 May 2008 21:44:36 +0100 (BST)
Author: murrayc
Date: Fri May 16 20:44:35 2008
New Revision: 1495
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1495&view=rev
Log:
2008-05-16 Murray Cumming <murrayc murrayc com>
* gstreamer/src/elementfactory.ccg:
* gstreamer/src/elementfactory.hg: Rename create() to create_element()
and add an override that takes no name, because that can be NULL in the
C API.
* examples/element_link/element_link.cc:
* examples/media_player_gtkmm/PlayerWindow.cc:
* examples/media_player_gtkmm/PlayerWindow.h:
* examples/media_player_gtkmm/main.cc:
* examples/ogg_player/main.cc:
* examples/ogg_player_gtkmm/PlayerWindow.cc:
* examples/ogg_player_gtkmm/PlayerWindow.h:
* examples/ogg_player_gtkmm/main.cc:
* tests/test-caps.cc:
* tests/test-create-bin.cc:
* tests/test-create-element.cc:
* tests/test-interface.cc:
* tests/test-link-elements.cc:
* tests/test-pipeline-add-element.cc:
Adapt to the API change, and remove unused create_elemnt() name
parameters. Also change (void) to () in method declarations, for
consistency with other *mm examples.
Modified:
gstreamermm/trunk/ChangeLog
gstreamermm/trunk/examples/element_link/element_link.cc
gstreamermm/trunk/examples/media_player_gtkmm/PlayerWindow.cc
gstreamermm/trunk/examples/media_player_gtkmm/PlayerWindow.h
gstreamermm/trunk/examples/media_player_gtkmm/main.cc
gstreamermm/trunk/examples/ogg_player/main.cc
gstreamermm/trunk/examples/ogg_player_gtkmm/PlayerWindow.cc
gstreamermm/trunk/examples/ogg_player_gtkmm/PlayerWindow.h
gstreamermm/trunk/examples/ogg_player_gtkmm/main.cc
gstreamermm/trunk/gstreamer/src/elementfactory.ccg
gstreamermm/trunk/gstreamer/src/elementfactory.hg
gstreamermm/trunk/tests/test-caps.cc
gstreamermm/trunk/tests/test-create-bin.cc
gstreamermm/trunk/tests/test-create-element.cc
gstreamermm/trunk/tests/test-interface.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 May 16 20:44:35 2008
@@ -37,9 +37,9 @@
// create elements
try
{
- m_Element_Source = Gst::ElementFactory::create("fakesrc", "source");
- m_Element_Filter = Gst::ElementFactory::create("identity", "filter");
- m_Element_Sink = Gst::ElementFactory::create("fakesink", "sink");
+ m_Element_Source = Gst::ElementFactory::create_element("fakesrc");
+ m_Element_Filter = Gst::ElementFactory::create_element("identity");
+ m_Element_Sink = Gst::ElementFactory::create_element("fakesink");
}
catch(std::runtime_error& error)
{
Modified: gstreamermm/trunk/examples/media_player_gtkmm/PlayerWindow.cc
==============================================================================
--- gstreamermm/trunk/examples/media_player_gtkmm/PlayerWindow.cc (original)
+++ gstreamermm/trunk/examples/media_player_gtkmm/PlayerWindow.cc Fri May 16 20:44:35 2008
@@ -227,7 +227,7 @@
return true; // Keep buffer in pipeline (do not throw away)
}
-void PlayerWindow::on_play(void)
+void PlayerWindow::on_play()
{
progressScale.set_sensitive(true);
playButton.set_sensitive(false);
@@ -249,7 +249,7 @@
playbin->set_state(Gst::STATE_PLAYING);
}
-void PlayerWindow::on_pause(void)
+void PlayerWindow::on_pause()
{
playButton.set_sensitive(true);
pauseButton.set_sensitive(false);
@@ -264,7 +264,7 @@
playbin->set_state(Gst::STATE_PAUSED);
}
-void PlayerWindow::on_stop(void)
+void PlayerWindow::on_stop()
{
progressScale.set_sensitive(false);
playButton.set_sensitive(true);
@@ -313,7 +313,7 @@
}
}
-void PlayerWindow::on_rewind(void)
+void PlayerWindow::on_rewind()
{
static const gint64 skipAmount = GST_SECOND * 2;
@@ -333,7 +333,7 @@
}
}
-void PlayerWindow::on_forward(void)
+void PlayerWindow::on_forward()
{
static const gint64 skipAmount = GST_SECOND * 3;
@@ -369,7 +369,7 @@
}
}
-void PlayerWindow::on_open(void)
+void PlayerWindow::on_open()
{
static Glib::ustring workingDir = Glib::get_home_dir();
@@ -409,7 +409,7 @@
}
}
-bool PlayerWindow::update_stream_progress(void)
+bool PlayerWindow::update_stream_progress()
{
Gst::Format fmt = Gst::FORMAT_TIME;
gint64 pos = 0;
Modified: gstreamermm/trunk/examples/media_player_gtkmm/PlayerWindow.h
==============================================================================
--- gstreamermm/trunk/examples/media_player_gtkmm/PlayerWindow.h (original)
+++ gstreamermm/trunk/examples/media_player_gtkmm/PlayerWindow.h Fri May 16 20:44:35 2008
@@ -62,15 +62,15 @@
virtual bool on_video_pad_got_buffer(const Glib::RefPtr<Gst::Pad>& pad,
const Glib::RefPtr<Gst::MiniObject>& buffer);
- virtual void on_play(void);
- virtual void on_pause(void);
- virtual void on_stop(void);
+ virtual void on_play();
+ virtual void on_pause();
+ virtual void on_stop();
virtual bool on_scale_value_changed(Gtk::ScrollType type, double value);
- virtual void on_rewind(void);
- virtual void on_forward(void);
- virtual void on_open(void);
+ virtual void on_rewind();
+ virtual void on_forward();
+ virtual void on_open();
protected:
- bool update_stream_progress(void);
+ bool update_stream_progress();
void display_label_progress(gint64 pos, gint64 len);
private:
Glib::RefPtr<Gst::Pipeline> playbin;
Modified: gstreamermm/trunk/examples/media_player_gtkmm/main.cc
==============================================================================
--- gstreamermm/trunk/examples/media_player_gtkmm/main.cc (original)
+++ gstreamermm/trunk/examples/media_player_gtkmm/main.cc Fri May 16 20:44:35 2008
@@ -38,11 +38,11 @@
// Autoplays any media type. Implements GstBase::XOverlay so accepts
// a window id in which to draw video
- Glib::RefPtr<Gst::Element> playbin = Gst::ElementFactory::create("playbin", "media-player");
+ Glib::RefPtr<Gst::Element> playbin = Gst::ElementFactory::create_element("playbin");
Glib::RefPtr<Gst::Pipeline> playbinPipeline = Glib::RefPtr<Gst::Pipeline>::cast_dynamic(playbin);
// Video sink where video (if any) will be drawn
- Glib::RefPtr<Gst::Element> videoSink = Gst::ElementFactory::create("ximagesink", "video-sink");
+ Glib::RefPtr<Gst::Element> videoSink = Gst::ElementFactory::create_element("ximagesink");
if (!playbinPipeline || !videoSink)
{
Modified: gstreamermm/trunk/examples/ogg_player/main.cc
==============================================================================
--- gstreamermm/trunk/examples/ogg_player/main.cc (original)
+++ gstreamermm/trunk/examples/ogg_player/main.cc Fri May 16 20:44:35 2008
@@ -23,13 +23,12 @@
#include <iostream>
#include <iomanip>
-// Global objects are usually a bad thing. For the purpose of this example, we will use them, however.
Glib::RefPtr<Glib::MainLoop> mainloop;
Glib::RefPtr<Gst::Pipeline> pipeline;
Glib::RefPtr<Gst::Element> decoder;
-gulong data_probe_id;
+gulong data_probe_id = 0;
-bool print_stream_position(void)
+bool on_timeout()
{
Gst::Format fmt = Gst::FORMAT_TIME;
gint64 pos = 0;
@@ -38,12 +37,13 @@
Glib::RefPtr<Gst::Query> query = Gst::QueryPosition::create(fmt);
if (pipeline->query(query)
- && pipeline->query_duration(fmt, len)) {
-
- Glib::RefPtr<Gst::QueryPosition> posQuery =
+ && pipeline->query_duration(fmt, len))
+ {
+ //TODO: Document why we do this cast:
+ Glib::RefPtr<Gst::QueryPosition> query_pos =
Glib::RefPtr<Gst::QueryPosition>::cast_dynamic(query);
-
- posQuery->parse(fmt, pos);
+ if(query_pos)
+ query_pos->parse(fmt, pos);
std::cout << std::right << "Time: " << std::setfill('0') <<
std::setw(3) << Gst::get_hours(pos) << ":" <<
@@ -122,34 +122,35 @@
return -1;
}
- // initialize Gstreamermm
+ // Initialize Gstreamermm:
Gst::init(argc, argv);
mainloop = Glib::MainLoop::create();
- // Create the pipeline
+ // Create the pipeline:
pipeline = Gst::Pipeline::create("audio-player");
std::cout << "pipeline=" << pipeline << std::endl;
- // Create the elements
- // Reads file from disk
- Glib::RefPtr<Gst::Element> source = Gst::ElementFactory::create("filesrc", "file-source");
+ // Create the elements:
+
+ // filsrc reads the file from disk:
+ Glib::RefPtr<Gst::Element> source = Gst::ElementFactory::create_element("filesrc");
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::ElementFactory::create("oggdemux", "ogg-parser");
+ // oggdemux parses the ogg streams into elementary streams (audio and video):
+ Glib::RefPtr<Gst::Element> parser = Gst::ElementFactory::create_element("oggdemux");
std::cout << "parser=" << parser << std::endl;
- // Decodes a vorbis stream
- decoder = Gst::ElementFactory::create("vorbisdec", "vorbis-decoder");
+ // vorbisdec decodes a vorbis (audio) stream:
+ decoder = Gst::ElementFactory::create_element("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::ElementFactory::create("audioconvert", "converter");
+ // audioconvert converts raw audio to a format which can be used by the next element
+ Glib::RefPtr<Gst::Element> conv = Gst::ElementFactory::create_element("audioconvert");
std::cout << "conv=" << conv << std::endl;
// Outputs sound to an ALSA audio device
- Glib::RefPtr<Gst::Element> sink = Gst::ElementFactory::create("alsasink", "alsa-output");
+ Glib::RefPtr<Gst::Element> sink = Gst::ElementFactory::create_element("alsasink");
std::cout << "sink=" << sink << std::endl;
if (!pipeline || !source || !parser || !decoder || !conv || !sink)
@@ -163,7 +164,6 @@
std::cout << "sink data probe id = " << data_probe_id << std::endl;
- // //eireuo
// Set filename property on the file source. Also add a message handler:
source->set_property("location", std::string(argv[1]));
@@ -194,9 +194,9 @@
decoder->link(conv)->link(sink);
- // Call print_stream_position function at a 200ms
+ // Call on_timeout function at a 200ms
// interval to regularly print the position of the stream
- Glib::signal_timeout().connect(sigc::ptr_fun(&print_stream_position), 200);
+ Glib::signal_timeout().connect(sigc::ptr_fun(&on_timeout), 200);
// Now set to playing and iterate: TODO: What is iterated? Is the comment wrong?
std::cout << "Setting to PLAYING." << std::endl;
Modified: gstreamermm/trunk/examples/ogg_player_gtkmm/PlayerWindow.cc
==============================================================================
--- gstreamermm/trunk/examples/ogg_player_gtkmm/PlayerWindow.cc (original)
+++ gstreamermm/trunk/examples/ogg_player_gtkmm/PlayerWindow.cc Fri May 16 20:44:35 2008
@@ -133,7 +133,7 @@
return true;
}
-void PlayerWindow::on_play(void)
+void PlayerWindow::on_play()
{
progressScale.set_sensitive(true);
playButton.set_sensitive(false);
@@ -155,7 +155,7 @@
mainPipeline->set_state(Gst::STATE_PLAYING);
}
-void PlayerWindow::on_pause(void)
+void PlayerWindow::on_pause()
{
playButton.set_sensitive(true);
pauseButton.set_sensitive(false);
@@ -170,7 +170,7 @@
mainPipeline->set_state(Gst::STATE_PAUSED);
}
-void PlayerWindow::on_stop(void)
+void PlayerWindow::on_stop()
{
progressScale.set_sensitive(false);
playButton.set_sensitive(true);
@@ -208,7 +208,7 @@
}
}
-void PlayerWindow::on_rewind(void)
+void PlayerWindow::on_rewind()
{
static const gint64 skipAmount = GST_SECOND * 2;
@@ -228,7 +228,7 @@
}
}
-void PlayerWindow::on_forward(void)
+void PlayerWindow::on_forward()
{
static const gint64 skipAmount = GST_SECOND * 3;
@@ -264,7 +264,7 @@
}
}
-void PlayerWindow::on_open(void)
+void PlayerWindow::on_open()
{
static Glib::ustring workingDir = Glib::get_home_dir();
@@ -296,7 +296,7 @@
}
}
-bool PlayerWindow::update_stream_progress(void)
+bool PlayerWindow::update_stream_progress()
{
Gst::Format fmt = Gst::FORMAT_TIME;
gint64 pos = 0;
Modified: gstreamermm/trunk/examples/ogg_player_gtkmm/PlayerWindow.h
==============================================================================
--- gstreamermm/trunk/examples/ogg_player_gtkmm/PlayerWindow.h (original)
+++ gstreamermm/trunk/examples/ogg_player_gtkmm/PlayerWindow.h Fri May 16 20:44:35 2008
@@ -51,15 +51,15 @@
protected:
virtual bool on_bus_message(const Glib::RefPtr<Gst::Bus>& bus,
const Glib::RefPtr<Gst::Message>& message);
- virtual void on_play(void);
- virtual void on_pause(void);
- virtual void on_stop(void);
+ virtual void on_play();
+ virtual void on_pause();
+ virtual void on_stop();
virtual bool on_scale_value_changed(Gtk::ScrollType type, double value);
- virtual void on_rewind(void);
- virtual void on_forward(void);
- virtual void on_open(void);
+ virtual void on_rewind();
+ virtual void on_forward();
+ virtual void on_open();
protected:
- bool update_stream_progress(void);
+ bool update_stream_progress();
void display_label_progress(gint64 pos, gint64 len);
private:
Glib::RefPtr<Gst::Element> sourceElement;
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 May 16 20:44:35 2008
@@ -49,19 +49,19 @@
// Create the elements
// Reads file from disk
- Glib::RefPtr<Gst::Element> source = Gst::ElementFactory::create("filesrc", "file-source");
+ Glib::RefPtr<Gst::Element> source = Gst::ElementFactory::create_element("filesrc");
// Parses the ogg streams into elementary streams (note that an ogg file may contain a video stream too)
- Glib::RefPtr<Gst::Element> parser = Gst::ElementFactory::create("oggdemux", "ogg-parser");
+ Glib::RefPtr<Gst::Element> parser = Gst::ElementFactory::create_element("oggdemux");
// Decodes a vorbis stream
- decoder = Gst::ElementFactory::create("vorbisdec", "vorbis-decoder");
+ decoder = Gst::ElementFactory::create_element("vorbisdec", "vorbis-decoder");
// Converts audio() to a format which can be used by the next element
- Glib::RefPtr<Gst::Element> conv = Gst::ElementFactory::create("audioconvert", "converter");
+ Glib::RefPtr<Gst::Element> conv = Gst::ElementFactory::create_element("audioconvert");
// Outputs sound to an ALSA audio device
- Glib::RefPtr<Gst::Element> sink = Gst::ElementFactory::create("alsasink", "alsa-output");
+ Glib::RefPtr<Gst::Element> sink = Gst::ElementFactory::create_element("alsasink");
if (!pipeline || !source || !parser || !decoder || !conv || !sink)
{
Modified: gstreamermm/trunk/gstreamer/src/elementfactory.ccg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/elementfactory.ccg (original)
+++ gstreamermm/trunk/gstreamer/src/elementfactory.ccg Fri May 16 20:44:35 2008
@@ -26,3 +26,14 @@
#include <gstreamermm/plugin.h>
_PINCLUDE(gstreamermm/private/pluginfeature_p.h)
+
+namespace Gst
+{
+
+Glib::RefPtr<Element> ElementFactory::create_element(const Glib::ustring& factory_name)
+{
+ return Glib::wrap(gst_element_factory_make(factory_name.c_str(), NULL));
+}
+
+} //namespace Gst
+
Modified: gstreamermm/trunk/gstreamer/src/elementfactory.hg
==============================================================================
--- gstreamermm/trunk/gstreamer/src/elementfactory.hg (original)
+++ gstreamermm/trunk/gstreamer/src/elementfactory.hg Fri May 16 20:44:35 2008
@@ -52,9 +52,20 @@
//TODO: Rename as create_*()? How is this different to gst_element_factory_create()?
_WRAP_METHOD(static Glib::RefPtr<ElementFactory> find(const Glib::ustring& name), gst_element_factory_find)
- _WRAP_METHOD(Glib::RefPtr<Element> create(const Glib::ustring& name), gst_element_factory_create)
- _WRAP_METHOD(static Glib::RefPtr<Element> create(const Glib::ustring& factory_name, const Glib::ustring& name), gst_element_factory_make)
+ //Note that name can't be NULL here, though it seems like gstreamer should allow that as for gst_element_factory_make().
+ //TODO: Wrap, but with a different name to avoid the clash: _WRAP_METHOD(Glib::RefPtr<Element> create_element(const Glib::ustring& name), gst_element_factory_create)
+
+ //TODO: Customize documentatoin to avoid mention of NULL for name.
+ _WRAP_METHOD(static Glib::RefPtr<Element> create_element(const Glib::ustring& factory_name, const Glib::ustring& name), gst_element_factory_make)
+ /** Create a new element of the type defined by the given element factory,
+ * with a guaranteed unique name consisting of the element factory name and a number.
+ * @param factoryname A named factory to instantiate.
+ * @param name Name of new element.
+ * @return New Gst::Element or an empty RefPtr if unable to create element.
+ */
+ static Glib::RefPtr<Element> create_element(const Glib::ustring& factory_name);
+
_WRAP_METHOD(GType get_element_type() const, gst_element_factory_get_element_type)
_WRAP_METHOD(Glib::ustring get_long_name() const, gst_element_factory_get_longname)
_WRAP_METHOD(Glib::ustring get_kclass() const, gst_element_factory_get_klass)
Modified: gstreamermm/trunk/tests/test-caps.cc
==============================================================================
--- gstreamermm/trunk/tests/test-caps.cc (original)
+++ gstreamermm/trunk/tests/test-caps.cc Fri May 16 20:44:35 2008
@@ -59,8 +59,8 @@
pipeline = Gst::Pipeline::create("pipeline");
- e1 = Gst::ElementFactory::create("fakesrc", "source");
- e2 = Gst::ElementFactory::create("fakesink", "sink");
+ e1 = Gst::ElementFactory::create_element("fakesrc", "source");
+ e2 = Gst::ElementFactory::create_element("fakesink", "sink");
pipeline->add(e1)->add(e2);
Modified: gstreamermm/trunk/tests/test-create-bin.cc
==============================================================================
--- gstreamermm/trunk/tests/test-create-bin.cc (original)
+++ gstreamermm/trunk/tests/test-create-bin.cc Fri May 16 20:44:35 2008
@@ -33,8 +33,8 @@
pipeline = Gst::Pipeline::create("my-pipeline");
bin = Gst::Bin::create("my-bin");
- source = Gst::ElementFactory::create("fakesrc", "source");
- sink = Gst::ElementFactory::create("fakesink", "sink");
+ source = Gst::ElementFactory::create_element("fakesrc", "source");
+ sink = Gst::ElementFactory::create_element("fakesink", "sink");
bin->add(source)->add(sink);
Modified: gstreamermm/trunk/tests/test-create-element.cc
==============================================================================
--- gstreamermm/trunk/tests/test-create-element.cc (original)
+++ gstreamermm/trunk/tests/test-create-element.cc Fri May 16 20:44:35 2008
@@ -26,7 +26,7 @@
{
Gst::init(argc, argv);
- Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create("fakesrc", "source");
+ Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create_element("fakesrc", "source");
if(element)
std::cout << "Successfully created gst element '" <<
Modified: gstreamermm/trunk/tests/test-interface.cc
==============================================================================
--- gstreamermm/trunk/tests/test-interface.cc (original)
+++ gstreamermm/trunk/tests/test-interface.cc Fri May 16 20:44:35 2008
@@ -27,7 +27,7 @@
{
Gst::init(argc, argv);
- Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create("filesrc", "source");
+ Glib::RefPtr<Gst::Element> element = Gst::ElementFactory::create_element("filesrc", "source");
if (element)
std::cout << "Successfully created gst element '" <<
Modified: gstreamermm/trunk/tests/test-link-elements.cc
==============================================================================
--- gstreamermm/trunk/tests/test-link-elements.cc (original)
+++ gstreamermm/trunk/tests/test-link-elements.cc Fri May 16 20:44:35 2008
@@ -31,9 +31,9 @@
pipeline = Gst::Pipeline::create("my-pipeline");
- source = Gst::ElementFactory::create("fakesrc", "source");
- filter = Gst::ElementFactory::create("identity", "filter");
- sink = Gst::ElementFactory::create("fakesink", "sink");
+ source = Gst::ElementFactory::create_element("fakesrc", "source");
+ filter = Gst::ElementFactory::create_element("identity", "filter");
+ sink = Gst::ElementFactory::create_element("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 May 16 20:44:35 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::ElementFactory::create("fakesrc", "source");
+ Glib::RefPtr<Gst::Element> source = Gst::ElementFactory::create_element("fakesrc", "source");
pipeline->add(source);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]