printf("RTP: PT=%02x: bad cseq %04x expected=%04x\n",
av_log(&s->st->codec, AV_LOG_ERROR, "RTP: PT=%02x: bad cseq %04x expected=%04x\n",
int rtp_parse_packet(RTPDemuxContext *s, AVPacket *pkt,                      const uint8_t *buf, int len){    unsigned int ssrc, h;    int payload_type, seq, delta_timestamp, ret;    AVStream *st;    uint32_t timestamp;        if (!buf) {        /* return the next packets, if any */        if (s->read_buf_index >= s->read_buf_size)            return -1;        ret = mpegts_parse_packet(s->ts, pkt, s->buf + s->read_buf_index,                                   s->read_buf_size - s->read_buf_index);        if (ret < 0)            return -1;        s->read_buf_index += ret;        if (s->read_buf_index < s->read_buf_size)            return 1;        else            return 0;    }    if (len < 12)        return -1;    if ((buf[0] & 0xc0) != (RTP_VERSION << 6))        return -1;    if (buf[1] >= 200 && buf[1] <= 204) {        rtcp_parse_packet(s, buf, len);        return -1;    }    payload_type = buf[1] & 0x7f;    seq  = (buf[2] << 8) | buf[3];    timestamp = decode_be32(buf + 4);    ssrc = decode_be32(buf + 8);        /* NOTE: we can handle only one payload type */    if (s->payload_type != payload_type)        return -1;#if defined(DEBUG) || 1    if (seq != ((s->seq + 1) & 0xffff)) {        printf("RTP: PT=%02x: bad cseq %04x expected=%04x\n",                payload_type, seq, ((s->seq + 1) & 0xffff));    }    s->seq = seq;#endif    len -= 12;    buf += 12;    st = s->st;    if (!st) {        /* specific MPEG2TS demux support */        ret = mpegts_parse_packet(s->ts, pkt, buf, len);        if (ret < 0)            return -1;        if (ret < len) {            s->read_buf_size = len - ret;            memcpy(s->buf, buf + ret, s->read_buf_size);            s->read_buf_index = 0;            return 1;        }    } else {        switch(st->codec.codec_id) {        case CODEC_ID_MP2:            /* better than nothing: skip mpeg audio RTP header */            if (len <= 4)                return -1;            h = decode_be32(buf);            len -= 4;            buf += 4;            av_new_packet(pkt, len);            memcpy(pkt->data, buf, len);            break;        case CODEC_ID_MPEG1VIDEO:            /* better than nothing: skip mpeg video RTP header */            if (len <= 4)                return -1;            h = decode_be32(buf);            buf += 4;            len -= 4;            if (h & (1 << 26)) {                /* mpeg2 */                if (len <= 4)                    return -1;                buf += 4;                len -= 4;            }            av_new_packet(pkt, len);            memcpy(pkt->data, buf, len);            break;        default:            av_new_packet(pkt, len);            memcpy(pkt->data, buf, len);            break;        }                switch(st->codec.codec_id) {        case CODEC_ID_MP2:        case CODEC_ID_MPEG1VIDEO:            if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) {                int64_t addend;                /* XXX: is it really necessary to unify the timestamp base ? */                /* compute pts from timestamp with received ntp_time */                delta_timestamp = timestamp - s->last_rtcp_timestamp;                /* convert to 90 kHz without overflow */                addend = (s->last_rtcp_ntp_time - s->first_rtcp_ntp_time) >> 14;                addend = (addend * 5625) >> 14;                pkt->pts = addend + delta_timestamp;            }            break;        default:            /* no timestamp info yet */            break;        }        pkt->stream_index = s->st->index;    }    return 0;}