Hello everyone,
I’m trying to establish an SDP connection using webrtcbin in Node.js
When I call create-offer to create an SDP, I always got NULL
I refer to this article: Nirbheek’s Rantings: GStreamer has grown a WebRTC implementation
Min code snippet:
import * as gi from 'node-gtk';
(async () => {
const Gst = gi.require('Gst');
gi.startLoop();
Gst.init(null);
const pipeline = Gst.parseLaunch(`
webrtcbin name=src
src. ! queue ! decodebin ! videoconvert ! autovideosink
src. ! queue ! decodebin ! audioconvert ! autoaudiosink
`);
const webrtcbin = pipeline.getByName('src');
webrtcbin.on('on-negotiation-needed', () => {
console.log('🌟 Negotiation needed');
webrtcbin.emit(
'create-offer',
new Gst.Structure('NULL'),
Gst.Promise.newWithChangeFunc((promise) => {
promise.wait();
const reply = promise.getReply();
console.log('🌟 Sending SDP Offer');
console.log(reply.toString());
promise.interrupt();
}),
);
});
console.log('🚀 Setting pipeline state to PLAYING');
pipeline.setState(Gst.State.PLAYING);
await new Promise((resolve) => setTimeout(resolve, 20000));
console.log('🛑 Setting pipeline state to NULL');
pipeline.setState(Gst.State.NULL);
})();
Execution Results
🚀 Setting pipeline state to PLAYING
🌟 Negotiation needed
🌟 Sending SDP Offer
0:00:00.045074285 265189 0x33b9e990 WARN structure gststructure.c:2099:priv_gst_structure_append_to_gstring: No value transform to serialize field 'offer' of type 'GstWebRTCSessionDescription'
application/x-gst-promise, offer=(GstWebRTCSessionDescription)NULL;
🛑 Setting pipeline state to NULL
Why I cannot create SDP offer?
Any insights or suggestions would be greatly appreciated! Thank you in advance.