static int libquvi_read_header(AVFormatContext *s)

{

    int i, ret;

    quvi_t q;

    quvi_media_t m;

    QUVIcode rc;

    LibQuviContext *qc = s->priv_data;

    char *media_url, *pagetitle;



    rc = quvi_init(&q);

    if (rc != QUVI_OK)

        goto quvi_fail;



    quvi_setopt(q, QUVIOPT_FORMAT, qc->format);



    rc = quvi_parse(q, s->filename, &m);

    if (rc != QUVI_OK)

        goto quvi_fail;



    rc = quvi_getprop(m, QUVIPROP_MEDIAURL, &media_url);

    if (rc != QUVI_OK)

        goto quvi_fail;



    av_assert0(!qc->fmtctx->codec_whitelist && !qc->fmtctx->format_whitelist);

    qc->fmtctx-> codec_whitelist = av_strdup(s->codec_whitelist);

    qc->fmtctx->format_whitelist = av_strdup(s->format_whitelist);



    ret = avformat_open_input(&qc->fmtctx, media_url, NULL, NULL);

    if (ret < 0)

        goto end;



    rc = quvi_getprop(m, QUVIPROP_PAGETITLE, &pagetitle);

    if (rc == QUVI_OK)

        av_dict_set(&s->metadata, "title", pagetitle, 0);



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

        AVStream *st = avformat_new_stream(s, NULL);

        AVStream *ist = qc->fmtctx->streams[i];

        if (!st) {

            ret = AVERROR(ENOMEM);

            goto end;

        }

        avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);

        avcodec_copy_context(st->codec, qc->fmtctx->streams[i]->codec);

    }



    return 0;



quvi_fail:

    av_log(s, AV_LOG_ERROR, "%s\n", quvi_strerror(q, rc));

    ret = AVERROR_EXTERNAL;



end:

    quvi_parse_close(&m);

    quvi_close(&q);

    return ret;

}

static int libquvi_read_header(AVFormatContext *s)

{

    int i, ret;

    quvi_t q;

    quvi_media_t m;

    QUVIcode rc;

    LibQuviContext *qc = s->priv_data;

    char *media_url, *pagetitle;



    rc = quvi_init(&q);

    if (rc != QUVI_OK)

        goto quvi_fail;



    quvi_setopt(q, QUVIOPT_FORMAT, qc->format);



    rc = quvi_parse(q, s->filename, &m);

    if (rc != QUVI_OK)

        goto quvi_fail;



    rc = quvi_getprop(m, QUVIPROP_MEDIAURL, &media_url);

    if (rc != QUVI_OK)

        goto quvi_fail;



    av_assert0(!qc->fmtctx->codec_whitelist && !qc->fmtctx->format_whitelist);

    qc->fmtctx-> codec_whitelist = av_strdup(s->codec_whitelist);

    qc->fmtctx->format_whitelist = av_strdup(s->format_whitelist);



    ret = avformat_open_input(&qc->fmtctx, media_url, NULL, NULL);

    if (ret < 0)

        goto end;



    rc = quvi_getprop(m, QUVIPROP_PAGETITLE, &pagetitle);

    if (rc == QUVI_OK)

        av_dict_set(&s->metadata, "title", pagetitle, 0);



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

        AVStream *st = avformat_new_stream(s, NULL);

        AVStream *ist = qc->fmtctx->streams[i];

        if (!st) {

            ret = AVERROR(ENOMEM);

            goto end;

        }

        avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);

        avcodec_copy_context(st->codec, qc->fmtctx->streams[i]->codec);

    }



    return 0;



quvi_fail:

    av_log(s, AV_LOG_ERROR, "%s\n", quvi_strerror(q, rc));

    ret = AVERROR_EXTERNAL;



end:

    quvi_parse_close(&m);

    quvi_close(&q);

    return ret;

}

    av_assert0(!qc->fmtctx->codec_whitelist && !qc->fmtctx->format_whitelist);     qc->fmtctx-> codec_whitelist = av_strdup(s->codec_whitelist);     qc->fmtctx->format_whitelist = av_strdup(s->format_whitelist);
static int FUNC_0(AVFormatContext *VAR_0)

