diff options
author | Marton Balint <cus@passwd.hu> | 2017-12-29 01:01:37 +0100 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2018-01-28 23:06:43 +0100 |
commit | ea3672b7d67c432724bdbc8de0221f869b6a04c6 (patch) | |
tree | 7127b576630f140f79a0f73d07bc4a34a92ea824 /libavformat/utils.c | |
parent | dc5d1515681b57a257443ba72bb81fb3e6e6621b (diff) | |
download | ffmpeg-ea3672b7d67c432724bdbc8de0221f869b6a04c6.tar.gz |
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>
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index c15b8cc818..74e615f86e 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -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)); +} |