Go to the documentation of this file.
73 for (
i = 0;
i <
s->n_segments;
i++)
82 for (
i = 0;
i <
s->n_variants;
i++)
93 int key_len,
char **dest,
int *dest_len)
95 if (!strncmp(
key,
"BANDWIDTH=", key_len)) {
96 *dest =
info->bandwidth;
97 *dest_len =
sizeof(
info->bandwidth);
105 int ret = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
111 &
h->interrupt_callback,
NULL,
112 h->protocol_whitelist,
h->protocol_blacklist)) < 0)
116 if (strcmp(
line,
"#EXTM3U")) {
134 s->start_seq_no = atoi(ptr);
142 }
else if (
line[0]) {
153 }
else if (is_variant) {
187 const char *nested_url;
195 av_strlcpy(
s->playlisturl, nested_url,
sizeof(
s->playlisturl));
196 }
else if (
av_strstart(uri,
"hls://", &nested_url)) {
198 "No nested protocol specified. Specify e.g. hls+http://%s\n",
208 "Using the hls protocol is discouraged, please try using the "
209 "hls demuxer instead. The hls demuxer should be more complete "
210 "and work as well as the protocol implementation. (If not, "
211 "please report it.) To use the demuxer, simply use %s as url.\n",
217 if (
s->n_segments == 0 &&
s->n_variants > 0) {
218 int max_bandwidth = 0, maxvar = -1;
219 for (
i = 0;
i <
s->n_variants;
i++) {
220 if (
s->variants[
i]->bandwidth > max_bandwidth ||
i == 0) {
221 max_bandwidth =
s->variants[
i]->bandwidth;
226 sizeof(
s->playlisturl));
231 if (
s->n_segments == 0) {
236 s->cur_seq_no =
s->start_seq_no;
237 if (!
s->finished &&
s->n_segments >= 3)
238 s->cur_seq_no =
s->start_seq_no +
s->n_segments - 3;
264 reload_interval =
s->n_segments > 0 ?
265 s->segments[
s->n_segments - 1]->duration :
270 if (now -
s->last_load_time >= reload_interval) {
276 reload_interval =
s->target_duration / 2;
279 if (
s->cur_seq_no <
s->start_seq_no) {
281 "skipping %d segments ahead, expired from playlist\n",
282 s->start_seq_no -
s->cur_seq_no);
283 s->cur_seq_no =
s->start_seq_no;
285 if (
s->cur_seq_no -
s->start_seq_no >=
s->n_segments) {
295 url =
s->segments[
s->cur_seq_no -
s->start_seq_no]->url;
298 &
h->interrupt_callback,
NULL,
299 h->protocol_whitelist,
h->protocol_blacklist,
h);
static int hls_open(URLContext *h, const char *uri, int flags)
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.
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
int ffio_open_whitelist(AVIOContext **s, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist)
#define AV_LOG_WARNING
Something somehow does not look correct.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
#define AVERROR_EOF
End of file.
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
const URLProtocol ff_hls_protocol
int ffurl_open_whitelist(URLContext **puc, const char *filename, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist, URLContext *parent)
Create an URLContext for accessing to the resource indicated by url, and open it.
static int hls_close(URLContext *h)
#define AVIO_FLAG_WRITE
write-only
static void handle_variant_args(struct variant_info *info, const char *key, int key_len, char **dest, int *dest_len)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static void free_segment_list(HLSContext *s)
static int hls_read(URLContext *h, uint8_t *buf, int size)
int av_usleep(unsigned usec)
Sleep for a period of time.
struct variant ** variants
static int parse_playlist(URLContext *h, const char *url)
struct segment ** segments
char playlisturl[MAX_URL_SIZE]
#define URL_PROTOCOL_FLAG_NESTED_SCHEME
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
#define i(width, name, range_min, range_max)
#define AV_TIME_BASE
Internal time base represented as integer.
int ffurl_closep(URLContext **hh)
Close the resource accessed by the URLContext h, and free the memory used by it.
#define AVIO_FLAG_READ
read-only
static void free_variant_list(HLSContext *s)
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.
#define flags(name, subs,...)
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
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.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
static int ffurl_read(URLContext *h, uint8_t *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf.