static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,

                           int64_t dts, int64_t next)

{

    AVIOContext *pb = s->pb;

    AVStream *st    = NULL;

    char buf[20];

    int ret = AVERROR_INVALIDDATA;

    int i, length = -1;



    switch (avio_r8(pb)) {

    case AMF_DATA_TYPE_MIXEDARRAY:

        avio_seek(pb, 4, SEEK_CUR);

    case AMF_DATA_TYPE_OBJECT:

        break;

    default:

        goto skip;

    }



    while ((ret = amf_get_string(pb, buf, sizeof(buf))) > 0) {

        AMFDataType type = avio_r8(pb);

        if (type == AMF_DATA_TYPE_STRING && !strcmp(buf, "text")) {

            length = avio_rb16(pb);

            ret    = av_get_packet(pb, pkt, length);

            if (ret < 0)

                goto skip;

            else

                break;

        } else {

            if ((ret = amf_skip_tag(pb, type)) < 0)

                goto skip;

        }

    }



    if (length < 0) {

        ret = AVERROR_INVALIDDATA;

        goto skip;

    }



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

        st = s->streams[i];

        if (st->codec->codec_type == AVMEDIA_TYPE_DATA)

            break;

    }



    if (i == s->nb_streams) {

        st = create_stream(s, AVMEDIA_TYPE_DATA);

        if (!st)

            return AVERROR_INVALIDDATA;

        st->codec->codec_id = AV_CODEC_ID_TEXT;

    }



    pkt->dts  = dts;

    pkt->pts  = dts;

    pkt->size = ret;



    pkt->stream_index = st->index;

    pkt->flags       |= AV_PKT_FLAG_KEY;



skip:

    avio_seek(s->pb, next + 4, SEEK_SET);



    return ret;

}

static int flv_data_packet(AVFormatContext *s, AVPacket *pkt,

                           int64_t dts, int64_t next)

{

    AVIOContext *pb = s->pb;

    AVStream *st    = NULL;

    char buf[20];

    int ret = AVERROR_INVALIDDATA;

    int i, length = -1;



    switch (avio_r8(pb)) {

    case AMF_DATA_TYPE_MIXEDARRAY:

        avio_seek(pb, 4, SEEK_CUR);

    case AMF_DATA_TYPE_OBJECT:

        break;

    default:

        goto skip;

    }



    while ((ret = amf_get_string(pb, buf, sizeof(buf))) > 0) {

        AMFDataType type = avio_r8(pb);

        if (type == AMF_DATA_TYPE_STRING && !strcmp(buf, "text")) {

            length = avio_rb16(pb);

            ret    = av_get_packet(pb, pkt, length);

            if (ret < 0)

                goto skip;

            else

                break;

        } else {

            if ((ret = amf_skip_tag(pb, type)) < 0)

                goto skip;

        }

    }



    if (length < 0) {

        ret = AVERROR_INVALIDDATA;

        goto skip;

    }



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

        st = s->streams[i];

        if (st->codec->codec_type == AVMEDIA_TYPE_DATA)

            break;

    }



    if (i == s->nb_streams) {

        st = create_stream(s, AVMEDIA_TYPE_DATA);

        if (!st)

            return AVERROR_INVALIDDATA;

        st->codec->codec_id = AV_CODEC_ID_TEXT;

    }



    pkt->dts  = dts;

    pkt->pts  = dts;

    pkt->size = ret;



    pkt->stream_index = st->index;

    pkt->flags       |= AV_PKT_FLAG_KEY;



skip:

    avio_seek(s->pb, next + 4, SEEK_SET);



    return ret;

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1,

                           int64_t VAR_2, int64_t VAR_3)

{

    AVIOContext *pb = VAR_0->pb;

    AVStream *st    = NULL;

    char VAR_4[20];

    int VAR_5 = AVERROR_INVALIDDATA;

    int VAR_6, VAR_7 = -1;



    switch (avio_r8(pb)) {

    case AMF_DATA_TYPE_MIXEDARRAY:

        avio_seek(pb, 4, SEEK_CUR);

    case AMF_DATA_TYPE_OBJECT:

        break;

    default:

        goto skip;

    }



    while ((VAR_5 = amf_get_string(pb, VAR_4, sizeof(VAR_4))) > 0) {

        AMFDataType type = avio_r8(pb);

        if (type == AMF_DATA_TYPE_STRING && !strcmp(VAR_4, "text")) {

            VAR_7 = avio_rb16(pb);

            VAR_5    = av_get_packet(pb, VAR_1, VAR_7);

            if (VAR_5 < 0)

                goto skip;

            else

                break;

        } else {

            if ((VAR_5 = amf_skip_tag(pb, type)) < 0)

                goto skip;

        }

    }



    if (VAR_7 < 0) {

        VAR_5 = AVERROR_INVALIDDATA;

        goto skip;

    }



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

        st = VAR_0->streams[VAR_6];

        if (st->codec->codec_type == AVMEDIA_TYPE_DATA)

            break;

    }



    if (VAR_6 == VAR_0->nb_streams) {

        st = create_stream(VAR_0, AVMEDIA_TYPE_DATA);

        if (!st)

            return AVERROR_INVALIDDATA;

        st->codec->codec_id = AV_CODEC_ID_TEXT;

    }



    VAR_1->VAR_2  = VAR_2;

    VAR_1->pts  = VAR_2;

    VAR_1->size = VAR_5;



    VAR_1->stream_index = st->index;

    VAR_1->flags       |= AV_PKT_FLAG_KEY;



skip:

    avio_seek(VAR_0->pb, VAR_3 + 4, SEEK_SET);



    return VAR_5;

}

static int FUNC_0(AVFormatContext *VAR_0, AVPacket *VAR_1,
int64_t VAR_2, int64_t VAR_3)
{ AVIOContext *pb = VAR_0->pb; AVStream *st    = NULL; char VAR_4[20]; int VAR_5 = AVERROR_INVALIDDATA; int VAR_6, VAR_7 = -1; switch (avio_r8(pb)) { case AMF_DATA_TYPE_MIXEDARRAY:
avio_seek(pb, 4, SEEK_CUR); case AMF_DATA_TYPE_OBJECT:
break; default:
goto skip; } while ((VAR_5 = amf_get_string(pb, VAR_4, sizeof(VAR_4))) > 0) { AMFDataType type = avio_r8(pb); if (type == AMF_DATA_TYPE_STRING && !strcmp(VAR_4, "text")) { VAR_7 = avio_rb16(pb); VAR_5    = av_get_packet(pb, VAR_1, VAR_7); if (VAR_5 < 0)
goto skip; else
break; } else { if ((VAR_5 = amf_skip_tag(pb, type)) < 0)
goto skip; } } if (VAR_7 < 0) { VAR_5 = AVERROR_INVALIDDATA; goto skip; } for (VAR_6 = 0; VAR_6 < VAR_0->nb_streams; VAR_6++) { st = VAR_0->streams[VAR_6]; if (st->codec->codec_type == AVMEDIA_TYPE_DATA)
break; } if (VAR_6 == VAR_0->nb_streams) { st = create_stream(VAR_0, AVMEDIA_TYPE_DATA); if (!st)
return AVERROR_INVALIDDATA; st->codec->codec_id = AV_CODEC_ID_TEXT; } VAR_1->VAR_2  = VAR_2; VAR_1->pts  = VAR_2; VAR_1->size = VAR_5; VAR_1->stream_index = st->index; VAR_1->flags       |= AV_PKT_FLAG_KEY; skip:
avio_seek(VAR_0->pb, VAR_3 + 4, SEEK_SET); return VAR_5; }