Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create NULL? #343

Open
chfritz opened this issue Mar 3, 2023 · 1 comment
Open

How to create NULL? #343

chfritz opened this issue Mar 3, 2023 · 1 comment

Comments

@chfritz
Copy link
Contributor

chfritz commented Mar 3, 2023

I've found in various situations the need to pass NULL as a parameter but wasn't able to create it, e.g., to call https://gstreamer.freedesktop.org/documentation/webrtc/index.html?gi-language=javascript#webrtcbin::get-stats with a NULL pad. I've tried null but get:

TypeError: Cannot convert value "null" to type GstPad

If I try new Gst.Pad(null) instead I get:

** (node:10962): CRITICAL **: 12:35:13.471: gst_webrtc_bin_get_stats: assertion 'pad == NULL || GST_IS_WEBRTC_BIN_PAD (pad)' failed

So for some reason null in JS is not translated to NULL in C.

What's the correct way to set a parameter when the C documentation of the gtk method requires NULL?

Minimal example:

const gi = require('node-gtk');
const Gst = gi.require('Gst', '1.0');
const GObject = gi.require('GObject');
const GstWebRTC = gi.require('GstWebRTC');

gi.startLoop();
Gst.init();

const p = Gst.parseLaunch('fakesrc ! webrtcbin name=webrtc');
const w = p.getByName('webrtc');
w.emit('get-stats', null, Gst.Promise.newWithChangeFunc((promise) => 
  console.log('got stats', promise)));
// Uncaught TypeError: Cannot convert value "null" to type GstPad

(Move here from #11 (comment).)

@romgrk
Copy link
Owner

romgrk commented Mar 10, 2023

I've been trying to find the typing annotations for that function but couldn't find them, Gst is a particular module.

I'm not sure if the annotations are wrong or if we should be allowing null in general for pointer types, but if it's the later then we'll need to update the conversion functions to accept null pointers:

But I don't have enough time to implement the changes myself these days. PR welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants