static int handle_metadata(RTMPContext *rt, RTMPPacket *pkt)

{

    int ret, old_flv_size, type;

    const uint8_t *next;

    uint8_t *p;

    uint32_t size;

    uint32_t ts, cts, pts = 0;



    old_flv_size = update_offset(rt, pkt->size);



    if ((ret = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) {

        rt->flv_size = rt->flv_off = 0;

        return ret;

    }



    next = pkt->data;

    p    = rt->flv_data + old_flv_size;



    /* copy data while rewriting timestamps */

    ts = pkt->timestamp;



    while (next - pkt->data < pkt->size - RTMP_HEADER) {

        type = bytestream_get_byte(&next);

        size = bytestream_get_be24(&next);

        cts  = bytestream_get_be24(&next);

        cts |= bytestream_get_byte(&next) << 24;

        if (!pts)

            pts = cts;

        ts += cts - pts;

        pts = cts;

        bytestream_put_byte(&p, type);

        bytestream_put_be24(&p, size);

        bytestream_put_be24(&p, ts);

        bytestream_put_byte(&p, ts >> 24);

        memcpy(p, next, size + 3 + 4);

        next += size + 3 + 4;

        p    += size + 3 + 4;

    }

    memcpy(p, next, RTMP_HEADER);



    return 0;

}

static int handle_metadata(RTMPContext *rt, RTMPPacket *pkt)

{

    int ret, old_flv_size, type;

    const uint8_t *next;

    uint8_t *p;

    uint32_t size;

    uint32_t ts, cts, pts = 0;



    old_flv_size = update_offset(rt, pkt->size);



    if ((ret = av_reallocp(&rt->flv_data, rt->flv_size)) < 0) {

        rt->flv_size = rt->flv_off = 0;

        return ret;

    }



    next = pkt->data;

    p    = rt->flv_data + old_flv_size;



    

    ts = pkt->timestamp;



    while (next - pkt->data < pkt->size - RTMP_HEADER) {

        type = bytestream_get_byte(&next);

        size = bytestream_get_be24(&next);

        cts  = bytestream_get_be24(&next);

        cts |= bytestream_get_byte(&next) << 24;

        if (!pts)

            pts = cts;

        ts += cts - pts;

        pts = cts;

        bytestream_put_byte(&p, type);

        bytestream_put_be24(&p, size);

        bytestream_put_be24(&p, ts);

        bytestream_put_byte(&p, ts >> 24);

        memcpy(p, next, size + 3 + 4);

        next += size + 3 + 4;

        p    += size + 3 + 4;

    }

    memcpy(p, next, RTMP_HEADER);



    return 0;

}

    memcpy(p, next, RTMP_HEADER);
static int FUNC_0(RTMPContext *VAR_0, RTMPPacket *VAR_1)

{

    int VAR_2, VAR_3, VAR_4;

    const uint8_t *VAR_5;

    uint8_t *p;

    uint32_t size;

    uint32_t ts, cts, pts = 0;



    VAR_3 = update_offset(VAR_0, VAR_1->size);



    if ((VAR_2 = av_reallocp(&VAR_0->flv_data, VAR_0->flv_size)) < 0) {

        VAR_0->flv_size = VAR_0->flv_off = 0;

        return VAR_2;

    }



    VAR_5 = VAR_1->data;

    p    = VAR_0->flv_data + VAR_3;



    

    ts = VAR_1->timestamp;



    while (VAR_5 - VAR_1->data < VAR_1->size - RTMP_HEADER) {

        VAR_4 = bytestream_get_byte(&VAR_5);

        size = bytestream_get_be24(&VAR_5);

        cts  = bytestream_get_be24(&VAR_5);

        cts |= bytestream_get_byte(&VAR_5) << 24;

        if (!pts)

            pts = cts;

        ts += cts - pts;

        pts = cts;

        bytestream_put_byte(&p, VAR_4);

        bytestream_put_be24(&p, size);

        bytestream_put_be24(&p, ts);

        bytestream_put_byte(&p, ts >> 24);

        memcpy(p, VAR_5, size + 3 + 4);

        VAR_5 += size + 3 + 4;

        p    += size + 3 + 4;

    }

    memcpy(p, VAR_5, RTMP_HEADER);



    return 0;

}

static int FUNC_0(RTMPContext *VAR_0, RTMPPacket *VAR_1)
{ int VAR_2, VAR_3, VAR_4; const uint8_t *VAR_5; uint8_t *p; uint32_t size; uint32_t ts, cts, pts = 0; VAR_3 = update_offset(VAR_0, VAR_1->size); if ((VAR_2 = av_reallocp(&VAR_0->flv_data, VAR_0->flv_size)) < 0) { VAR_0->flv_size = VAR_0->flv_off = 0; return VAR_2; } VAR_5 = VAR_1->data; p    = VAR_0->flv_data + VAR_3; ts = VAR_1->timestamp; while (VAR_5 - VAR_1->data < VAR_1->size - RTMP_HEADER) { VAR_4 = bytestream_get_byte(&VAR_5); size = bytestream_get_be24(&VAR_5); cts  = bytestream_get_be24(&VAR_5); cts |= bytestream_get_byte(&VAR_5) << 24; if (!pts)
pts = cts; ts += cts - pts; pts = cts; bytestream_put_byte(&p, VAR_4); bytestream_put_be24(&p, size); bytestream_put_be24(&p, ts); bytestream_put_byte(&p, ts >> 24); memcpy(p, VAR_5, size + 3 + 4); VAR_5 += size + 3 + 4; p    += size + 3 + 4; } memcpy(p, VAR_5, RTMP_HEADER); return 0; }