void av_close_input_stream(AVFormatContext *s)
{
    int i;
    AVStream *st;
    if (s->cur_st && s->cur_st->parser)
        av_free_packet(&s->cur_pkt);
    if (s->iformat->read_close)
        s->iformat->read_close(s);
    for(i=0;i<s->nb_streams;i++) {
        st = s->streams[i];
        if (st->parser) {
            av_parser_close(st->parser);
        }
        av_free(st->index_entries);
        av_free(st->codec->extradata);
        av_free(st->codec);
        av_free(st->filename);
        av_free(st);
    }
    for(i=s->nb_programs-1; i>=0; i--) {
        av_freep(&s->programs[i]->provider_name);
        av_freep(&s->programs[i]->name);
        av_freep(&s->programs[i]->stream_index);
        av_freep(&s->programs[i]);
    }
    flush_packet_queue(s);
    av_freep(&s->priv_data);
    av_free(s);
}
['static void build_file_streams(void)\n{\n    FFStream *stream, *stream_next;\n    AVFormatContext *infile;\n    int i;\n    for(stream = first_stream; stream != NULL; stream = stream_next) {\n        stream_next = stream->next;\n        if (stream->stream_type == STREAM_TYPE_LIVE &&\n            !stream->feed) {\n            stream->ap_in = av_mallocz(sizeof(AVFormatParameters));\n            if (stream->fmt && !strcmp(stream->fmt->name, "rtp")) {\n                stream->ap_in->mpeg2ts_raw = 1;\n                stream->ap_in->mpeg2ts_compute_pcr = 1;\n            }\n            if (av_open_input_file(&infile, stream->feed_filename,\n                                   stream->ifmt, 0, stream->ap_in) < 0) {\n                http_log("%s not found", stream->feed_filename);\n            fail:\n                remove_stream(stream);\n            } else {\n                if (av_find_stream_info(infile) < 0) {\n                    http_log("Could not find codec parameters from \'%s\'",\n                             stream->feed_filename);\n                    av_close_input_file(infile);\n                    goto fail;\n                }\n                extract_mpeg4_header(infile);\n                for(i=0;i<infile->nb_streams;i++)\n                    add_av_stream1(stream, infile->streams[i]->codec);\n                av_close_input_file(infile);\n            }\n        }\n    }\n}', 'void av_close_input_file(AVFormatContext *s)\n{\n    ByteIOContext *pb = s->iformat->flags & AVFMT_NOFILE ? NULL : s->pb;\n    av_close_input_stream(s);\n    if (pb)\n        url_fclose(pb);\n}', 'void av_close_input_stream(AVFormatContext *s)\n{\n    int i;\n    AVStream *st;\n    if (s->cur_st && s->cur_st->parser)\n        av_free_packet(&s->cur_pkt);\n    if (s->iformat->read_close)\n        s->iformat->read_close(s);\n    for(i=0;i<s->nb_streams;i++) {\n        st = s->streams[i];\n        if (st->parser) {\n            av_parser_close(st->parser);\n        }\n        av_free(st->index_entries);\n        av_free(st->codec->extradata);\n        av_free(st->codec);\n        av_free(st->filename);\n        av_free(st);\n    }\n    for(i=s->nb_programs-1; i>=0; i--) {\n        av_freep(&s->programs[i]->provider_name);\n        av_freep(&s->programs[i]->name);\n        av_freep(&s->programs[i]->stream_index);\n        av_freep(&s->programs[i]);\n    }\n    flush_packet_queue(s);\n    av_freep(&s->priv_data);\n    av_free(s);\n}']