static void close_connection(HTTPContext *c)
{
    HTTPContext **cp, *c1;
    int i, nb_streams;
    AVFormatContext *ctx;
    URLContext *h;
    AVStream *st;
    /* remove connection from list */
    cp = &first_http_ctx;
    while ((*cp) != NULL) {
        c1 = *cp;
        if (c1 == c) {
            *cp = c->next;
        } else {
            cp = &c1->next;
    /* remove connection associated resources */
    if (c->fd >= 0)
        close(c->fd);
    if (c->fmt_in) {
        /* close each frame parser */
        for(i=0;i<c->fmt_in->nb_streams;i++) {
            st = c->fmt_in->streams[i];
            if (st->codec.codec) {
                avcodec_close(&st->codec);
        av_close_input_file(c->fmt_in);
    /* free RTP output streams if any */
    nb_streams = 0;
    if (c->stream) 
        nb_streams = c->stream->nb_streams;
    for(i=0;i<nb_streams;i++) {
        ctx = c->rtp_ctx[i];
        if (ctx) {
            av_free(ctx);
        h = c->rtp_handles[i];
        if (h) {
            url_close(h);
    if (c->stream)
        current_bandwidth -= c->stream->bandwidth;
    av_freep(&c->pb_buffer);
    av_free(c->buffer);
    av_free(c);
    nb_connections--;
static void close_connection(HTTPContext *c)
{
    HTTPContext **cp, *c1;
    int i, nb_streams;
    AVFormatContext *ctx;
    URLContext *h;
    AVStream *st;
    
    cp = &first_http_ctx;
    while ((*cp) != NULL) {
        c1 = *cp;
        if (c1 == c) {
            *cp = c->next;
        } else {
            cp = &c1->next;
    
    if (c->fd >= 0)
        close(c->fd);
    if (c->fmt_in) {
        
        for(i=0;i<c->fmt_in->nb_streams;i++) {
            st = c->fmt_in->streams[i];
            if (st->codec.codec) {
                avcodec_close(&st->codec);
        av_close_input_file(c->fmt_in);
    
    nb_streams = 0;
    if (c->stream) 
        nb_streams = c->stream->nb_streams;
    for(i=0;i<nb_streams;i++) {
        ctx = c->rtp_ctx[i];
        if (ctx) {
            av_free(ctx);
        h = c->rtp_handles[i];
        if (h) {
            url_close(h);
    if (c->stream)
        current_bandwidth -= c->stream->bandwidth;
    av_freep(&c->pb_buffer);
    av_free(c->buffer);
    av_free(c);
    nb_connections--;
static void FUNC_0(HTTPContext *VAR_0)
{
    HTTPContext **cp, *c1;
    int VAR_1, VAR_2;
    AVFormatContext *ctx;
    URLContext *h;
    AVStream *st;
    
    cp = &first_http_ctx;
    while ((*cp) != NULL) {
        c1 = *cp;
        if (c1 == VAR_0) {
            *cp = VAR_0->next;
        } else {
            cp = &c1->next;
    
    if (VAR_0->fd >= 0)
        close(VAR_0->fd);
    if (VAR_0->fmt_in) {
        
        for(VAR_1=0;VAR_1<VAR_0->fmt_in->VAR_2;VAR_1++) {
            st = VAR_0->fmt_in->streams[VAR_1];
            if (st->codec.codec) {
                avcodec_close(&st->codec);
        av_close_input_file(VAR_0->fmt_in);
    
    VAR_2 = 0;
    if (VAR_0->stream) 
        VAR_2 = VAR_0->stream->VAR_2;
    for(VAR_1=0;VAR_1<VAR_2;VAR_1++) {
        ctx = VAR_0->rtp_ctx[VAR_1];
        if (ctx) {
            av_free(ctx);
        h = VAR_0->rtp_handles[VAR_1];
        if (h) {
            url_close(h);
    if (VAR_0->stream)
        current_bandwidth -= VAR_0->stream->bandwidth;
    av_freep(&VAR_0->pb_buffer);
    av_free(VAR_0->buffer);
    av_free(VAR_0);
    nb_connections--;
static void FUNC_0(HTTPContext *VAR_0)
{ HTTPContext **cp, *c1; int VAR_1, VAR_2; AVFormatContext *ctx; URLContext *h; AVStream *st; cp = &first_http_ctx; while ((*cp) != NULL) { c1 = *cp; if (c1 == VAR_0) { *cp = VAR_0->next; } else { cp = &c1->next; if (VAR_0->fd >= 0)
close(VAR_0->fd); if (VAR_0->fmt_in) { for(VAR_1=0;VAR_1<VAR_0->fmt_in->VAR_2;VAR_1++) { st = VAR_0->fmt_in->streams[VAR_1]; if (st->codec.codec) { avcodec_close(&st->codec); av_close_input_file(VAR_0->fmt_in); VAR_2 = 0; if (VAR_0->stream)
VAR_2 = VAR_0->stream->VAR_2; for(VAR_1=0;VAR_1<VAR_2;VAR_1++) { ctx = VAR_0->rtp_ctx[VAR_1]; if (ctx) { av_free(ctx); h = VAR_0->rtp_handles[VAR_1]; if (h) { url_close(h); if (VAR_0->stream)
current_bandwidth -= VAR_0->stream->bandwidth; av_freep(&VAR_0->pb_buffer); av_free(VAR_0->buffer); av_free(VAR_0); nb_connections--;