]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/applehttpproto.c
h263dec: restore error concealment functionality after merge
[ffmpeg] / libavformat / applehttpproto.c
index 8218c0e05f195cb8c500c7db177c106a98b85155..8295ccc5f5ea6a0615512aa2d88ddd99270f59cf 100644 (file)
@@ -174,19 +174,25 @@ fail:
     return ret;
 }
 
+static int applehttp_close(URLContext *h)
+{
+    AppleHTTPContext *s = h->priv_data;
+
+    free_segment_list(s);
+    free_variant_list(s);
+    ffurl_close(s->seg_hd);
+    return 0;
+}
+
 static int applehttp_open(URLContext *h, const char *uri, int flags)
 {
-    AppleHTTPContext *s;
+    AppleHTTPContext *s = h->priv_data;
     int ret, i;
     const char *nested_url;
 
     if (flags & AVIO_FLAG_WRITE)
         return AVERROR(ENOSYS);
 
-    s = av_mallocz(sizeof(AppleHTTPContext));
-    if (!s)
-        return AVERROR(ENOMEM);
-    h->priv_data = s;
     h->is_streamed = 1;
 
     if (av_strstart(uri, "applehttp+", &nested_url)) {
@@ -229,7 +235,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags)
     return 0;
 
 fail:
-    av_free(s);
+    applehttp_close(h);
     return ret;
 }
 
@@ -287,21 +293,11 @@ retry:
     goto start;
 }
 
-static int applehttp_close(URLContext *h)
-{
-    AppleHTTPContext *s = h->priv_data;
-
-    free_segment_list(s);
-    free_variant_list(s);
-    ffurl_close(s->seg_hd);
-    av_free(s);
-    return 0;
-}
-
 URLProtocol ff_applehttp_protocol = {
-    .name      = "applehttp",
-    .url_open  = applehttp_open,
-    .url_read  = applehttp_read,
-    .url_close = applehttp_close,
-    .flags     = URL_PROTOCOL_FLAG_NESTED_SCHEME,
+    .name           = "applehttp",
+    .url_open       = applehttp_open,
+    .url_read       = applehttp_read,
+    .url_close      = applehttp_close,
+    .flags          = URL_PROTOCOL_FLAG_NESTED_SCHEME,
+    .priv_data_size = sizeof(AppleHTTPContext),
 };