Changeset 408 for pjproject/trunk/pjmedia/src/pjmedia/rtcp.c
- Timestamp:
- Apr 24, 2006 11:13:00 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/src/pjmedia/rtcp.c
r403 r408 110 110 if (PJ_TIME_VAL_MSEC(diff) >= MIN_DIFF) { 111 111 112 TRACE_(( THIS_FILE, "NTP timestamp corrected by %d ms",112 TRACE_((sess->name, "RTCP NTP timestamp corrected by %d ms", 113 113 PJ_TIME_VAL_MSEC(diff))); 114 114 … … 126 126 127 127 PJ_DEF(void) pjmedia_rtcp_init(pjmedia_rtcp_session *sess, 128 char *name, 128 129 unsigned clock_rate, 129 130 unsigned samples_per_frame, … … 135 136 pj_memset(rtcp_pkt, 0, sizeof(pjmedia_rtcp_pkt)); 136 137 138 /* Name */ 139 sess->name = name ? name : THIS_FILE, 140 137 141 /* Set clock rate */ 138 142 sess->clock_rate = clock_rate; … … 238 242 239 243 /* 240 * Calculate jitter (see RFC 3550 section A.8)244 * Calculate jitter only when sequence is good (see RFC 3550 section A.8) 241 245 */ 242 243 /* Get arrival time and convert timestamp to samples */ 244 pj_get_timestamp(&ts); 245 ts.u64 = ts.u64 * sess->clock_rate / sess->ts_freq.u64; 246 arrival = ts.u32.lo; 247 248 transit = arrival - rtp_ts; 249 250 /* Ignore the first N packets as they normally have bad jitter 251 * due to other threads working to establish the call 252 */ 253 if (sess->transit == 0 || sess->received < 25 ) { 254 sess->transit = transit; 255 sess->stat.rx.jitter.min = 2000; 256 } else { 257 pj_int32_t d; 258 pj_uint32_t jitter; 259 260 d = transit - sess->transit; 261 sess->transit = transit; 262 if (d < 0) 263 d = -d; 264 265 sess->jitter += d - ((sess->jitter + 8) >> 4); 266 267 /* Get jitter in usec */ 268 if (d < 4294) 269 jitter = d * 1000000 / sess->clock_rate; 270 else { 271 jitter = d * 1000 / sess->clock_rate; 272 jitter *= 1000; 246 if (seq_st.diff == 1) { 247 /* Get arrival time and convert timestamp to samples */ 248 pj_get_timestamp(&ts); 249 ts.u64 = ts.u64 * sess->clock_rate / sess->ts_freq.u64; 250 arrival = ts.u32.lo; 251 252 transit = arrival - rtp_ts; 253 254 /* Ignore the first N packets as they normally have bad jitter 255 * due to other threads working to establish the call 256 */ 257 if (sess->transit == 0 || sess->received < 25 ) { 258 sess->transit = transit; 259 sess->stat.rx.jitter.min = 2000; 260 } else { 261 pj_int32_t d; 262 pj_uint32_t jitter; 263 264 d = transit - sess->transit; 265 sess->transit = transit; 266 if (d < 0) 267 d = -d; 268 269 sess->jitter += d - ((sess->jitter + 8) >> 4); 270 271 /* Get jitter in usec */ 272 if (d < 4294) 273 jitter = d * 1000000 / sess->clock_rate; 274 else { 275 jitter = d * 1000 / sess->clock_rate; 276 jitter *= 1000; 277 } 278 279 /* Update jitter stat */ 280 if (jitter < sess->stat.rx.jitter.min) 281 sess->stat.rx.jitter.min = jitter; 282 if (jitter > sess->stat.rx.jitter.max) 283 sess->stat.rx.jitter.max = jitter; 284 sess->stat.rx.jitter.last = jitter; 273 285 } 274 275 /* Update jitter stat */276 if (jitter < sess->stat.rx.jitter.min)277 sess->stat.rx.jitter.min = jitter;278 if (jitter > sess->stat.rx.jitter.max)279 sess->stat.rx.jitter.max = jitter;280 sess->stat.rx.jitter.last = jitter;281 286 } 282 287 } … … 308 313 pj_get_timestamp(&sess->rx_lsr_time); 309 314 310 TRACE_(( THIS_FILE, "Rx RTCP SR: ntp_ts=%p",315 TRACE_((sess->name, "Rx RTCP SR: ntp_ts=%p", 311 316 sess->rx_lsr, 312 317 (pj_uint32_t)(sess->rx_lsr_time.u64*65536/sess->ts_freq.u64))); … … 405 410 } 406 411 407 TRACE_(( THIS_FILE, "Rx RTCP RR: lsr=%p, dlsr=%p (%d:%03dms), "412 TRACE_((sess->name, "Rx RTCP RR: lsr=%p, dlsr=%p (%d:%03dms), " 408 413 "now=%p, rtt=%p", 409 414 lsr, dlsr, dlsr/65536, (dlsr%65536)*1000/65536, … … 416 421 unsigned rtt = (pj_uint32_t)eedelay; 417 422 418 TRACE_(( THIS_FILE, "RTT is set to %d usec", rtt));423 TRACE_((sess->name, "RTCP RTT is set to %d usec", rtt)); 419 424 420 425 if (rtt >= 1000000) { … … 441 446 442 447 } else { 443 PJ_LOG(5, ( THIS_FILE, "InternalNTP clock skew detected: "448 PJ_LOG(5, (sess->name, "Internal RTCP NTP clock skew detected: " 444 449 "lsr=%p, now=%p, dlsr=%p (%d:%03dms), " 445 450 "diff=%d", … … 526 531 rtcp_pkt->sr.ntp_frac = pj_htonl(ntp.lo); 527 532 528 TRACE_(( THIS_FILE, "TX RTCP SR: ntp_ts=%p",533 TRACE_((sess->name, "TX RTCP SR: ntp_ts=%p", 529 534 ((ntp.hi & 0xFFFF) << 16) + ((ntp.lo & 0xFFFF0000) 530 535 >> 16))); … … 559 564 rtcp_pkt->rr.dlsr = pj_htonl(dlsr); 560 565 561 TRACE_(( THIS_FILE,"Tx RTCP RR: lsr=%p, lsr_time=%p, now=%p, dlsr=%p"566 TRACE_((sess->name,"Tx RTCP RR: lsr=%p, lsr_time=%p, now=%p, dlsr=%p" 562 567 "(%ds:%03dms)", 563 568 lsr,
Note: See TracChangeset
for help on using the changeset viewer.