Hi, I’m working with WebRTC DataChannel for an application that performs reception and sending of data directly to/from the app itself, respectively. And found a bit of confusing lack of symmetry in DataProducer/DataConsumer features, so let me ask about it:
Lacks an event
DataProducer.on("message", fn(message, ppid))in SCTP transports. This could be useful to receive ingress data from a remote peer directly into the app. It would seem like there isn’t actually any technical reason to force it passing through the router towards a DataConsumer’s
"message"event, is it?
Has a method
DataProducer.send(message, ppid)in DirectTransports. Used to inject data from the app into the router.
Has an event
DataConsumer.on("message", fn(message, ppid))in DirectTransports. Used to extract data from the router into the app.
Also has a method
DataConsumer.send(message, ppid)in SCTP transports. Useful to send egress data from the app directly to a remote peer.
Either the existence of (4) or the lack of (1) is what confused me (and I bet more users). I think there’s no harm in having more options instead of less, so would it make sense to consider adding (1) as a feature?
Extra question: Given that DataConsumer has
DataConsumer.send(message, ppid) in SCTP transports, looks like it might make sense that it was able to work standalone and send data generated by the application, regardless of any DataProducer.
Would it make sense that mediasoup allowed just creating a DataConsumer without passing a DataProducer id (
DataConsumerOptions.dataProducerId)? After all, if the need is only to egress in-app-generated SCTP data, no DataProducer is needed at all. Otherwise, a dummy of fake one can always be created, I guess.