39 #define INITIAL_BUFFER_SIZE 32768
160 const char *
url,
const char *base)
177 int key_len,
char **dest,
int *dest_len)
179 if (!strncmp(key,
"BANDWIDTH=", key_len)) {
192 int key_len,
char **dest,
int *dest_len)
194 if (!strncmp(key,
"METHOD=", key_len)) {
196 *dest_len =
sizeof(info->
method);
197 }
else if (!strncmp(key,
"URI=", key_len)) {
199 *dest_len =
sizeof(info->
uri);
200 }
else if (!strncmp(key,
"IV=", key_len)) {
202 *dest_len =
sizeof(info->
iv);
209 int ret = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
237 if (strcmp(line,
"#EXTM3U")) {
248 if (
av_strstart(line,
"#EXT-X-STREAM-INF:", &ptr)) {
254 }
else if (
av_strstart(line,
"#EXT-X-KEY:", &ptr)) {
260 if (!strcmp(info.
method,
"AES-128"))
262 if (!strncmp(info.
iv,
"0x", 2) || !strncmp(info.
iv,
"0X", 2)) {
267 }
else if (
av_strstart(line,
"#EXT-X-TARGETDURATION:", &ptr)) {
276 }
else if (
av_strstart(line,
"#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
285 }
else if (
av_strstart(line,
"#EXT-X-ENDLIST", &ptr)) {
293 }
else if (line[0]) {
319 memcpy(seg->
iv, iv,
sizeof(iv));
322 memset(seg->
iv, 0,
sizeof(seg->
iv));
363 !=
sizeof(var->
key)) {
376 iv[32] = key[32] =
'\0';
377 if (strstr(seg->
url,
"://"))
430 "skipping %d segments ahead, expired from playlists\n",
490 if (
c->user_agent && !strlen(
c->user_agent))
496 if (
c->cookies && !strlen(
c->cookies))
503 if (
c->n_variants == 0) {
510 if (
c->n_variants > 1 ||
c->variants[0]->n_segments == 0) {
511 for (i = 0; i <
c->n_variants; i++) {
518 if (
c->variants[0]->n_segments == 0) {
526 if (
c->variants[0]->finished) {
528 for (i = 0; i <
c->variants[0]->n_segments; i++)
529 duration +=
c->variants[0]->segments[i]->duration;
534 for (i = 0; i <
c->n_variants; i++) {
537 char bitrate_str[20];
658 int ret, i, minvariant = -1;
714 if (minvariant < 0 || var->cur_seq_no < minvar->
cur_seq_no) {
717 int64_t dts = var->
pkt.
dts;
718 int64_t mindts = minvar->
pkt.
dts;
742 if (minvariant >= 0) {
760 int64_t timestamp,
int flags)
803 if (timestamp >= pos &&
821 if (strncmp(p->
buf,
"#EXTM3U", 7))
823 if (strstr(p->
buf,
"#EXT-X-STREAM-INF:") ||
824 strstr(p->
buf,
"#EXT-X-TARGETDURATION:") ||
825 strstr(p->
buf,
"#EXT-X-MEDIA-SEQUENCE:"))
831 .
name =
"hls,applehttp",