summaryrefslogtreecommitdiff
path: root/libavformat/udp.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2011-01-06 15:16:50 +0000
committerMartin Storsjö <martin@martin.st>2011-01-06 15:16:50 +0000
commit21a569f3022e968d74bfde4d1bfff8dab5edd41c (patch)
tree6c8e48febc3977bd1665015b6d8d90a3c79db25f /libavformat/udp.c
parentbabd19ce2e38446cdabe0f648c6189c7f1dc7378 (diff)
udp: Allow specifying the connect option in udp_set_remote_url, too
If the remote address is updated later with this function, the caller shouldn't set the connect option until in this call. Originally committed as revision 26245 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/udp.c')
-rw-r--r--libavformat/udp.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/libavformat/udp.c b/libavformat/udp.c
index b998086407..0b62c6da2d 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -245,8 +245,9 @@ static int udp_port(struct sockaddr_storage *addr, int addr_len)
int udp_set_remote_url(URLContext *h, const char *uri)
{
UDPContext *s = h->priv_data;
- char hostname[256];
+ char hostname[256], buf[10];
int port;
+ const char *p;
av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
@@ -256,6 +257,21 @@ int udp_set_remote_url(URLContext *h, const char *uri)
return AVERROR(EIO);
}
s->is_multicast = ff_is_multicast_address((struct sockaddr*) &s->dest_addr);
+ p = strchr(uri, '?');
+ if (p) {
+ if (find_info_tag(buf, sizeof(buf), "connect", p)) {
+ int was_connected = s->is_connected;
+ s->is_connected = strtol(buf, NULL, 10);
+ if (s->is_connected && !was_connected) {
+ if (connect(s->udp_fd, (struct sockaddr *) &s->dest_addr,
+ s->dest_addr_len)) {
+ s->is_connected = 0;
+ av_log(NULL, AV_LOG_ERROR, "connect: %s\n", strerror(errno));
+ return AVERROR(EIO);
+ }
+ }
+ }
+ }
return 0;
}