From bfc0a505a2f5279f85a516c9991050842017443d Mon Sep 17 00:00:00 2001 From: Alexander Kojevnikov Date: Fri, 30 Apr 2010 20:49:40 +1000 Subject: [PATCH] GStreamer bindings - proof of concept --- src/spek-window.vala | 37 +++++++++++++++++++++++++++++++++++-- src/spek.vala | 3 ++- 2 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/spek-window.vala b/src/spek-window.vala index b6ac884..2c8d55c 100644 --- a/src/spek-window.vala +++ b/src/spek-window.vala @@ -1,3 +1,4 @@ +using Gst; using Gtk; namespace Spek { @@ -28,8 +29,40 @@ namespace Spek { STOCK_CANCEL, ResponseType.CANCEL, STOCK_OPEN, ResponseType.ACCEPT, null); if (chooser.run () == ResponseType.ACCEPT) { - // TODO + open (chooser.get_filename ()); + } + chooser.destroy (); + } + + private void open (string name) { + var pipeline = new Pipeline ("pipeline"); + var filesrc = ElementFactory.make ("filesrc", "filesrc"); + var decodebin = ElementFactory.make ("decodebin", "decodebin"); + pipeline.add_many (filesrc, decodebin); + filesrc.link (decodebin); + filesrc.set ("location", name); + + Signal.connect (decodebin, "new-decoded-pad", (GLib.Callback) on_new_decoded_pad, pipeline); + pipeline.set_state (State.PAUSED); + pipeline.get_state (null, null, -1); + + unowned Iterator it = decodebin.iterate_src_pads (); + void *data; + while (it.next (out data) == IteratorResult.OK) { + var pad = (Pad) data; + var caps = pad.get_caps (); + var structure = caps.get_structure (0); + stdout.printf ("structure=%s\n", structure.to_string ()); } } + + private static void on_new_decoded_pad ( + Element decodebin, Pad new_pad, bool last, Pipeline pipeline) { + var fakesink = ElementFactory.make ("fakesink", null); + pipeline.add (fakesink); + var sinkpad = fakesink.get_static_pad ("sink"); + new_pad.link (sinkpad); + fakesink.set_state (State.PAUSED); + } } -} \ No newline at end of file +} diff --git a/src/spek.vala b/src/spek.vala index 593a599..6325286 100644 --- a/src/spek.vala +++ b/src/spek.vala @@ -7,7 +7,8 @@ int main (string[] args) { Gtk.init (ref args); Gst.init (ref args); - new Spek.Window (); + var window = new Spek.Window (); Gtk.main (); + window.destroy (); return 0; }