[FFmpeg-devel] [PATCH 8/8] avformat/hlsenc: usage of error handling utility function
Steven Liu
lq at chinaffmpeg.org
Fri Mar 30 09:33:27 EEST 2018
> On 30 Mar 2018, at 13:09, vdixit at akamai.com wrote:
>
> From: Vishwanath Dixit <vdixit at akamai.com>
>
> ---
> doc/muxers.texi | 9 +++++++++
> libavformat/hlsenc.c | 16 +++++++++-------
> 2 files changed, 18 insertions(+), 7 deletions(-)
>
> diff --git a/doc/muxers.texi b/doc/muxers.texi
> index 0d9ecef..a651a49 100644
> --- a/doc/muxers.texi
> +++ b/doc/muxers.texi
> @@ -977,6 +977,15 @@ Use persistent HTTP connections. Applicable only for HTTP output.
> @item timeout
> Set timeout for socket I/O operations. Applicable only for HTTP output.
>
> + at item -ignore_nw_error @var{ignore_nw_error}
> +Enable (1) or disable (0) ignoring the following non-fatal network errors during
> +muxing. Applicable only for HTTP output.
> + at example
> +EPIPE - Broken pipe
> +ECONNREFUSED - Connection refused
> +ECONNRESET - Connection reset by peer
> + at end example
> +
> @end table
>
> @anchor{ico}
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 334720f..f6de326 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -225,6 +225,7 @@ typedef struct HLSContext {
> AVIOContext *m3u8_out;
> AVIOContext *sub_m3u8_out;
> int64_t timeout;
> + int ignore_nw_err;
> } HLSContext;
>
> static int mkdir_p(const char *path) {
> @@ -2247,7 +2248,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
> ret = flush_dynbuf(vs, &range_length);
> if (ret < 0) {
> av_free(old_filename);
> - return ret;
> + return av_handle_error(s, ret, hls->ignore_nw_err);
> }
> vs->size = range_length;
> } else {
> @@ -2255,12 +2256,12 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
> if (ret < 0) {
> av_log(s, AV_LOG_ERROR, "Failed to open file '%s'\n",
> vs->avf->url);
> - return ret;
> + return av_handle_error(s, ret, hls->ignore_nw_err);
> }
> write_styp(vs->out);
> ret = flush_dynbuf(vs, &range_length);
> if (ret < 0) {
> - return ret;
> + return av_handle_error(s, ret, hls->ignore_nw_err);
> }
> ff_format_io_close(s, &vs->out);
> }
> @@ -2277,7 +2278,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
> vs->duration = 0;
> if (ret < 0) {
> av_free(old_filename);
> - return ret;
> + return av_handle_error(s, ret, hls->ignore_nw_err);
> }
> }
>
> @@ -2308,12 +2309,12 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
> av_free(old_filename);
>
> if (ret < 0) {
> - return ret;
> + return av_handle_error(s, ret, hls->ignore_nw_err);
> }
>
> if (!vs->fmp4_init_mode || byterange_mode)
> if ((ret = hls_window(s, 0, vs)) < 0) {
> - return ret;
> + return av_handle_error(s, ret, hls->ignore_nw_err);
> }
> }
>
> @@ -2321,7 +2322,7 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
> if (oc->pb)
> ret = ff_write_chained(oc, stream_index, pkt, s, 0);
>
> - return ret;
> + return av_handle_error(s, ret, hls->ignore_nw_err);
> }
>
> static int hls_write_trailer(struct AVFormatContext *s)
> @@ -2835,6 +2836,7 @@ static const AVOption options[] = {
> {"master_pl_publish_rate", "Publish master play list every after this many segment intervals", OFFSET(master_publish_rate), AV_OPT_TYPE_INT, {.i64 = 0}, 0, UINT_MAX, E},
> {"http_persistent", "Use persistent HTTP connections", OFFSET(http_persistent), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
> {"timeout", "set timeout for socket I/O operations", OFFSET(timeout), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, .flags = E },
> + { "ignore_nw_error", "Ignores any non-fatal network errors during muxing", OFFSET(ignore_nw_err), AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1, E },
> { NULL },
> };
>
> --
> 1.9.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
LGTM
Thanks
Steven
More information about the ffmpeg-devel
mailing list