[FFmpeg-devel] [PATCH 4/7] avformat/tee: Support flushing by writing NULL pkt

sebechlebskyjan at gmail.com sebechlebskyjan at gmail.com
Mon Jul 4 17:45:12 EEST 2016


From: Jan Sebechlebsky <sebechlebskyjan at gmail.com>

This will fix crash when caller attempts to flush by
calling write_packet with NULL packet pointer and
flushes slaves as expected.

Signed-off-by: Jan Sebechlebsky <sebechlebskyjan at gmail.com>
---
 libavformat/tee.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/libavformat/tee.c b/libavformat/tee.c
index a56d449..996d64d 100644
--- a/libavformat/tee.c
+++ b/libavformat/tee.c
@@ -520,6 +520,17 @@ static int tee_write_packet(AVFormatContext *avf, AVPacket *pkt)
         if (!(avf2 = tee->slaves[i].avf))
             continue;
 
+        /* Flush slave if pkt is NULL*/
+        if (!pkt) {
+            ret = av_interleaved_write_frame(avf2, NULL);
+            if (ret < 0) {
+                ret = tee_process_slave_failure(avf, i, ret);
+                if (!ret_all && ret < 0)
+                    ret_all = ret;
+            }
+            continue;
+        }
+
         s = pkt->stream_index;
         s2 = tee->slaves[i].stream_map[s];
         if (s2 < 0)
-- 
1.9.1



More information about the ffmpeg-devel mailing list