{

    int VAR_1, VAR_2;

    quvi_t q;

    quvi_media_t m;

    QUVIcode rc;

    LibQuviContext *qc = VAR_0->priv_data;

    char *VAR_3, *VAR_4;



    rc = quvi_init(&q);

    if (rc != QUVI_OK)

        goto quvi_fail;



    quvi_setopt(q, QUVIOPT_FORMAT, qc->format);



    rc = quvi_parse(q, VAR_0->filename, &m);

    if (rc != QUVI_OK)

        goto quvi_fail;



    rc = quvi_getprop(m, QUVIPROP_MEDIAURL, &VAR_3);

    if (rc != QUVI_OK)

        goto quvi_fail;



    av_assert0(!qc->fmtctx->codec_whitelist && !qc->fmtctx->format_whitelist);

    qc->fmtctx-> codec_whitelist = av_strdup(VAR_0->codec_whitelist);

    qc->fmtctx->format_whitelist = av_strdup(VAR_0->format_whitelist);



    VAR_2 = avformat_open_input(&qc->fmtctx, VAR_3, NULL, NULL);

    if (VAR_2 < 0)

        goto end;



    rc = quvi_getprop(m, QUVIPROP_PAGETITLE, &VAR_4);

    if (rc == QUVI_OK)

        av_dict_set(&VAR_0->metadata, "title", VAR_4, 0);



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

        AVStream *st = avformat_new_stream(VAR_0, NULL);

        AVStream *ist = qc->fmtctx->streams[VAR_1];

        if (!st) {

            VAR_2 = AVERROR(ENOMEM);

            goto end;

        }

        avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den);

        avcodec_copy_context(st->codec, qc->fmtctx->streams[VAR_1]->codec);

    }



    return 0;



quvi_fail:

    av_log(VAR_0, AV_LOG_ERROR, "%VAR_0\n", quvi_strerror(q, rc));

    VAR_2 = AVERROR_EXTERNAL;



end:

    quvi_parse_close(&m);

    quvi_close(&q);

    return VAR_2;

}

static int FUNC_0(AVFormatContext *VAR_0)
{ int VAR_1, VAR_2; quvi_t q; quvi_media_t m; QUVIcode rc; LibQuviContext *qc = VAR_0->priv_data; char *VAR_3, *VAR_4; rc = quvi_init(&q); if (rc != QUVI_OK)
goto quvi_fail; quvi_setopt(q, QUVIOPT_FORMAT, qc->format); rc = quvi_parse(q, VAR_0->filename, &m); if (rc != QUVI_OK)
goto quvi_fail; rc = quvi_getprop(m, QUVIPROP_MEDIAURL, &VAR_3); if (rc != QUVI_OK)
goto quvi_fail; av_assert0(!qc->fmtctx->codec_whitelist && !qc->fmtctx->format_whitelist); qc->fmtctx-> codec_whitelist = av_strdup(VAR_0->codec_whitelist); qc->fmtctx->format_whitelist = av_strdup(VAR_0->format_whitelist); VAR_2 = avformat_open_input(&qc->fmtctx, VAR_3, NULL, NULL); if (VAR_2 < 0)
goto end; rc = quvi_getprop(m, QUVIPROP_PAGETITLE, &VAR_4); if (rc == QUVI_OK)
av_dict_set(&VAR_0->metadata, "title", VAR_4, 0); for (VAR_1 = 0; VAR_1 < qc->fmtctx->nb_streams; VAR_1++) { AVStream *st = avformat_new_stream(VAR_0, NULL); AVStream *ist = qc->fmtctx->streams[VAR_1]; if (!st) { VAR_2 = AVERROR(ENOMEM); goto end; } avpriv_set_pts_info(st, ist->pts_wrap_bits, ist->time_base.num, ist->time_base.den); avcodec_copy_context(st->codec, qc->fmtctx->streams[VAR_1]->codec); } return 0; quvi_fail:
av_log(VAR_0, AV_LOG_ERROR, "%VAR_0\n", quvi_strerror(q, rc)); VAR_2 = AVERROR_EXTERNAL; end:
quvi_parse_close(&m); quvi_close(&q); return VAR_2; }