Beispiel #1
0
static void
update_jitter_stats(struct rtp_analyze_jdata *jdp,
  struct rtp_info *rinfo, double rtime, int hint)
{
    int64_t dval;
    uint64_t rtime_ts, wrcorr;
#if 0
    int64_t rtime_ts_delta;
#endif

    rtime_ts = rtp_dtime2time_ts64(rinfo->rtp_profile->ts_rate, rtime);
    if (rinfo->rtp_profile->pt_kind == RTP_PTK_AUDIO &&
      CALL_METHOD(jdp->ts_dedup, locate, &rinfo->ts) >= 0) {
        jdp->jss.ts_dcount++;
        if (jdp->jss.pcount == 1) {
            jdp->jss.prev_rtime_ts = rtime_ts;
            jdp->jss.prev_ts = rinfo->ts;
        }
        return;
    }
    if (jdp->jss.prev_rtime_ts != 0) {
        if (hint == RTP_SEQ_RESET) {
            jdp->jss.seq_rcount++;
            goto saveandexit;
        }
#if 0
        rtime_ts_delta = jdp->jss.prev_rtime_ts - rtime_ts;
#endif
        if (jdp->jss.prev_ts > rinfo->ts) {
            if ((jdp->jss.prev_ts - rinfo->ts) > (1 << 31)) {
                /* Normal case, timestamp wrap */
                wrcorr = (uint64_t)1 << 32;
#if 0
            } else if (rtime_ts_delta != 0 && (jdp->jss.prev_ts - rinfo->ts) >
              ABS(rtime_ts_delta) * 20) {
                /* Timestamp reset */
                jdp->jss.ts_rcount++;
                goto saveandexit;
#endif
            } else {
                wrcorr = 0;
            }
        } else {
# if 0
            if (rtime_ts_delta != 0 && (rinfo->ts - jdp->jss.prev_ts) >
              ABS(rtime_ts_delta) * 1024) {
                /* Timestamp jump */
                jdp->jss.ts_jcount++;
                goto saveandexit;
            }
#endif
            wrcorr = 0;
        }
        dval = (rtime_ts - ((uint64_t)rinfo->ts + wrcorr)) -
          (jdp->jss.prev_rtime_ts - jdp->jss.prev_ts);
        jdp->jss.jlast = jdp->jss.jlast + (double)(ABS(dval) - jdp->jss.jlast) / 16.0;
        if (jdp->jss.jlast > jdp->jss.jmax) {
            jdp->jss.jmax = jdp->jss.jlast;
        }
        jdp->jss.jtotal += jdp->jss.jlast;
    }
#if RTPP_DEBUG_analyze
    fprintf(stderr, SSRC_FMT ",%lld,%llu,%u,%f\n", rinfo->ssrc, jdp->jss.pcount,
      rtime_ts, rinfo->ts, jdp->jss.jlast);
#endif
    jdp->jss.pcount++;
saveandexit:
    if (rinfo->rtp_profile->pt_kind == RTP_PTK_AUDIO) {
        CALL_METHOD(jdp->ts_dedup, push, &rinfo->ts);
    }
    jdp->jss.prev_rtime_ts = rtime_ts;
    jdp->jss.prev_ts = rinfo->ts;
}
Beispiel #2
0
static void
update_jitter_stats(struct rtp_analyze_jdata *jdp, struct rtp_info *rinfo,
  double rtime, int hint, struct rtpp_log *rlog)
{
    int64_t dval;
    uint64_t rtime_ts, wrcorr;
#if FIX_TIMESTAMP_RESET
    int64_t rtime_ts_delta;
#endif

    rtime_ts = rtp_dtime2time_ts64(rinfo->rtp_profile->ts_rate, rtime);
    if (rinfo->rtp_profile->pt_kind == RTP_PTK_AUDIO &&
      CALL_METHOD(jdp->ts_dedup, locate, &rinfo->ts) >= 0) {
        jdp->jss.ts_dcount++;
        if (jdp->jss.pcount == 1) {
            jdp->jss.prev_rtime_ts = rtime_ts;
            jdp->jss.prev_ts = rinfo->ts;
        }
        return;
    }
    if (jdp->jss.prev_rtime_ts != 0) {
        if (hint == RTP_SEQ_RESET) {
            jdp->jss.seq_rcount++;
            goto saveandexit;
        }
#if FIX_TIMESTAMP_RESET
        rtime_ts_delta = jdp->jss.prev_rtime_ts - rtime_ts;
#endif
        if (jdp->jss.prev_ts > rinfo->ts) {
            if (((uint64_t)jdp->jss.prev_ts - (uint64_t)rinfo->ts) > (1 << 31)) {
                /* Normal case, timestamp wrap */
                wrcorr = (uint64_t)1 << 32;
#if FIX_TIMESTAMP_RESET
            } else if (rtime_ts_delta != 0 && ((uint64_t)jdp->jss.prev_ts - (uint64_t)rinfo->ts) >
              ABS(rtime_ts_delta) * 50) {
                /* Timestamp reset */
#if DEBUG_TIMESTAMP_RESET
                LOGD_IF_NOT_NULL(rlog, "update_jitter_stats() : timestamp reset : " SSRC_FMT ", %lld, %lld",
                  rinfo->ssrc, ABS(rtime_ts_delta), (uint64_t)jdp->jss.prev_ts - (uint64_t)rinfo->ts);
#endif
                jdp->jss.ts_rcount++;
                goto saveandexit;
#endif
            } else {
                wrcorr = 0;
            }
        } else {
# if FIX_TIMESTAMP_RESET
            if (rtime_ts_delta != 0 && ((uint64_t)rinfo->ts - (uint64_t)jdp->jss.prev_ts) >
              ABS(rtime_ts_delta) * 1024) {
                /* Timestamp jump */
#if DEBUG_TIMESTAMP_RESET
                LOGD_IF_NOT_NULL(rlog,"update_jitter_stats() : timestamp jump : " SSRC_FMT ", %lld, %lld",
                  rinfo->ssrc, ABS(rtime_ts_delta), (uint64_t)rinfo->ts - (uint64_t)jdp->jss.prev_ts);
#endif
                jdp->jss.ts_jcount++;
                goto saveandexit;
            }
#endif
            wrcorr = 0;
        }
        dval = (rtime_ts - ((uint64_t)rinfo->ts + wrcorr)) -
          (jdp->jss.prev_rtime_ts - (uint64_t)jdp->jss.prev_ts);
#if DEBUG_TIMESTAMP_RESET
        if (dval > 10000)
            LOGD_IF_NOT_NULL(rlog, "##### LARGE VALUE #####" SSRC_FMT ",%lld,%lld,%u,%lld,%u,%lld,%lld",
              rinfo->ssrc, jdp->jss.pcount, rtime_ts, rinfo->ts, jdp->jss.prev_rtime_ts,
              jdp->jss.prev_ts, wrcorr, dval);
#endif
        jdp->jss.jlast = jdp->jss.jlast + (double)(ABS(dval) - jdp->jss.jlast) / 16.0;
        if (jdp->jss.jlast > jdp->jss.jmax) {
            jdp->jss.jmax = jdp->jss.jlast;
        }
        jdp->jss.jtotal += jdp->jss.jlast;
    }
#if RTPP_DEBUG_analyze
    LOGD_IF_NOT_NULL(rlog, SSRC_FMT ",%lld,%llu,%u,%f", rinfo->ssrc, jdp->jss.pcount,
      rtime_ts, rinfo->ts, jdp->jss.jlast);
#endif
    jdp->jss.pcount++;
saveandexit:
    if (rinfo->rtp_profile->pt_kind == RTP_PTK_AUDIO) {
        CALL_METHOD(jdp->ts_dedup, push, &rinfo->ts);
    }
    jdp->jss.prev_rtime_ts = rtime_ts;
    jdp->jss.prev_ts = rinfo->ts;
}