Home > Gstreamer > Making your life easier with Vala

Making your life easier with Vala

November 8th, 2009

We have been watching Vala for a while now. It’s a really cool idea (and if you have programmed GObject before you know what I’m talking about).

Well, we have finally spare the time to integrate support for Vala on the RidgeRun SDK, thanks to the support by the latest automake version. This allow us to easily write vala code for the target platform and the SDK will take care of the cross compilation (and proper vala bindings for the cross compiled libraries).

There are two main points where using vala will greatly speed our customers development capabilities:

  • GStreamer: developing GStreamer applications is a lot easier if you use object oriented languages, but our experience so far using C++ bindings doesn’t provide the more elegant code possible, and when it comes to integrate it with other technologies like dbus, things start to turn complex. Vala could also be used to develop gstreamer plugins.
  • DBus: doing glib marshals is a bit of a pain. Vala does dbus interactions as beauty as they should be.

Of course there are tons of other APIs where vala will help us that we haven’t play around yet (sqlite, clutter, WebKit, etc). We are really excited about the possibilities!

If you have never see vala code, here is a simple snippet of a gst pipeline for playing audio.

using Gst;

public void main (string[] args) {
    Element src;
    Element sink;
    Pipeline pipeline;

    // Initializing GStreamer
    Gst.init (ref args);

    // Creating pipeline and elements
    // NOTE: The return type of the pipeline construction method is Element,
    // not Pipeline, so we have to cast
    pipeline = (Pipeline) new Pipeline ("test");
    src = ElementFactory.make ("audiotestsrc", "my_src");
    sink = ElementFactory.make ("autoaudiosink", "my_sink");

    // Adding elements to pipeline
    pipeline.add_many (src, sink);

    // Linking source to sink
    src.link (sink);

    // Setting waveform to square
    src.set ("wave", 1);

    // Set pipeline state to PLAYING
    pipeline.set_state (State.PLAYING);

    // Creating a GLib main loop with a default context
    var loop = new MainLoop (null, false);

    // Start GLib mainloop
    loop.run ();
}

Gstreamer

Comments are closed.