]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/http.c
Remove static function name prefixes from American Laser Games MM demuxer
[ffmpeg] / libavformat / http.c
index a404ff3df062174447b779029805a609ef0eddf6..feeba5f6ecf01dade19dd5c92e376ab5d8defe66 100644 (file)
@@ -69,17 +69,13 @@ static int http_open_cnx(URLContext *h)
     /* fill the dest addr */
  redo:
     /* needed in any case to build the host string */
-    url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
-              path1, sizeof(path1), s->location);
-    if (port > 0) {
-        snprintf(hoststr, sizeof(hoststr), "%s:%d", hostname, port);
-    } else {
-        av_strlcpy(hoststr, hostname, sizeof(hoststr));
-    }
+    ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
+                 path1, sizeof(path1), s->location);
+    ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
 
     if (use_proxy) {
-        url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
-                  NULL, 0, proxy_path);
+        ff_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
+                     NULL, 0, proxy_path);
         path = s->location;
     } else {
         if (path1[0] == '\0')
@@ -90,7 +86,7 @@ static int http_open_cnx(URLContext *h)
     if (port < 0)
         port = 80;
 
-    snprintf(buf, sizeof(buf), "tcp://%s:%d", hostname, port);
+    ff_url_join(buf, sizeof(buf), "tcp", NULL, hostname, port, NULL);
     err = url_open(&hd, buf, URL_RDWR);
     if (err < 0)
         goto fail;
@@ -394,6 +390,8 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
     HTTPContext *s = h->priv_data;
     URLContext *old_hd = s->hd;
     int64_t old_off = s->off;
+    uint8_t old_buf[BUFFER_SIZE];
+    int old_buf_size;
 
     if (whence == AVSEEK_SIZE)
         return s->filesize;
@@ -401,6 +399,8 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
         return -1;
 
     /* we save the old context in case the seek fails */
+    old_buf_size = s->buf_end - s->buf_ptr;
+    memcpy(old_buf, s->buf_ptr, old_buf_size);
     s->hd = NULL;
     if (whence == SEEK_CUR)
         off += s->off;
@@ -410,6 +410,9 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
 
     /* if it fails, continue on old connection */
     if (http_open_cnx(h) < 0) {
+        memcpy(s->buffer, old_buf, old_buf_size);
+        s->buf_ptr = s->buffer;
+        s->buf_end = s->buffer + old_buf_size;
         s->hd = old_hd;
         s->off = old_off;
         return -1;