🎥 Improve Media Support: Add Polyfill for Audio/Video Transmission
Hello,
First of all, I really appreciate the effort put into node-datachannel. It’s a great library for WebRTC applications in Node.js, and I’d love to see its capabilities expand further.
Currently, there is a limitation in handling media streams (audio/video) due to missing support for key WebRTC functionalities. While data channels work well, certain media-related methods are either unavailable or not fully functional.
Missing Media Features: ontrack, addTransceiver, replaceTrack , stop, etc...
Proposed Enhancements: Implement Polyfill for Media Transmission – Support essential WebRTC APIs such as ontrack, addTransceiver, replaceTrack, and stop. FFmpeg Integration (if needed) – A built-in bridge or helper function to encode/decode media streams efficiently. Middleware or Helper Functions – If full WebRTC API support is difficult to achieve, consider exposing helper functions to allow developers to process media streams externally (e.g., via FFmpeg).
Expanding node-datachannel to support media properly would make it the go-to library for WebRTC in Node.js, filling a major gap left by old wrtc library. This would unlock real-time VoIP, video conferencing, and live streaming capabilities with a stable, well-maintained library.
Thank you again for your hard work!
Hello @Aviv1000,
Thank you for sharing your thoughts/suggestions. I totally agree with what you have written. Also, I have in mind that media streams need to be supported more.
The problem is, as always, time. I am working and have a family, etc.
Despite these things, it is achievable. The hardest step is the first step, I need some free days to set up/structure and write down what we have and what we need. In the coming months, we will see.
On the other hand, there is still too much work for polyfills. Especially web tests.
I will welcome all efforts about these subjects.
Yes, things can take time and its really challenge part.
In the meantime, I’ve been reviewing code from various sources discussing media integration with node-datachannel. one of them: https://github.com/Canees/node-datachannel/blob/master/examples/media-send/peer-send/index.js
Before diving into the polyfill part, let’s first define what’s missing at a basic level:
event trigger when receiving video/audio – The receiving peer has no way of detecting an incoming media stream, making it impossible to determine which decoder to use. Typically, WebRTC relies on the ontrack event for this.
many codec support – only work by add H.264 manually using video.addH264Codec(97), no built-in support for broader codec negotiation. WebRTC typically handles codec selection dynamically based on what both peers support.
Stopping tracks handled – clean way to stop and remove media tracks