static void hds_free(AVFormatContext *s)

{

    HDSContext *c = s->priv_data;

    int i, j;

    if (!c->streams)

        return;

    for (i = 0; i < s->nb_streams; i++) {

        OutputStream *os = &c->streams[i];

        if (os->out)

            avio_close(os->out);

        os->out = NULL;

        if (os->ctx && os->ctx_inited)

            av_write_trailer(os->ctx);

        if (os->ctx && os->ctx->pb)

            av_free(os->ctx->pb);

        if (os->ctx)

            avformat_free_context(os->ctx);

        av_free(os->metadata);

        for (j = 0; j < os->nb_extra_packets; j++)

            av_free(os->extra_packets[j]);

        for (j = 0; j < os->nb_fragments; j++)

            av_free(os->fragments[j]);

        av_free(os->fragments);

    }

    av_freep(&c->streams);

}

static void hds_free(AVFormatContext *s)

{

    HDSContext *c = s->priv_data;

    int i, j;

    if (!c->streams)

        return;

    for (i = 0; i < s->nb_streams; i++) {

        OutputStream *os = &c->streams[i];

        if (os->out)

            avio_close(os->out);

        os->out = NULL;

        if (os->ctx && os->ctx_inited)

            av_write_trailer(os->ctx);

        if (os->ctx && os->ctx->pb)

            av_free(os->ctx->pb);

        if (os->ctx)

            avformat_free_context(os->ctx);

        av_free(os->metadata);

        for (j = 0; j < os->nb_extra_packets; j++)

            av_free(os->extra_packets[j]);

        for (j = 0; j < os->nb_fragments; j++)

            av_free(os->fragments[j]);

        av_free(os->fragments);

    }

    av_freep(&c->streams);

}

static void FUNC_0(AVFormatContext *VAR_0)

{

    HDSContext *c = VAR_0->priv_data;

    int VAR_1, VAR_2;

    if (!c->streams)

        return;

    for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) {

        OutputStream *os = &c->streams[VAR_1];

        if (os->out)

            avio_close(os->out);

        os->out = NULL;

        if (os->ctx && os->ctx_inited)

            av_write_trailer(os->ctx);

        if (os->ctx && os->ctx->pb)

            av_free(os->ctx->pb);

        if (os->ctx)

            avformat_free_context(os->ctx);

        av_free(os->metadata);

        for (VAR_2 = 0; VAR_2 < os->nb_extra_packets; VAR_2++)

            av_free(os->extra_packets[VAR_2]);

        for (VAR_2 = 0; VAR_2 < os->nb_fragments; VAR_2++)

            av_free(os->fragments[VAR_2]);

        av_free(os->fragments);

    }

    av_freep(&c->streams);

}

static void FUNC_0(AVFormatContext *VAR_0)
{ HDSContext *c = VAR_0->priv_data; int VAR_1, VAR_2; if (!c->streams)
return; for (VAR_1 = 0; VAR_1 < VAR_0->nb_streams; VAR_1++) { OutputStream *os = &c->streams[VAR_1]; if (os->out)
avio_close(os->out); os->out = NULL; if (os->ctx && os->ctx_inited)
av_write_trailer(os->ctx); if (os->ctx && os->ctx->pb)
av_free(os->ctx->pb); if (os->ctx)
avformat_free_context(os->ctx); av_free(os->metadata); for (VAR_2 = 0; VAR_2 < os->nb_extra_packets; VAR_2++) av_free(os->extra_packets[VAR_2]); for (VAR_2 = 0; VAR_2 < os->nb_fragments; VAR_2++) av_free(os->fragments[VAR_2]); av_free(os->fragments); } av_freep(&c->streams); }