Data binaries exchange via webRTC datachannels is a feature??

Hello,

I need to send a volumetric video as binary via webRTC datachannel. I try it with another webRTC library but I would like to try with mediasoup. Datachannel text message is a feature, I have read in the documentation but binary exchange is a feature as well?

Thanks in advance and sorry for the initial questions, I am starting with this framework,

Beka

I have found this information in the documentation, sorry.

  • Just use router.createDirectTransport() to create a DirectTransport and then create use directTransport.consumeData() on it to create a DataConsumer that will receive the data messages sent by WebRTC endpoints.
  • The new dataConsumer.on('message') event will trigger with those received messages so the Node.js application can handle them.
  • In the other direction, use directTransport.produceData() to create a DataProducer in Node.js and make the WebRTC peers consume it as usual.
  • Then use dataProducer.send() method to send text or binary messages to them.

There is also daraConsumer.send() for WebRTC based DataConsumers which is more optimal. It’s documented in the API section.

Thanks

What’s the difference between DataProducer.send() and DataConsumer.send()? Why latest is more optimal?

In a DataConsumer created on a WebRtcTransport you can directly call send() which means no need to send the data through a DataProducer first.

1 Like

Will need to read source code to understand it better, but thank you anyway :slight_smile: