GStreamer and gjs

Tony Houghton h at realh.co.uk
Mon Sep 21 15:55:17 UTC 2020


I'm having some trouble using GStreamer with gjs. I wasn't sure whether it
was supposed top be supported at all, because Javascript isn't mentioned in
its list of bindings <https://gstreamer.freedesktop.org/bindings/>, and
other bindings, like python, seem to need help from custom bindings instead
of being able to rely on gi alone. But the API docs support Javascript, so
it seems like gjs is intended to be supported.

However, problems started almost immediately. The first is that if I call
Gst.init(ARGV) it crashes with an attempt to free a block of memory that
isn't freeable. I solved that by simply passing null instead, and I guess I
could find a workaround if I really do need it to process ARGV.

More problems occurred when I attempted to write a very simple pipeline,
similar to the playbin example:

function bus_cb(bus, message) {
    log(`Got GstMessage type ${gst.message_type_get_name(message.type)}`);
    ...
    return true;
}

const playbin = gst.ElementFactory.make("playbin", "play");
playbin.get_bus().add_watch(glib.PRIORITY_DEFAULT, bus_cb);
playbin.set_property("uri", uri);
playbin.set_state(gst.State.PLAYING);
const playbin = gst.ElementFactory.make("playbin", "play");
playbin.get_bus().add_watch_full(glib.PRIORITY_DEFAULT, bus_cb);
playbin.set_property("uri", uri);
playbin.set_state(gst.State.PLAYING);

(The URI I'm using is HTTP to stream DVB as an MPEG transport stream from
tvheadend, but I have the same problem if I try to use a file:/// for a
saved mpeg.ts instead).

First, note that although the API docs say you need to use add_watch_full(),
AFAICT you actually have to use add_watch() with arguments as for
add_watch_full(), because the latter doesn't exist in gjs. This is
something to do with the 'full' version shadowing the other, which I don't
fully understand, but I managed to work it out by looking at the output of
ts-for-gjs.

The main problem though is that the pipeline only runs for a few seconds,
then crashes with this error:

Trying to dispose element inputselector2, but it is in PLAYING instead of
the NULL state.

I haven't tested whether this is specific to gjs, or also occurs in python
or even C, but I get the same error in OS X as well as Arch Linux. Both are
using gstreamer 1.18.0.

-- 
TH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20200921/25f7356c/attachment.htm>


More information about the gstreamer-devel mailing list