75 for (
i = 0;
i <
s->n_segments;
i++)
84 for (
i = 0;
i <
s->n_variants;
i++)
95 int key_len,
char **dest,
int *dest_len)
97 if (!strncmp(
key,
"BANDWIDTH=", key_len)) {
107 int ret = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
113 &
h->interrupt_callback,
NULL,
114 h->protocol_whitelist,
h->protocol_blacklist)) < 0)
118 if (strcmp(
line,
"#EXTM3U")) {
136 s->start_seq_no = atoi(ptr);
144 }
else if (
line[0]) {
155 }
else if (is_variant) {
189 const char *nested_url;
197 av_strlcpy(
s->playlisturl, nested_url,
sizeof(
s->playlisturl));
198 }
else if (
av_strstart(uri,
"hls://", &nested_url)) {
200 "No nested protocol specified. Specify e.g. hls+http://%s\n",
210 "Using the hls protocol is discouraged, please try using the "
211 "hls demuxer instead. The hls demuxer should be more complete "
212 "and work as well as the protocol implementation. (If not, "
213 "please report it.) To use the demuxer, simply use %s as url.\n",
219 if (
s->n_segments == 0 &&
s->n_variants > 0) {
220 int max_bandwidth = 0, maxvar = -1;
221 for (
i = 0;
i <
s->n_variants;
i++) {
222 if (
s->variants[
i]->bandwidth > max_bandwidth ||
i == 0) {
223 max_bandwidth =
s->variants[
i]->bandwidth;
228 sizeof(
s->playlisturl));
233 if (
s->n_segments == 0) {
238 s->cur_seq_no =
s->start_seq_no;
239 if (!
s->finished &&
s->n_segments >= 3)
240 s->cur_seq_no =
s->start_seq_no +
s->n_segments - 3;
254 int64_t reload_interval;
266 reload_interval =
s->n_segments > 0 ?
267 s->segments[
s->n_segments - 1]->duration :
272 if (now -
s->last_load_time >= reload_interval) {
278 reload_interval =
s->target_duration / 2;
281 if (
s->cur_seq_no <
s->start_seq_no) {
283 "skipping %d segments ahead, expired from playlist\n",
284 s->start_seq_no -
s->cur_seq_no);
285 s->cur_seq_no =
s->start_seq_no;
287 if (
s->cur_seq_no -
s->start_seq_no >=
s->n_segments) {
297 url =
s->segments[
s->cur_seq_no -
s->start_seq_no]->url;
300 &
h->interrupt_callback,
NULL,
301 h->protocol_whitelist,
h->protocol_blacklist,
h);
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
int ffurl_read(URLContext *h, unsigned char *buf, int size)
Read up to size bytes from the resource accessed by h, and store the read bytes in buf.
int ff_check_interrupt(AVIOInterruptCB *cb)
Check if the user has requested to interrupt a blocking function associated with cb.
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.
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
int avio_feof(AVIOContext *s)
Similar to feof() but also returns nonzero on read errors.
#define AVIO_FLAG_WRITE
write-only
int avio_close(AVIOContext *s)
Close the resource accessed by the AVIOContext s and free it.
int ffio_open_whitelist(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options, const char *whitelist, const char *blacklist)
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,...)
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
#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_ERROR
Something went wrong and cannot losslessly be recovered.
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.
#define AV_TIME_BASE
Internal time base represented as integer.
static void handle_variant_args(struct variant_info *info, const char *key, int key_len, char **dest, int *dest_len)
static int hls_read(URLContext *h, uint8_t *buf, int size)
static int parse_playlist(URLContext *h, const char *url)
static int hls_open(URLContext *h, const char *uri, int flags)
static void free_segment_list(HLSContext *s)
const URLProtocol ff_hls_protocol
static int hls_close(URLContext *h)
static void free_variant_list(HLSContext *s)
common internal API header
char playlisturl[MAX_URL_SIZE]
struct segment ** segments
struct variant ** variants
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.
unbuffered private I/O API
#define URL_PROTOCOL_FLAG_NESTED_SCHEME