summaryrefslogtreecommitdiff
path: root/libavformat/avio.c
diff options
context:
space:
mode:
authorMartin Storsjö <martin@martin.st>2010-06-22 13:58:48 +0000
committerMartin Storsjö <martin@martin.st>2010-06-22 13:58:48 +0000
commit9b07a2dc02e9b14e5b18485e7b16333a520b5dbb (patch)
tree7a6fad5f3125dddfb50a48d3ff976936c045f4b6 /libavformat/avio.c
parente10412a334092bc2884674799318ff7fc60be785 (diff)
Add an av_register_protocol2 function that takes a size parameter
This allows extending the URLProtocol struct without breaking binary compatibility with code compiled with older definitions of the struct. Originally committed as revision 23702 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/avio.c')
-rw-r--r--libavformat/avio.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/libavformat/avio.c b/libavformat/avio.c
index e79c8fcbfd..3371b40c4d 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -56,9 +56,14 @@ URLProtocol *av_protocol_next(URLProtocol *p)
else return first_protocol;
}
-int av_register_protocol(URLProtocol *protocol)
+int av_register_protocol2(URLProtocol *protocol, int size)
{
URLProtocol **p;
+ if (size < sizeof(URLProtocol)) {
+ URLProtocol* temp = av_mallocz(sizeof(URLProtocol));
+ memcpy(temp, protocol, size);
+ protocol = temp;
+ }
p = &first_protocol;
while (*p != NULL) p = &(*p)->next;
*p = protocol;
@@ -67,6 +72,22 @@ int av_register_protocol(URLProtocol *protocol)
}
#if LIBAVFORMAT_VERSION_MAJOR < 53
+/* The layout of URLProtocol as of when major was bumped to 52 */
+struct URLProtocol_compat {
+ const char *name;
+ int (*url_open)(URLContext *h, const char *filename, int flags);
+ int (*url_read)(URLContext *h, unsigned char *buf, int size);
+ int (*url_write)(URLContext *h, unsigned char *buf, int size);
+ int64_t (*url_seek)(URLContext *h, int64_t pos, int whence);
+ int (*url_close)(URLContext *h);
+ struct URLProtocol *next;
+};
+
+int av_register_protocol(URLProtocol *protocol)
+{
+ return av_register_protocol2(protocol, sizeof(struct URLProtocol_compat));
+}
+
int register_protocol(URLProtocol *protocol)
{
return av_register_protocol(protocol);