gstreamer-java/gst1-java-core

Element.get("stats") not working

thomas-schn opened this issue · 8 comments

If im trying to get the property "stats" from an Element like this:

BaseSink srtserversink = (BaseSink) ElementFactory.make("srtsink", "srtsink");
srtserversink.set("uri", "srt://:8888/");
Object stats = srtserversink.get("stats");

i'm getting an Exception, although the property should be present on the element:
Exception in thread "main" java.lang.IllegalArgumentException: Unknown conversion from Type=[GstStructure:705543728] at org.freedesktop.gstreamer.glib.GObject.get(GObject.java:210)

Yes, a known issue at the moment, sorry. Not all types are correctly mapped back and forth via GObject set and get. That whole area really needs looking at and rewriting. There may be a workaround if you explore the lowlevel mappings.

Thanks for your support. Finaly we were able to find a workaround with the lowlevel API

        BaseSink srtserversink = (BaseSink) ElementFactory.make("srtsink", "srtsink");
        srtserversink.set("uri", "srt://:8888/");

        GValueAPI.GValue propValue = new GValueAPI.GValue();
        GType gstStructure = GType.valueOf("GstStructure");
        GValueAPI.GVALUE_API.g_value_init(propValue, gstStructure);
        GObjectAPI.GOBJECT_API.g_object_get_property(srtserversink, "stats", propValue);
        Pointer pointer = GValueAPI.GVALUE_API.g_value_get_boxed(propValue);
        Structure d = Natives.objectFor(pointer, Structure.class, false, false);
        for (int i = 0; i < d.getFields(); i++) {
            String name = d.getName(i);
            Object value = d.getValue(name);
            LOGGER.info("srt stats - {} = {}", name, value);
        }

In this way, we were able to get the srt statistics.

But I don't know, if there will be memoryleak with the lowlevel Api.

Great! Except that you're now locked to this version of the bindings, unfortunately. Must try and get this fixed up sometime. Part of the error might be that Structure isn't registered at https://github.com/gstreamer-java/gst1-java-core/blob/master/src/org/freedesktop/gstreamer/Gst.java#L670 although I don't think that's all of it. We need to review the very similar code that exists in a few places in the code base and get it working and in one place!

I think you're good with the memory handling there.

Now I have another problem.
I do get the srt statistics from the receiver (srtsrc in caller mode)

srt stats - packets-sent = 0
srt stats - packets-sent-lost = 0
srt stats - packets-retransmitted = 0
srt stats - packet-ack-received = 0
srt stats - packet-nack-received = 0
srt stats - send-duration-us = 0
srt stats - bytes-sent = 0
srt stats - bytes-retransmitted = 0
srt stats - bytes-sent-dropped = 0
srt stats - packets-sent-dropped = 0
srt stats - send-rate-mbps = 0.323
srt stats - bandwidth-mbps = 66.12
srt stats - rtt-ms = 0.323
srt stats - negotiated-latency-ms = 120

But the srtsink (in listener mode) delivers empty statistics to me

 application/x-srt-statistics; 

I can't really judge that because I'm not that experienced with c/c++.
Don't you use the master version of gst-plugins-bad?
https://github.com/GStreamer/gst-plugins-bad/blob/master/ext/srt/gstsrtobject.c#L1428
There is no gstsrtbasesink and the stats are delievered by gstsrtobject. To me it looks like there is taken care of return statistics to the srt sender.

I just searched for your output text on the repo 😉 For some reason that link showed up before master. The code you linked will still give an empty structure if ret is less than 0.

Hopefully now fixed by #220