Changeset 455 for pjproject/trunk
- Timestamp:
- May 18, 2006 6:35:05 PM (19 years ago)
- Location:
- pjproject/trunk/pjmedia
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjmedia/include/pjmedia/rtcp.h
r427 r455 176 176 177 177 struct { 178 unsigned count; /**< Number of updates. */ 178 179 unsigned min; /**< Minimum jitter (in usec) */ 179 180 unsigned avg; /**< Average jitter (in usec) */ … … 216 217 */ 217 218 typedef struct pjmedia_rtcp_stat pjmedia_rtcp_stat; 219 220 221 #if defined(PJ_HAS_FLOATING_POINT) && PJ_HAS_FLOATING_POINT!=0 222 typedef double PJMEDIA_AVG_JITTER_TYPE; 223 #else 224 typedef pj_uint32_t PJMEDIA_AVG_JITTER_TYPE; 225 #endif; 218 226 219 227 … … 245 253 246 254 pjmedia_rtcp_stat stat; /**< Bidirectional stream stat. */ 255 256 /* Keep jitter calculation in floating point to prevent the values 257 * from being rounded-down to nearest integer. 258 */ 259 PJMEDIA_AVG_JITTER_TYPE avg_jitter; /**< Average RX jitter. */ 247 260 }; 248 261 -
pjproject/trunk/pjmedia/src/pjmedia/rtcp.c
r427 r455 139 139 /* Reset statistics */ 140 140 pj_memset(&sess->stat, 0, sizeof(pjmedia_rtcp_stat)); 141 sess->avg_jitter = 0; 141 142 142 143 /* Name */ … … 286 287 } 287 288 289 /* Add to average */ 290 sess->avg_jitter = 291 (jitter + sess->avg_jitter * sess->stat.rx.jitter.count) / 292 (sess->stat.rx.jitter.count + 1); 293 sess->stat.rx.jitter.avg = (unsigned)sess->avg_jitter; 294 ++sess->stat.rx.jitter.count; 295 288 296 /* Update jitter stat */ 289 297 if (jitter < sess->stat.rx.jitter.min) … … 291 299 if (jitter > sess->stat.rx.jitter.max) 292 300 sess->stat.rx.jitter.max = jitter; 301 293 302 sess->stat.rx.jitter.last = jitter; 294 303 } … … 394 403 395 404 /* Update jitter statistics */ 396 if (sess->stat.tx. update_cnt == 0)405 if (sess->stat.tx.jitter.count == 0) 397 406 sess->stat.tx.jitter.min = jitter; 398 407 if (jitter < sess->stat.tx.jitter.min && jitter) … … 401 410 sess->stat.tx.jitter.max = jitter; 402 411 sess->stat.tx.jitter.avg = 403 (sess->stat.tx.jitter.avg * sess->stat.tx.update_cnt + jitter) / 404 (sess->stat.tx.update_cnt + 1); 412 (sess->stat.tx.jitter.avg * sess->stat.tx.jitter.count + jitter) / 413 (sess->stat.tx.jitter.count + 1); 414 ++sess->stat.tx.jitter.count; 405 415 sess->stat.tx.jitter.last = jitter; 406 416 … … 509 519 { 510 520 pj_uint32_t expected, expected_interval, received_interval, lost_interval; 511 pj_uint32_t jitter_samp, jitter;512 521 pjmedia_rtcp_pkt *rtcp_pkt = &sess->rtcp_pkt; 513 522 pj_timestamp ts_now; … … 528 537 529 538 /* Jitter */ 530 jitter_samp = (sess->jitter >> 4); 531 rtcp_pkt->rr.jitter = pj_htonl(jitter_samp); 532 533 /* Calculate jitter in usec, avoiding overflows */ 534 if (jitter_samp <= 4294) 535 jitter = jitter_samp * 1000000 / sess->clock_rate; 536 else { 537 jitter = jitter_samp * 1000 / sess->clock_rate; 538 jitter *= 1000; 539 } 540 541 /* Update jitter statistics */ 542 sess->stat.rx.jitter.avg = 543 (sess->stat.rx.jitter.avg * sess->stat.rx.update_cnt + jitter) / 544 (sess->stat.rx.update_cnt + 1); 539 rtcp_pkt->rr.jitter = pj_htonl(sess->jitter >> 4); 540 545 541 546 542 /* Total lost. */
Note: See TracChangeset
for help on using the changeset viewer.