Skip to content

How to create NULL? #343

@chfritz

Description

@chfritz

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).)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions