[FFmpeg-cvslog] lavf/segment: mark #EXT-X-ENDLIST in M3U8 only at the end of stream

Stefano Sabatini git at videolan.org
Wed Jan 23 18:33:31 CET 2013


ffmpeg | branch: master | Stefano Sabatini <stefasab at gmail.com> | Wed Jan 23 00:23:47 2013 +0100| [ca68acd7ac3720b76efcf37219700e76e111062c] | committer: Stefano Sabatini

lavf/segment: mark #EXT-X-ENDLIST in M3U8 only at the end of stream

Should fix immediate playback termination.

In particular, should fix trac ticket #2172.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ca68acd7ac3720b76efcf37219700e76e111062c
---

 libavformat/segment.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/libavformat/segment.c b/libavformat/segment.c
index d26bfec..a3e49f4 100644
--- a/libavformat/segment.c
+++ b/libavformat/segment.c
@@ -258,7 +258,7 @@ static void segment_list_print_entry(AVIOContext      *list_ioctx,
     }
 }
 
-static int segment_end(AVFormatContext *s, int write_trailer)
+static int segment_end(AVFormatContext *s, int write_trailer, int is_last)
 {
     SegmentContext *seg = s->priv_data;
     AVFormatContext *oc = seg->avf;
@@ -300,7 +300,7 @@ static int segment_end(AVFormatContext *s, int write_trailer)
                 goto end;
             for (entry = seg->segment_list_entries; entry; entry = entry->next)
                 segment_list_print_entry(seg->list_pb, seg->list_type, entry);
-            if (seg->list_type == LIST_TYPE_M3U8)
+            if (seg->list_type == LIST_TYPE_M3U8 && is_last)
                 avio_printf(seg->list_pb, "#EXT-X-ENDLIST\n");
         } else {
             segment_list_print_entry(seg->list_pb, seg->list_type, &seg->cur_entry);
@@ -664,7 +664,7 @@ static int seg_write_packet(AVFormatContext *s, AVPacket *pkt)
          (pkt->pts != AV_NOPTS_VALUE &&
           av_compare_ts(pkt->pts, st->time_base,
                         end_pts-seg->time_delta, AV_TIME_BASE_Q) >= 0))) {
-        ret = segment_end(s, seg->individual_header_trailer);
+        ret = segment_end(s, seg->individual_header_trailer, 0);
 
         if (!ret)
             ret = segment_start(s, seg->individual_header_trailer);
@@ -729,13 +729,13 @@ static int seg_write_trailer(struct AVFormatContext *s)
 
     int ret;
     if (!seg->write_header_trailer) {
-        if ((ret = segment_end(s, 0)) < 0)
+        if ((ret = segment_end(s, 0, 1)) < 0)
             goto fail;
         open_null_ctx(&oc->pb);
         ret = av_write_trailer(oc);
         close_null_ctx(oc->pb);
     } else {
-        ret = segment_end(s, 1);
+        ret = segment_end(s, 1, 1);
     }
 fail:
     if (seg->list)



More information about the ffmpeg-cvslog mailing list