static int tee_write_header(AVFormatContext *avf)

{

    TeeContext *tee = avf->priv_data;

    unsigned nb_slaves = 0, i;

    const char *filename = avf->filename;

    char *slaves[MAX_SLAVES];

    int ret;



    while (*filename) {

        if (nb_slaves == MAX_SLAVES) {

            av_log(avf, AV_LOG_ERROR, "Maximum %d slave muxers reached.\n",

                   MAX_SLAVES);

            ret = AVERROR_PATCHWELCOME;

            goto fail;

        }

        if (!(slaves[nb_slaves++] = av_get_token(&filename, slave_delim))) {

            ret = AVERROR(ENOMEM);

            goto fail;

        }

        if (strspn(filename, slave_delim))

            filename++;

    }



    for (i = 0; i < nb_slaves; i++) {

        if ((ret = open_slave(avf, slaves[i], &tee->slaves[i])) < 0)

            goto fail;

        log_slave(&tee->slaves[i], avf, AV_LOG_VERBOSE);

        av_freep(&slaves[i]);

    }



    tee->nb_slaves = nb_slaves;



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

        int j, mapped = 0;

        for (j = 0; j < tee->nb_slaves; j++)

            mapped += tee->slaves[j].stream_map[i] >= 0;

        if (!mapped)

            av_log(avf, AV_LOG_WARNING, "Input stream #%d is not mapped "

                   "to any slave.\n", i);

    }

    return 0;



fail:

    for (i = 0; i < nb_slaves; i++)

        av_freep(&slaves[i]);

    close_slaves(avf);

    return ret;

}

static int tee_write_header(AVFormatContext *avf)

{

    TeeContext *tee = avf->priv_data;

    unsigned nb_slaves = 0, i;

    const char *filename = avf->filename;

    char *slaves[MAX_SLAVES];

    int ret;



    while (*filename) {

        if (nb_slaves == MAX_SLAVES) {

            av_log(avf, AV_LOG_ERROR, "Maximum %d slave muxers reached.\n",

                   MAX_SLAVES);

            ret = AVERROR_PATCHWELCOME;

            goto fail;

        }

        if (!(slaves[nb_slaves++] = av_get_token(&filename, slave_delim))) {

            ret = AVERROR(ENOMEM);

            goto fail;

        }

        if (strspn(filename, slave_delim))

            filename++;

    }



    for (i = 0; i < nb_slaves; i++) {

        if ((ret = open_slave(avf, slaves[i], &tee->slaves[i])) < 0)

            goto fail;

        log_slave(&tee->slaves[i], avf, AV_LOG_VERBOSE);

        av_freep(&slaves[i]);

    }



    tee->nb_slaves = nb_slaves;



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

        int j, mapped = 0;

        for (j = 0; j < tee->nb_slaves; j++)

            mapped += tee->slaves[j].stream_map[i] >= 0;

        if (!mapped)

            av_log(avf, AV_LOG_WARNING, "Input stream #%d is not mapped "

                   "to any slave.\n", i);

    }

    return 0;



fail:

    for (i = 0; i < nb_slaves; i++)

        av_freep(&slaves[i]);

    close_slaves(avf);

    return ret;

}

    tee->nb_slaves = nb_slaves;     close_slaves(avf);
static int FUNC_0(AVFormatContext *VAR_0)

{

    TeeContext *tee = VAR_0->priv_data;

    unsigned VAR_1 = 0, VAR_2;

    const char *VAR_3 = VAR_0->VAR_3;

    char *VAR_4[MAX_SLAVES];

    int VAR_5;



    while (*VAR_3) {

        if (VAR_1 == MAX_SLAVES) {

            av_log(VAR_0, AV_LOG_ERROR, "Maximum %d slave muxers reached.\n",

                   MAX_SLAVES);

            VAR_5 = AVERROR_PATCHWELCOME;

            goto fail;

        }

        if (!(VAR_4[VAR_1++] = av_get_token(&VAR_3, slave_delim))) {

            VAR_5 = AVERROR(ENOMEM);

            goto fail;

        }

        if (strspn(VAR_3, slave_delim))

            VAR_3++;

    }



    for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) {

        if ((VAR_5 = open_slave(VAR_0, VAR_4[VAR_2], &tee->VAR_4[VAR_2])) < 0)

            goto fail;

        log_slave(&tee->VAR_4[VAR_2], VAR_0, AV_LOG_VERBOSE);

        av_freep(&VAR_4[VAR_2]);

    }



    tee->VAR_1 = VAR_1;



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

        int j, mapped = 0;

        for (j = 0; j < tee->VAR_1; j++)

            mapped += tee->VAR_4[j].stream_map[VAR_2] >= 0;

        if (!mapped)

            av_log(VAR_0, AV_LOG_WARNING, "Input stream #%d is not mapped "

                   "to any slave.\n", VAR_2);

    }

    return 0;



fail:

    for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++)

        av_freep(&VAR_4[VAR_2]);

    close_slaves(VAR_0);

    return VAR_5;

}

static int FUNC_0(AVFormatContext *VAR_0)
{ TeeContext *tee = VAR_0->priv_data; unsigned VAR_1 = 0, VAR_2; const char *VAR_3 = VAR_0->VAR_3; char *VAR_4[MAX_SLAVES]; int VAR_5; while (*VAR_3) { if (VAR_1 == MAX_SLAVES) { av_log(VAR_0, AV_LOG_ERROR, "Maximum %d slave muxers reached.\n",
MAX_SLAVES); VAR_5 = AVERROR_PATCHWELCOME; goto fail; } if (!(VAR_4[VAR_1++] = av_get_token(&VAR_3, slave_delim))) { VAR_5 = AVERROR(ENOMEM); goto fail; } if (strspn(VAR_3, slave_delim))
VAR_3++; } for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) { if ((VAR_5 = open_slave(VAR_0, VAR_4[VAR_2], &tee->VAR_4[VAR_2])) < 0)
goto fail; log_slave(&tee->VAR_4[VAR_2], VAR_0, AV_LOG_VERBOSE); av_freep(&VAR_4[VAR_2]); } tee->VAR_1 = VAR_1; for (VAR_2 = 0; VAR_2 < VAR_0->nb_streams; VAR_2++) { int j, mapped = 0; for (j = 0; j < tee->VAR_1; j++) mapped += tee->VAR_4[j].stream_map[VAR_2] >= 0; if (!mapped)
av_log(VAR_0, AV_LOG_WARNING, "Input stream #%d is not mapped "
"to any slave.\n", VAR_2); } return 0; fail:
for (VAR_2 = 0; VAR_2 < VAR_1; VAR_2++) av_freep(&VAR_4[VAR_2]); close_slaves(VAR_0); return VAR_5; }