42 #define INITIAL_BUFFER_SIZE 32768
44 #define MAX_FIELD_LEN 64
45 #define MAX_CHARACTERISTICS_LEN 512
47 #define MPEG_TIME_BASE 90000
48 #define MPEG_TIME_BASE_Q (AVRational){1, MPEG_TIME_BASE}
221 for (
i = 0;
i < n_segments;
i++) {
250 for (
i = 0;
i <
c->n_playlists;
i++) {
279 for (
i = 0;
i <
c->n_variants;
i++) {
291 for (
i = 0;
i <
c->n_renditions;
i++)
332 const char *
url,
const char *
base)
358 int key_len,
char **dest,
int *dest_len)
360 if (!strncmp(
key,
"BANDWIDTH=", key_len)) {
363 }
else if (!strncmp(
key,
"AUDIO=", key_len)) {
365 *dest_len =
sizeof(info->
audio);
366 }
else if (!strncmp(
key,
"VIDEO=", key_len)) {
368 *dest_len =
sizeof(info->
video);
369 }
else if (!strncmp(
key,
"SUBTITLES=", key_len)) {
382 int key_len,
char **dest,
int *dest_len)
384 if (!strncmp(
key,
"METHOD=", key_len)) {
386 *dest_len =
sizeof(info->
method);
387 }
else if (!strncmp(
key,
"URI=", key_len)) {
389 *dest_len =
sizeof(info->
uri);
390 }
else if (!strncmp(
key,
"IV=", key_len)) {
392 *dest_len =
sizeof(info->
iv);
403 const char *url_base)
446 int key_len,
char **dest,
int *dest_len)
448 if (!strncmp(
key,
"URI=", key_len)) {
450 *dest_len =
sizeof(info->
uri);
451 }
else if (!strncmp(
key,
"BYTERANGE=", key_len)) {
470 const char *url_base)
474 char *characteristic;
478 if (!strcmp(info->
type,
"AUDIO"))
480 else if (!strcmp(info->
type,
"VIDEO"))
482 else if (!strcmp(info->
type,
"SUBTITLES"))
484 else if (!strcmp(info->
type,
"CLOSED-CAPTIONS"))
527 int langlen = strlen(rend->
language);
528 if (langlen <
sizeof(rend->
language) - 3) {
531 sizeof(rend->
language) - langlen - 2);
537 if (!strcmp(info->
forced,
"YES"))
541 while ((characteristic =
av_strtok(chr_ptr,
",", &saveptr))) {
542 if (!strcmp(characteristic,
"public.accessibility.describes-music-and-sound"))
544 else if (!strcmp(characteristic,
"public.accessibility.describes-video"))
554 int key_len,
char **dest,
int *dest_len)
556 if (!strncmp(
key,
"TYPE=", key_len)) {
558 *dest_len =
sizeof(info->
type);
559 }
else if (!strncmp(
key,
"URI=", key_len)) {
561 *dest_len =
sizeof(info->
uri);
562 }
else if (!strncmp(
key,
"GROUP-ID=", key_len)) {
565 }
else if (!strncmp(
key,
"LANGUAGE=", key_len)) {
568 }
else if (!strncmp(
key,
"ASSOC-LANGUAGE=", key_len)) {
571 }
else if (!strncmp(
key,
"NAME=", key_len)) {
573 *dest_len =
sizeof(info->
name);
574 }
else if (!strncmp(
key,
"DEFAULT=", key_len)) {
577 }
else if (!strncmp(
key,
"FORCED=", key_len)) {
579 *dest_len =
sizeof(info->
forced);
580 }
else if (!strncmp(
key,
"CHARACTERISTICS=", key_len)) {
603 *pls =
c->playlists[
c->n_playlists - 1];
610 #if !CONFIG_HTTP_PROTOCOL
616 (*pb)->eof_reached = 0;
630 const char *proto_name =
NULL;
635 if (url[6] ==
'+' || url[6] ==
':')
638 if (url[4] ==
'+' || url[4] ==
':')
650 if (strcmp(
c->allowed_extensions,
"ALL") && !
av_match_ext(url,
c->allowed_extensions)) {
652 "Filename extension of \'%s\' is not a common multimedia extension, blocked for security reasons.\n"
653 "If you wish to override this adjust allowed_extensions, you can set it to \'ALL\' to allow all\n",
664 if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] ==
':')
666 else if (
av_strstart(url,
"crypto",
NULL) && !strncmp(proto_name, url + 7, strlen(proto_name)) && url[7 + strlen(proto_name)] ==
':')
668 else if (
av_strstart(url,
"data",
NULL) && !strncmp(proto_name, url + 5, strlen(proto_name)) && url[5 + strlen(proto_name)] ==
':')
670 else if (strcmp(proto_name,
"file") || !strncmp(url,
"file,", 5))
676 if (is_http &&
c->http_persistent && *pb) {
681 }
else if (ret < 0) {
684 "keepalive request failed for '%s' with error: '%s' when opening url, retrying with new connection\n",
695 char *new_cookies =
NULL;
707 *is_http_out = is_http;
715 int ret = 0, is_segment = 0, is_variant = 0;
732 int prev_n_segments = 0;
733 int64_t prev_start_seq_no = -1;
735 if (is_http && !
in &&
c->http_persistent &&
c->playlist_pb) {
740 }
else if (ret < 0) {
743 "keepalive request failed for '%s' with error: '%s' when parsing playlist\n",
753 if (
c->http_persistent)
761 if (is_http &&
c->http_persistent)
771 if (strcmp(
line,
"#EXTM3U")) {
799 if (!strcmp(info.
method,
"AES-128"))
801 if (!strcmp(info.
method,
"SAMPLE-AES"))
803 if (!strncmp(info.
iv,
"0x", 2) || !strncmp(info.
iv,
"0X", 2)) {
818 t = strtoll(ptr,
NULL, 10);
829 seq_no = strtoull(ptr,
NULL, 10);
830 if (seq_no > INT64_MAX/2) {
832 "INT64_MAX/2, mask out the highest bit\n");
833 seq_no &= INT64_MAX/2;
840 if (!strcmp(ptr,
"EVENT"))
842 else if (!strcmp(ptr,
"VOD"))
852 cur_init_section->
key_type = key_type;
854 memcpy(cur_init_section->
iv, iv,
sizeof(iv));
857 memset(cur_init_section->
iv, 0,
sizeof(cur_init_section->
iv));
869 if (!cur_init_section->
key) {
885 seg_size = strtoll(ptr,
NULL, 10);
886 ptr = strchr(ptr,
'@');
888 seg_offset = strtoll(ptr+1,
NULL, 10);
892 }
else if (
line[0]) {
911 memcpy(seg->
iv,
iv,
sizeof(
iv));
914 memset(seg->
iv, 0,
sizeof(seg->
iv));
953 " set to default value to 1ms.\n", seg->
url);
961 seg->
size = seg_size;
964 seg_offset += seg_size;
977 int64_t prev_timestamp =
c->first_timestamp;
980 for (
i = 0;
i < prev_n_segments &&
i <
diff;
i++) {
981 c->first_timestamp += prev_segments[
i]->
duration;
984 " reflected in first_timestamp: %"PRId64
" -> %"PRId64
"\n",
986 prev_timestamp,
c->first_timestamp);
1002 if (!
c->n_variants || !
c->variants[0]->n_playlists ||
1003 !(
c->variants[0]->playlists[0]->finished ||
1043 static const char id3_priv_owner_ts[] =
"com.apple.streaming.transportStreamTimestamp";
1047 for (meta = *extra_meta; meta; meta = meta->
next) {
1048 if (!strcmp(meta->
tag,
"PRIV")) {
1050 if (priv->
datasize == 8 && !strcmp(priv->
owner, id3_priv_owner_ts)) {
1054 if ((ts & ~((1ULL << 33) - 1)) == 0)
1059 }
else if (!strcmp(meta->
tag,
"APIC") && apic)
1073 if (!oldentry || strcmp(oldentry->
value, entry->
value) != 0)
1101 parse_id3(pls->
ctx, pb, &metadata, ×tamp, &apic, &extra_meta);
1137 int buf_size,
int *
len)
1142 int id3_buf_pos = 0;
1160 }
else if (*
len <= 0) {
1173 int tag_got_bytes =
FFMIN(taglen, *
len);
1174 int remaining = taglen - tag_got_bytes;
1176 if (taglen > maxsize) {
1192 memcpy(pls->
id3_buf + id3_buf_pos, buf, tag_got_bytes);
1193 id3_buf_pos += tag_got_bytes;
1196 *
len -= tag_got_bytes;
1197 memmove(buf, buf + tag_got_bytes, *
len);
1200 if (remaining > 0) {
1204 id3_buf_pos += remaining;
1242 if (
c->http_persistent)
1245 if (seg->
size >= 0) {
1263 if (ret !=
sizeof(pls->
key)) {
1276 iv[32] =
key[32] =
'\0';
1277 if (strstr(seg->
url,
"://"))
1292 "SAMPLE-AES encryption is not supported yet\n");
1308 if (ret == 0 && !is_http && seg->
url_offset) {
1325 static const int max_init_section_size = 1024*1024;
1342 "Failed to open an initialization section in playlist %d\n",
1352 sec_size = max_init_section_size;
1355 "Downloading an initialization section of size %"PRId64
"\n",
1358 sec_size =
FFMIN(sec_size, max_init_section_size);
1391 int stream_needed = 0;
1417 for (
i = 0;
i <
s->nb_programs;
i++) {
1438 int just_opened = 0;
1439 int reload_count = 0;
1465 if (reload_count >
c->max_reload)
1482 "skipping %"PRId64
" segments ahead, expired from playlists\n",
1537 if (
c->http_multiple == -1) {
1541 c->http_multiple = (!strncmp((
const char *)http_version_opt,
"1.1", 3) || !strncmp((
const char *)http_version_opt,
"2.0", 3));
1580 if (
c->http_persistent &&
1598 for (
i = 0;
i <
c->n_renditions;
i++) {
1654 0 :
c->first_timestamp;
1656 if (timestamp <
pos) {
1679 if (!pls->
finished && !
c->first_packet &&
1693 if (!
c->first_packet &&
1700 return c->cur_seq_no;
1704 if (
c->live_start_index < 0)
1717 static const char *
const opts[] = {
1718 "headers",
"http_proxy",
"user_agent",
"cookies",
"referer",
"rw_timeout",
"icy",
NULL };
1719 const char *
const * opt =
opts;
1740 "A HLS playlist item '%s' referred to an external file '%s'. "
1741 "Opening this file was forbidden for security reasons\n",
1752 for (
i = 0;
i <
c->n_variants;
i++) {
1796 memcpy(dst_data, sd_src->
data, sd_src->
size);
1833 int flag_needed = 0;
1836 for (
i = 0;
i <
c->n_playlists;
i++) {
1869 int64_t highest_cur_seq_no = 0;
1872 c->interrupt_callback = &
s->interrupt_callback;
1874 c->first_packet = 1;
1889 if (
c->n_variants == 0) {
1896 if (
c->n_playlists > 1 ||
c->playlists[0]->n_segments == 0) {
1897 for (
i = 0;
i <
c->n_playlists;
i++) {
1903 if (
c->n_playlists > 1)
1910 for (
i = 0;
i <
c->n_variants;
i++) {
1911 if (
c->variants[
i]->playlists[0]->n_segments == 0) {
1913 c->variants[
i]->playlists[0]->broken = 1;
1919 if (
c->variants[0]->playlists[0]->finished) {
1921 for (
i = 0;
i <
c->variants[0]->playlists[0]->n_segments;
i++)
1922 duration +=
c->variants[0]->playlists[0]->segments[
i]->duration;
1927 for (
i = 0;
i <
c->n_variants;
i++) {
1939 for (
i = 0;
i <
c->n_variants;
i++) {
1950 for (
i = 0;
i <
c->n_playlists;
i++) {
1961 for (
i = 0;
i <
c->n_playlists;
i++) {
1999 pls->
ctx->
probesize =
s->probesize > 0 ?
s->probesize : 1024 * 4;
2083 for (
i = 0;
i <
c->n_playlists;
i++) {
2091 if (cur_needed && !pls->
needed) {
2103 }
else if (first && !cur_needed && pls->
needed) {
2161 int ret,
i, minplaylist = -1;
2164 c->first_packet = 0;
2166 for (
i = 0;
i <
c->n_playlists;
i++) {
2218 struct playlist *minpls = minplaylist < 0 ?
2219 NULL :
c->playlists[minplaylist];
2220 if (minplaylist < 0) {
2234 if (minplaylist >= 0) {
2235 struct playlist *pls =
c->playlists[minplaylist];
2263 av_log(
s,
AV_LOG_ERROR,
"stream index inconsistency: index %d, %d main streams, %d subdemuxer streams\n",
2300 int stream_subdemuxer_index;
2308 0 :
c->first_timestamp;
2311 s->streams[stream_index]->time_base.den,
2322 for (
i = 0;
i <
c->n_playlists;
i++) {
2327 stream_subdemuxer_index = j;
2341 for (
i = 0;
i <
c->n_playlists;
i++) {
2360 if (pls != seek_pls) {
2380 if (strncmp(p->
buf,
"#EXTM3U", 7))
2383 if (strstr(p->
buf,
"#EXT-X-STREAM-INF:") ||
2384 strstr(p->
buf,
"#EXT-X-TARGETDURATION:") ||
2385 strstr(p->
buf,
"#EXT-X-MEDIA-SEQUENCE:"))
2390 #define OFFSET(x) offsetof(HLSContext, x)
2391 #define FLAGS AV_OPT_FLAG_DECODING_PARAM
2393 {
"live_start_index",
"segment index to start live streams at (negative values are from the end)",
2395 {
"allowed_extensions",
"List of file extensions that hls is allowed to access",
2397 {.str =
"3gp,aac,avi,ac3,eac3,flac,mkv,m3u8,m4a,m4s,m4v,mpg,mov,mp2,mp3,mp4,mpeg,mpegts,ogg,ogv,oga,ts,vob,wav"},
2398 INT_MIN, INT_MAX,
FLAGS},
2399 {
"max_reload",
"Maximum number of times a insufficient list is attempted to be reloaded",
2401 {
"m3u8_hold_counters",
"The maximum number of times to load m3u8 when it refreshes without new segments",
2403 {
"http_persistent",
"Use persistent HTTP connections",
2405 {
"http_multiple",
"Use multiple HTTP connections for fetching segments",
2407 {
"http_seekable",
"Use HTTP partial requests, 0 = disable, 1 = enable, -1 = auto",
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define FF_COMPLIANCE_EXPERIMENTAL
Allow nonstandardized experimental things.
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
const char * avio_find_protocol_name(const char *url)
Return the name of the protocol that will handle the passed URL.
int64_t avio_seek(AVIOContext *s, int64_t offset, int whence)
fseek() equivalent for AVIOContext.
#define AVIO_FLAG_READ
read-only
int64_t avio_size(AVIOContext *s)
Get the filesize.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
int avio_read(AVIOContext *s, unsigned char *buf, int size)
Read size bytes from AVIOContext into buf.
URLContext * ffio_geturlcontext(AVIOContext *s)
Return the URLContext associated with the AVIOContext.
int ffio_init_context(AVIOContext *s, unsigned char *buffer, int buffer_size, int write_flag, void *opaque, int(*read_packet)(void *opaque, uint8_t *buf, int buf_size), int(*write_packet)(void *opaque, uint8_t *buf, int buf_size), int64_t(*seek)(void *opaque, int64_t offset, int whence))
static int read_packet(void *opaque, uint8_t *buf, int buf_size)
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.
#define flags(name, subs,...)
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
#define FFSWAP(type, a, b)
const OptionDef options[]
static int read_header(FFV1Context *f)
static av_cold void cleanup(FlashSV2Context *s)
#define AV_OPT_SEARCH_CHILDREN
Search in possible children of the given object first.
#define AV_OPT_ALLOW_NULL
In av_opt_get, return NULL if the option has a pointer type and is set to NULL, rather than returning...
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
@ AVDISCARD_ALL
discard all
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, size_t size)
Allocate new information from stream.
AVProgram * av_new_program(AVFormatContext *s, int id)
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
AVFormatContext * avformat_alloc_context(void)
Allocate an AVFormatContext.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
int av_probe_input_buffer(AVIOContext *pb, ff_const59 AVInputFormat **fmt, const char *url, void *logctx, unsigned int offset, unsigned int max_probe_size)
Like av_probe_input_buffer2() but returns 0 on success.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
void av_program_add_stream_index(AVFormatContext *ac, int progid, unsigned int idx)
int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
Read packets of a media file to get stream information.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
int avformat_open_input(AVFormatContext **ps, const char *url, ff_const59 AVInputFormat *fmt, AVDictionary **options)
Open an input stream and read the header.
int avformat_queue_attached_pictures(AVFormatContext *s)
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values.
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key,...
int av_dict_copy(AVDictionary **dst, const AVDictionary *src, int flags)
Copy entries from one AVDictionary struct into another.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
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_MATCH_CASE
Only get an entry with exact-case key match.
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
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_EXIT
Immediate exit was requested; the called function should not be restarted.
#define AVERROR_PROTOCOL_NOT_FOUND
Protocol not found.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#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_INFO
Standard 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_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd)
Rescale a 64-bit integer with specified rounding.
@ AV_ROUND_DOWN
Round toward -infinity.
@ AV_ROUND_UP
Round toward +infinity.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
int64_t av_compare_mod(uint64_t a, uint64_t b, uint64_t mod)
Compare the remainders of two integer operands divided by a common divisor.
void av_fast_malloc(void *ptr, unsigned int *size, size_t min_size)
Allocate a buffer, reusing the given one if large enough.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
char * av_strdup(const char *s)
Duplicate a string.
void * av_fast_realloc(void *ptr, unsigned int *size, size_t min_size)
Reallocate the given buffer if it is not large enough, otherwise do nothing.
@ AVMEDIA_TYPE_UNKNOWN
Usually treated as AVMEDIA_TYPE_DATA.
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_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.
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
Internal time base represented as integer.
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
#define LIBAVUTIL_VERSION_INT
int av_opt_get(void *obj, const char *name, int search_flags, uint8_t **out_val)
static void update_noheader_flag(AVFormatContext *s)
#define MAX_CHARACTERISTICS_LEN
static void handle_variant_args(struct variant_info *info, const char *key, int key_len, char **dest, int *dest_len)
static int open_input(HLSContext *c, struct playlist *pls, struct segment *seg, AVIOContext **in)
static int update_init_section(struct playlist *pls, struct segment *seg)
static struct segment * next_segment(struct playlist *pls)
static struct rendition * new_rendition(HLSContext *c, struct rendition_info *info, const char *url_base)
static int read_from_url(struct playlist *pls, struct segment *seg, uint8_t *buf, int buf_size)
#define INITIAL_BUFFER_SIZE
static void handle_init_section_args(struct init_section_info *info, const char *key, int key_len, char **dest, int *dest_len)
static int hls_read_header(AVFormatContext *s)
static struct segment * current_segment(struct playlist *pls)
static int read_data(void *opaque, uint8_t *buf, int buf_size)
static int set_stream_info_from_input_stream(AVStream *st, struct playlist *pls, AVStream *ist)
static void free_segment_list(struct playlist *pls)
static void handle_rendition_args(struct rendition_info *info, const char *key, int key_len, char **dest, int *dest_len)
static void free_init_section_list(struct playlist *pls)
static void add_renditions_to_variant(HLSContext *c, struct variant *var, enum AVMediaType type, const char *group_id)
static int hls_probe(const AVProbeData *p)
static int ensure_playlist(HLSContext *c, struct playlist **pls, const char *url)
static int recheck_discard_flags(AVFormatContext *s, int first)
static AVRational get_timebase(struct playlist *pls)
static void fill_timing_for_id3_timestamped_stream(struct playlist *pls)
static void parse_id3(AVFormatContext *s, AVIOContext *pb, AVDictionary **metadata, int64_t *dts, ID3v2ExtraMetaAPIC **apic, ID3v2ExtraMeta **extra_meta)
static void handle_key_args(struct key_info *info, const char *key, int key_len, char **dest, int *dest_len)
static int64_t default_reload_interval(struct playlist *pls)
static int find_timestamp_in_playlist(HLSContext *c, struct playlist *pls, int64_t timestamp, int64_t *seq_no)
static int open_url_keepalive(AVFormatContext *s, AVIOContext **pb, const char *url, AVDictionary **options)
static void add_metadata_from_renditions(AVFormatContext *s, struct playlist *pls, enum AVMediaType type)
static int update_streams_from_subdemuxer(AVFormatContext *s, struct playlist *pls)
static void add_stream_to_programs(AVFormatContext *s, struct playlist *pls, AVStream *stream)
static int hls_close(AVFormatContext *s)
static struct playlist * new_playlist(HLSContext *c, const char *url, const char *base)
static int nested_io_open(AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **opts)
static void handle_id3(AVIOContext *pb, struct playlist *pls)
static void free_segment_dynarray(struct segment **segments, int n_segments)
static int compare_ts_with_wrapdetect(int64_t ts_a, struct playlist *pls_a, int64_t ts_b, struct playlist *pls_b)
static struct segment * new_init_section(struct playlist *pls, struct init_section_info *info, const char *url_base)
static int parse_playlist(HLSContext *c, const char *url, struct playlist *pls, AVIOContext *in)
static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
static int save_avio_options(AVFormatContext *s)
static const AVOption hls_options[]
static void free_rendition_list(HLSContext *c)
static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url, AVDictionary **opts, AVDictionary *opts2, int *is_http_out)
static int id3_has_changed_values(struct playlist *pls, AVDictionary *metadata, ID3v2ExtraMetaAPIC *apic)
static void free_playlist_list(HLSContext *c)
static const AVClass hls_class
static int64_t select_cur_seq_no(HLSContext *c, struct playlist *pls)
static struct variant * new_variant(HLSContext *c, struct variant_info *info, const char *url, const char *base)
static void intercept_id3(struct playlist *pls, uint8_t *buf, int buf_size, int *len)
static int playlist_needed(struct playlist *pls)
static void free_variant_list(HLSContext *c)
AVInputFormat ff_hls_demuxer
static int hls_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
int ff_http_do_new_request2(URLContext *h, const char *uri, AVDictionary **opts)
Send a new HTTP request, reusing the old connection.
int ff_id3v2_tag_len(const uint8_t *buf)
Get the length of an ID3v2 tag.
int ff_id3v2_match(const uint8_t *buf, const char *magic)
Detect ID3v2 Header.
void ff_id3v2_free_extra_meta(ID3v2ExtraMeta **extra_meta)
Free memory allocated parsing special (non-text) metadata.
int ff_id3v2_parse_priv_dict(AVDictionary **metadata, ID3v2ExtraMeta *extra_meta)
Parse PRIV tags into a dictionary.
int ff_id3v2_parse_apic(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Create a stream for each APIC (attached picture) extracted from the ID3v2 header.
int ff_id3v2_parse_priv(AVFormatContext *s, ID3v2ExtraMeta *extra_meta)
Add metadata for all PRIV tags in the ID3v2 header.
void ff_id3v2_read_dict(AVIOContext *pb, AVDictionary **metadata, const char *magic, ID3v2ExtraMeta **extra_meta)
Read an ID3v2 tag into specified dictionary and retrieve supported extra metadata.
#define ID3v2_DEFAULT_MAGIC
Default magic bytes for ID3v2 header: "ID3".
#define ID3v2_HEADER_SIZE
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
void avpriv_report_missing_feature(void *avc, const char *msg,...) av_printf_format(2
Log a generic warning message about a missing feature.
static av_cold int read_close(AVFormatContext *ctx)
static int read_seek(AVFormatContext *ctx, int stream_index, int64_t timestamp, int flags)
int size
Size of data in bytes.
uint8_t * data
The data buffer.
Describe the class of an AVClass context structure.
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
enum AVMediaType codec_type
General type of the encoded data.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
int event_flags
Flags indicating events happening on the file, a combination of AVFMT_EVENT_FLAG_*.
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
AVIOContext * pb
I/O context.
AVDictionary * metadata
Metadata that applies to the whole file.
int flags
Flags modifying the (de)muxer behaviour.
int64_t max_analyze_duration
Maximum duration (in AV_TIME_BASE units) of the data read from input in avformat_find_stream_info().
int ctx_flags
Flags signalling stream properties.
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
void * priv_data
Format private data.
int64_t probesize
Maximum size of the data read from input for determining the input container format.
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.
unsigned char * buf_end
End of the data, may be less than buffer+buffer_size if the read function returned less data than req...
unsigned char * buf_ptr
Current position in the buffer.
int64_t pos
position in the file of the current buffer
unsigned char * buffer
Start of the buffer.
int eof_reached
true if was unable to read due to error or eof
Callback for checking whether to abort blocking functions.
enum AVPacketSideDataType type
This structure stores compressed data.
int flags
A combination of AV_PKT_FLAG values.
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed.
This structure contains the data a format has to probe a file.
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
New fields can be added to the end with minor version bumps.
unsigned int nb_stream_indexes
unsigned int * stream_index
enum AVDiscard discard
selects which program to discard and which to feed to the caller
Rational number (pair of numerator and denominator).
int need_context_update
Whether the internal avctx needs to be updated from codecpar (after a late change to codecpar)
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
int id
Format-specific stream ID.
int index
stream index in AVFormatContext
int pts_wrap_bits
number of bits in pts (used for wrapping control)
AVPacket attached_pic
For streams with AV_DISPOSITION_ATTACHED_PIC disposition, this packet will contain the attached pictu...
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int event_flags
Flags indicating events happening on the stream, a combination of AVSTREAM_EVENT_FLAG_*.
int nb_side_data
The number of elements in the AVStream.side_data array.
AVStreamInternal * internal
An opaque field for libavformat internal usage.
int disposition
AV_DISPOSITION_* bit field.
struct rendition ** renditions
AVIOInterruptCB * interrupt_callback
AVIOContext * playlist_pb
struct variant ** variants
struct playlist ** playlists
char * allowed_extensions
int64_t id3_mpegts_timestamp
struct rendition ** renditions
unsigned int init_sec_data_len
unsigned int id3_buf_size
unsigned int init_sec_buf_read_offset
struct segment * cur_init_section
char key_url[MAX_URL_SIZE]
struct segment ** segments
struct segment ** init_sections
unsigned int init_sec_buf_size
ID3v2ExtraMeta * id3_deferred_extra
AVDictionary * id3_initial
char language[MAX_FIELD_LEN]
char group_id[MAX_FIELD_LEN]
char characteristics[MAX_CHARACTERISTICS_LEN]
char assoc_language[MAX_FIELD_LEN]
char group_id[MAX_FIELD_LEN]
char language[MAX_FIELD_LEN]
struct playlist * playlist
struct segment * init_section
char video[MAX_FIELD_LEN]
char subtitles[MAX_FIELD_LEN]
char audio[MAX_FIELD_LEN]
char audio_group[MAX_FIELD_LEN]
struct playlist ** playlists
char video_group[MAX_FIELD_LEN]
char subtitles_group[MAX_FIELD_LEN]
int av_usleep(unsigned usec)
Sleep for a period of time.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
int ff_make_absolute_url(char *buf, int size, const char *base, const char *rel)
Convert a relative url into an absolute url, given a base url.
static void fill_buf(uint8_t *data, int w, int h, int linesize, uint8_t v)
static av_always_inline int diff(const uint32_t a, const uint32_t b)