Question about one of the examples

Hi there,

in Example: Inject Audio and Video using FFmpeg, this logic is shown (not exact code, but same operations):

const transport = await router.createPlainTransport(
  { 
    ip       : '127.0.0.1',
    rtcpMux  : false,
    comedia  : true
  });
const rtpPort = transport.tuple.localPort;

(Note, it should read “router.createPlainRtpTransport()” and “listenIp” instead of “ip”, I’ve created a PR for these small typos: #6)

My doubt comes from the fact that PlainRtpTransport.tuple should not exist before calling PlainRtpTransport.connect(); docs say:

plainRtpTransport.tuple
The transport tuple. It’s set after calling connect() method (it’s undefined otherwise).

However, the linked example uses comedia, which forbids using connect():

comedia, Boolean, […] If enabled, connect() method must not be called.

Which brings me to this question: is the example valid at all?

Does the call await router.createPlainRtpTransport() only return after having actually received remote RTP packets (thus being able to obtain the remote IP address and port)? If not, I don’t see how the example would be correct, so I’d appreciate an explanation of how this works :slight_smile:

Hope this helps. I’ll also improve other parts of the API that you mentioned.

And this.

So, to confirm, going over my own question:

The correct answer would be no, it just returns whenever the PlainRtpTransport construction Promise returns, and then because comedia = true, PlainRtpTransport.tuple.local{IP,Port} will immediately be set, but PlainRtpTransport.tuple.remote{IP,Port} may be undefined for an unknown amount of time (basically until the remote peer starts sending RTCP packets and its IP address + port can be obtained)

Thank you for the clarifications

Better say RTP and, optionally, RTCP (if rtcpMux is not true).