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

Martin Storsjö martin
Wed Feb 10 21:58:35 CET 2010


Hi,

The current code for receiving RTP/UDP streams doesn't work too well if 
the receiver is behind NAT (unless the NAT inspects the RTSP setup 
conversation and sets up forwarding for those ports).

Other players (such as RealPlayer on Symbian S60) handles this by sending 
one dummy packet on each UDP port when starting the stream, in order to 
set up proper forwarding rules in the NAT.

The attached patch implements something similar, for our RTSP demuxer. 
(I guess the same could be applied to the SDP demuxer, too.)

(When the RTSP muxer gets merged, the added line in rtsp.c in this patch 
needs an "if (!rt->is_output)" prepended.)

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 this sound like an acceptable approach, or is it considered violating 
the specifications?

// Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rtp-udp-nat-punching.patch
Type: text/x-diff
Size: 2828 bytes
Desc: 
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100210/7fcf02d1/attachment.patch>



More information about the ffmpeg-devel mailing list