Closed kirianguiller closed 7 months ago
You need to send RTP packets into the track, similarly to what the media example does but in the other direction. The SSRC of the RTP stream must match the SSRC in the video description. libdatachannel has such an example in C++.
Thanks. I've indeed studied the C++ example but didn't quite manage to make it works as I didn't succeed to bind an udp socket (with the node dgram library). I still don't have a working example to share to other people.
Listening on a UDP socket with node.js is quite straightforward, you can do it like this:
const server = dgram.createSocket('udp4');
server.on('error', (err) => {
console.error(err);
server.close();
});
server.on('message', (msg) => {
if (track.isOpen()) {
// Foward in track
track.sendMessageBinary(msg);
}
});
server.bind(6000);
Thank you. I will try something simple and suggest it in the examples of the project !
Sorry for the late arrival, I thought this would help you, this is the example I tested earlier, and so far it has worked
https://github.com/Canees/node-datachannel/blob/master/examples/media-send/peer-send/index.js
I am closing the issue. Feel free to open a new issue when you need to. Thanks.
Hi, I originally sent this message on the issue #122 , but it might never be seen as the issue is closed since long time.
I would like to send a video stream (from a go2rtc server) from a server (but more specifically a node-datachannel client) to another node-datachannel client. However, I don't understand how to send this stream.
In this issue #122, we can see that @Canees set the Video track on the server, but I don't understand how this track is reading from another source.
Here is the relevant code snippet from @Canees :
Is the
video.addSSRC
method responsible for this ? How does it works ? I don't see this method being tested in the tests files, neither do I see it in one of the 5 examples. Maybe this project could benefit by having an example showing how to use this library to send a video stream with datachannel. I would gladly help adding such an example once I will have figured how to make this works.Thanks a lot for your help !