avformat: add url field to AVFormatContext

This will replace the 1024 character limited filename field. Compatiblity for
output contexts are provided by copying filename field to URL if URL is unset
and by providing an internal function for muxers to set both url and filename
at once.

Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
Marton Balint
2017-12-29 01:01:37 +01:00
parent dc5d151568
commit ea3672b7d6
6 changed files with 50 additions and 2 deletions

View File

@@ -186,8 +186,12 @@ int avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputFormat *ofor
} else
s->priv_data = NULL;
if (filename)
if (filename) {
av_strlcpy(s->filename, filename, sizeof(s->filename));
if (!(s->url = av_strdup(filename)))
goto nomem;
}
*avctx = s;
return 0;
nomem:
@@ -251,6 +255,11 @@ static int init_muxer(AVFormatContext *s, AVDictionary **options)
(ret = av_opt_set_dict2(s->priv_data, &tmp, AV_OPT_SEARCH_CHILDREN)) < 0)
goto fail;
if (!s->url && !(s->url = av_strdup(s->filename))) {
ret = AVERROR(ENOMEM);
goto fail;
}
#if FF_API_LAVF_AVCTX
FF_DISABLE_DEPRECATION_WARNINGS
if (s->nb_streams && s->streams[0]->codec->flags & AV_CODEC_FLAG_BITEXACT) {