GStreamer and gjs

Tony Houghton h at realh.co.uk
Tue Sep 22 12:01:56 UTC 2020


On Mon, 21 Sep 2020 at 21:25, Sebastian Dröge <sebastian at centricular.com>
wrote:

>
> Can you provide a full gjs example for the application that causes the
> problem above? Seems like another bug in gjs to me though but I can
> take a short look first :)
>

I've tried distilling it down to a small standalone script, but now I can't
reproduce the problem, even in the full version if I replace the
signal-based watch with the threaded one. I'll attach the simple version
anyway. Another, rarer, symptom is that sometimes the window doesn't open
and the messages stop appearing.

One possible reason for the original error message could be that the
callback was getting EOS or ERROR messages and quitting without stopping
the pipeline, and the threading was causing the log of the message to get
lost. But there must have been something wrong for the pipeline to have
been sending such messages or otherwise quitting. I'll ask for
clarification about threaded callbacks in gjs on the GNOME discourse
bindings forum <https://discourse.gnome.org/c/platform/language-bindings/11>
.


> Thanks for reporting the issues btw!
>

The least I could do after you helpfully provided links :-).

-- 
TH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20200922/62fb1c66/attachment.htm>
-------------- next part --------------
"use strict";
imports.gi.versions.Gst = "1.0";

const glib = imports.gi.GLib;
const gobject = imports.gi.GObject;
const gst = imports.gi.Gst;

gst.init(null);

let main_loop;

function bus_cb(bus, message) {
    log(`Got GstMessage type ${gst.message_type_get_name(message.type)}`);
    switch (message.type) {
        case gst.MessageType.ERROR:
            var [error, debug] = message.parse_error();
            log(`Error: ${error ? error.message : 'null'}, debug: ${debug}`);
            main_loop.quit();
            break;
        case gst.MessageType.EOS:
            main_loop.quit();
            break;
    }
    return true;
}

main_loop = glib.MainLoop.new(null, false);
const playbin = gst.ElementFactory.make("playbin", "play");
const bus = playbin.get_bus();
bus.add_watch(glib.PRIORITY_DEFAULT, bus_cb);
playbin.set_property("uri", ARGV[0]);
playbin.set_state(gst.State.PLAYING);
main_loop.run();


More information about the gstreamer-devel mailing list