| 788 | } |
| 789 | |
| 790 | static int parse_playlist(HLSContext *c, const char *url, |
| 791 | struct playlist *pls, AVIOContext *in) |
| 792 | { |
| 793 | int ret = 0, is_segment = 0, is_variant = 0; |
| 794 | int64_t duration = 0; |
| 795 | enum KeyType key_type = KEY_NONE; |
| 796 | uint8_t iv[16] = ""; |
| 797 | int has_iv = 0; |
| 798 | char key[MAX_URL_SIZE] = ""; |
| 799 | char line[MAX_URL_SIZE]; |
| 800 | const char *ptr; |
| 801 | int close_in = 0; |
| 802 | int64_t seg_offset = 0; |
| 803 | int64_t seg_size = -1; |
| 804 | uint8_t *new_url = NULL; |
| 805 | struct variant_info variant_info; |
| 806 | char tmp_str[MAX_URL_SIZE]; |
| 807 | struct segment *cur_init_section = NULL; |
| 808 | int is_http = av_strstart(url, "http", NULL); |
| 809 | struct segment **prev_segments = NULL; |
| 810 | int prev_n_segments = 0; |
| 811 | int64_t prev_start_seq_no = -1; |
| 812 | |
| 813 | if (is_http && !in && c->http_persistent && c->playlist_pb) { |
| 814 | in = c->playlist_pb; |
| 815 | ret = open_url_keepalive(c->ctx, &c->playlist_pb, url, NULL); |
| 816 | if (ret == AVERROR_EXIT) { |
| 817 | return ret; |
| 818 | } else if (ret < 0) { |
| 819 | if (ret != AVERROR_EOF) |
| 820 | av_log(c->ctx, AV_LOG_WARNING, |
| 821 | "keepalive request failed for '%s' with error: '%s' when parsing playlist\n", |
| 822 | url, av_err2str(ret)); |
| 823 | in = NULL; |
| 824 | } |
| 825 | } |
| 826 | |
| 827 | if (!in) { |
| 828 | AVDictionary *opts = NULL; |
| 829 | av_dict_copy(&opts, c->avio_opts, 0); |
| 830 | |
| 831 | if (c->http_persistent) |
| 832 | av_dict_set(&opts, "multiple_requests", "1", 0); |
| 833 | |
| 834 | ret = c->ctx->io_open(c->ctx, &in, url, AVIO_FLAG_READ, &opts); |
| 835 | av_dict_free(&opts); |
| 836 | if (ret < 0) |
| 837 | return ret; |
| 838 | |
| 839 | if (is_http && c->http_persistent) |
| 840 | c->playlist_pb = in; |
| 841 | else |
| 842 | close_in = 1; |
| 843 | } |
| 844 | |
| 845 | if (av_opt_get(in, "location", AV_OPT_SEARCH_CHILDREN, &new_url) >= 0) |
| 846 | url = new_url; |
| 847 |
no test coverage detected