-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Feature Request (more like a feedback request)
Protoype: ggarber@14a3ba0
Some use cases require custom processing of Media and Data packets and because of the performance implications it is not always possible to forward to those packets in real time from C++ to JS and then back from JS to C++ using DirectTransport capability.
Some examples of those use cases could be:
- Store RTP packets for all the producers in some pcap like format like Janus MJR format.
- Implement a custom datachannels protocol where the destination of each message is included in the message itself.
Nowadays the solution in these cases is to use an additional server and forward those messages from mediasoup to this server but that adds some extra complexity in terms of orchestration and also maintaining that additional server. The other solution today is to use Rust instead of JS library but that's not an option for all the teams.
The alternative is to provide support to extend mediasoup C++ layer with some custom code (let's call it plugins for now) so that developers can extend the standard capabilities of mediasoup with their use case specific logic.
The main components of that approach would be:
A) The API exposed by mediasoup to those plugins.
B) How those plugins are loaded.
API exposed to those plugins
It needs to be a mix of methods and events.
Methods: Initially all the public interface of mediasoup objects (Transports, Consumers, Producers... ) could be used from plugins but some interfaces could be extracted (TransportApi, ConsumerApi, ProducerApi...) so that plugins don't see the whole interface.
Events: mediasoup needs to expose a mechanism for plugins to listen for events. This can be in the form of events that plugins can be attached for (see prototype).
Loading of plugins
There are different alternatives:
- Fork mediasoup and add plugins to the repository. This is far from ideal but a potential solution for the short term and initial development and testing of the API.
- Use mediasoup as a library and generate your own mediasoup worker binary with that library and their own plugins. This looks too complex for most of developers but maybe it is reasonable in some cases.
- Add some simple dynamic loading capabilities. Mediasoup JS API could add a method
worker.loadPlugins('xxxx.so', 'yyyy.so')
.