1 /* Demo Recorder for MAEMO 5
2 * Copyright (C) 2010 Dru Moore <usr@dru-id.co.uk>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2,
5 * or (at your option) any later version, as published by the Free
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 public class ImportBin : Gst.Bin {
23 Gst.Element converter;
25 Gst.GhostPad sink_pad;
28 public ImportBin(string name) {
31 decoder = Gst.ElementFactory.make("uridecodebin", "decoder-" + name);
32 decoder.connect("swapped-object-signal::autoplug-continue", autoplug_continue, this);
33 decoder.connect("swapped-object-signal::drained", drained, this);
36 converter = Gst.ElementFactory.make("audioconvert", "converter-" + name);
39 //queue = Gst.ElementFactory.make("queue2", "queue");
42 //this.converter.link(this.queue);
45 sink_pad = new Gst.GhostPad("sink", decoder.get_static_pad("sink"));
46 this.add_pad(sink_pad);
47 src_pad = new Gst.GhostPad("src", converter.get_static_pad("src"));
48 this.add_pad(src_pad);
52 private bool autoplug_continue(Gst.Pad decodebin, Gst.Caps arg1, void* data) {
53 stdout.printf("autoplug continue called: %s\n", this.get_name());
55 Gst.PadLinkReturn ret = decodebin.link(converter.get_static_pad("sink"));
56 if (Gst.PadLinkReturn.OK != ret) {
57 stdout.printf("link failed: %s %s\n", this.get_name(), ret.to_string());
61 stdout.printf("link succeded: %s\n", this.get_name());
67 private void drained(Gst.Pad decodebin, void* data) {
70 public new Gst.PadTemplate get_pad_template(string name) {
73 return this.converter.get_pad_template("src");
75 return this.decoder.get_pad_template("sink");
77 return this.get_pad_template(name);
82 this.set_state(Gst.State.PLAYING);
86 this.set_state(Gst.State.PAUSED);
90 this.set_state(Gst.State.READY);
93 public void set_uri(string uri) {
94 stdout.printf("set_uri: %s\n", uri);
96 this.set_state(Gst.State.NULL);
97 decoder.set_property("uri", uri);
99 public string get_uri() {
100 GLib.Value ret = 0.0;
101 decoder.get_property("uri", ref ret);
102 return ret.get_string();