[FFmpeg-cvslog] avformat/webm_chunk: Don't copy header filename
Andreas Rheinhardt
git at videolan.org
Thu Mar 26 03:22:34 EET 2020
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sun Mar 1 00:13:07 2020 +0100| [8a632b3e2e06258e3a9053f82f777dcd3d04ed26] | committer: Andreas Rheinhardt
avformat/webm_chunk: Don't copy header filename
Instead just reuse the filename string that is given via an option
for the child muxer's url field.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8a632b3e2e06258e3a9053f82f777dcd3d04ed26
---
libavformat/webm_chunk.c | 34 ++++++++++------------------------
1 file changed, 10 insertions(+), 24 deletions(-)
diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c
index 30ba30e929..7b1f1a8b48 100644
--- a/libavformat/webm_chunk.c
+++ b/libavformat/webm_chunk.c
@@ -65,6 +65,11 @@ static int chunk_mux_init(AVFormatContext *s)
AVDictionary *dict = NULL;
int ret;
+ if (!wc->header_filename) {
+ av_log(s, AV_LOG_ERROR, "No header filename provided\n");
+ return AVERROR(EINVAL);
+ }
+
oformat = av_guess_format("webm", s->url, "video/webm");
if (!oformat)
return AVERROR_MUXER_NOT_FOUND;
@@ -74,6 +79,9 @@ static int chunk_mux_init(AVFormatContext *s)
return ret;
oc = wc->avf;
+ ff_format_set_url(oc, wc->header_filename);
+ wc->header_filename = NULL;
+
oc->interrupt_callback = s->interrupt_callback;
oc->max_delay = s->max_delay;
oc->flags = s->flags & ~AVFMT_FLAG_FLUSH_PACKETS;
@@ -120,30 +128,17 @@ static int chunk_mux_init(AVFormatContext *s)
return 0;
}
-static int get_chunk_filename(AVFormatContext *s, int is_header, char filename[MAX_FILENAME_SIZE])
+static int get_chunk_filename(AVFormatContext *s, char filename[MAX_FILENAME_SIZE])
{
WebMChunkContext *wc = s->priv_data;
if (!filename) {
return AVERROR(EINVAL);
}
- if (is_header) {
- int len;
- if (!wc->header_filename) {
- av_log(s, AV_LOG_ERROR, "No header filename provided\n");
- return AVERROR(EINVAL);
- }
- len = av_strlcpy(filename, wc->header_filename, MAX_FILENAME_SIZE);
- if (len >= MAX_FILENAME_SIZE) {
- av_log(s, AV_LOG_ERROR, "Header filename too long\n");
- return AVERROR(EINVAL);
- }
- } else {
if (av_get_frame_filename(filename, MAX_FILENAME_SIZE,
s->url, wc->chunk_index - 1) < 0) {
av_log(s, AV_LOG_ERROR, "Invalid chunk filename template '%s'\n", s->url);
return AVERROR(EINVAL);
}
- }
return 0;
}
@@ -153,8 +148,6 @@ static int webm_chunk_write_header(AVFormatContext *s)
AVFormatContext *oc = NULL;
int ret;
AVDictionary *options = NULL;
- char oc_filename[MAX_FILENAME_SIZE];
- char *oc_url;
// DASH Streams can only have either one track per file.
if (s->nb_streams != 1) { return AVERROR_INVALIDDATA; }
@@ -166,13 +159,6 @@ static int webm_chunk_write_header(AVFormatContext *s)
if (ret < 0)
return ret;
oc = wc->avf;
- ret = get_chunk_filename(s, 1, oc_filename);
- if (ret < 0)
- return ret;
- oc_url = av_strdup(oc_filename);
- if (!oc_url)
- return AVERROR(ENOMEM);
- ff_format_set_url(oc, oc_url);
if (wc->http_method)
av_dict_set(&options, "method", wc->http_method, 0);
ret = s->io_open(s, &oc->pb, oc->url, AVIO_FLAG_WRITE, &options);
@@ -220,7 +206,7 @@ static int chunk_end(AVFormatContext *s, int flush)
av_write_frame(oc, NULL);
buffer_size = avio_close_dyn_buf(oc->pb, &buffer);
oc->pb = NULL;
- ret = get_chunk_filename(s, 0, filename);
+ ret = get_chunk_filename(s, filename);
if (ret < 0)
goto fail;
if (wc->http_method)
More information about the ffmpeg-cvslog
mailing list