avformat/hlsenc: fix ticket id 5988 for DISCONTINUITY
add EXT-X-DISCONTINUITY tag at the position of the append point. Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
This commit is contained in:
parent
1f5630af51
commit
55affd95bd
@ -46,6 +46,7 @@ typedef struct HLSSegment {
|
||||
char filename[1024];
|
||||
char sub_filename[1024];
|
||||
double duration; /* in seconds */
|
||||
int discont;
|
||||
int64_t pos;
|
||||
int64_t size;
|
||||
|
||||
@ -107,6 +108,7 @@ typedef struct HLSContext {
|
||||
int64_t max_seg_size; // every segment file max size
|
||||
int nb_entries;
|
||||
int discontinuity_set;
|
||||
int discontinuity;
|
||||
|
||||
HLSSegment *segments;
|
||||
HLSSegment *last_segment;
|
||||
@ -387,6 +389,12 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double
|
||||
en->pos = pos;
|
||||
en->size = size;
|
||||
en->next = NULL;
|
||||
en->discont = 0;
|
||||
|
||||
if (hls->discontinuity) {
|
||||
en->discont = 1;
|
||||
hls->discontinuity = 0;
|
||||
}
|
||||
|
||||
if (hls->key_info_file) {
|
||||
av_strlcpy(en->key_uri, hls->key_uri, sizeof(en->key_uri));
|
||||
@ -446,6 +454,7 @@ static int parse_playlist(AVFormatContext *s, const char *url)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
hls->discontinuity = 0;
|
||||
while (!avio_feof(in)) {
|
||||
read_chomp_line(in, line, sizeof(line));
|
||||
if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
|
||||
@ -560,6 +569,10 @@ static int hls_window(AVFormatContext *s, int last)
|
||||
iv_string = en->iv_string;
|
||||
}
|
||||
|
||||
if (en->discont) {
|
||||
avio_printf(out, "#EXT-X-DISCONTINUITY\n");
|
||||
}
|
||||
|
||||
if (hls->flags & HLS_ROUND_DURATIONS)
|
||||
avio_printf(out, "#EXTINF:%ld,\n", lrint(en->duration));
|
||||
else
|
||||
@ -883,6 +896,7 @@ static int hls_write_header(AVFormatContext *s)
|
||||
|
||||
if (hls->flags & HLS_APPEND_LIST) {
|
||||
parse_playlist(s, s->filename);
|
||||
hls->discontinuity = 1;
|
||||
if (hls->init_time > 0) {
|
||||
av_log(s, AV_LOG_WARNING, "append_list mode does not support hls_init_time,"
|
||||
" hls_init_time value will have no effect\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user