Browse code

Add priv_data_size and priv_data_class to URLProtocol

This allows url_alloc to allocate and initialize the priv_data.

Originally committed as revision 23706 to svn://svn.ffmpeg.org/ffmpeg/trunk

Martin Storsjö authored on 2010/06/22 23:09:08
Showing 3 changed files
... ...
@@ -22,7 +22,7 @@
22 22
 #define AVFORMAT_AVFORMAT_H
23 23
 
24 24
 #define LIBAVFORMAT_VERSION_MAJOR 52
25
-#define LIBAVFORMAT_VERSION_MINOR 70
25
+#define LIBAVFORMAT_VERSION_MINOR 71
26 26
 #define LIBAVFORMAT_VERSION_MICRO  0
27 27
 
28 28
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
... ...
@@ -118,6 +118,13 @@ static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up,
118 118
     uc->flags = flags;
119 119
     uc->is_streamed = 0; /* default = not streamed */
120 120
     uc->max_packet_size = 0; /* default: stream file */
121
+    if (up->priv_data_size) {
122
+        uc->priv_data = av_mallocz(up->priv_data_size);
123
+        if (up->priv_data_class) {
124
+            *(AVClass**)uc->priv_data = up->priv_data_class;
125
+            av_opt_set_defaults(uc->priv_data);
126
+        }
127
+    }
121 128
 
122 129
     *puc = uc;
123 130
     return 0;
... ...
@@ -272,6 +279,8 @@ int url_close(URLContext *h)
272 272
 #if CONFIG_NETWORK
273 273
     ff_network_close();
274 274
 #endif
275
+    if (h->prot->priv_data_size)
276
+        av_free(h->priv_data);
275 277
     av_free(h);
276 278
     return ret;
277 279
 }
... ...
@@ -251,6 +251,8 @@ typedef struct URLProtocol {
251 251
     int64_t (*url_read_seek)(URLContext *h, int stream_index,
252 252
                              int64_t timestamp, int flags);
253 253
     int (*url_get_file_handle)(URLContext *h);
254
+    int priv_data_size;
255
+    const AVClass *priv_data_class;
254 256
 } URLProtocol;
255 257
 
256 258
 #if LIBAVFORMAT_VERSION_MAJOR < 53