]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/udp.c
porting optimizations from 4x4 dct to 8x8
[ffmpeg] / libavformat / udp.c
index 3d159ef4f803435546f64ae6cabcdc3d2c352d26..0ba76fa141e2c6aeef67be7ab0b1972d5a28b1f4 100644 (file)
@@ -48,6 +48,7 @@ typedef struct {
  * option: 'multicast=1' : enable multicast 
  *         'ttl=n'       : set the ttl value (for multicast only)
  *         'localport=n' : set the local port
+ *         'pkt_size=n'  : set max packet size
  *
  * @param s1 media file context
  * @param uri of the remote server
@@ -59,11 +60,11 @@ int udp_set_remote_url(URLContext *h, const char *uri)
     char hostname[256];
     int port;
     
-    url_split(NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
+    url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
 
     /* set the destination address */
     if (resolve_host(&s->dest_addr.sin_addr, hostname) < 0)
-        return -EIO;
+        return AVERROR_IO;
     s->dest_addr.sin_family = AF_INET;
     s->dest_addr.sin_port = htons(port);
     return 0;
@@ -104,6 +105,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
     char buf[256];
 
     h->is_streamed = 1;
+    h->max_packet_size = 1472;
 
     is_output = (flags & URL_WRONLY);
     
@@ -114,6 +116,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
     h->priv_data = s;
     s->ttl = 16;
     s->is_multicast = 0;
+    s->local_port = 0;
     p = strchr(uri, '?');
     if (p) {
         s->is_multicast = find_info_tag(buf, sizeof(buf), "multicast", p);
@@ -123,10 +126,13 @@ static int udp_open(URLContext *h, const char *uri, int flags)
         if (find_info_tag(buf, sizeof(buf), "localport", p)) {
             s->local_port = strtol(buf, NULL, 10);
         }
+        if (find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
+            h->max_packet_size = strtol(buf, NULL, 10);
+        }
     }
 
     /* fill the dest addr */
-    url_split(NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
+    url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
     
     /* XXX: fix url_split */
     if (hostname[0] == '\0' || hostname[0] == '?') {
@@ -191,7 +197,6 @@ static int udp_open(URLContext *h, const char *uri, int flags)
     }
 
     s->udp_fd = udp_fd;
-    h->max_packet_size = 1472; /* XXX: probe it ? */
     return 0;
  fail:
     if (udp_fd >= 0)
@@ -201,10 +206,10 @@ static int udp_open(URLContext *h, const char *uri, int flags)
         close(udp_fd);
 #endif
     av_free(s);
-    return -EIO;
+    return AVERROR_IO;
 }
 
-static int udp_read(URLContext *h, UINT8 *buf, int size)
+static int udp_read(URLContext *h, uint8_t *buf, int size)
 {
     UDPContext *s = h->priv_data;
     struct sockaddr_in from;
@@ -216,7 +221,7 @@ static int udp_read(URLContext *h, UINT8 *buf, int size)
                         (struct sockaddr *)&from, &from_len);
         if (len < 0) {
             if (errno != EAGAIN && errno != EINTR)
-                return -EIO;
+                return AVERROR_IO;
         } else {
             break;
         }
@@ -224,7 +229,7 @@ static int udp_read(URLContext *h, UINT8 *buf, int size)
     return len;
 }
 
-static int udp_write(URLContext *h, UINT8 *buf, int size)
+static int udp_write(URLContext *h, uint8_t *buf, int size)
 {
     UDPContext *s = h->priv_data;
     int ret;
@@ -235,7 +240,7 @@ static int udp_write(URLContext *h, UINT8 *buf, int size)
                       sizeof (s->dest_addr));
         if (ret < 0) {
             if (errno != EINTR && errno != EAGAIN)
-                return -EIO;
+                return AVERROR_IO;
         } else {
             break;
         }