GStreamer and gjs

Sebastian Dröge sebastian at centricular.com
Mon Sep 21 16:10:02 UTC 2020


On Mon, 2020-09-21 at 16:55 +0100, Tony Houghton wrote:
> 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, 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.

It's supposed to work, yes. There might be some bugs though, it's not
the most widely used language for GStreamer.

> 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.

Can you report that to gjs? That would be a bug on the bindings side
  https://gitlab.gnome.org/GNOME/gjs

> More problems occurred when I attempted to write a very simple
> pipeline, similar to the playbin example:
> 
> [...]
> 
> 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.

That seems like a problem in the documentation indeed. The non-full
version is not usable from bindings, so the full version is configured
to shadow/hide the non-full one.

Where is that in the documentation? Can you create an issue for that at
  https://gitlab.freedesktop.org/gstreamer/gst-docs/

> 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.

Your code doesn't have any main loop or similar, so after setting the
pipeline to PLAYING it simply exits. You probably want to wait in one
way or another until the EOS (or ERROR) message is received from the
bus.

Then before shutting down the application you need to set the state of
the pipeline to NULL. When the last reference goes out of scope in gjs,
the object will be destroyed. But GStreamer requires for all elements
that their state is NULL before they're destroyed. This is something
you need to take care of here.

-- 
Sebastian Dröge, Centricular Ltd · https://www.centricular.com




More information about the gstreamer-devel mailing list