1- From ad70425a954678c0cbcb779b15d2bc3cd0d36f0f Mon Sep 17 00:00:00 2001
1+ From dc595d866ab9a0a67331b10dc969b434ab5e4e6b Mon Sep 17 00:00:00 2001
22From: qianlongxu <
[email protected] >
3- Date: Mon, 12 Jun 2023 16:15:15 +0800
4- Subject: [PATCH 05/15 ] hls support discontinuity
3+ Date: Wed, 22 May 2024 14:55:43 +0800
4+ Subject: [PATCH 05/17 ] hls support discontinuity tag
55
66---
7- libavformat/hls.c | 60 +++++++++++++++++++++++++++++++++++++++++------
8- 1 file changed, 53 insertions(+), 7 deletions(-)
7+ libavformat/hls.c | 59 +++++++++++++++++++++++++++++++++++++++++------
8+ 1 file changed, 52 insertions(+), 7 deletions(-)
99
1010diff --git a/libavformat/hls.c b/libavformat/hls.c
11- index bf7fdc1..2e3bff6 100644
11+ index bf7fdc1..6cf1fc2 100644
1212--- a/libavformat/hls.c
1313+++ b/libavformat/hls.c
1414@@ -73,6 +73,8 @@ enum KeyType {
@@ -20,15 +20,7 @@ index bf7fdc1..2e3bff6 100644
2020 int64_t duration;
2121 int64_t url_offset;
2222 int64_t size;
23- @@ -686,6 +688,7 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
24-
25- av_dict_copy(&tmp, *opts, 0);
26- av_dict_copy(&tmp, opts2, 0);
27- + av_dict_set(&tmp, "seekable", "1", 0);
28-
29- if (is_http && c->http_persistent && *pb) {
30- ret = open_url_keepalive(c->ctx, pb, url, &tmp);
31- @@ -726,6 +729,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
23+ @@ -726,6 +728,8 @@ static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,
3224 static int parse_playlist(HLSContext *c, const char *url,
3325 struct playlist *pls, AVIOContext *in)
3426 {
@@ -37,15 +29,15 @@ index bf7fdc1..2e3bff6 100644
3729 int ret = 0, is_segment = 0, is_variant = 0;
3830 int64_t duration = 0;
3931 enum KeyType key_type = KEY_NONE;
40- @@ -797,6 +802 ,7 @@ static int parse_playlist(HLSContext *c, const char *url,
32+ @@ -797,6 +801 ,7 @@ static int parse_playlist(HLSContext *c, const char *url,
4133 pls->finished = 0;
4234 pls->type = PLS_TYPE_UNSPECIFIED;
4335 }
4436+ int start_seq_no = -1;
4537 while (!avio_feof(in)) {
4638 ff_get_chomp_line(in, line, sizeof(line));
4739 if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
48- @@ -846,7 +852 ,11 @@ static int parse_playlist(HLSContext *c, const char *url,
40+ @@ -846,7 +851 ,11 @@ static int parse_playlist(HLSContext *c, const char *url,
4941 "INT64_MAX/2, mask out the highest bit\n");
5042 seq_no &= INT64_MAX/2;
5143 }
@@ -58,7 +50,7 @@ index bf7fdc1..2e3bff6 100644
5850 } else if (av_strstart(line, "#EXT-X-PLAYLIST-TYPE:", &ptr)) {
5951 ret = ensure_playlist(c, &pls, url);
6052 if (ret < 0)
61- @@ -911,6 +921 ,8 @@ static int parse_playlist(HLSContext *c, const char *url,
53+ @@ -911,6 +920 ,8 @@ static int parse_playlist(HLSContext *c, const char *url,
6254 } else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
6355 if (pls)
6456 pls->finished = 1;
@@ -67,7 +59,7 @@ index bf7fdc1..2e3bff6 100644
6759 } else if (av_strstart(line, "#EXTINF:", &ptr)) {
6860 is_segment = 1;
6961 duration = atof(ptr) * AV_TIME_BASE;
70- @@ -986,6 +998 ,11 @@ static int parse_playlist(HLSContext *c, const char *url,
62+ @@ -986,6 +997 ,11 @@ static int parse_playlist(HLSContext *c, const char *url,
7163 " set to default value to 1ms.\n", seg->url);
7264 duration = 0.001 * AV_TIME_BASE;
7365 }
@@ -79,15 +71,15 @@ index bf7fdc1..2e3bff6 100644
7971 seg->duration = duration;
8072 seg->key_type = key_type;
8173 dynarray_add(&pls->segments, &pls->n_segments, seg);
82- @@ -2292,6 +2309 ,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
74+ @@ -2292,6 +2308 ,7 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
8375 * stream */
8476 if (pls->needed && !pls->pkt->data) {
8577 while (1) {
8678+ int64_t pkt_ts = AV_NOPTS_VALUE;
8779 int64_t ts_diff;
8880 AVRational tb;
8981 struct segment *seg = NULL;
90- @@ -2305,12 +2323 ,40 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
82+ @@ -2305,12 +2322 ,40 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
9183 if (pls->is_id3_timestamped && pls->pkt->stream_index == 0) {
9284 /* audio elementary streams are id3 timestamped */
9385 fill_timing_for_id3_timestamped_stream(pls);
@@ -132,7 +124,7 @@ index bf7fdc1..2e3bff6 100644
132124 }
133125
134126 seg = current_segment(pls);
135- @@ -2327,13 +2373 ,13 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
127+ @@ -2327,13 +2372 ,13 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
136128 if (pls->seek_stream_index < 0 ||
137129 pls->seek_stream_index == pls->pkt->stream_index) {
138130
@@ -149,5 +141,5 @@ index bf7fdc1..2e3bff6 100644
149141 pls->seek_timestamp;
150142 if (ts_diff >= 0 && (pls->seek_flags & AVSEEK_FLAG_ANY ||
151143- -
152- 2.39.3 (Apple Git-145 )
144+ 2.39.3 (Apple Git-146 )
153145
0 commit comments