diff options
author | Martin Storsjö <martin@martin.st> | 2011-01-06 15:16:09 +0000 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2011-01-06 15:16:09 +0000 |
commit | babd19ce2e38446cdabe0f648c6189c7f1dc7378 (patch) | |
tree | bc380c41bb27680d395c228d433574756df74ad9 /libavformat | |
parent | 1ba44140a3169868eb94e62888d8d2f9861968ab (diff) | |
download | ffmpeg-babd19ce2e38446cdabe0f648c6189c7f1dc7378.tar.gz |
rtpproto: Allow specifying the connect option, passed through to udp
By calling connect on the UDP socket, only packets from the chosen
peer address and port are received on the socket. This is one
solution to issue 1688.
Originally committed as revision 26244 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat')
-rw-r--r-- | libavformat/rtpproto.c | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c index 70ed84cec3..0e2abf556b 100644 --- a/libavformat/rtpproto.c +++ b/libavformat/rtpproto.c @@ -101,7 +101,7 @@ static void url_add_option(char *buf, int buf_size, const char *fmt, ...) static void build_udp_url(char *buf, int buf_size, const char *hostname, int port, int local_port, int ttl, - int max_packet_size) + int max_packet_size, int connect) { ff_url_join(buf, buf_size, "udp", NULL, hostname, port, NULL); if (local_port >= 0) @@ -110,6 +110,8 @@ static void build_udp_url(char *buf, int buf_size, url_add_option(buf, buf_size, "ttl=%d", ttl); if (max_packet_size >=0) url_add_option(buf, buf_size, "pkt_size=%d", max_packet_size); + if (connect) + url_add_option(buf, buf_size, "connect=1"); } /** @@ -119,6 +121,7 @@ static void build_udp_url(char *buf, int buf_size, * 'localrtpport=n' : set the local rtp port to n * 'localrtcpport=n' : set the local rtcp port to n * 'pkt_size=n' : set max packet size + * 'connect=0/1' : do a connect() on the UDP socket * deprecated option: * 'localport=n' : set the local port to n * @@ -132,7 +135,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) { RTPContext *s; int rtp_port, rtcp_port, - is_output, ttl, + is_output, ttl, connect, local_rtp_port, local_rtcp_port, max_packet_size; char hostname[256]; char buf[1024]; @@ -154,6 +157,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags) local_rtp_port = -1; local_rtcp_port = -1; max_packet_size = -1; + connect = 0; p = strchr(uri, '?'); if (p) { @@ -175,17 +179,22 @@ static int rtp_open(URLContext *h, const char *uri, int flags) if (find_info_tag(buf, sizeof(buf), "pkt_size", p)) { max_packet_size = strtol(buf, NULL, 10); } + if (find_info_tag(buf, sizeof(buf), "connect", p)) { + connect = strtol(buf, NULL, 10); + } } build_udp_url(buf, sizeof(buf), - hostname, rtp_port, local_rtp_port, ttl, max_packet_size); + hostname, rtp_port, local_rtp_port, ttl, max_packet_size, + connect); if (url_open(&s->rtp_hd, buf, flags) < 0) goto fail; if (local_rtp_port>=0 && local_rtcp_port<0) local_rtcp_port = udp_get_local_port(s->rtp_hd) + 1; build_udp_url(buf, sizeof(buf), - hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size); + hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size, + connect); if (url_open(&s->rtcp_hd, buf, flags) < 0) goto fail; |