node-gtk icon indicating copy to clipboard operation
node-gtk copied to clipboard

Watching Gst Properties

Open Morpheus235 opened this issue 4 years ago • 6 comments

So I am currently trying out some Stuff using node-gtk. First of all thanks for this great piece of Software. While trying to build a simple SRT to RTMP Pipeline I tried using Gstreamers Property Watchers to watch the stats Property of srtsrc but i never get any notfications either on the bus or the Element itself. So far i tried using Element.addPropertyWatch and Element.notify with the matching Eventhandlers as .on and .connect handlers. None of these Methods seem to work, which is why I am asking here if someone could clarify if this is a Bug or just me doing it the wrong way. Also I tried with wildcard notifies ex. notify::*.

Example:

src.addPropertyNotifyWatch("stats", true)

src.on("notify::stats", (msg) => {
     console.log("updated")
})

bus.on("notify::stats", (msg) => {
      console.log("updated")
})

//or
src.notify("stats", ()=>{
            console.log("updated")
})

Morpheus235 avatar Feb 18 '21 10:02 Morpheus235

TBH I'm not familiar with the GStreamer API. Would you happen to have a C example that works? node-gtk adds a thin layer over the C calls so the translation is usually quite simple if I can see the C source.

romgrk avatar Feb 20 '21 11:02 romgrk

So I searched for a valid C example and found this gist: https://gist.github.com/tetkuz/a764b64adb52c47751b1c1114c503e15 I compiled it and it seems to be working fine. Also the related documentation entry of Gstreamer: https://gstreamer.freedesktop.org/documentation/gstreamer/gstelement.html#gst_element_add_property_notify_watch I hope this is helpful and I would be happy to help if needed.

Morpheus235 avatar Feb 22 '21 12:02 Morpheus235

Well I at least found a somewhat useful workaround. Instead of relying on Signals being emitted, I am just reading the stats property in a loop and at least get the Data that way. Now I just need to get around the concept of GObject Types and how they are connected using node-gtk but thats another Story.

Morpheus235 avatar Feb 23 '21 03:02 Morpheus235

So I tried to translate the example to javascript but I ran into issues with the gst-launch-1.0 command so I couldn't get very far -_-

One thing I notice though, the C example's code handles property-notify's here. It seems that the equivalent in our gstreamer example is here. IMHO with that you should have enough information to finish your implementation, if not please share your runnable example I can take a look.

And for GObjects & types, if you have any documentation requests please do so, I can write more docs about how things work in node-gtk.

romgrk avatar Mar 03 '21 09:03 romgrk

Yeah saw that the property change should be displayed in the Bus and I even added the needed Watchers but for some reason it is not being emitted in my use case. I omitted this from my first post as I simply forgot. Maybe because the stats Property of srtsrc is a GstStructure and Gstreamer doesnt emit the nested changes for these even though I also tried a deep Watch. The nesting looks kinda like this: srtsrc (GstElement) -> stats (GstStructure) -> callers (GValueArray) -> properties of Caller. Since you already mentioned it and since I am not really profound in using GObject libraries a Documentation regarding Data types of GObject and how to acess them in Javacript would really go a long way as a help on getting started.

Morpheus235 avatar Mar 03 '21 10:03 Morpheus235

I've added documentation here, when you take a look let me know if it's clear enough, I can elaborate more if needed.

As for the issue at hand, link a runnable example (repo or gist or whatever) so I can understand the issue more, I'll then be able to tell if there's something we can do on node-gtk side to make it work.

romgrk avatar Mar 04 '21 05:03 romgrk