} else {
} } }   for(stream = first_stream; stream != NULL; stream = stream->next) { feed = stream->feed; if (feed) { if (stream->is_feed) {
void build_feed_streams(void){    FFStream *stream, *feed;    int i;    /* gather all streams */    for(stream = first_stream; stream != NULL; stream = stream->next) {        feed = stream->feed;        if (feed) {            if (!stream->is_feed) {                for(i=0;i<stream->nb_streams;i++) {                    stream->feed_streams[i] = add_av_stream(feed, stream->streams[i]);                }            } else {                for(i=0;i<stream->nb_streams;i++) {                    stream->feed_streams[i] = i;                }            }        }    }    /* create feed files if needed */    for(feed = first_feed; feed != NULL; feed = feed->next_feed) {        int fd;        if (!url_exist(feed->feed_filename)) {            AVFormatContext s1, *s = &s1;            /* only write the header of the ffm file */            if (url_fopen(&s->pb, feed->feed_filename, URL_WRONLY) < 0) {                fprintf(stderr, "Could not open output feed file '%s'\n",                        feed->feed_filename);                exit(1);            }            s->oformat = feed->fmt;            s->nb_streams = feed->nb_streams;            for(i=0;i<s->nb_streams;i++) {                AVStream *st;                st = feed->streams[i];                s->streams[i] = st;            }            av_write_header(s);            /* XXX: need better api */            av_freep(&s->priv_data);            url_fclose(&s->pb);        }        /* get feed size and write index */        fd = open(feed->feed_filename, O_RDONLY);        if (fd < 0) {            fprintf(stderr, "Could not open output feed file '%s'\n",                    feed->feed_filename);            exit(1);        }        feed->feed_write_index = ffm_read_write_index(fd);        feed->feed_size = lseek(fd, 0, SEEK_END);        /* ensure that we do not wrap before the end of file */        if (feed->feed_max_size < feed->feed_size)            feed->feed_max_size = feed->feed_size;        close(fd);    }}