return len;
}
-static void make_absolute_url(char *buf, int size, const char *base,
- const char *rel)
-{
- char *sep;
- /* Absolute path, relative to the current server */
- if (base && strstr(base, "://") && rel[0] == '/') {
- if (base != buf)
- av_strlcpy(buf, base, size);
- sep = strstr(buf, "://");
- if (sep) {
- sep += 3;
- sep = strchr(sep, '/');
- if (sep)
- *sep = '\0';
- }
- av_strlcat(buf, rel, size);
- return;
- }
- /* If rel actually is an absolute url, just copy it */
- if (!base || strstr(rel, "://") || rel[0] == '/') {
- av_strlcpy(buf, rel, size);
- return;
- }
- if (base != buf)
- av_strlcpy(buf, base, size);
- /* Remove the file name from the base url */
- sep = strrchr(buf, '/');
- if (sep)
- sep[1] = '\0';
- else
- buf[0] = '\0';
- while (av_strstart(rel, "../", NULL) && sep) {
- /* Remove the path delimiter at the end */
- sep[0] = '\0';
- sep = strrchr(buf, '/');
- /* If the next directory name to pop off is "..", break here */
- if (!strcmp(sep ? &sep[1] : buf, "..")) {
- /* Readd the slash we just removed */
- av_strlcat(buf, "/", size);
- break;
- }
- /* Cut off the directory name */
- if (sep)
- sep[1] = '\0';
- else
- buf[0] = '\0';
- rel += 3;
- }
- av_strlcat(buf, rel, size);
-}
-
static void free_segment_list(struct variant *var)
{
int i;
return NULL;
reset_packet(&var->pkt);
var->bandwidth = bandwidth;
- make_absolute_url(var->url, sizeof(var->url), base, url);
+ ff_make_absolute_url(var->url, sizeof(var->url), base, url);
dynarray_add(&c->variants, &c->n_variants, var);
return var;
}
if (var)
free_segment_list(var);
c->finished = 0;
- while (!in->eof_reached) {
+ while (!url_feof(in)) {
read_chomp_line(in, line, sizeof(line));
if (av_strstart(line, "#EXT-X-STREAM-INF:", &ptr)) {
struct variant_info info = {{0}};
goto fail;
}
seg->duration = duration;
- make_absolute_url(seg->url, sizeof(seg->url), url, line);
+ ff_make_absolute_url(seg->url, sizeof(seg->url), url, line);
dynarray_add(&var->segments, &var->n_segments, seg);
is_segment = 0;
}
if (var->pb && !var->pkt.data) {
ret = av_read_frame(var->ctx, &var->pkt);
if (ret < 0) {
- if (!var->pb->eof_reached)
+ if (!url_feof(var->pb))
return ret;
reset_packet(&var->pkt);
}
c->max_start_seq - c->cur_seq_no);
c->cur_seq_no = c->max_start_seq;
}
- /* If more segments exit, open the next one */
+ /* If more segments exist, open the next one */
if (c->cur_seq_no < c->min_end_seq)
goto start;
/* We've reached the end of the playlists - return eof if this is a
return AVERROR_EOF;
while (av_gettime() - c->last_load_time < c->target_duration*1000000) {
if (url_interrupt_cb())
- return AVERROR(EINTR);
+ return AVERROR_EXIT;
usleep(100*1000);
}
/* Enough time has elapsed since the last reload */