|
|
|
@@ -101,7 +101,9 @@ typedef struct HLSContext { |
|
|
|
float time; // Set by a private option. |
|
|
|
float init_time; // Set by a private option. |
|
|
|
int max_nb_segments; // Set by a private option. |
|
|
|
#if FF_API_HLS_WRAP |
|
|
|
int wrap; // Set by a private option. |
|
|
|
#endif |
|
|
|
uint32_t flags; // enum HLSFlags |
|
|
|
uint32_t pl_type; // enum PlaylistType |
|
|
|
char *segment_filename; |
|
|
|
@@ -566,7 +568,11 @@ static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, double |
|
|
|
hls->initial_prog_date_time += en->duration; |
|
|
|
hls->segments = en->next; |
|
|
|
if (en && hls->flags & HLS_DELETE_SEGMENTS && |
|
|
|
#if FF_API_HLS_WRAP |
|
|
|
!(hls->flags & HLS_SINGLE_FILE || hls->wrap)) { |
|
|
|
#else |
|
|
|
!(hls->flags & HLS_SINGLE_FILE)) { |
|
|
|
#endif |
|
|
|
en->next = hls->old_segments; |
|
|
|
hls->old_segments = en; |
|
|
|
if ((ret = hls_delete_old_segments(hls)) < 0) |
|
|
|
@@ -834,7 +840,11 @@ static int hls_start(AVFormatContext *s) |
|
|
|
sizeof(vtt_oc->filename)); |
|
|
|
} else if (c->max_seg_size > 0) { |
|
|
|
if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename), |
|
|
|
#if FF_API_HLS_WRAP |
|
|
|
c->basename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) { |
|
|
|
#else |
|
|
|
c->basename, 'd', c->sequence) < 1) { |
|
|
|
#endif |
|
|
|
av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s', you can try to use -use_localtime 1 with it\n", c->basename); |
|
|
|
return AVERROR(EINVAL); |
|
|
|
} |
|
|
|
@@ -853,7 +863,11 @@ static int hls_start(AVFormatContext *s) |
|
|
|
if (!filename) |
|
|
|
return AVERROR(ENOMEM); |
|
|
|
if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename), |
|
|
|
#if FF_API_HLS_WRAP |
|
|
|
filename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) { |
|
|
|
#else |
|
|
|
filename, 'd', c->sequence) < 1) { |
|
|
|
#endif |
|
|
|
av_log(c, AV_LOG_ERROR, |
|
|
|
"Invalid second level segment filename template '%s', " |
|
|
|
"you can try to remove second_level_segment_index flag\n", |
|
|
|
@@ -910,13 +924,21 @@ static int hls_start(AVFormatContext *s) |
|
|
|
av_free(fn_copy); |
|
|
|
} |
|
|
|
} else if (replace_int_data_in_filename(oc->filename, sizeof(oc->filename), |
|
|
|
#if FF_API_HLS_WRAP |
|
|
|
c->basename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) { |
|
|
|
#else |
|
|
|
c->basename, 'd', c->sequence) < 1) { |
|
|
|
#endif |
|
|
|
av_log(oc, AV_LOG_ERROR, "Invalid segment filename template '%s' you can try to use -use_localtime 1 with it\n", c->basename); |
|
|
|
return AVERROR(EINVAL); |
|
|
|
} |
|
|
|
if( c->vtt_basename) { |
|
|
|
if (replace_int_data_in_filename(vtt_oc->filename, sizeof(vtt_oc->filename), |
|
|
|
#if FF_API_HLS_WRAP |
|
|
|
c->vtt_basename, 'd', c->wrap ? c->sequence % c->wrap : c->sequence) < 1) { |
|
|
|
#else |
|
|
|
c->vtt_basename, 'd', c->sequence) < 1) { |
|
|
|
#endif |
|
|
|
av_log(vtt_oc, AV_LOG_ERROR, "Invalid segment filename template '%s'\n", c->vtt_basename); |
|
|
|
return AVERROR(EINVAL); |
|
|
|
} |
|
|
|
@@ -1421,7 +1443,9 @@ static const AVOption options[] = { |
|
|
|
{"hls_list_size", "set maximum number of playlist entries", OFFSET(max_nb_segments), AV_OPT_TYPE_INT, {.i64 = 5}, 0, INT_MAX, E}, |
|
|
|
{"hls_ts_options","set hls mpegts list of options for the container format used for hls", OFFSET(format_options_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, |
|
|
|
{"hls_vtt_options","set hls vtt list of options for the container format used for hls", OFFSET(vtt_format_options_str), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, |
|
|
|
{"hls_wrap", "set number after which the index wraps", OFFSET(wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E}, |
|
|
|
#if FF_API_HLS_WRAP |
|
|
|
{"hls_wrap", "set number after which the index wraps (will be deprecated)", OFFSET(wrap), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, E}, |
|
|
|
#endif |
|
|
|
{"hls_allow_cache", "explicitly set whether the client MAY (1) or MUST NOT (0) cache media segments", OFFSET(allowcache), AV_OPT_TYPE_INT, {.i64 = -1}, INT_MIN, INT_MAX, E}, |
|
|
|
{"hls_base_url", "url to prepend to each playlist entry", OFFSET(baseurl), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, |
|
|
|
{"hls_segment_filename", "filename template for segment files", OFFSET(segment_filename), AV_OPT_TYPE_STRING, {.str = NULL}, 0, 0, E}, |
|
|
|
|