static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext *c)

{

    int i, start_index = 0, start_number = 1;

    if (c->window_size) {

        start_index  = FFMAX(os->nb_segments   - c->window_size, 0);

        start_number = FFMAX(os->segment_index - c->window_size, 1);

    }



    if (c->use_template) {

        int timescale = c->use_timeline ? os->ctx->streams[0]->time_base.den : AV_TIME_BASE;

        avio_printf(out, "\t\t\t\t<SegmentTemplate timescale=\"%d\" ", timescale);

        if (!c->use_timeline)

            avio_printf(out, "duration=\"%d\" ", c->last_duration);

        avio_printf(out, "initialization=\"%s\" media=\"%s\" startNumber=\"%d\">\n", c->init_seg_name, c->media_seg_name, c->use_timeline ? start_number : 1);

        if (c->use_timeline) {

            avio_printf(out, "\t\t\t\t\t<SegmentTimeline>\n");

            for (i = start_index; i < os->nb_segments; ) {

                Segment *seg = os->segments[i];

                int repeat = 0;

                avio_printf(out, "\t\t\t\t\t\t<S ");

                if (i == start_index)

                    avio_printf(out, "t=\"%"PRId64"\" ", seg->time);

                avio_printf(out, "d=\"%d\" ", seg->duration);

                while (i + repeat + 1 < os->nb_segments && os->segments[i + repeat + 1]->duration == seg->duration)

                    repeat++;

                if (repeat > 0)

                    avio_printf(out, "r=\"%d\" ", repeat);

                avio_printf(out, "/>\n");

                i += 1 + repeat;

            }

            avio_printf(out, "\t\t\t\t\t</SegmentTimeline>\n");

        }

        avio_printf(out, "\t\t\t\t</SegmentTemplate>\n");

    } else if (c->single_file) {

        avio_printf(out, "\t\t\t\t<BaseURL>%s</BaseURL>\n", os->initfile);

        avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, c->last_duration, start_number);

        avio_printf(out, "\t\t\t\t\t<Initialization range=\"%"PRId64"-%"PRId64"\" />\n", os->init_start_pos, os->init_start_pos + os->init_range_length - 1);

        for (i = start_index; i < os->nb_segments; i++) {

            Segment *seg = os->segments[i];

            avio_printf(out, "\t\t\t\t\t<SegmentURL mediaRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->range_length - 1);

            if (seg->index_length)

                avio_printf(out, "indexRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->index_length - 1);

            avio_printf(out, "/>\n");

        }

        avio_printf(out, "\t\t\t\t</SegmentList>\n");

    } else {

        avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, c->last_duration, start_number);

        avio_printf(out, "\t\t\t\t\t<Initialization sourceURL=\"%s\" />\n", os->initfile);

        for (i = start_index; i < os->nb_segments; i++) {

            Segment *seg = os->segments[i];

            avio_printf(out, "\t\t\t\t\t<SegmentURL media=\"%s\" />\n", seg->file);

        }

        avio_printf(out, "\t\t\t\t</SegmentList>\n");

    }

}

static void output_segment_list(OutputStream *os, AVIOContext *out, DASHContext *c)

