Ticket #2172: 0001-lavf-segment-mark-EXT-X-ENDLIST-in-M3U8-only-at-the-.patch

File 0001-lavf-segment-mark-EXT-X-ENDLIST-in-M3U8-only-at-the-.patch, 2.3 KB (added by saste, 4 years ago)
  • libavformat/segment.c

    From b5c0fdba090b7b3729abb604c58deb8d63741ac3 Mon Sep 17 00:00:00 2001
    From: Stefano Sabatini <stefasab@gmail.com>
    Date: Wed, 23 Jan 2013 00:23:47 +0100
    Subject: [PATCH] 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.
    ---
     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 b static void segment_list_print_entry(AVIOContext *list_ioctx, 
    258258    } 
    259259} 
    260260 
    261 static int segment_end(AVFormatContext *s, int write_trailer) 
     261static int segment_end(AVFormatContext *s, int write_trailer, int is_last) 
    262262{ 
    263263    SegmentContext *seg = s->priv_data; 
    264264    AVFormatContext *oc = seg->avf; 
    static int segment_end(AVFormatContext *s, int write_trailer) 
    300300                goto end; 
    301301            for (entry = seg->segment_list_entries; entry; entry = entry->next) 
    302302                segment_list_print_entry(seg->list_pb, seg->list_type, entry); 
    303             if (seg->list_type == LIST_TYPE_M3U8) 
     303            if (seg->list_type == LIST_TYPE_M3U8 && is_last) 
    304304                avio_printf(seg->list_pb, "#EXT-X-ENDLIST\n"); 
    305305        } else { 
    306306            segment_list_print_entry(seg->list_pb, seg->list_type, &seg->cur_entry); 
    static int seg_write_packet(AVFormatContext *s, AVPacket *pkt) 
    664664         (pkt->pts != AV_NOPTS_VALUE && 
    665665          av_compare_ts(pkt->pts, st->time_base, 
    666666                        end_pts-seg->time_delta, AV_TIME_BASE_Q) >= 0))) { 
    667         ret = segment_end(s, seg->individual_header_trailer); 
     667        ret = segment_end(s, seg->individual_header_trailer, 0); 
    668668 
    669669        if (!ret) 
    670670            ret = segment_start(s, seg->individual_header_trailer); 
    static int seg_write_trailer(struct AVFormatContext *s) 
    729729 
    730730    int ret; 
    731731    if (!seg->write_header_trailer) { 
    732         if ((ret = segment_end(s, 0)) < 0) 
     732        if ((ret = segment_end(s, 0, 1)) < 0) 
    733733            goto fail; 
    734734        open_null_ctx(&oc->pb); 
    735735        ret = av_write_trailer(oc); 
    736736        close_null_ctx(oc->pb); 
    737737    } else { 
    738         ret = segment_end(s, 1); 
     738        ret = segment_end(s, 1, 1); 
    739739    } 
    740740fail: 
    741741    if (seg->list)