Set SSRC in consumer of PlainRTP transport

From what I see the SSRC is randomly generated by mediasoup when creating a plainRTPtransport consumer. Is there a way to set it to a different value?

No, there is not.

If you need it for something, please clarify why and, if it makes sense, we’ll add an API option for that.

Connecting two mediasoups together. Ideally with SRTP :smiley:

If you check how router.pipeToRouter() method is internally implemented, it does not need to decide the SSRC of the consumers, so the same is possible when interconnecting two routers in different hosts:

  1. Have router_1 in worker_1 in host_1.
  2. Have router_2 in worker_2 in host_2.
  3. Create pipeTransport_1 in router_1.
  4. Create pipeTransport_2 in router_2.
  5. Connect them by exchanging their binding IP and port and call connect() with them in each side.
  6. Create webRtcTransport_1 in router_1.
  7. Create producer_1 in webRtcTransport_1.
  8. Call pipeTransport_1.consume({ producerId: }) => consumer_1.
  9. Get consumer_1.rtpParameters and exchange them with router_2 (in host_2).
  10. Create producer_2 in pipeTransport_2 by passing those consumer_1.rtpParameters to pipeTransport_2.produce().
  11. Also exchange consumer_1 events to producer_1 via signalling.
  12. Then consume in router_2 from producer_2.

So, in step 9-10 you can see that the SSRC already exists in the consumer_1.rtpParameters. There is no need for the application to set the consumer SSRC.


Since it’s possible to produce and consume RTP from mediasoup, I tried to connect the two mediasoups via the plain RTP transports, not the pipe to router. Which I was able to do, the only problem being mediasoup complaining about not matching the producer because of the unknown SSRC.

Definitely you need to use a PipeTransport (and not a PlainRtpTransport) to intercommunicate Routers, no matter that happens in the same host (so you can use router.pipeToRouter() method) or between different hosts (in that case you need to implement your own logic that must behave similar to pipeTpRouter() as I explained in my previous response). There is an obvious reason for using PipeTransport to achieve that, as explained in the doc:

Please don’t assume you need to set the Consumer SSRC due to that error. You are doing something wrong in your code. Please try to follow the steps I said before and check the pipeToRouter() code to implement something similar that connects routers in different hosts.

OK, just tried the pipe transport and that worked as described. Thank you!

There’s just one thing that I believe is misleading:

Step 6 I believe should be “Create producer_1 in router_1”

Not exactly. Producers are created on a transport, and not directly in a Router. I’ve fixed steps 6 and 7 above.