24#include "config_components.h"
50#if CONFIG_HTTP_PROTOCOL
73#define LINE_BUFFER_SIZE MAX_URL_SIZE
74#define HLS_MICROSECOND_UNIT 1000000
75#define BUFSIZE (16 * 1024)
76#define POSTFIX_PATTERN "_%d"
271 struct tm *tm, tmpbuf;
298#if CONFIG_HTTP_PROTOCOL
320#if CONFIG_HTTP_PROTOCOL
337 }
else if (http_base_proto) {
342 if (
c->http_persistent)
370 "%s%s", codec_strlen ?
"," :
"", attr);
396 if (
c ==
'%' && *(p+1) ==
'%')
398 else if (
c ==
'%' && *(p+1) == placeholder) {
406 if (addchar_count > 0) {
424 int nd, addchar_count;
436 if (
c ==
'%' && *(p+1) ==
'%')
438 else if (
c ==
'%' && (
av_isdigit(*(p+1)) || *(p+1) == placeholder)) {
442 nd = nd * 10 + *(p + addchar_count) -
'0';
446 if (*(p + addchar_count) == placeholder) {
447 av_bprintf(&buf,
"%0*"PRId64, (number < 0) ? nd : nd++, number);
448 p += (addchar_count + 1);
506 char *path,
const char *proto)
522 }
else if (unlink(path) < 0) {
524 path, strerror(errno));
534 float playlist_duration = 0.0f;
538 const char *dirname =
NULL;
539 char *dirname_r =
NULL;
540 char *dirname_repl =
NULL;
541 const char *vtt_dirname =
NULL;
542 char *vtt_dirname_r =
NULL;
543 const char *proto =
NULL;
560 if (playlist_duration <= -previous_segment->
duration) {
590 dirname = dirname_repl;
609 if ((
segment->sub_filename[0] !=
'\0')) {
648 len = strlen(key_basename_source) + 4 + 1;
665 uint8_t iv[16] = { 0 };
671 memcpy(iv, hls->
iv,
sizeof(iv));
760 if (ret !=
sizeof(
key)) {
778 int remaining_options;
835 for (
i = 0;
i <
s->nb_programs;
i++) {
849 av_log(
s,
AV_LOG_WARNING,
"http persistent mode is currently unsupported for fragment mp4 in the HLS muxer.\n");
862 if (byterange_mode) {
881 snprintf(period,
sizeof(period),
"%d", (INT_MAX / 2) - 1);
890 if (remaining_options) {
920 char *filename =
NULL;
923 "Invalid second level segment filename template '%s', "
924 "you can try to remove second_level_segment_size flag\n",
932 char *filename =
NULL;
936 "Invalid second level segment filename template '%s', "
937 "you can try to remove second_level_segment_duration flag\n",
954 "second_level_segment_duration hls_flag requires strftime to be true\n");
959 "second_level_segment_size hls_flag requires strfime to be true\n");
964 "second_level_segment_index hls_flag requires strftime to be true\n");
974 int segment_renaming_ok = proto && !strcmp(proto,
"file");
979 "second_level_segment_duration hls_flag works only with file protocol segment names\n");
984 "second_level_segment_size hls_flag works only with file protocol segment names\n");
1001 char *filename =
NULL;
1005 "you can try to remove second_level_segment_index flag\n",
1016 char *filename =
NULL;
1019 "you can try to remove second_level_segment_size flag\n",
1027 char *filename =
NULL;
1030 "you can try to remove second_level_segment_duration flag\n",
1048 const char *filename;
1076 && !byterange_mode) {
1103#define NEXT(s) ((s) + strlen(s) + 1)
1146 const char *dot = strrchr(filename,
'.');
1147 const char *num_start;
1153 if (dot == filename)
1157 while (num_start > filename &&
1158 num_start[-1] >=
'0' && num_start[-1] <=
'9')
1160 if (num_start == dot)
1164 value = strtol(num_start, &end, 10);
1165 if (errno == ERANGE || end != dot ||
value > INT_MAX)
1175 int ret = 0, is_segment = 0;
1180 double discont_program_date_time = 0;
1186 if (strcmp(
line,
"#EXTM3U")) {
1196 if (tmp_sequence < vs->sequence)
1198 "Found playlist sequence number was smaller """
1199 "than specified start sequence number: %"PRId64
" < %"PRId64
", "
1202 av_log(hls,
AV_LOG_DEBUG,
"Found playlist sequence number: %"PRId64
"\n", tmp_sequence);
1214 ptr += strlen(
"URI=\"");
1215 end = strchr(ptr,
'"');
1227 ptr += strlen(
"IV=0x");
1236 struct tm program_date_time = { 0 };
1246 program_date_time.tm_isdst = -1;
1249 time_t t = mktime(&program_date_time);
1250 if (t == (time_t)-1 && errno == EOVERFLOW) {
1254 discont_program_date_time = t;
1256 discont_program_date_time += (
double)(ms / 1000);
1259 }
else if (
line[0]) {
1271 char *vtt_file =
NULL;
1273 if (ret < 0 || !vtt_file) {
1285 if (discont_program_date_time) {
1287 discont_program_date_time += vs->
duration;
1314 size_t len = strlen(oc->
url);
1318 if (!final_filename)
1320 final_filename[
len-4] =
'\0';
1329 const char *p = strrchr(master_url,
'/');
1330 size_t base_len = 0;
1332 if (!p) p = strrchr(master_url,
'\\');
1335 base_len = p - master_url;
1344 return media_url + base_len + 1;
1373 int ret, bandwidth, avg_bandwidth;
1374 const char *m3u8_rel_name =
NULL;
1375 const char *vtt_m3u8_rel_name =
NULL;
1376 const char *ccgroup;
1377 const char *sgroup =
NULL;
1380 int is_file_proto = proto && !strcmp(proto,
"file");
1428 if (!m3u8_rel_name) {
1446 if (!m3u8_rel_name) {
1460 if (!vid_st && !aud_st) {
1494 bandwidth += bandwidth / 10;
1512 if (vid_st && vs->
sgroup) {
1515 if (!vtt_m3u8_rel_name) {
1548 int target_duration = 0;
1554 int is_file_proto = proto && !strcmp(proto,
"file");
1556 static unsigned warned_non_file;
1557 const char *key_uri =
NULL;
1558 char *iv_string =
NULL;
1569 if (byterange_mode) {
1587 av_log(
s,
AV_LOG_ERROR,
"Cannot use rename on non file protocol, this may lead to races and temporary partial files\n");
1590 snprintf(temp_filename,
sizeof(temp_filename), use_temp_file ?
"%s.tmp" :
"%s", vs->
m3u8_name);
1598 if (target_duration <= en->
duration)
1647 snprintf(temp_vtt_filename,
sizeof(temp_vtt_filename), use_temp_file ?
"%s.tmp" :
"%s", vs->
vtt_m3u8_name);
1676 if (use_temp_file) {
1694 const char *proto =
NULL;
1695 int use_temp_file = 0;
1696 char iv_string[
KEYSIZE*2 + 1];
1710 }
else if (
c->max_seg_size > 0) {
1711 char *filename =
NULL;
1720 if (
c->use_localtime) {
1722 char *expanded =
NULL;
1736 if (
c->use_localtime_mkdir) {
1742 if (
ff_mkdir_p(dir) == -1 && errno != EEXIST) {
1743 av_log(oc,
AV_LOG_ERROR,
"Could not create directory %s with use_localtime_mkdir\n", dir);
1750 char *filename =
NULL;
1760 char *filename =
NULL;
1772 use_temp_file = proto && !strcmp(proto,
"file") && (
c->flags &
HLS_TEMP_FILE);
1774 if (use_temp_file) {
1781 if (
c->key_info_file ||
c->encrypt) {
1787 if (
c->key_info_file &&
c->encrypt) {
1789 " ignoring -hls_enc\n");
1793 if (
c->key_info_file) {
1797 if (!
c->encrypt_started) {
1800 c->encrypt_started = 1;
1812 memcpy(vs->
iv_string, iv_string,
sizeof(iv_string));
1820 if (
c->key_info_file ||
c->encrypt) {
1837 if (
c->ignore_io_errors)
1843 if (
c->ignore_io_errors)
1853 if (
c->ignore_io_errors)
1879 int strftime_s_supported = 0;
1882 time_t t = time(
NULL);
1885 int strftime_s_supported = strftime(
b,
sizeof(
b),
"%s", p) && strcmp(
b,
"%s");
1889 return strftime_s_supported ?
"-%s.m4s" :
"-%Y%m%d%H%M%S.m4s";
1891 return strftime_s_supported ?
"-%s.ts" :
"-%Y%m%d%H%M%S.ts";
1897 char extension[10] = {
'\0'};
1899 p = strrchr(
name,
'.');
1907 if (strlen(extension))
1915 const char *filename, *subdir_name;
1916 char *fn_dup =
NULL;
1930 "either in the filename or in the sub-directory name of file %s\n",
fn);
1937 "in the sub-directory name of file %s, but only in one of them\n",
fn);
1949 const char *proto, *dir;
1950 char *orig_buf_dup =
NULL, *mod_buf_dup =
NULL;
1978 if (
av_stristr(dir,
"%v") && proto && !strcmp(proto,
"file")) {
1981 if (
ff_mkdir_p(dir) == -1 && errno != EEXIST) {
1997 unsigned int stream_index, cnt;
1998 if (stream_id < 0 || stream_id >
s->nb_streams - 1)
2001 for (stream_index = 0; stream_index <
s->nb_streams; stream_index++) {
2002 if (
s->streams[stream_index]->codecpar->codec_type !=
codec_type)
2004 if (cnt == stream_id)
2005 return stream_index;
2015 int stream_index,
i, j;
2018 char *p, *q, *saveptr1, *saveptr2, *varstr, *keyval;
2041 while (
av_strtok(q,
" \t", &saveptr1)) {
2054 while (varstr =
av_strtok(p,
" \t", &saveptr1)) {
2057 if (nb_varstreams < hls->nb_varstreams) {
2080 while (keyval =
av_strtok(varstr,
",", &saveptr2)) {
2119 num = strtoll(
val, &end, 10);
2128 if (vs->
streams[
i] ==
s->streams[stream_index]) {
2130 "variant definition #%d\n", nb_varstreams - 1);
2134 for (j = 0; nb_varstreams > 1 && j < nb_varstreams - 1; j++) {
2138 "in two different variant definitions #%d and #%d\n",
2139 j, nb_varstreams - 1);
2160 int nb_ccstreams = 0;
2161 char *p, *q, *ccstr, *keyval;
2162 char *saveptr1 =
NULL, *saveptr2 =
NULL;
2171 while (
av_strtok(q,
" \t", &saveptr1)) {
2184 while (ccstr =
av_strtok(p,
" \t", &saveptr1)) {
2187 if (nb_ccstreams < hls->nb_ccstreams)
2192 while (keyval =
av_strtok(ccstr,
",", &saveptr2)) {
2213 if (atoi(
val) < 1 || atoi(
val) > 4) {
2219 if (atoi(
val) < 1 || atoi(
val) > 63) {
2266 for (
i = 0;
i <
s->nb_streams;
i++)
2297 if (dir && strcmp(dir,
"."))
2321 int subtitle_streams = 0;
2336 "(%"PRId64
" > %"PRId64
"), the result maybe not be what you want.",
2342 inner_st = vs->
avf->
streams[j - subtitle_streams];
2397 char *filename =
NULL;
2411 if (read_byte > 0) {
2413 total_size += read_byte;
2416 }
while (read_byte > 0);
2431 int stream_index = 0;
2432 int range_length = 0;
2433 const char *proto =
NULL;
2434 int use_temp_file = 0;
2436 char *old_filename =
NULL;
2439 int subtitle_streams = 0;
2451 stream_index = j - subtitle_streams;
2473 end_pts = init_list_dur + after_init_list_dur ;
2506 if (
pkt->duration) {
2509 av_log(
s,
AV_LOG_WARNING,
"Stream %d packet with pts %" PRId64
" has duration 0. The segment duration may not be precise.\n",
2510 pkt->stream_index,
pkt->pts);
2521 double cur_duration;
2530 if (range_length <= 0)
2539 if (!byterange_mode) {
2544 if (!byterange_mode) {
2556 vs->
size = range_length;
2562 use_temp_file = proto && !strcmp(proto,
"file")
2568 char *filename =
NULL;
2590 "Failed to open file '%s'\n", filename);
2604 vs->
size = range_length;
2608 " will retry with a new http session.\n");
2629 if (!old_filename) {
2742 char *old_filename =
NULL;
2743 const char *proto =
NULL;
2744 int use_temp_file = 0;
2749 int range_length, byterange_mode;
2752 char *filename =
NULL;
2759 if (!old_filename) {
2788 if (!byterange_mode) {
2808 vs->
size = range_length;
2845 if (!old_filename) {
2882 const char *pattern;
2887 double initial_program_date_time =
av_gettime() / 1000000.0;
2906 if (!hls->
method && http_base_proto) {
2944 time_t t = time(
NULL);
2951 struct tm *p, tmbuf;
2954 if (!strftime(
b,
sizeof(
b),
"%Y%m%d%H%M%S", p))
2967 "'split_by_time' and 'independent_segments' cannot be "
2968 "enabled together. Disabling 'independent_segments' flag\n");
3037 fmp4_init_filename_len);
3052 char *expanded =
NULL;
3115 " hls_init_time value will have no effect\n");
3129#define OFFSET(x) offsetof(HLSContext, x)
3130#define E AV_OPT_FLAG_ENCODING_PARAM
3135 {
"hls_list_size",
"set maximum number of playlist entries",
OFFSET(max_nb_segments),
AV_OPT_TYPE_INT, {.i64 = 5}, 0, INT_MAX,
E},
3136 {
"hls_delete_threshold",
"set number of unreferenced segments to keep before deleting",
OFFSET(hls_delete_threshold),
AV_OPT_TYPE_INT, {.i64 = 1}, 1, INT_MAX,
E},
3137 {
"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},
3138 {
"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},
3141 {
"hls_segment_options",
"set segments files format options of hls",
OFFSET(format_options),
AV_OPT_TYPE_DICT, {.str =
NULL}, 0, 0,
E},
3142 {
"hls_segment_size",
"maximum size per segment file, (in bytes)",
OFFSET(max_seg_size),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX,
E},
3152 {
"hls_fmp4_init_filename",
"set fragment mp4 file init filename",
OFFSET(fmp4_init_filename),
AV_OPT_TYPE_STRING, {.str =
"init.mp4"}, 0, 0,
E},
3153 {
"hls_fmp4_init_resend",
"resend fragment mp4 init file after refresh m3u8 every time",
OFFSET(resend_init_file),
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1,
E },
3154 {
"hls_flags",
"set flags affecting HLS playlist and media file generation",
OFFSET(
flags),
AV_OPT_TYPE_FLAGS, {.i64 = 0 }, 0, UINT_MAX,
E, .unit =
"flags"},
3156 {
"temp_file",
"write segment and playlist to temporary file and rename when complete", 0,
AV_OPT_TYPE_CONST, {.i64 =
HLS_TEMP_FILE }, 0, UINT_MAX,
E, .unit =
"flags"},
3168 {
"independent_segments",
"add EXT-X-INDEPENDENT-SEGMENTS, whenever applicable", 0,
AV_OPT_TYPE_CONST, { .i64 =
HLS_INDEPENDENT_SEGMENTS }, 0, UINT_MAX,
E, .unit =
"flags"},
3169 {
"iframes_only",
"add EXT-X-I-FRAMES-ONLY, whenever applicable", 0,
AV_OPT_TYPE_CONST, { .i64 =
HLS_I_FRAMES_ONLY }, 0, UINT_MAX,
E, .unit =
"flags"},
3170 {
"strftime",
"set filename expansion with strftime at segment creation",
OFFSET(use_localtime),
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1,
E },
3171 {
"strftime_mkdir",
"create last directory component in strftime-generated filename",
OFFSET(use_localtime_mkdir),
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1,
E },
3185 {
"master_pl_publish_rate",
"Publish master play list every after this many segment intervals",
OFFSET(master_publish_rate),
AV_OPT_TYPE_INT, {.i64 = 0}, 0, UINT_MAX,
E},
3186 {
"http_persistent",
"Use persistent HTTP connections",
OFFSET(http_persistent),
AV_OPT_TYPE_BOOL, {.i64 = 0 }, 0, 1,
E },
3187 {
"timeout",
"set timeout for socket I/O operations",
OFFSET(timeout),
AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, .flags =
E },
3188 {
"ignore_io_errors",
"Ignore IO errors for stable long-duration runs with network output",
OFFSET(ignore_io_errors),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
E },
3189 {
"headers",
"set custom HTTP headers, can override built in default headers",
OFFSET(headers),
AV_OPT_TYPE_STRING, { .str =
NULL }, 0, 0,
E },
3194 .class_name =
"hls muxer",
3204 .p.extensions =
"m3u8",
static double val(void *priv, double ch)
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ffurl_shutdown(URLContext *h, int flags)
Signal the URLContext that we are done reading or writing the stream.
URLContext * ffio_geturlcontext(AVIOContext *s)
Return the URLContext associated with the AVIOContext.
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
int ff_rename(const char *url_src, const char *url_dst, void *logctx)
Wrap ffurl_move() and log if error happens.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
void avio_wb32(AVIOContext *s, unsigned int val)
#define AVIO_FLAG_READ
read-only
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
#define AVIO_FLAG_WRITE
write-only
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2
Writes a formatted string to the context.
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void avio_flush(AVIOContext *s)
Force flushing of buffered data.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
static av_always_inline void ffio_wfourcc(AVIOContext *pb, const uint8_t *s)
int ff_get_chomp_line(AVIOContext *s, char *buf, int maxlen)
Same as ff_get_line but strip the white-space characters in the text tail.
int ff_get_line(AVIOContext *s, char *buf, int maxlen)
Read a whole line of text from AVIOContext.
char * av_asprintf(const char *fmt,...)
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
#define AV_BPRINT_SIZE_UNLIMITED
#define flags(name, subs,...)
#define i(width, name, range_min, range_max)
static void deinit(AVFormatContext *s)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
int ff_make_codec_str(void *logctx, const AVCodecParameters *par, const AVRational *frame_rate, struct AVBPrint *out)
Make a RFC 4281/6381 like string describing a codec.
static void can_split(const VVCLocalContext *lc, int x0, int y0, int cb_width, int cb_height, int mtt_depth, int depth_offset, int part_idx, VVCSplitMode last_split_mode, VVCTreeType tree_type, VVCModeType mode_type, VVCAllowedSplit *split)
Misc types and constants that do not belong anywhere else.
int(* init)(AVBSFContext *ctx)
static int write_packet(Muxer *mux, OutputStream *ost, AVPacket *pkt)
static unsigned int nb_streams
static void write_header(FFV1Context *f)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
@ AV_OPT_TYPE_DURATION
Underlying C type is int64_t.
@ AV_OPT_TYPE_FLAGS
Underlying C type is unsigned int.
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
@ AV_OPT_TYPE_INT
Underlying C type is int.
@ AV_OPT_TYPE_DICT
Underlying C type is AVDictionary*.
@ AV_OPT_TYPE_BOOL
Underlying C type is int.
@ AV_OPT_TYPE_STRING
Underlying C type is a uint8_t* that is either NULL or points to a C string allocated with the av_mal...
const AVPacketSideData * av_packet_side_data_get(const AVPacketSideData *sd, int nb_sd, enum AVPacketSideDataType type)
Get side information from a side data array.
@ AV_PKT_DATA_CPB_PROPERTIES
This side data corresponds to the AVCPBProperties struct.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
AVStream * avformat_new_stream(AVFormatContext *s, const struct AVCodec *c)
Add a new stream to a media file.
int av_program_copy(AVFormatContext *dst, const AVFormatContext *src, int progid, int flags)
Copy an AVProgram from one AVFormatContext to another.
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
av_warn_unused_result int avformat_init_output(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and initialize the codec, but do not write the header.
av_warn_unused_result int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
int av_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file.
unsigned int av_codec_get_tag(const struct AVCodecTag *const *tags, enum AVCodecID id)
Get the codec tag for the given codec id id.
enum AVCodecID av_codec_get_id(const struct AVCodecTag *const *tags, unsigned int tag)
Get the AVCodecID for the given codec tag tag.
static int av_bprint_is_complete(const AVBPrint *buf)
Test if the print buffer is complete (not truncated).
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
void av_bprint_append_data(AVBPrint *buf, const char *data, unsigned size)
Append data to a print buffer.
void av_bprint_chars(AVBPrint *buf, char c, unsigned n)
Append char c n times to a print buffer.
void av_bprint_clear(AVBPrint *buf)
Reset the string to "" but keep internal allocated data.
void av_bprint_init_for_buffer(AVBPrint *buf, char *buffer, unsigned size)
Init a print buffer using a pre-existing buffer.
int av_random_bytes(uint8_t *buf, size_t len)
Generate cryptographically secure random data, i.e.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
#define AV_DICT_APPEND
If the entry already exists, append to it.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
int av_dict_count(const AVDictionary *m)
Get number of entries in dictionary.
int av_dict_set_int(AVDictionary **pm, const char *key, int64_t value, int flags)
Convenience wrapper for av_dict_set() that converts the value to a string and stores it.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_MUXER_NOT_FOUND
Muxer not found.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_WARNING
Something somehow does not look correct.
#define AV_LOG_VERBOSE
Detailed information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const char * av_default_item_name(void *ptr)
Return the context name.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes,...
char * av_stristr(const char *s1, const char *s2)
Locate the first case-independent occurrence in the string haystack of the string needle.
char * av_strtok(char *s, const char *delim, char **saveptr)
Split the string into several tokens which can be accessed by successive calls to av_strtok().
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static av_const int av_isdigit(int c)
Locale-independent conversion of ASCII isdigit.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
const char * av_dirname(char *path)
Thread safe dirname.
const char * av_basename(const char *path)
Thread safe basename.
int av_stristart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str independent of case.
char * av_append_path_component(const char *path, const char *component)
Append path component to the existing path.
int av_strncasecmp(const char *a, const char *b, size_t n)
Locale-independent case-insensitive compare.
#define AV_NOPTS_VALUE
Undefined timestamp value.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
#define LIBAVUTIL_VERSION_INT
int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
static const AVClass hls_class
static int sls_flag_check_duration_size_index(HLSContext *hls)
static int update_variant_stream_info(AVFormatContext *s)
static int64_t get_stream_bit_rate(AVStream *stream)
static HLSSegment * find_segment_by_filename(HLSSegment *segment, const char *filename)
static void set_http_options(AVFormatContext *s, AVDictionary **options, HLSContext *c)
static int create_master_playlist(AVFormatContext *s, VariantStream *const input_vs, int final)
static int hls_init(AVFormatContext *s)
static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
static int validate_name(int nb_vs, const char *fn)
static const char * get_relative_url(const char *master_url, const char *media_url)
static int get_nth_codec_stream_index(AVFormatContext *s, enum AVMediaType codec_type, int64_t stream_id)
static int hls_rename_temp_file(AVFormatContext *s, AVFormatContext *oc)
static int parse_variant_stream_mapstring(AVFormatContext *s)
static int extract_segment_number(const char *filename)
static int append_postfix(char *name, int name_buf_len, int i)
static void hls_free_segments(HLSSegment *p)
static int hls_write_header(AVFormatContext *s)
static int hls_append_segment(struct AVFormatContext *s, HLSContext *hls, VariantStream *vs, double duration, int64_t pos, int64_t size)
static int format_name(const char *buf, char **s, int index, const char *varname)
static int replace_int_data_in_filename(char **s, const char *filename, char placeholder, int64_t number)
static int replace_str_data_in_filename(char **s, const char *filename, char placeholder, const char *datastring)
static void reflush_dynbuf(VariantStream *vs, int *range_length)
static int do_encrypt(AVFormatContext *s, VariantStream *vs)
static int sls_flag_use_localtime_filename(AVFormatContext *oc, HLSContext *c, VariantStream *vs)
static int hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char *filename)
static int hls_init_file_resend(AVFormatContext *s, VariantStream *vs)
static int64_t append_single_file(AVFormatContext *s, VariantStream *vs)
static void sls_flag_file_rename(HLSContext *hls, VariantStream *vs, char *old_filename)
static int strftime_expand(const char *fmt, char **dest)
static int hls_write_trailer(struct AVFormatContext *s)
static void hls_deinit(AVFormatContext *s)
@ HLS_START_SEQUENCE_AS_MICROSECONDS_SINCE_EPOCH
@ HLS_START_SEQUENCE_AS_FORMATTED_DATETIME
@ HLS_START_SEQUENCE_AS_SECONDS_SINCE_EPOCH
@ HLS_START_SEQUENCE_LAST
@ HLS_START_SEQUENCE_AS_START_NUMBER
static int flush_dynbuf(VariantStream *vs, int *range_length)
static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, const char *filename, AVDictionary **options)
static int parse_playlist(AVFormatContext *s, const char *url, VariantStream *vs)
#define HLS_MICROSECOND_UNIT
static int hls_start(AVFormatContext *s, VariantStream *vs)
static void write_styp(AVIOContext *pb)
static const char * get_default_pattern_localtime_fmt(AVFormatContext *s)
static int hls_encryption_start(AVFormatContext *s, VariantStream *vs)
static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
static int hls_mux_init(AVFormatContext *s, VariantStream *vs)
static int parse_cc_stream_mapstring(AVFormatContext *s)
@ HLS_SECOND_LEVEL_SEGMENT_INDEX
@ HLS_INDEPENDENT_SEGMENTS
@ HLS_SECOND_LEVEL_SEGMENT_DURATION
@ HLS_SECOND_LEVEL_SEGMENT_SIZE
@ CODEC_ATTRIBUTE_WILL_NOT_BE_WRITTEN
@ CODEC_ATTRIBUTE_WRITTEN
static int hls_delete_old_segments(AVFormatContext *s, HLSContext *hls, VariantStream *vs)
static int hls_delete_file(HLSContext *hls, AVFormatContext *avf, char *path, const char *proto)
static int sls_flags_filename_process(struct AVFormatContext *s, HLSContext *hls, VariantStream *vs, double duration, int64_t pos, int64_t size)
static int sls_flag_check_duration_size(HLSContext *hls, VariantStream *vs)
static int update_master_pl_info(AVFormatContext *s)
static void write_codec_attr(AVStream *st, VariantStream *vs)
void ff_hls_write_playlist_version(AVIOContext *out, int version)
void ff_hls_write_playlist_header(AVIOContext *out, int version, int allowcache, int target_duration, int64_t sequence, uint32_t playlist_type, int iframe_mode)
void ff_hls_write_audio_rendition(AVIOContext *out, const char *agroup, const char *filename, const char *language, int name_id, int is_default, int nb_channels)
void ff_hls_write_init_file(AVIOContext *out, const char *filename, int byterange_mode, int64_t size, int64_t pos)
void ff_hls_write_subtitle_rendition(AVIOContext *out, const char *sgroup, const char *filename, const char *language, const char *sname, int name_id, int is_default)
void ff_hls_write_end_list(AVIOContext *out)
int ff_hls_write_file_entry(AVIOContext *out, int insert_discont, int byterange_mode, double duration, int round_duration, int64_t size, int64_t pos, const char *baseurl, const char *filename, double *prog_date_time, int iframe_mode)
void ff_hls_write_stream_info(AVStream *st, AVIOContext *out, int bandwidth, int avg_bandwidth, const char *filename, const char *agroup, const char *codecs, const char *ccgroup, const char *sgroup)
int ff_http_do_new_request(URLContext *h, const char *uri)
Send a new HTTP request, reusing the old connection.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
static av_always_inline av_const double round(double x)
Utility Preprocessor macros.
#define MKTAG(a, b, c, d)
Memory handling functions.
#define FF_OFMT_FLAG_ALLOW_FLUSH
This flag indicates that the muxer stores data internally and supports flushing it.
miscellaneous OS support macros and functions.
char * av_small_strptime(const char *p, const char *fmt, struct tm *dt)
Simplified version of strptime.
enum AVMediaType codec_type
static const uint8_t start_sequence[]
This structure describes the bitrate properties of an encoded bitstream.
int64_t max_bitrate
Maximum bitrate of the stream, in bits per second.
int nb_channels
Number of channels in this layout.
Describe the class of an AVClass context structure.
int nb_coded_side_data
Amount of entries in coded_side_data.
AVChannelLayout ch_layout
The channel layout and number of channels.
int64_t bit_rate
The average bitrate of the encoded data (in bits per second).
enum AVMediaType codec_type
General type of the encoded data.
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
AVPacketSideData * coded_side_data
Additional data associated with the entire stream.
int(* io_close2)(struct AVFormatContext *s, AVIOContext *pb)
A callback for closing the streams opened with AVFormatContext.io_open().
AVIOContext * pb
I/O context.
AVDictionary * metadata
Metadata that applies to the whole file.
int flags
Flags modifying the (de)muxer behaviour.
const struct AVOutputFormat * oformat
The output container format.
int strict_std_compliance
Allow non-standard and experimental extension.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
char * url
input or output URL.
void * priv_data
Format private data.
AVStream ** streams
A list of all streams in the file.
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
A callback for opening new IO streams.
This structure stores auxiliary information for decoding, presenting, or otherwise processing the cod...
This structure stores compressed data.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
int id
Format-specific stream ID.
int index
stream index in AVFormatContext
int pts_wrap_bits
Number of bits in timestamps.
AVRational avg_frame_rate
Average framerate.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
unsigned int nb_ccstreams
ClosedCaptionsStream * cc_streams
AVDictionary * format_options
unsigned int master_publish_rate
VariantStream * var_streams
uint32_t start_sequence_source_type
AVIOContext * sub_m3u8_out
char key_string[KEYSIZE *2+1]
char * fmp4_init_filename
char key_uri[LINE_BUFFER_SIZE+1]
int use_localtime_mkdir
flag to mkdir dirname in timebased filename
char * vtt_format_options_str
int use_localtime
flag to expand filename with localtime
AVIOContext * http_delete
unsigned int nb_varstreams
int resend_init_file
resend init file into disk after refresh m3u8
char iv_string[KEYSIZE *2+1]
AVDictionary * vtt_format_options
char key_file[LINE_BUFFER_SIZE+1]
double discont_program_date_time
const char * sub_filename
char iv_string[KEYSIZE *2+1]
char key_file[LINE_BUFFER_SIZE+1]
double initial_prog_date_time
HLSSegment * old_segments
AVIOContext * out_single_file
const char * subtitle_varname
const AVOutputFormat * vtt_oformat
int reference_stream_index
const AVOutputFormat * oformat
char * fmp4_init_filename
char key_string[KEYSIZE *2+1]
char key_uri[LINE_BUFFER_SIZE+1]
AVFormatContext * vtt_avf
char * base_output_dirname
CodecAttributeStatus attr_status
char current_segment_final_filename_fmt[MAX_URL_SIZE]
char iv_string[KEYSIZE *2+1]
HLSSegment * last_segment
static AVFormatContext * ctx
int64_t av_gettime(void)
Get the current time in microseconds.
unbuffered private I/O API
static int write_trailer(AVFormatContext *s1)