[FFmpeg-devel] [PATCH 1/2] avformat/dashenc : Handled error from ff_http_do_new_request() cleanly
Jeyapal, Karthick
kjeyapal at akamai.com
Thu Nov 22 08:38:18 EET 2018
Pushed the patchset.
On 11/16/18 2:27 PM, Karthick J wrote:
> ---
> libavformat/dashenc.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
> index d151921175..2c1cce0c92 100644
> --- a/libavformat/dashenc.c
> +++ b/libavformat/dashenc.c
> @@ -168,6 +168,8 @@ static int dashenc_io_open(AVFormatContext *s, AVIOContext **pb, char *filename,
> URLContext *http_url_context = ffio_geturlcontext(*pb);
> av_assert0(http_url_context);
> err = ff_http_do_new_request(http_url_context, filename);
> + if (err < 0)
> + ff_format_io_close(s, pb);
> #endif
> }
> return err;
> @@ -177,6 +179,9 @@ static void dashenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filenam
> DASHContext *c = s->priv_data;
> int http_base_proto = filename ? ff_is_http_proto(filename) : 0;
>
> + if (!*pb)
> + return;
> +
> if (!http_base_proto || !c->http_persistent) {
> ff_format_io_close(s, pb);
> #if CONFIG_HTTP_PROTOCOL
> @@ -318,7 +323,8 @@ static int flush_dynbuf(OutputStream *os, int *range_length)
> // write out to file
> *range_length = avio_close_dyn_buf(os->ctx->pb, &buffer);
> os->ctx->pb = NULL;
> - avio_write(os->out, buffer + os->written_len, *range_length - os->written_len);
> + if (os->out)
> + avio_write(os->out, buffer + os->written_len, *range_length - os->written_len);
> os->written_len = 0;
> av_free(buffer);
>
> @@ -1496,9 +1502,9 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
> use_rename ? "%s.tmp" : "%s", os->full_path);
> set_http_options(&opts, c);
> ret = dashenc_io_open(s, &os->out, os->temp_path, &opts);
> + av_dict_free(&opts);
> if (ret < 0)
> return ret;
> - av_dict_free(&opts);
> }
>
> //write out the data immediately in streaming mode
More information about the ffmpeg-devel
mailing list