Brodcast WebRTC transport to RTP

I’m trying to use mediasoup to expose WebRTCTransport over RTP.

The idea is to be able to stream from a web app with WebRTC to RTP which can be sent to AWS MediaLive.

For now, I have my WebRTC producer which I send to a plainRTC endpoint as follow.

app.post('/produce', async (req: $Request, res: $Response) => {
    const { kind, rtpParameters } = req.body;
    const producer = await webrtcTransport.produce({ kind, rtpParameters});

    const rtpTransport = await router.createPlainTransport({ 
      listenIp: '127.0.0.1',
      rtcpMux: true,
      multiSource: false,
      comedia: true,
    });

    console.log({ tuple: rtpTransport.tuple });

    await rtpTransport.enableTraceEvent([ 'probation' ]);

    rtpTransport.on('trace', (trace) => {
      console.log('trace', trace);
    });
    rtpTransport.on('tuple', (tuple) => {
      console.log('tuple', tuple);
    });
    rtpTransport.on('rtcptuple', (rtcptuple) => {
      console.log('rtcptuple', rtcptuple);
    });

    rtpTransport.consume({
      producerId: producer.id,
      rtpCapabilities: router.rtpCapabilities
    });

    res.json({ id: producer.id });
  });

Unfortunately, this doesn’t seem to work. I don’t know how to test, but I tried to use VLC to connect to udp stream with the form udp://127.0.0.1:${rtpTransport.tuple.port}

Why are you using comedia:true? Please, read the docs.

Thanks for your quick reply.

I’ve read the doc, but there is a lot to digest here. I just started last week on mediasooup.

From the doc it’s stated in connect

  • If comedia is enabled in this plain transport and SRTP is not, connect must not be called.

I also tried without comedia but connect requires ip & port which I don’t know because I’d like to just consume rtp stream. Maybe I don’t have the correct representation of rtp, might not be just a pull request as you would do with http :thinking:

Ask yourself: how is mediasoup supposed to know where to send the RTP if you tell nothing to it?

It’s not possible for the client to get the RTP stream, i.e. connect to it?

So RTP is a protocol only between server? Each side expose an endpoint and they communicate by sending requests to each side exposed port?

I cannot explain here how RTP protocol works (no matter how you would like it to be), sorry. The docs are clear: don’t use comedia mode if the remote endpoint just wishes to consume RTP. You need to provide the PlainTransport.connect() method with the remote endpoint’s IP and port in which it wishes to receive RTP.

Thanks, I think I need to dig deeper. Will update the thread if I manage to make it work