diff avio.c @ 6161:f7090c70ed34 libavformat

Add priv_data_size and priv_data_class to URLProtocol This allows url_alloc to allocate and initialize the priv_data.
author mstorsjo
date Tue, 22 Jun 2010 14:09:08 +0000
parents 1b4be334ef89
children 47456957844f
line wrap: on
line diff
--- a/avio.c	Tue Jun 22 14:03:37 2010 +0000
+++ b/avio.c	Tue Jun 22 14:09:08 2010 +0000
@@ -118,6 +118,13 @@
     uc->flags = flags;
     uc->is_streamed = 0; /* default = not streamed */
     uc->max_packet_size = 0; /* default: stream file */
+    if (up->priv_data_size) {
+        uc->priv_data = av_mallocz(up->priv_data_size);
+        if (up->priv_data_class) {
+            *(AVClass**)uc->priv_data = up->priv_data_class;
+            av_opt_set_defaults(uc->priv_data);
+        }
+    }
 
     *puc = uc;
     return 0;
@@ -272,6 +279,8 @@
 #if CONFIG_NETWORK
     ff_network_close();
 #endif
+    if (h->prot->priv_data_size)
+        av_free(h->priv_data);
     av_free(h);
     return ret;
 }