From 735cf6b2657c48ffd9ba4eb66ae8a0a3419de074 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Tue, 22 Jun 2010 14:09:08 +0000 Subject: [PATCH] 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 --- libavformat/avformat.h | 2 +- libavformat/avio.c | 9 +++++++++ libavformat/avio.h | 2 ++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/libavformat/avformat.h b/libavformat/avformat.h index f8dff367ea..861d60e63f 100644 --- a/libavformat/avformat.h +++ b/libavformat/avformat.h @@ -22,7 +22,7 @@ #define AVFORMAT_AVFORMAT_H #define LIBAVFORMAT_VERSION_MAJOR 52 -#define LIBAVFORMAT_VERSION_MINOR 70 +#define LIBAVFORMAT_VERSION_MINOR 71 #define LIBAVFORMAT_VERSION_MICRO 0 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ diff --git a/libavformat/avio.c b/libavformat/avio.c index 240289d686..5d48ac04cc 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -118,6 +118,13 @@ static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up, 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 @@ int url_close(URLContext *h) #if CONFIG_NETWORK ff_network_close(); #endif + if (h->prot->priv_data_size) + av_free(h->priv_data); av_free(h); return ret; } diff --git a/libavformat/avio.h b/libavformat/avio.h index 752f6e2cba..f41f6fac41 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -251,6 +251,8 @@ typedef struct URLProtocol { int64_t (*url_read_seek)(URLContext *h, int stream_index, int64_t timestamp, int flags); int (*url_get_file_handle)(URLContext *h); + int priv_data_size; + const AVClass *priv_data_class; } URLProtocol; #if LIBAVFORMAT_VERSION_MAJOR < 53