{

    int i, start_index = 0, start_number = 1;

    if (c->window_size) {

        start_index  = FFMAX(os->nb_segments   - c->window_size, 0);

        start_number = FFMAX(os->segment_index - c->window_size, 1);

    }



    if (c->use_template) {

        int timescale = c->use_timeline ? os->ctx->streams[0]->time_base.den : AV_TIME_BASE;

        avio_printf(out, "\t\t\t\t<SegmentTemplate timescale=\"%d\" ", timescale);

        if (!c->use_timeline)

            avio_printf(out, "duration=\"%d\" ", c->last_duration);

        avio_printf(out, "initialization=\"%s\" media=\"%s\" startNumber=\"%d\">\n", c->init_seg_name, c->media_seg_name, c->use_timeline ? start_number : 1);

        if (c->use_timeline) {

            avio_printf(out, "\t\t\t\t\t<SegmentTimeline>\n");

            for (i = start_index; i < os->nb_segments; ) {

                Segment *seg = os->segments[i];

                int repeat = 0;

                avio_printf(out, "\t\t\t\t\t\t<S ");

                if (i == start_index)

                    avio_printf(out, "t=\"%"PRId64"\" ", seg->time);

                avio_printf(out, "d=\"%d\" ", seg->duration);

                while (i + repeat + 1 < os->nb_segments && os->segments[i + repeat + 1]->duration == seg->duration)

                    repeat++;

                if (repeat > 0)

                    avio_printf(out, "r=\"%d\" ", repeat);

                avio_printf(out, "/>\n");

                i += 1 + repeat;

            }

            avio_printf(out, "\t\t\t\t\t</SegmentTimeline>\n");

        }

        avio_printf(out, "\t\t\t\t</SegmentTemplate>\n");

    } else if (c->single_file) {

        avio_printf(out, "\t\t\t\t<BaseURL>%s</BaseURL>\n", os->initfile);

        avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, c->last_duration, start_number);

        avio_printf(out, "\t\t\t\t\t<Initialization range=\"%"PRId64"-%"PRId64"\" />\n", os->init_start_pos, os->init_start_pos + os->init_range_length - 1);

        for (i = start_index; i < os->nb_segments; i++) {

            Segment *seg = os->segments[i];

            avio_printf(out, "\t\t\t\t\t<SegmentURL mediaRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->range_length - 1);

            if (seg->index_length)

                avio_printf(out, "indexRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->index_length - 1);

            avio_printf(out, "/>\n");

        }

        avio_printf(out, "\t\t\t\t</SegmentList>\n");

    } else {

        avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, c->last_duration, start_number);

        avio_printf(out, "\t\t\t\t\t<Initialization sourceURL=\"%s\" />\n", os->initfile);

        for (i = start_index; i < os->nb_segments; i++) {

            Segment *seg = os->segments[i];

            avio_printf(out, "\t\t\t\t\t<SegmentURL media=\"%s\" />\n", seg->file);

        }

        avio_printf(out, "\t\t\t\t</SegmentList>\n");

    }

}

            avio_printf(out, "duration=\"%d\" ", c->last_duration);         avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, c->last_duration, start_number);         avio_printf(out, "\t\t\t\t<SegmentList timescale=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, c->last_duration, start_number);
static void FUNC_0(OutputStream *VAR_0, AVIOContext *VAR_1, DASHContext *VAR_2)

{

    int VAR_3, VAR_4 = 0, VAR_5 = 1;

    if (VAR_2->window_size) {

        VAR_4  = FFMAX(VAR_0->nb_segments   - VAR_2->window_size, 0);

        VAR_5 = FFMAX(VAR_0->segment_index - VAR_2->window_size, 1);

    }



    if (VAR_2->use_template) {

        int VAR_6 = VAR_2->use_timeline ? VAR_0->ctx->streams[0]->time_base.den : AV_TIME_BASE;

        avio_printf(VAR_1, "\t\t\t\t<SegmentTemplate VAR_6=\"%d\" ", VAR_6);

        if (!VAR_2->use_timeline)

            avio_printf(VAR_1, "duration=\"%d\" ", VAR_2->last_duration);

        avio_printf(VAR_1, "initialization=\"%s\" media=\"%s\" startNumber=\"%d\">\n", VAR_2->init_seg_name, VAR_2->media_seg_name, VAR_2->use_timeline ? VAR_5 : 1);

        if (VAR_2->use_timeline) {

            avio_printf(VAR_1, "\t\t\t\t\t<SegmentTimeline>\n");

            for (VAR_3 = VAR_4; VAR_3 < VAR_0->nb_segments; ) {

                Segment *seg = VAR_0->segments[VAR_3];

                int repeat = 0;

                avio_printf(VAR_1, "\t\t\t\t\t\t<S ");

                if (VAR_3 == VAR_4)

                    avio_printf(VAR_1, "t=\"%"PRId64"\" ", seg->time);

                avio_printf(VAR_1, "d=\"%d\" ", seg->duration);

                while (VAR_3 + repeat + 1 < VAR_0->nb_segments && VAR_0->segments[VAR_3 + repeat + 1]->duration == seg->duration)

                    repeat++;

                if (repeat > 0)

                    avio_printf(VAR_1, "r=\"%d\" ", repeat);

                avio_printf(VAR_1, "/>\n");

                VAR_3 += 1 + repeat;

            }

            avio_printf(VAR_1, "\t\t\t\t\t</SegmentTimeline>\n");

        }

        avio_printf(VAR_1, "\t\t\t\t</SegmentTemplate>\n");

    } else if (VAR_2->single_file) {

        avio_printf(VAR_1, "\t\t\t\t<BaseURL>%s</BaseURL>\n", VAR_0->initfile);

        avio_printf(VAR_1, "\t\t\t\t<SegmentList VAR_6=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, VAR_2->last_duration, VAR_5);

        avio_printf(VAR_1, "\t\t\t\t\t<Initialization range=\"%"PRId64"-%"PRId64"\" />\n", VAR_0->init_start_pos, VAR_0->init_start_pos + VAR_0->init_range_length - 1);

        for (VAR_3 = VAR_4; VAR_3 < VAR_0->nb_segments; VAR_3++) {

            Segment *seg = VAR_0->segments[VAR_3];

            avio_printf(VAR_1, "\t\t\t\t\t<SegmentURL mediaRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->range_length - 1);

            if (seg->index_length)

                avio_printf(VAR_1, "indexRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->index_length - 1);

            avio_printf(VAR_1, "/>\n");

        }

        avio_printf(VAR_1, "\t\t\t\t</SegmentList>\n");

    } else {

        avio_printf(VAR_1, "\t\t\t\t<SegmentList VAR_6=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, VAR_2->last_duration, VAR_5);

        avio_printf(VAR_1, "\t\t\t\t\t<Initialization sourceURL=\"%s\" />\n", VAR_0->initfile);

        for (VAR_3 = VAR_4; VAR_3 < VAR_0->nb_segments; VAR_3++) {

            Segment *seg = VAR_0->segments[VAR_3];

            avio_printf(VAR_1, "\t\t\t\t\t<SegmentURL media=\"%s\" />\n", seg->file);

        }

        avio_printf(VAR_1, "\t\t\t\t</SegmentList>\n");

    }

}

static void FUNC_0(OutputStream *VAR_0, AVIOContext *VAR_1, DASHContext *VAR_2)
{ int VAR_3, VAR_4 = 0, VAR_5 = 1; if (VAR_2->window_size) { VAR_4  = FFMAX(VAR_0->nb_segments   - VAR_2->window_size, 0); VAR_5 = FFMAX(VAR_0->segment_index - VAR_2->window_size, 1); } if (VAR_2->use_template) { int VAR_6 = VAR_2->use_timeline ? VAR_0->ctx->streams[0]->time_base.den : AV_TIME_BASE; avio_printf(VAR_1, "\t\t\t\t<SegmentTemplate VAR_6=\"%d\" ", VAR_6); if (!VAR_2->use_timeline)
avio_printf(VAR_1, "duration=\"%d\" ", VAR_2->last_duration); avio_printf(VAR_1, "initialization=\"%s\" media=\"%s\" startNumber=\"%d\">\n", VAR_2->init_seg_name, VAR_2->media_seg_name, VAR_2->use_timeline ? VAR_5 : 1); if (VAR_2->use_timeline) { avio_printf(VAR_1, "\t\t\t\t\t<SegmentTimeline>\n"); for (VAR_3 = VAR_4; VAR_3 < VAR_0->nb_segments; ) { Segment *seg = VAR_0->segments[VAR_3]; int repeat = 0; avio_printf(VAR_1, "\t\t\t\t\t\t<S "); if (VAR_3 == VAR_4)
avio_printf(VAR_1, "t=\"%"PRId64"\" ", seg->time); avio_printf(VAR_1, "d=\"%d\" ", seg->duration); while (VAR_3 + repeat + 1 < VAR_0->nb_segments && VAR_0->segments[VAR_3 + repeat + 1]->duration == seg->duration)
repeat++; if (repeat > 0)
avio_printf(VAR_1, "r=\"%d\" ", repeat); avio_printf(VAR_1, "/>\n"); VAR_3 += 1 + repeat; } avio_printf(VAR_1, "\t\t\t\t\t</SegmentTimeline>\n"); } avio_printf(VAR_1, "\t\t\t\t</SegmentTemplate>\n"); } else if (VAR_2->single_file) { avio_printf(VAR_1, "\t\t\t\t<BaseURL>%s</BaseURL>\n", VAR_0->initfile); avio_printf(VAR_1, "\t\t\t\t<SegmentList VAR_6=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, VAR_2->last_duration, VAR_5); avio_printf(VAR_1, "\t\t\t\t\t<Initialization range=\"%"PRId64"-%"PRId64"\" />\n", VAR_0->init_start_pos, VAR_0->init_start_pos + VAR_0->init_range_length - 1); for (VAR_3 = VAR_4; VAR_3 < VAR_0->nb_segments; VAR_3++) { Segment *seg = VAR_0->segments[VAR_3]; avio_printf(VAR_1, "\t\t\t\t\t<SegmentURL mediaRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->range_length - 1); if (seg->index_length)
avio_printf(VAR_1, "indexRange=\"%"PRId64"-%"PRId64"\" ", seg->start_pos, seg->start_pos + seg->index_length - 1); avio_printf(VAR_1, "/>\n"); } avio_printf(VAR_1, "\t\t\t\t</SegmentList>\n"); } else { avio_printf(VAR_1, "\t\t\t\t<SegmentList VAR_6=\"%d\" duration=\"%d\" startNumber=\"%d\">\n", AV_TIME_BASE, VAR_2->last_duration, VAR_5); avio_printf(VAR_1, "\t\t\t\t\t<Initialization sourceURL=\"%s\" />\n", VAR_0->initfile); for (VAR_3 = VAR_4; VAR_3 < VAR_0->nb_segments; VAR_3++) { Segment *seg = VAR_0->segments[VAR_3]; avio_printf(VAR_1, "\t\t\t\t\t<SegmentURL media=\"%s\" />\n", seg->file); } avio_printf(VAR_1, "\t\t\t\t</SegmentList>\n"); } }