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,
duration = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
236 if (strcmp(line,
"#EXTM3U")) {
247 if (
av_strstart(line,
"#EXT-X-STREAM-INF:", &ptr)) {
253 }
else if (
av_strstart(line,
"#EXT-X-KEY:", &ptr)) {
259 if (!strcmp(info.
method,
"AES-128"))
261 if (!strncmp(info.
iv,
"0x", 2) || !strncmp(info.
iv,
"0X", 2)) {
266 }
else if (
av_strstart(line,
"#EXT-X-TARGETDURATION:", &ptr)) {
275 }
else if (
av_strstart(line,
"#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
284 }
else if (
av_strstart(line,
"#EXT-X-ENDLIST", &ptr)) {
292 }
else if (line[0]) {
318 memcpy(seg->
iv, iv,
sizeof(iv));
321 memset(seg->
iv, 0,
sizeof(seg->
iv));
362 !=
sizeof(var->
key)) {
375 iv[32] = key[32] =
'\0';
376 if (strstr(seg->
url,
"://"))
416 reload_interval *= 1000000;
430 "skipping %d segments ahead, expired from playlists\n",
489 if (
c->user_agent && !strlen(
c->user_agent))
495 if (
c->cookies && !strlen(
c->cookies))
502 if (
c->n_variants == 0) {
509 if (
c->n_variants > 1 ||
c->variants[0]->n_segments == 0) {
510 for (i = 0; i <
c->n_variants; i++) {
517 if (
c->variants[0]->n_segments == 0) {
525 if (
c->variants[0]->finished) {
527 for (i = 0; i <
c->variants[0]->n_segments; i++)
528 duration +=
c->variants[0]->segments[i]->duration;
533 for (i = 0; i <
c->n_variants; i++) {
536 char bitrate_str[20];
657 int ret, i, minvariant = -1;
710 int64_t dts = var->
pkt.
dts;
711 int64_t mindts = minvar->
pkt.
dts;
728 if (minvariant >= 0) {
746 int64_t timestamp,
int flags)
792 if (timestamp >= pos &&
810 if (strncmp(p->
buf,
"#EXTM3U", 7))
812 if (strstr(p->
buf,
"#EXT-X-STREAM-INF:") ||
813 strstr(p->
buf,
"#EXT-X-TARGETDURATION:") ||
814 strstr(p->
buf,
"#EXT-X-MEDIA-SEQUENCE:"))
820 .
name =
"hls,applehttp",