static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf,

                             int len)

{

    int payload_len;

    while (len >= 4) {

        payload_len = FFMIN(len, (AV_RB16(buf + 2) + 1) * 4);



        switch (buf[1]) {

        case RTCP_SR:

            if (payload_len < 20) {

                av_log(NULL, AV_LOG_ERROR,

                       "Invalid length for RTCP SR packet\n");

                return AVERROR_INVALIDDATA;

            }



            s->last_rtcp_reception_time = av_gettime_relative();

            s->last_rtcp_ntp_time  = AV_RB64(buf + 8);

            s->last_rtcp_timestamp = AV_RB32(buf + 16);

            if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) {

                s->first_rtcp_ntp_time = s->last_rtcp_ntp_time;

                if (!s->base_timestamp)

                    s->base_timestamp = s->last_rtcp_timestamp;

                s->rtcp_ts_offset = s->last_rtcp_timestamp - s->base_timestamp;

            }



            break;

        case RTCP_BYE:

            return -RTCP_BYE;

        }



        buf += payload_len;

        len -= payload_len;

    }

    return -1;

}

static int rtcp_parse_packet(RTPDemuxContext *s, const unsigned char *buf,

                             int len)

{

    int payload_len;

    while (len >= 4) {

        payload_len = FFMIN(len, (AV_RB16(buf + 2) + 1) * 4);



        switch (buf[1]) {

        case RTCP_SR:

            if (payload_len < 20) {

                av_log(NULL, AV_LOG_ERROR,

                       "Invalid length for RTCP SR packet\n");

                return AVERROR_INVALIDDATA;

            }



            s->last_rtcp_reception_time = av_gettime_relative();

            s->last_rtcp_ntp_time  = AV_RB64(buf + 8);

            s->last_rtcp_timestamp = AV_RB32(buf + 16);

            if (s->first_rtcp_ntp_time == AV_NOPTS_VALUE) {

                s->first_rtcp_ntp_time = s->last_rtcp_ntp_time;

                if (!s->base_timestamp)

                    s->base_timestamp = s->last_rtcp_timestamp;

                s->rtcp_ts_offset = s->last_rtcp_timestamp - s->base_timestamp;

            }



            break;

        case RTCP_BYE:

            return -RTCP_BYE;

        }



        buf += payload_len;

        len -= payload_len;

    }

    return -1;

}

static int FUNC_0(RTPDemuxContext *VAR_0, const unsigned char *VAR_1,

                             int VAR_2)

{

    int VAR_3;

    while (VAR_2 >= 4) {

        VAR_3 = FFMIN(VAR_2, (AV_RB16(VAR_1 + 2) + 1) * 4);



        switch (VAR_1[1]) {

        case RTCP_SR:

            if (VAR_3 < 20) {

                av_log(NULL, AV_LOG_ERROR,

                       "Invalid length for RTCP SR packet\n");

                return AVERROR_INVALIDDATA;

            }



            VAR_0->last_rtcp_reception_time = av_gettime_relative();

            VAR_0->last_rtcp_ntp_time  = AV_RB64(VAR_1 + 8);

            VAR_0->last_rtcp_timestamp = AV_RB32(VAR_1 + 16);

            if (VAR_0->first_rtcp_ntp_time == AV_NOPTS_VALUE) {

                VAR_0->first_rtcp_ntp_time = VAR_0->last_rtcp_ntp_time;

                if (!VAR_0->base_timestamp)

                    VAR_0->base_timestamp = VAR_0->last_rtcp_timestamp;

                VAR_0->rtcp_ts_offset = VAR_0->last_rtcp_timestamp - VAR_0->base_timestamp;

            }



            break;

        case RTCP_BYE:

            return -RTCP_BYE;

        }



        VAR_1 += VAR_3;

        VAR_2 -= VAR_3;

    }

    return -1;

}

static int FUNC_0(RTPDemuxContext *VAR_0, const unsigned char *VAR_1,
int VAR_2)
{ int VAR_3; while (VAR_2 >= 4) { VAR_3 = FFMIN(VAR_2, (AV_RB16(VAR_1 + 2) + 1) * 4); switch (VAR_1[1]) { case RTCP_SR:
if (VAR_3 < 20) { av_log(NULL, AV_LOG_ERROR,
"Invalid length for RTCP SR packet\n"); return AVERROR_INVALIDDATA; } VAR_0->last_rtcp_reception_time = av_gettime_relative(); VAR_0->last_rtcp_ntp_time  = AV_RB64(VAR_1 + 8); VAR_0->last_rtcp_timestamp = AV_RB32(VAR_1 + 16); if (VAR_0->first_rtcp_ntp_time == AV_NOPTS_VALUE) { VAR_0->first_rtcp_ntp_time = VAR_0->last_rtcp_ntp_time; if (!VAR_0->base_timestamp)
VAR_0->base_timestamp = VAR_0->last_rtcp_timestamp; VAR_0->rtcp_ts_offset = VAR_0->last_rtcp_timestamp - VAR_0->base_timestamp; } break; case RTCP_BYE:
return -RTCP_BYE; } VAR_1 += VAR_3; VAR_2 -= VAR_3; } return -1; }