/* Demo Recorder for MAEMO 5 * Copyright (C) 2010 Dru Moore * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * or (at your option) any later version, as published by the Free * Software Foundation * * This program 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 General Public License for more details * * You should have received a copy of the GNU General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ namespace IdWorks { public class ImportBin : Gst.Bin { Gst.Element decoder; Gst.Element converter; //Gst.Element queue; Gst.GhostPad sink_pad; Gst.GhostPad src_pad; public ImportBin(string name) { this.set_name(name); decoder = Gst.ElementFactory.make("uridecodebin", "decoder-" + name); decoder.connect("swapped-object-signal::autoplug-continue", autoplug_continue, this); decoder.connect("swapped-object-signal::drained", drained, this); this.add(decoder); converter = Gst.ElementFactory.make("audioconvert", "converter-" + name); this.add(converter); //queue = Gst.ElementFactory.make("queue2", "queue"); //this.add(queue); //this.converter.link(this.queue); sink_pad = new Gst.GhostPad("sink", decoder.get_static_pad("sink")); this.add_pad(sink_pad); src_pad = new Gst.GhostPad("src", converter.get_static_pad("src")); this.add_pad(src_pad); } private bool autoplug_continue(Gst.Pad decodebin, Gst.Caps arg1, void* data) { stdout.printf("autoplug continue called: %s\n", this.get_name()); stdout.flush(); Gst.PadLinkReturn ret = decodebin.link(converter.get_static_pad("sink")); if (Gst.PadLinkReturn.OK != ret) { stdout.printf("link failed: %s %s\n", this.get_name(), ret.to_string()); stdout.flush(); } else { stdout.printf("link succeded: %s\n", this.get_name()); stdout.flush(); } return true; } private void drained(Gst.Pad decodebin, void* data) { } public new Gst.PadTemplate get_pad_template(string name) { switch (name) { case "src": return this.converter.get_pad_template("src"); case "sink": return this.decoder.get_pad_template("sink"); default: return this.get_pad_template(name); } } public void play() { this.set_state(Gst.State.PLAYING); } public void pause() { this.set_state(Gst.State.PAUSED); } public void stop() { this.set_state(Gst.State.READY); } public void set_uri(string uri) { stdout.printf("set_uri: %s\n", uri); stdout.flush(); this.set_state(Gst.State.NULL); decoder.set_property("uri", uri); } public string get_uri() { GLib.Value ret = 0.0; decoder.get_property("uri", ref ret); return ret.get_string(); } } }