39 #define INITIAL_BUFFER_SIZE 32768
193 const char *
url,
const char *base)
217 int key_len,
char **dest,
int *dest_len)
219 if (!strncmp(key,
"BANDWIDTH=", key_len)) {
232 int key_len,
char **dest,
int *dest_len)
234 if (!strncmp(key,
"METHOD=", key_len)) {
236 *dest_len =
sizeof(info->
method);
237 }
else if (!strncmp(key,
"URI=", key_len)) {
239 *dest_len =
sizeof(info->
uri);
240 }
else if (!strncmp(key,
"IV=", key_len)) {
242 *dest_len =
sizeof(info->
iv);
249 int ret = 0, is_segment = 0, is_variant = 0, bandwidth = 0;
282 if (strcmp(line,
"#EXTM3U")) {
293 if (
av_strstart(line,
"#EXT-X-STREAM-INF:", &ptr)) {
299 }
else if (
av_strstart(line,
"#EXT-X-KEY:", &ptr)) {
305 if (!strcmp(info.
method,
"AES-128"))
307 if (!strncmp(info.
iv,
"0x", 2) || !strncmp(info.
iv,
"0X", 2)) {
312 }
else if (
av_strstart(line,
"#EXT-X-TARGETDURATION:", &ptr)) {
321 }
else if (
av_strstart(line,
"#EXT-X-MEDIA-SEQUENCE:", &ptr)) {
330 }
else if (
av_strstart(line,
"#EXT-X-ENDLIST", &ptr)) {
338 }
else if (line[0]) {
364 memcpy(seg->
iv, iv,
sizeof(iv));
367 memset(seg->
iv, 0,
sizeof(seg->
iv));
414 !=
sizeof(pls->
key)) {
427 iv[32] = key[32] =
'\0';
428 if (strstr(seg->
url,
"://"))
480 "skipping %d segments ahead, expired from playlists\n",
529 int variant_count = 0;
532 for (i = 0; i < c->
n_variants && variant_count < 2; i++) {
543 return variant_count >= 2;
550 int ret = 0, i, j, stream_offset = 0;
559 if (
c->user_agent && !strlen(
c->user_agent))
565 if (
c->cookies && !strlen(
c->cookies))
571 if (
c->headers && !strlen(
c->headers))
578 if (
c->n_variants == 0) {
585 if (
c->n_playlists > 1 ||
c->playlists[0]->n_segments == 0) {
586 for (i = 0; i <
c->n_playlists; i++) {
593 if (
c->variants[0]->playlists[0]->n_segments == 0) {
601 if (
c->variants[0]->playlists[0]->finished) {
603 for (i = 0; i <
c->variants[0]->playlists[0]->n_segments; i++)
604 duration +=
c->variants[0]->playlists[0]->segments[i]->duration;
609 for (i = 0; i <
c->n_playlists; i++) {
675 for (i = 0; i <
c->n_variants; i++) {
677 char bitrate_str[20];
753 int ret, i, minplaylist = -1;
808 struct playlist *minpls = minplaylist < 0 ?
810 if (minplaylist < 0 || pls->cur_seq_no < minpls->
cur_seq_no) {
813 int64_t dts = pls->
pkt.
dts;
814 int64_t mindts = minpls->
pkt.
dts;
838 if (minplaylist >= 0) {
857 int64_t timestamp,
int flags)
900 if (timestamp >= pos &&
918 if (strncmp(p->
buf,
"#EXTM3U", 7))
920 if (strstr(p->
buf,
"#EXT-X-STREAM-INF:") ||
921 strstr(p->
buf,
"#EXT-X-TARGETDURATION:") ||
922 strstr(p->
buf,
"#EXT-X-MEDIA-SEQUENCE:"))
928 .
name =
"hls,applehttp",