summaryrefslogtreecommitdiff
path: root/libavformat/udp.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-10 03:09:46 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-10 03:45:23 +0100
commitafc0a24d7d60f855676d8069011624d52361d7ed (patch)
tree5480e1c0a3f177805d9a2a85321117a94a2bf878 /libavformat/udp.c
parentdec354ba1dcc3c7858277d30c73dac030e2a441e (diff)
parentf1f6d3615f3f9a81f41905ea0c8116b4985870e4 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: avcodec: add support for planar signed 8-bit PCM. ra144enc: add sample_fmts list to ff_ra_144_encoder smackaud: use uint8_t* for 8-bit output buffer type smackaud: clip output samples smackaud: use sign_extend() for difference value instead of casting sipr: use a function pointer to select the decode_frame function sipr: set mode based on block_align instead of bit_rate sipr: do not needlessly set *data_size to 0 when returning an error ra288: fix formatting of LOCAL_ALIGNED_16 udp: Allow specifying the local IP address VC1: Add bottom field offset to block_index[] to avoid rewriting (+10L) vc1dec: move an if() block. vc1dec: use correct hybrid prediction threshold. vc1dec: Partial rewrite of vc1_pred_mv() vc1dec: take ME precision into account while scaling MV predictors. lavf: don't leak corrupted packets Conflicts: libavcodec/8svx.c libavcodec/ra288.c libavcodec/version.h libavformat/iff.c libavformat/udp.c libavformat/utils.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/udp.c')
-rw-r--r--libavformat/udp.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/libavformat/udp.c b/libavformat/udp.c
index dd80bb0e89..170f132190 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -31,6 +31,7 @@
#include "libavutil/parseutils.h"
#include "libavutil/fifo.h"
#include "libavutil/intreadwrite.h"
+#include "libavutil/avstring.h"
#include <unistd.h>
#include "internal.h"
#include "network.h"
@@ -195,8 +196,8 @@ static int udp_set_url(struct sockaddr_storage *addr,
return addr_len;
}
-static int udp_socket_create(UDPContext *s,
- struct sockaddr_storage *addr, int *addr_len)
+static int udp_socket_create(UDPContext *s, struct sockaddr_storage *addr,
+ int *addr_len, const char *localaddr)
{
int udp_fd = -1;
struct addrinfo *res0 = NULL, *res = NULL;
@@ -204,7 +205,8 @@ static int udp_socket_create(UDPContext *s,
if (((struct sockaddr *) &s->dest_addr)->sa_family)
family = ((struct sockaddr *) &s->dest_addr)->sa_family;
- res0 = udp_resolve_host(0, s->local_port, SOCK_DGRAM, family, AI_PASSIVE);
+ res0 = udp_resolve_host(localaddr[0] ? localaddr : NULL, s->local_port,
+ SOCK_DGRAM, family, AI_PASSIVE);
if (res0 == 0)
goto fail;
for (res = res0; res; res=res->ai_next) {
@@ -377,7 +379,7 @@ static void *circular_buffer_task( void *_URLContext)
/* return non zero if error */
static int udp_open(URLContext *h, const char *uri, int flags)
{
- char hostname[1024];
+ char hostname[1024], localaddr[1024] = "";
int port, udp_fd = -1, tmp, bind_ret = -1;
UDPContext *s = NULL;
int is_output;
@@ -430,6 +432,9 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
s->circular_buffer_size = strtol(buf, NULL, 10)*188;
}
+ if (av_find_info_tag(buf, sizeof(buf), "localaddr", p)) {
+ av_strlcpy(localaddr, buf, sizeof(localaddr));
+ }
}
/* fill the dest addr */
@@ -447,7 +452,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if ((s->is_multicast || !s->local_port) && (h->flags & AVIO_FLAG_READ))
s->local_port = port;
- udp_fd = udp_socket_create(s, &my_addr, &len);
+ udp_fd = udp_socket_create(s, &my_addr, &len, localaddr);
if (udp_fd < 0)
goto fail;