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

@@ -555,6 +555,11 @@ int avformat_open_input(AVFormatContext **ps, const char *filename,
if ((ret = av_opt_set_dict(s, &tmp)) < 0)
goto fail;
if (!(s->url = av_strdup(filename ? filename : ""))) {
ret = AVERROR(ENOMEM);
goto fail;
}
av_strlcpy(s->filename, filename ? filename : "", sizeof(s->filename));
if ((ret = init_input(s, filename, &tmp)) < 0)
goto fail;
@@ -4371,6 +4376,7 @@ void avformat_free_context(AVFormatContext *s)
av_freep(&s->streams);
flush_packet_queue(s);
av_freep(&s->internal);
av_freep(&s->url);
av_free(s);
}
@@ -5636,3 +5642,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
return st->internal->avctx->time_base;
#endif
}
void ff_format_set_url(AVFormatContext *s, char *url)
{
av_assert0(url);
av_freep(&s->url);
s->url = url;
av_strlcpy(s->filename, url, sizeof(s->filename));
}