aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-11-10 04:34:35 +0100
committerMichael Niedermayer <michaelni@gmx.at>2011-11-22 20:54:51 +0100
commit6161c41817f6e53abb3021d67ca0f19def682718 (patch)
tree1d4427dd3f83ab45b4df12a5902463a3d1ae7539
parentc12e1bd1bc7f0dd0dae2937d7f8c564e887c84ff (diff)
downloadffmpeg-6161c41817f6e53abb3021d67ca0f19def682718.tar.gz
avio: Support private options in URLProtocols
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--libavformat/avio.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/libavformat/avio.c b/libavformat/avio.c
index 446f681f6c..a9f4253059 100644
--- a/libavformat/avio.c
+++ b/libavformat/avio.c
@@ -145,8 +145,31 @@ static int url_alloc_for_protocol (URLContext **puc, struct URLProtocol *up,
if (up->priv_data_size) {
uc->priv_data = av_mallocz(up->priv_data_size);
if (up->priv_data_class) {
+ char *start = strchr(uc->filename, ',');
*(const AVClass**)uc->priv_data = up->priv_data_class;
av_opt_set_defaults(uc->priv_data);
+ if(start){
+ int ret= 0;
+ char *p= start;
+ char sep= *++p;
+ char *key, *val;
+ p++;
+ while(ret >= 0 && (key= strchr(p, sep)) && p<key && (val = strchr(key+1, sep))){
+ *val= *key= 0;
+ ret= av_opt_set(uc->priv_data, p, key+1, 0);
+ if (ret == AVERROR_OPTION_NOT_FOUND)
+ av_log(uc, AV_LOG_ERROR, "Key '%s' not found.\n", p);
+ *val= *key= sep;
+ p= val+1;
+ }
+ if(ret<0 || p!=key){
+ av_log(uc, AV_LOG_ERROR, "Error parsing options string %s\n", start);
+ av_freep(&uc->priv_data);
+ av_freep(&uc);
+ goto fail;
+ }
+ memmove(start, key+1, strlen(key));
+ }
}
}
if (int_cb)
@@ -277,6 +300,8 @@ int ffurl_alloc(URLContext **puc, const char *filename, int flags,
else
av_strlcpy(proto_str, filename, FFMIN(proto_end-filename+1, sizeof(proto_str)));
+ if ((ptr = strchr(proto_str, ',')))
+ *ptr = '\0';
av_strlcpy(proto_nested, proto_str, sizeof(proto_nested));
if ((ptr = strchr(proto_nested, '+')))
*ptr = '\0';