[FFmpeg-devel] [PATCH 5/8] avformat/dashenc: usage of error handling utility function

vdixit at akamai.com vdixit at akamai.com
Fri Mar 30 08:08:43 EEST 2018


From: Vishwanath Dixit <vdixit at akamai.com>

---
 doc/muxers.texi       |  8 ++++++++
 libavformat/dashenc.c | 10 ++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/doc/muxers.texi b/doc/muxers.texi
index cb75c26..0d9ecef 100644
--- a/doc/muxers.texi
+++ b/doc/muxers.texi
@@ -266,6 +266,14 @@ To map all video (or audio) streams to an AdaptationSet, "v" (or "a") can be use
 When no assignment is defined, this defaults to an AdaptationSet for each stream.
 @item -timeout @var{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{framecrc}
diff --git a/libavformat/dashenc.c b/libavformat/dashenc.c
index 4c8fc6f..05ebd6b 100644
--- a/libavformat/dashenc.c
+++ b/libavformat/dashenc.c
@@ -118,6 +118,7 @@ typedef struct DASHContext {
     AVIOContext *m3u8_out;
     int streaming;
     int64_t timeout;
+    int ignore_nw_err;
 } DASHContext;
 
 static struct codec_string {
@@ -1321,7 +1322,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
         }
 
         if ((ret = dash_flush(s, 0, pkt->stream_index)) < 0)
-            return ret;
+            return av_handle_error(s, ret, c->ignore_nw_err);
     }
 
     if (!os->packets_written) {
@@ -1339,7 +1340,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
         os->max_pts = FFMAX(os->max_pts, pkt->pts + pkt->duration);
     os->packets_written++;
     if ((ret = ff_write_chained(os->ctx, 0, pkt, s, 0)) < 0)
-        return ret;
+        return av_handle_error(s, ret, c->ignore_nw_err);
 
     if (!os->init_range_length)
         flush_init_segment(s, os);
@@ -1360,7 +1361,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
         set_http_options(&opts, c);
         ret = dashenc_io_open(s, &os->out, os->temp_path, &opts);
         if (ret < 0)
-            return ret;
+            return av_handle_error(s, ret, c->ignore_nw_err);
         av_dict_free(&opts);
     }
 
@@ -1379,7 +1380,7 @@ static int dash_write_packet(AVFormatContext *s, AVPacket *pkt)
         os->written_len = len;
     }
 
-    return ret;
+    return av_handle_error(s, ret, c->ignore_nw_err);
 }
 
 static int dash_write_trailer(AVFormatContext *s)
@@ -1458,6 +1459,7 @@ static const AVOption options[] = {
     { "hls_playlist", "Generate HLS playlist files(master.m3u8, media_%d.m3u8)", OFFSET(hls_playlist), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, E },
     { "streaming", "Enable/Disable streaming mode of output. Each frame will be moof fragment", OFFSET(streaming), 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



More information about the ffmpeg-devel mailing list