diff options
author | Martin Storsjö <martin@martin.st> | 2010-02-16 22:50:50 +0000 |
---|---|---|
committer | Ronald S. Bultje <rsbultje@gmail.com> | 2010-02-16 22:50:50 +0000 |
commit | 9c8fa20d7e60760f117c2123a51137db1ac91682 (patch) | |
tree | 1167eca1e68c73f232872ebab1f925d4e0b673e7 /libavformat/rtpdec.c | |
parent | fe74099aee7b2c4f918194c4ed560e244677df7a (diff) | |
download | ffmpeg-9c8fa20d7e60760f117c2123a51137db1ac91682.tar.gz |
When using RTP-over-UDP, send dummy packets during stream setup, similar to
what e.g. RealPlayer does. This allows proper port forwarding setup in NAT-
based environments.
Patch by Martin Storsjö <$firstname at $firstname dot st>.
Originally committed as revision 21856 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/rtpdec.c')
-rw-r--r-- | libavformat/rtpdec.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 80b576c28a..dfc5b0b482 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -273,6 +273,45 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count) return 0; } +void rtp_send_punch_packets(URLContext* rtp_handle) +{ + ByteIOContext *pb; + uint8_t *buf; + int len; + + /* Send a small RTP packet */ + if (url_open_dyn_buf(&pb) < 0) + return; + + put_byte(pb, (RTP_VERSION << 6)); + put_byte(pb, 0); /* Payload type */ + put_be16(pb, 0); /* Seq */ + put_be32(pb, 0); /* Timestamp */ + put_be32(pb, 0); /* SSRC */ + + put_flush_packet(pb); + len = url_close_dyn_buf(pb, &buf); + if ((len > 0) && buf) + url_write(rtp_handle, buf, len); + av_free(buf); + + /* Send a minimal RTCP RR */ + if (url_open_dyn_buf(&pb) < 0) + return; + + put_byte(pb, (RTP_VERSION << 6)); + put_byte(pb, 201); /* receiver report */ + put_be16(pb, 1); /* length in words - 1 */ + put_be32(pb, 0); /* our own SSRC */ + + put_flush_packet(pb); + len = url_close_dyn_buf(pb, &buf); + if ((len > 0) && buf) + url_write(rtp_handle, buf, len); + av_free(buf); +} + + /** * open a new RTP parse context for stream 'st'. 'st' can be NULL for * MPEG2TS streams to indicate that they should be demuxed inside the |