*/
struct segment {
- int duration;
+ int64_t duration;
char url[MAX_URL_SIZE];
};
typedef struct HLSContext {
char playlisturl[MAX_URL_SIZE];
- int target_duration;
+ int64_t target_duration;
int start_seq_no;
int finished;
int n_segments;
{
HLSContext *s = h->priv_data;
AVIOContext *in;
- int ret = 0, duration = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
+ int ret = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
+ int64_t duration = 0;
char line[1024];
const char *ptr;
&info);
bandwidth = atoi(info.bandwidth);
} else if (av_strstart(line, "#EXT-X-TARGETDURATION:", &ptr)) {
- s->target_duration = atoi(ptr);
+ s->target_duration = atoi(ptr) * AV_TIME_BASE;
} else if (av_strstart(line, "#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
s->start_seq_no = atoi(ptr);
} else if (av_strstart(line, "#EXT-X-ENDLIST", &ptr)) {
s->finished = 1;
} else if (av_strstart(line, "#EXTINF:", &ptr)) {
is_segment = 1;
- duration = atoi(ptr);
+ duration = atof(ptr) * AV_TIME_BASE;
} else if (av_strstart(line, "#", NULL)) {
continue;
} else if (line[0]) {
nested_url);
ret = AVERROR(EINVAL);
goto fail;
-#if FF_API_APPLEHTTP_PROTO
- } else if (av_strstart(uri, "applehttp+", &nested_url)) {
- av_strlcpy(s->playlisturl, nested_url, sizeof(s->playlisturl));
- av_log(h, AV_LOG_WARNING,
- "The applehttp protocol is deprecated, use hls+%s as url "
- "instead.\n", nested_url);
- } else if (av_strstart(uri, "applehttp://", &nested_url)) {
- av_strlcpy(s->playlisturl, "http://", sizeof(s->playlisturl));
- av_strlcat(s->playlisturl, nested_url, sizeof(s->playlisturl));
- av_log(h, AV_LOG_WARNING,
- "The applehttp protocol is deprecated, use hls+http://%s as url "
- "instead.\n", nested_url);
-#endif
} else {
av_log(h, AV_LOG_ERROR, "Unsupported url %s\n", uri);
ret = AVERROR(EINVAL);
reload_interval = s->n_segments > 0 ?
s->segments[s->n_segments - 1]->duration :
s->target_duration;
- reload_interval *= 1000000;
retry:
if (!s->finished) {
int64_t now = av_gettime();
/* If we need to reload the playlist again below (if
* there's still no more segments), switch to a reload
* interval of half the target duration. */
- reload_interval = s->target_duration * 500000;
+ reload_interval = s->target_duration / 2;
}
}
if (s->cur_seq_no < s->start_seq_no) {
goto start;
}
-#if FF_API_APPLEHTTP_PROTO
-URLProtocol ff_applehttp_protocol = {
- .name = "applehttp",
- .url_open = hls_open,
- .url_read = hls_read,
- .url_close = hls_close,
- .flags = URL_PROTOCOL_FLAG_NESTED_SCHEME,
- .priv_data_size = sizeof(HLSContext),
-};
-#endif
-
URLProtocol ff_hls_protocol = {
.name = "hls",
.url_open = hls_open,