- Timestamp:
- Mar 23, 2009 1:25:26 PM (16 years ago)
- Location:
- pjproject/branches/1.0
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/branches/1.0
- Property svn:mergeinfo changed
/pjproject/trunk merged: 2447
- Property svn:mergeinfo changed
-
pjproject/branches/1.0/pjmedia/src/pjmedia/rtcp_xr.c
r2407 r2545 28 28 #include <pj/string.h> 29 29 30 #if 1 //defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0)30 #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) 31 31 32 32 #define THIS_FILE "rtcp_xr.c" … … 247 247 pj_uint32_t c32; 248 248 pj_uint32_t c33; 249 pj_uint32_t ctotal, p32, p23,m;249 pj_uint32_t ctotal, m; 250 250 unsigned est_extra_delay; 251 251 … … 258 258 r->header.length = pj_htons(8); 259 259 260 /* Calculate additional transition counts. */260 /* Use temp vars for easiness. */ 261 261 c11 = sess->voip_mtc_stat.c11; 262 262 c13 = sess->voip_mtc_stat.c13; … … 265 265 c23 = sess->voip_mtc_stat.c23; 266 266 c33 = sess->voip_mtc_stat.c33; 267 m = sess->ptime * sess->frames_per_packet; 268 269 /* Calculate additional transition counts. */ 267 270 c31 = c13; 268 271 c32 = c23; 269 272 ctotal = c11 + c14 + c13 + c22 + c23 + c31 + c32 + c33; 270 m = sess->ptime * sess->frames_per_packet; 271 272 /* Calculate burst and densities. */ 273 if (c11 && (c23 || c33)) { 274 p32 = c32 / (c31 + c32 + c33); 275 if((c22 + c23) < 1) { 276 p23 = 1; 273 274 if (ctotal) { 275 pj_uint32_t p32, p23; 276 277 //original version: 278 //p32 = c32 / (c31 + c32 + c33); 279 if (c31 + c32 + c33 == 0) 280 p32 = 0; 281 else 282 p32 = (c32 << 16) / (c31 + c32 + c33); 283 284 //original version: 285 //if ((c22 + c23) < 1) { 286 // p23 = 1; 287 //} else { 288 // p23 = 1 - c22 / (c22 + c23); 289 //} 290 if (c23 == 0) { 291 p23 = 0; 277 292 } else { 278 p23 = 1 - c22/(c22 + c23);293 p23 = (c23 << 16) / (c22 + c23); 279 294 } 280 sess->stat.rx.voip_mtc.burst_den = (pj_uint8_t)(256*p23/(p23 + p32)); 281 sess->stat.rx.voip_mtc.gap_den = (pj_uint8_t)(256*c14/(c11 + c14)); 282 283 /* Calculate burst and gap durations in ms */ 284 sess->stat.rx.voip_mtc.gap_dur = (pj_uint16_t)((c11+c14+c13)*m/c13); 285 sess->stat.rx.voip_mtc.burst_dur = (pj_uint16_t)(ctotal*m/c13 - 286 sess->stat.rx.voip_mtc.gap_dur); 295 296 /* Calculate loss/discard densities, scaled of 0-256 */ 297 if (c11 == 0) 298 sess->stat.rx.voip_mtc.gap_den = 0; 299 else 300 sess->stat.rx.voip_mtc.gap_den = (pj_uint8_t) 301 ((c14 << 8) / (c11 + c14)); 302 if (p23 == 0) 303 sess->stat.rx.voip_mtc.burst_den = 0; 304 else 305 sess->stat.rx.voip_mtc.burst_den = (pj_uint8_t) 306 ((p23 << 8) / (p23 + p32)); 307 308 /* Calculate (average) durations, in ms */ 309 if (c13 == 0) { 310 c13 = 1; 311 ctotal += 1; 312 } 313 sess->stat.rx.voip_mtc.gap_dur = (pj_uint16_t) 314 ((c11+c14+c13) * m / c13); 315 sess->stat.rx.voip_mtc.burst_dur = (pj_uint16_t) 316 ((ctotal - (c11+c14+c13)) * m / c13); 317 318 /* Callculate loss/discard rates, scaled 0-256 */ 319 sess->stat.rx.voip_mtc.loss_rate = (pj_uint8_t) 320 ((sess->voip_mtc_stat.loss_count << 8) / ctotal); 321 sess->stat.rx.voip_mtc.discard_rate = (pj_uint8_t) 322 ((sess->voip_mtc_stat.discard_count << 8) / ctotal); 287 323 } else { 288 /* No burst occurred yet until this time? 289 * Just report full gap. 290 */ 291 ctotal = sess->rtcp_session->stat.rx.pkt + 292 sess->voip_mtc_stat.loss_count + 293 sess->voip_mtc_stat.discard_count; 294 324 /* No lost/discarded packet yet. */ 325 sess->stat.rx.voip_mtc.gap_den = 0; 295 326 sess->stat.rx.voip_mtc.burst_den = 0; 296 sess->stat.rx.voip_mtc.gap_den = (pj_uint8_t)(256 * 297 (sess->voip_mtc_stat.loss_count + 298 sess->voip_mtc_stat.discard_count) / 299 ctotal); 300 301 /* Calculate burst and gap durations in ms */ 302 sess->stat.rx.voip_mtc.gap_dur = (pj_uint16_t)((m*ctotal) < 0xFFFF? 303 (m*ctotal) : 0xFFFF); 327 sess->stat.rx.voip_mtc.gap_dur = 0; 304 328 sess->stat.rx.voip_mtc.burst_dur = 0; 305 } 306 307 /* Calculate loss and discard rates */ 308 sess->stat.rx.voip_mtc.loss_rate = (pj_uint8_t) 309 (256 * sess->voip_mtc_stat.loss_count / ctotal); 310 sess->stat.rx.voip_mtc.discard_rate = (pj_uint8_t) 311 (256 * sess->voip_mtc_stat.discard_count / ctotal); 329 sess->stat.rx.voip_mtc.loss_rate = 0; 330 sess->stat.rx.voip_mtc.discard_rate = 0; 331 } 312 332 313 333 /* Set round trip delay (in ms) to RTT calculated after receiving
Note: See TracChangeset
for help on using the changeset viewer.