static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,

                    AVDictionary *opts, AVDictionary *opts2)

{

    HLSContext *c = s->priv_data;

    AVDictionary *tmp = NULL;

    const char *proto_name = avio_find_protocol_name(url);

    int ret;



    av_dict_copy(&tmp, opts, 0);

    av_dict_copy(&tmp, opts2, 0);



    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;



    ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp);

    if (ret >= 0) {

        // update cookies on http response with setcookies.

        void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;

        update_options(&c->cookies, "cookies", u);

        av_dict_set(&opts, "cookies", c->cookies, 0);

    }



    av_dict_free(&tmp);



    return ret;

}

static int open_url(AVFormatContext *s, AVIOContext **pb, const char *url,

                    AVDictionary *opts, AVDictionary *opts2)

{

    HLSContext *c = s->priv_data;

    AVDictionary *tmp = NULL;

    const char *proto_name = avio_find_protocol_name(url);

    int ret;



    av_dict_copy(&tmp, opts, 0);

    av_dict_copy(&tmp, opts2, 0);



    if (!proto_name)

        return AVERROR_INVALIDDATA;



    

    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;



    ret = s->io_open(s, pb, url, AVIO_FLAG_READ, &tmp);

    if (ret >= 0) {

        

        void *u = (s->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : s->pb;

        update_options(&c->cookies, "cookies", u);

        av_dict_set(&opts, "cookies", c->cookies, 0);

    }



    av_dict_free(&tmp);



    return ret;

}

static int FUNC_0(AVFormatContext *VAR_0, AVIOContext **VAR_1, const char *VAR_2,

                    AVDictionary *VAR_3, AVDictionary *VAR_4)

{

    HLSContext *c = VAR_0->priv_data;

    AVDictionary *tmp = NULL;

    const char *VAR_5 = avio_find_protocol_name(VAR_2);

    int VAR_6;



    av_dict_copy(&tmp, VAR_3, 0);

    av_dict_copy(&tmp, VAR_4, 0);



    if (!VAR_5)

        return AVERROR_INVALIDDATA;



    

    if (!av_strstart(VAR_5, "http", NULL) && !av_strstart(VAR_5, "file", NULL))

        return AVERROR_INVALIDDATA;

    if (!strncmp(VAR_5, VAR_2, strlen(VAR_5)) && VAR_2[strlen(VAR_5)] == ':')

        ;

    else if (strcmp(VAR_5, "file") || !strncmp(VAR_2, "file,", 5))

        return AVERROR_INVALIDDATA;



    VAR_6 = VAR_0->io_open(VAR_0, VAR_1, VAR_2, AVIO_FLAG_READ, &tmp);

    if (VAR_6 >= 0) {

        

        void *VAR_7 = (VAR_0->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : VAR_0->VAR_1;

        update_options(&c->cookies, "cookies", VAR_7);

        av_dict_set(&VAR_3, "cookies", c->cookies, 0);

    }



    av_dict_free(&tmp);



    return VAR_6;

}

static int FUNC_0(AVFormatContext *VAR_0, AVIOContext **VAR_1, const char *VAR_2,
AVDictionary *VAR_3, AVDictionary *VAR_4)
{ HLSContext *c = VAR_0->priv_data; AVDictionary *tmp = NULL; const char *VAR_5 = avio_find_protocol_name(VAR_2); int VAR_6; av_dict_copy(&tmp, VAR_3, 0); av_dict_copy(&tmp, VAR_4, 0); if (!VAR_5)
return AVERROR_INVALIDDATA; if (!av_strstart(VAR_5, "http", NULL) && !av_strstart(VAR_5, "file", NULL))
return AVERROR_INVALIDDATA; if (!strncmp(VAR_5, VAR_2, strlen(VAR_5)) && VAR_2[strlen(VAR_5)] == ':')
; else if (strcmp(VAR_5, "file") || !strncmp(VAR_2, "file,", 5))
return AVERROR_INVALIDDATA; VAR_6 = VAR_0->io_open(VAR_0, VAR_1, VAR_2, AVIO_FLAG_READ, &tmp); if (VAR_6 >= 0) { void *VAR_7 = (VAR_0->flags & AVFMT_FLAG_CUSTOM_IO) ? NULL : VAR_0->VAR_1; update_options(&c->cookies, "cookies", VAR_7); av_dict_set(&VAR_3, "cookies", c->cookies, 0); } av_dict_free(&tmp); return VAR_6; }