static int applehttp_read_seek(AVFormatContext *s, int stream_index,

                               int64_t timestamp, int flags)

{

    AppleHTTPContext *c = s->priv_data;

    int i, j, ret;



    if ((flags & AVSEEK_FLAG_BYTE) || !c->variants[0]->finished)

        return AVERROR(ENOSYS);



    timestamp = av_rescale_rnd(timestamp, 1, stream_index >= 0 ?

                               s->streams[stream_index]->time_base.den :

                               AV_TIME_BASE, flags & AVSEEK_FLAG_BACKWARD ?

                               AV_ROUND_DOWN : AV_ROUND_UP);

    ret = AVERROR(EIO);

    for (i = 0; i < c->n_variants; i++) {

        /* Reset reading */

        struct variant *var = c->variants[i];

        int64_t pos = 0;

        if (var->input) {

            ffurl_close(var->input);

            var->input = NULL;

        }

        av_free_packet(&var->pkt);

        reset_packet(&var->pkt);

        var->pb.eof_reached = 0;



        /* Locate the segment that contains the target timestamp */

        for (j = 0; j < var->n_segments; j++) {

            if (timestamp >= pos &&

                timestamp < pos + var->segments[j]->duration) {

                var->cur_seq_no = var->start_seq_no + j;

                ret = 0;

                break;

            }

            pos += var->segments[j]->duration;

        }

    }

    return ret;

}

static int applehttp_read_seek(AVFormatContext *s, int stream_index,

                               int64_t timestamp, int flags)

{

    AppleHTTPContext *c = s->priv_data;

    int i, j, ret;



    if ((flags & AVSEEK_FLAG_BYTE) || !c->variants[0]->finished)

        return AVERROR(ENOSYS);



    timestamp = av_rescale_rnd(timestamp, 1, stream_index >= 0 ?

                               s->streams[stream_index]->time_base.den :

                               AV_TIME_BASE, flags & AVSEEK_FLAG_BACKWARD ?

                               AV_ROUND_DOWN : AV_ROUND_UP);

    ret = AVERROR(EIO);

    for (i = 0; i < c->n_variants; i++) {

        

        struct variant *var = c->variants[i];

        int64_t pos = 0;

        if (var->input) {

            ffurl_close(var->input);

            var->input = NULL;

        }

        av_free_packet(&var->pkt);

        reset_packet(&var->pkt);

        var->pb.eof_reached = 0;



        

        for (j = 0; j < var->n_segments; j++) {

            if (timestamp >= pos &&

                timestamp < pos + var->segments[j]->duration) {

                var->cur_seq_no = var->start_seq_no + j;

                ret = 0;

                break;

            }

            pos += var->segments[j]->duration;

        }

    }

    return ret;

}

        int64_t pos = 0;         if (var->input) {
static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,

                               int64_t VAR_2, int VAR_3)

{

    AppleHTTPContext *c = VAR_0->priv_data;

    int VAR_4, VAR_5, VAR_6;



    if ((VAR_3 & AVSEEK_FLAG_BYTE) || !c->variants[0]->finished)

        return AVERROR(ENOSYS);



    VAR_2 = av_rescale_rnd(VAR_2, 1, VAR_1 >= 0 ?

                               VAR_0->streams[VAR_1]->time_base.den :

                               AV_TIME_BASE, VAR_3 & AVSEEK_FLAG_BACKWARD ?

                               AV_ROUND_DOWN : AV_ROUND_UP);

    VAR_6 = AVERROR(EIO);

    for (VAR_4 = 0; VAR_4 < c->n_variants; VAR_4++) {

        

        struct variant *var = c->variants[VAR_4];

        int64_t pos = 0;

        if (var->input) {

            ffurl_close(var->input);

            var->input = NULL;

        }

        av_free_packet(&var->pkt);

        reset_packet(&var->pkt);

        var->pb.eof_reached = 0;



        

        for (VAR_5 = 0; VAR_5 < var->n_segments; VAR_5++) {

            if (VAR_2 >= pos &&

                VAR_2 < pos + var->segments[VAR_5]->duration) {

                var->cur_seq_no = var->start_seq_no + VAR_5;

                VAR_6 = 0;

                break;

            }

            pos += var->segments[VAR_5]->duration;

        }

    }

    return VAR_6;

}

static int FUNC_0(AVFormatContext *VAR_0, int VAR_1,
int64_t VAR_2, int VAR_3)
{ AppleHTTPContext *c = VAR_0->priv_data; int VAR_4, VAR_5, VAR_6; if ((VAR_3 & AVSEEK_FLAG_BYTE) || !c->variants[0]->finished)
return AVERROR(ENOSYS); VAR_2 = av_rescale_rnd(VAR_2, 1, VAR_1 >= 0 ?
VAR_0->streams[VAR_1]->time_base.den :
AV_TIME_BASE, VAR_3 & AVSEEK_FLAG_BACKWARD ?
AV_ROUND_DOWN : AV_ROUND_UP); VAR_6 = AVERROR(EIO); for (VAR_4 = 0; VAR_4 < c->n_variants; VAR_4++) { struct variant *var = c->variants[VAR_4]; int64_t pos = 0; if (var->input) { ffurl_close(var->input); var->input = NULL; } av_free_packet(&var->pkt); reset_packet(&var->pkt); var->pb.eof_reached = 0; for (VAR_5 = 0; VAR_5 < var->n_segments; VAR_5++) { if (VAR_2 >= pos &&
VAR_2 < pos + var->segments[VAR_5]->duration) { var->cur_seq_no = var->start_seq_no + VAR_5; VAR_6 = 0; break; } pos += var->segments[VAR_5]->duration; } } return VAR_6; }