char *user_agent; ///< holds HTTP user agent set as an AVOption to the HTTP protocol context
char *cookies; ///< holds HTTP cookie values set in either the initial response or as an AVOption to the HTTP protocol context
char *headers; ///< holds HTTP headers set as an AVOption to the HTTP protocol context
+ char *http_proxy; ///< holds the address of the HTTP proxy server
AVDictionary *avio_opts;
int strict_std_compliance;
} HLSContext;
av_freep(&c->playlists);
av_freep(&c->cookies);
av_freep(&c->user_agent);
+ av_freep(&c->headers);
+ av_freep(&c->http_proxy);
c->n_playlists = 0;
}
{
AVDictionary *tmp = NULL;
int ret;
+ const char *proto_name = avio_find_protocol_name(url);
+
+ if (!proto_name)
+ return AVERROR_INVALIDDATA;
+
+ // only http(s) & file are allowed
+ if (!av_strstart(proto_name, "http", NULL) && !av_strstart(proto_name, "file", NULL))
+ return AVERROR_INVALIDDATA;
+ if (!strncmp(proto_name, url, strlen(proto_name)) && url[strlen(proto_name)] == ':')
+ ;
+ else if (strcmp(proto_name, "file") || !strncmp(url, "file,", 5))
+ return AVERROR_INVALIDDATA;
av_dict_copy(&tmp, c->avio_opts, 0);
av_dict_copy(&tmp, opts, 0);
av_dict_set(&opts, "user-agent", c->user_agent, 0);
av_dict_set(&opts, "cookies", c->cookies, 0);
av_dict_set(&opts, "headers", c->headers, 0);
+ av_dict_set(&opts, "http_proxy", c->http_proxy, 0);
ret = avio_open2(&in, url, AVIO_FLAG_READ,
c->interrupt_callback, &opts);
av_dict_set(&opts, "user-agent", c->user_agent, 0);
av_dict_set(&opts, "cookies", c->cookies, 0);
av_dict_set(&opts, "headers", c->headers, 0);
+ av_dict_set(&opts, "http_proxy", c->http_proxy, 0);
av_dict_set(&opts, "seekable", "0", 0);
if (seg->size >= 0) {
static int save_avio_options(AVFormatContext *s)
{
HLSContext *c = s->priv_data;
- const char *opts[] = { "headers", "user_agent", "user-agent", "cookies", NULL }, **opt = opts;
+ const char *opts[] = {
+ "headers", "http_proxy", "user_agent", "user-agent", "cookies", NULL };
+ const char **opt = opts;
uint8_t *buf;
int ret = 0;
// get the previous headers & set back to null if string size is zero
update_options(&c->headers, "headers", u->priv_data);
+
+ // get the previous http proxt & set back to null if string size is zero
+ update_options(&c->http_proxy, "http_proxy", u->priv_data);
}
if ((ret = parse_playlist(c, s->filename, NULL, s->pb)) < 0)
* somewhere for a proper match. */
if (strncmp(p->buf, "#EXTM3U", 7))
return 0;
+
+ if (p->filename && *p->filename && !av_match_ext(p->filename, "m3u8,m3u"))
+ return 0;
+
if (strstr(p->buf, "#EXT-X-STREAM-INF:") ||
strstr(p->buf, "#EXT-X-TARGETDURATION:") ||
strstr(p->buf, "#EXT-X-MEDIA-SEQUENCE:"))