Looking at the docs I can see GstBaseSink exposes a bunch of stats
However when using a specific sink likertmp2sink or srtsink I only have the stats defined on those sink’s available when getting the stats structure from the element.
I tried downcasting my element to a basesink but that did not yield the expected results.
How can I access the properties in the base sink stats object?
I am scraping the sinks to pull stats and am unable to get BaseSink stats properties, for example “dropped”, which I can see is declared in BaseSink GstBaseSink.
I am sure I am missing rather obvious.
for element in pipeline_elements {
let name = element.type_().name();
if name.eq("GstSRTSink") {
let srt_sink_stats = element
.property_value("stats")
.get::<gst::Structure>().unwrap();
let out_bytes_total = srt_sink_stats.get::<u64>("bytes-sent-total").unwrap();
println!("srt sink {:?}", out_bytes_total);
let dropped = srt_sink_stats.get::<u64>("dropped");
let avg_rate = srt_sink_stats.get::<u64>("average-rate");
let rendered = srt_sink_stats.get::<f64>("rendered");
println!("dropped {:?} avg rate {:?} rendered {:?}", dropped, avg_rate, rendered);
} ... I observe the same behaviour with rtmp2sink
}
I can see stats available in srtsink, and basesink, in different identifiers e.g. GstRtmpConnectionStats, application/x-gst-base-sink-stats and application/x-srt-statistics , the rtmp2 property being the odd named out.
I tried casting to gst_base::BaseSink and getting the .stats property from that, but it did not work either.
Yeah this is actually a bug. You can’t access the basesink stats by property from srtsink / rtmp2sink because they’re both providing a new property with the same name, effectively overriding the one from basesink. Can you create a gitlab issue for that?
To access the basesink stats you should be able to do
let sink = sink.downcast_ref::<gst_base::BaseSink>().unwrap();
let stats = sink.stats(); // calls gst_base_sink_get_stats() directly instead of going via the property
Also unrelated, this is the same but shorter
let srt_sink_stats = element
- .property_value("stats")
- .get::<gst::Structure>().unwrap();
+ .property::<gst::Structure>("stats");
let sink = sink.downcast_ref::<gst_base::BaseSink>().unwrap();
let stats = sink.stats();
I did this, and get an error. will dig a bit and report back.
sorry I used downcast, not downcast_ref.
Although neither seem t work.
My deps are
gst = { package = “gstreamer”, version = “0.22.4” }
gst-base = { package = “gstreamer-base”, version = “0.22.0” }
gst-video = { package = “gstreamer-video”, version = “0.22.4” }
gst-app = { package = “gstreamer-app”, version = “0.22.0” }
in my test base it is not compiling using stats property. And getting the stats via the glip property grabber gives me the same one as on the Rtmp2Sink (and SrtSink)