1
- From ad70425a954678c0cbcb779b15d2bc3cd0d36f0f Mon Sep 17 00:00:00 2001
1
+ From dc595d866ab9a0a67331b10dc969b434ab5e4e6b Mon Sep 17 00:00:00 2001
2
2
From: qianlongxu <qianlongxu@gmail.com>
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
5
5
6
6
---
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(-)
9
9
10
10
diff --git a/libavformat/hls.c b/libavformat/hls.c
11
- index bf7fdc1..2e3bff6 100644
11
+ index bf7fdc1..6cf1fc2 100644
12
12
--- a/libavformat/hls.c
13
13
+++ b/libavformat/hls.c
14
14
@@ -73,6 +73,8 @@ enum KeyType {
@@ -20,15 +20,7 @@ index bf7fdc1..2e3bff6 100644
20
20
int64_t duration;
21
21
int64_t url_offset;
22
22
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,
32
24
static int parse_playlist(HLSContext *c, const char *url,
33
25
struct playlist *pls, AVIOContext *in)
34
26
{
@@ -37,15 +29,15 @@ index bf7fdc1..2e3bff6 100644
37
29
int ret = 0, is_segment = 0, is_variant = 0;
38
30
int64_t duration = 0;
39
31
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,
41
33
pls->finished = 0;
42
34
pls->type = PLS_TYPE_UNSPECIFIED;
43
35
}
44
36
+ int start_seq_no = -1;
45
37
while (!avio_feof(in)) {
46
38
ff_get_chomp_line(in, line, sizeof(line));
47
39
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,
49
41
"INT64_MAX/2, mask out the highest bit\n");
50
42
seq_no &= INT64_MAX/2;
51
43
}
@@ -58,7 +50,7 @@ index bf7fdc1..2e3bff6 100644
58
50
} else if (av_strstart(line, "#EXT-X-PLAYLIST-TYPE:", &ptr)) {
59
51
ret = ensure_playlist(c, &pls, url);
60
52
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,
62
54
} else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
63
55
if (pls)
64
56
pls->finished = 1;
@@ -67,7 +59,7 @@ index bf7fdc1..2e3bff6 100644
67
59
} else if (av_strstart(line, "#EXTINF:", &ptr)) {
68
60
is_segment = 1;
69
61
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,
71
63
" set to default value to 1ms.\n", seg->url);
72
64
duration = 0.001 * AV_TIME_BASE;
73
65
}
@@ -79,15 +71,15 @@ index bf7fdc1..2e3bff6 100644
79
71
seg->duration = duration;
80
72
seg->key_type = key_type;
81
73
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)
83
75
* stream */
84
76
if (pls->needed && !pls->pkt->data) {
85
77
while (1) {
86
78
+ int64_t pkt_ts = AV_NOPTS_VALUE;
87
79
int64_t ts_diff;
88
80
AVRational tb;
89
81
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)
91
83
if (pls->is_id3_timestamped && pls->pkt->stream_index == 0) {
92
84
/* audio elementary streams are id3 timestamped */
93
85
fill_timing_for_id3_timestamped_stream(pls);
@@ -132,7 +124,7 @@ index bf7fdc1..2e3bff6 100644
132
124
}
133
125
134
126
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)
136
128
if (pls->seek_stream_index < 0 ||
137
129
pls->seek_stream_index == pls->pkt->stream_index) {
138
130
@@ -149,5 +141,5 @@ index bf7fdc1..2e3bff6 100644
149
141
pls->seek_timestamp;
150
142
if (ts_diff >= 0 && (pls->seek_flags & AVSEEK_FLAG_ANY ||
151
143
- -
152
- 2.39.3 (Apple Git-145 )
144
+ 2.39.3 (Apple Git-146 )
153
145
0 commit comments