diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index cbfd8f7c0d..cfc3093c1a 100644
|
a
|
b
|
|
| 25 | 25 | #include <stdint.h> |
| 26 | 26 | #if HAVE_UNISTD_H |
| 27 | 27 | #include <unistd.h> |
| | 28 | #include <stdbool.h> |
| | 29 | |
| 28 | 30 | #endif |
| 29 | 31 | |
| 30 | 32 | #if CONFIG_GCRYPT |
| … |
… |
typedef struct HLSSegment {
|
| 88 | 90 | char iv_string[KEYSIZE*2 + 1]; |
| 89 | 91 | |
| 90 | 92 | struct HLSSegment *next; |
| | 93 | double discont_program_date_time; |
| 91 | 94 | } HLSSegment; |
| 92 | 95 | |
| 93 | 96 | typedef enum HLSFlags { |
| … |
… |
static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls,
|
| 1124 | 1127 | en->keyframe_size = vs->video_keyframe_size; |
| 1125 | 1128 | en->next = NULL; |
| 1126 | 1129 | en->discont = 0; |
| | 1130 | en->discont_program_date_time = 0; |
| 1127 | 1131 | |
| 1128 | 1132 | if (vs->discontinuity) { |
| 1129 | 1133 | en->discont = 1; |
| … |
… |
static int parse_playlist(AVFormatContext *s, const char *url, VariantStream *vs
|
| 1182 | 1186 | char line[MAX_URL_SIZE]; |
| 1183 | 1187 | const char *ptr; |
| 1184 | 1188 | const char *end; |
| | 1189 | bool is_discont_detected = false; |
| | 1190 | double discont_program_date_time = 0; |
| 1185 | 1191 | |
| 1186 | 1192 | if ((ret = ffio_open_whitelist(&in, url, AVIO_FLAG_READ, |
| 1187 | 1193 | &s->interrupt_callback, NULL, |
| … |
… |
static int parse_playlist(AVFormatContext *s, const char *url, VariantStream *vs
|
| 1211 | 1217 | } else if (av_strstart(line, "#EXT-X-DISCONTINUITY", &ptr)) { |
| 1212 | 1218 | is_segment = 1; |
| 1213 | 1219 | vs->discontinuity = 1; |
| | 1220 | is_discont_detected = true; |
| 1214 | 1221 | } else if (av_strstart(line, "#EXTINF:", &ptr)) { |
| 1215 | 1222 | is_segment = 1; |
| 1216 | 1223 | vs->duration = atof(ptr); |
| … |
… |
static int parse_playlist(AVFormatContext *s, const char *url, VariantStream *vs
|
| 1236 | 1243 | av_strlcpy(vs->iv_string, ptr, sizeof(vs->iv_string)); |
| 1237 | 1244 | } |
| 1238 | 1245 | } |
| 1239 | | |
| | 1246 | } else if (av_strstart(line, "#EXT-X-PROGRAM-DATE-TIME:", &ptr) && is_discont_detected) { |
| | 1247 | av_log(hls, AV_LOG_VERBOSE, "program_date_time: %s\n", ptr); |
| | 1248 | struct tm program_date_time; |
| | 1249 | int y,M,d,h,m,s; |
| | 1250 | double ms; |
| | 1251 | sscanf(ptr, "%d-%d-%dT%d:%d:%d.%lf", &y, &M, &d, &h, &m, &s, &ms); |
| | 1252 | |
| | 1253 | program_date_time.tm_year = y - 1900; |
| | 1254 | program_date_time.tm_mon = M - 1; |
| | 1255 | program_date_time.tm_mday = d; |
| | 1256 | program_date_time.tm_hour = h; |
| | 1257 | program_date_time.tm_min = m; |
| | 1258 | program_date_time.tm_sec = s; |
| | 1259 | program_date_time.tm_isdst = -1; |
| | 1260 | |
| | 1261 | discont_program_date_time = mktime(&program_date_time); |
| | 1262 | discont_program_date_time += (double)(ms / 1000); |
| | 1263 | is_discont_detected = false; |
| 1240 | 1264 | } else if (av_strstart(line, "#", NULL)) { |
| 1241 | 1265 | continue; |
| 1242 | 1266 | } else if (line[0]) { |
| … |
… |
static int parse_playlist(AVFormatContext *s, const char *url, VariantStream *vs
|
| 1254 | 1278 | ret = hls_append_segment(s, hls, vs, vs->duration, vs->start_pos, vs->size); |
| 1255 | 1279 | if (ret < 0) |
| 1256 | 1280 | goto fail; |
| | 1281 | vs->last_segment->discont_program_date_time = discont_program_date_time; |
| | 1282 | discont_program_date_time += vs->duration; |
| 1257 | 1283 | vs->start_pos = new_start_pos; |
| 1258 | 1284 | } |
| 1259 | 1285 | } |
| … |
… |
static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
|
| 1572 | 1598 | ret = ff_hls_write_file_entry(byterange_mode ? hls->m3u8_out : vs->out, en->discont, byterange_mode, |
| 1573 | 1599 | en->duration, hls->flags & HLS_ROUND_DURATIONS, |
| 1574 | 1600 | en->size, en->pos, hls->baseurl, |
| 1575 | | en->filename, prog_date_time_p, en->keyframe_size, en->keyframe_pos, hls->flags & HLS_I_FRAMES_ONLY); |
| | 1601 | en->filename, |
| | 1602 | en->discont_program_date_time ? &en->discont_program_date_time : prog_date_time_p, |
| | 1603 | en->keyframe_size, en->keyframe_pos, hls->flags & HLS_I_FRAMES_ONLY); |
| 1576 | 1604 | if (ret < 0) { |
| 1577 | 1605 | av_log(s, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n"); |
| 1578 | 1606 | } |
| | 1607 | if (en->discont_program_date_time) |
| | 1608 | en->discont_program_date_time -= en->duration; |
| 1579 | 1609 | } |
| 1580 | 1610 | |
| 1581 | 1611 | if (last && (hls->flags & HLS_OMIT_ENDLIST)==0) |