What's the proper way to use `producer.send()`?

I was trying to do a setup where I did real-time analysis of RTP packets in call by putting a DirectTransport between two WebRTCTransports and echoing packets using consumer.on('rtp') and producer.send(). I couldn’t get this working, and ended up thinking that I had found a mediasoup bug, which I then fixed and pushed into this PR: https://github.com/versatica/mediasoup/pull/474.

The changes cause my code to work, but I’ve been informed that there was not actually a bug beforehand. This is completely possible as I’m not familiar with how DirectTransport send() and on('rtp') are supposed to be used. Does anyone know of any examples I could look at where these functions are used successfully? I know on('rtp') is firing, so it’s really a matter of how to use send().

For some additional context, when I run my application with the mediasoup debug flags on, I get a warning: “no suitable Producer for received RTP packet [ssrc: …, payloadType: …]”.

It was replied in the GitHub issue. Here the response:

  • Create a WebRTCTransport and connect to it with a client and produce, as usual and as documented. This creates a producer; we’ll call it producer1.
  • Create a DirectTransport, and use it to consume producer1, creating consumer1. Also create producer2 on the DirectTransport, using identical rtpParameters to producer1.

Well, that’s the problem. You are assuming that the rtpParameters of producer1 are the same as those in consumer1, and that’s not true at all. Check this:

The rtpParameters of consumer1 will have a single encodings with a random ssrc. So create producer2 with the real RTP parameters, this is, consumer1.rtpParameters.

Thanks so much! That makes sense. I’ve now hit another blocking point, though; when producer1 is a simulcast producer, then consumer1 will output a single encoding with a scalabilityMode, forcing producer2 to be an SVC producer. There doesn’t seem to be any codec that supports both simulcast and SVC (e.g. when I pick VP8 it says SVC is not supported, and when I pick VP9 it says simulcast is not supported). Is there any way of telling mediasoup to have the a simulcast producer keep its streams separate, for this kind of “forwarding” use case? Alternatively, is there a codec that we support with both simulcast and SVC?

I assume this must be possible to do, since mediasoup is designed to be able to do things like forward packets through PipeTransports between multiple mediasoup servers.

Actually, since this is a new question unrelated to the thread title, I’ll make a new topic.

Yes, please, create another topic.