avformat/dashdec: Simplify cleanup after read_header failure

by setting the FF_FMT_INIT_CLEANUP flag.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
pull/359/head
Andreas Rheinhardt 5 years ago
parent 2ca36ef08b
commit c3ba8f0d7e
  1. 34
      libavformat/dashdec.c

@ -2037,8 +2037,6 @@ static int copy_init_section(struct representation *rep_dest, struct representat
return 0; return 0;
} }
static int dash_close(AVFormatContext *s);
static void move_metadata(AVStream *st, const char *key, char **value) static void move_metadata(AVStream *st, const char *key, char **value)
{ {
if (*value) { if (*value) {
@ -2059,10 +2057,10 @@ static int dash_read_header(AVFormatContext *s)
c->interrupt_callback = &s->interrupt_callback; c->interrupt_callback = &s->interrupt_callback;
if ((ret = save_avio_options(s)) < 0) if ((ret = save_avio_options(s)) < 0)
goto fail; return ret;
if ((ret = parse_manifest(s, s->url, s->pb)) < 0) if ((ret = parse_manifest(s, s->url, s->pb)) < 0)
goto fail; return ret;
/* If this isn't a live stream, fill the total duration of the /* If this isn't a live stream, fill the total duration of the
* stream. */ * stream. */
@ -2081,12 +2079,12 @@ static int dash_read_header(AVFormatContext *s)
if (i > 0 && c->is_init_section_common_video) { if (i > 0 && c->is_init_section_common_video) {
ret = copy_init_section(rep, c->videos[0]); ret = copy_init_section(rep, c->videos[0]);
if (ret < 0) if (ret < 0)
goto fail; return ret;
} }
ret = open_demux_for_component(s, rep); ret = open_demux_for_component(s, rep);
if (ret) if (ret)
goto fail; return ret;
rep->stream_index = stream_index; rep->stream_index = stream_index;
++stream_index; ++stream_index;
} }
@ -2099,12 +2097,12 @@ static int dash_read_header(AVFormatContext *s)
if (i > 0 && c->is_init_section_common_audio) { if (i > 0 && c->is_init_section_common_audio) {
ret = copy_init_section(rep, c->audios[0]); ret = copy_init_section(rep, c->audios[0]);
if (ret < 0) if (ret < 0)
goto fail; return ret;
} }
ret = open_demux_for_component(s, rep); ret = open_demux_for_component(s, rep);
if (ret) if (ret)
goto fail; return ret;
rep->stream_index = stream_index; rep->stream_index = stream_index;
++stream_index; ++stream_index;
} }
@ -2117,27 +2115,23 @@ static int dash_read_header(AVFormatContext *s)
if (i > 0 && c->is_init_section_common_subtitle) { if (i > 0 && c->is_init_section_common_subtitle) {
ret = copy_init_section(rep, c->subtitles[0]); ret = copy_init_section(rep, c->subtitles[0]);
if (ret < 0) if (ret < 0)
goto fail; return ret;
} }
ret = open_demux_for_component(s, rep); ret = open_demux_for_component(s, rep);
if (ret) if (ret)
goto fail; return ret;
rep->stream_index = stream_index; rep->stream_index = stream_index;
++stream_index; ++stream_index;
} }
if (!stream_index) { if (!stream_index)
ret = AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
goto fail;
}
/* Create a program */ /* Create a program */
program = av_new_program(s, 0); program = av_new_program(s, 0);
if (!program) { if (!program)
ret = AVERROR(ENOMEM); return AVERROR(ENOMEM);
goto fail;
}
for (i = 0; i < c->n_videos; i++) { for (i = 0; i < c->n_videos; i++) {
rep = c->videos[i]; rep = c->videos[i];
@ -2165,9 +2159,6 @@ static int dash_read_header(AVFormatContext *s)
} }
return 0; return 0;
fail:
dash_close(s);
return ret;
} }
static void recheck_discard_flags(AVFormatContext *s, struct representation **p, int n) static void recheck_discard_flags(AVFormatContext *s, struct representation **p, int n)
@ -2402,6 +2393,7 @@ const AVInputFormat ff_dash_demuxer = {
.long_name = NULL_IF_CONFIG_SMALL("Dynamic Adaptive Streaming over HTTP"), .long_name = NULL_IF_CONFIG_SMALL("Dynamic Adaptive Streaming over HTTP"),
.priv_class = &dash_class, .priv_class = &dash_class,
.priv_data_size = sizeof(DASHContext), .priv_data_size = sizeof(DASHContext),
.flags_internal = FF_FMT_INIT_CLEANUP,
.read_probe = dash_probe, .read_probe = dash_probe,
.read_header = dash_read_header, .read_header = dash_read_header,
.read_packet = dash_read_packet, .read_packet = dash_read_packet,

Loading…
Cancel
Save