Re: gstmm add element to pipeline test
- From: José Alburquerque <jaalburquerque cox net>
- To: Murray Cumming <murrayc murrayc com>
- Cc: gtkmm-list gnome org
- Subject: Re: gstmm add element to pipeline test
- Date: Fri, 07 Dec 2007 11:42:53 -0500
Murray Cumming wrote:
So, I have committed bus-message-02.diff. Should I add one of the .cc
files (which one?) as an example?
Thanks. And sorry that you don't yet have svn write access - I have no
control over that svn repository.
Thanks. Yes, I suppose that the slot version might be good since it is
how it is done in C by default. I really appreciate you committing
these changes for me. I'm attaching a new version of the slot example
(which parses the message so the error output is more explicit) and
would you also add this small patch which consolidates the
Gst::Bus::add_watch() methods into one (if you think it's alright)? It
seems better to have just one "do-all" method, unless you think
otherwise. Thanks.
-Jose
#include <iostream>
#include <gstmm.h>
using namespace Glib;
using namespace Gst;
using namespace std;
bool process_bus_message(const RefPtr<Bus>& bus, const RefPtr<Message>& message,
RefPtr<MainLoop> mainLoop)
{
RefPtr<MessageError> msgError;
Error err;
std::string debug;
switch (message->get_type()) {
case MESSAGE_EOS:
cout << "End of stream" << endl;
mainLoop->quit();
return false;
case MESSAGE_ERROR:
msgError = RefPtr<MessageError>::cast_static(message);
if (msgError) {
msgError->parse(err, debug);
cerr << "Error: " << err.what() << endl;
}
else
cerr << "Error." << endl;
mainLoop->quit();
return false;
default:
break;
}
return true;
}
void parser_pad_added(const RefPtr<Pad>& newPad, RefPtr<Element> decoder)
{
cout << "Dynamic pad created, linking parser/decoder." << endl;
RefPtr<Pad> sinkPad = decoder->get_pad("sink");
newPad->link(sinkPad);
}
int main(int argc, char* argv[]) {
if (argc != 2) {
cout << "Usage: " << argv[0] << " <Ogg/Vorbis filename>" << endl;
return -1;
}
Gst::init(argc, argv);
RefPtr<MainLoop> mainLoop = Glib::MainLoop::create();
/* create elements */
RefPtr<Pipeline> pipeline = Gst::Pipeline::create("audio-player");
RefPtr<Element> source = Gst::Element::create("filesrc", "file-source");
RefPtr<Element> parser = Gst::Element::create("oggdemux", "ogg-parser");
RefPtr<Element> decoder = Gst::Element::create("vorbisdec", "vorbis-decoder");
RefPtr<Element> conv = Gst::Element::create("audioconvert", "converter");
RefPtr<Element> sink = Gst::Element::create("alsasink", "alsa-output");
if (!pipeline || !source || !parser || !decoder || !conv || !sink) {
cerr << "One element could not be created." << endl;
return -1;
}
/* set filename property on the file source. Also add a message
* handler. */
source->set_property("location", (string) argv[1]);
RefPtr<Bus> bus = pipeline->get_bus();
Bus::SlotWatch slot(sigc::bind< RefPtr<MainLoop> >( sigc::ptr_fun(&process_bus_message), mainLoop) );
bus->add_watch(slot);
/* put all elements in a bin */
pipeline->add(source)->add(parser)->add(decoder)->add(conv)->add(sink);
/* link together - note that we cannot link the parser and
* decoder yet, becuse the parser uses dynamic pads. For that,
* we set a pad-added signal handler. */
source->link(parser);
decoder->link(conv)->link(sink);
parser->signal_pad_added().connect(sigc::bind< RefPtr<Element> >(
sigc::ptr_fun(&parser_pad_added), decoder) );
/* Now set to playing and iterate. */
cout << "Setting to PLAYING." << endl;
pipeline->set_state(STATE_PLAYING);
cout << "Running." << endl;
mainLoop->run();
/* clean up nicely */
cout << "Returned, stopping playback." << endl;
pipeline->set_state(STATE_NULL);
return 0;
}
Index: gst/src/bus.hg
===================================================================
--- gst/src/bus.hg (revision 96)
+++ gst/src/bus.hg (working copy)
@@ -41,9 +41,9 @@
_WRAP_METHOD(void disable_sync_message_emission(), gst_bus_disable_sync_message_emission)
_WRAP_METHOD(void enable_sync_message_emission(), gst_bus_enable_sync_message_emission)
- _WRAP_METHOD(void add_signal_watch(), gst_bus_add_signal_watch)
- _WRAP_METHOD(void add_signal_watch_full(int priority), gst_bus_add_signal_watch_full)
+ _WRAP_METHOD(void add_signal_watch(int priority = G_PRIORITY_DEFAULT), gst_bus_add_signal_watch_full)
_WRAP_METHOD(void remove_signal_watch(), gst_bus_remove_signal_watch)
+ _IGNORE(gst_bus_add_signal_watch)
#m4 _CONVERSION(`GstMessage*',`const Glib::RefPtr<Message>&', `Glib::wrap($3, true)')
_WRAP_SIGNAL(void message(const Glib::RefPtr<Message>& message), "message")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]