[FFmpeg-devel] [PATCH] Send NAT punching packets when starting to read an RTP/UDP stream

Martin Storsjö martin
Thu Feb 11 09:43:53 CET 2010


On Wed, 10 Feb 2010, Ronald S. Bultje wrote:

> On Wed, Feb 10, 2010 at 3:58 PM, Martin Storsj? <martin at martin.st> wrote:
> > The dummy packets sent from RealPlayer on Symbian are empty RTCP receiver
> > reports (sent on both the RTP and RTCP ports), but due to the nature of
> > the RTP protocol in libavformat, we can't force an RTCP packet on the RTP
> > port, so instead I chose to send a minimal RTP packet with no payload
> > content.
> Does that work? I.e. have you tested that it still "fixes" the problem?

Yes, without this, I can't watch RTSP/RTP streams if behind a NAT, unless 
I add ?tcp at the end. With this patch, I can watch them without adding 
anything (and also if I specifically add ?udp).

> Also, the code should probably remain in rtsp.c, or at least add some
> comment that it's used for RDT as well.

I preferred to keep it in rtpdec.c, since I don't think the internal 
structure of RTP/RTCP packets shouldn't be visible in RTSP. Good point 
about RDT, though, I'll add a comment about that.

I don't really know anything about RDT - are RTCP packets used at all? If 
not, we probably should skip sending punch packets for RTCP...

> +    if (url_open_dyn_buf(&pb) < 0)
> +        return;
> Since you know the size in advance, you can use url_open_dyn_packet_buf().

Yes, but that doesn't really give any advantage, other than allocating a 
smaller buffer than what url_open_dyn_buf does (which is 1024 bytes). And 
instead, I'd have to skip over the first 4 bytes of the written data, that 
contains the payload length. But if you feel this is better, I'll change 
it. (url_open_dyn_buf is used in the same way in 
rtp_check_and_send_back_rr, btw, where the size is also known in advance.)

// Martin

More information about the ffmpeg-devel mailing list