MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / parse_playlist

Function parse_playlist

libavformat/hls.c:790–1125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

788}
789
790static 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

Callers 3

reload_playlistFunction · 0.70
select_cur_seq_noFunction · 0.70
hls_read_headerFunction · 0.70

Calls 15

av_strstartFunction · 0.85
open_url_keepaliveFunction · 0.85
av_logFunction · 0.85
av_dict_copyFunction · 0.85
av_dict_setFunction · 0.85
av_dict_freeFunction · 0.85
av_opt_getFunction · 0.85
ff_get_chomp_lineFunction · 0.85
avio_feofFunction · 0.85
ff_parse_key_valueFunction · 0.85
av_strncasecmpFunction · 0.85
ff_hex_to_dataFunction · 0.85

Tested by

no test coverage detected