Changeset 2152 for pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
- Timestamp:
- Jul 17, 2008 2:54:03 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c
r2130 r2152 2185 2185 *p++ = '\n'; 2186 2186 *p = '\0'; 2187 2188 #if defined(PJMEDIA_HAS_RTCP_XR) && (PJMEDIA_HAS_RTCP_XR != 0) 2189 # define SAMPLES_TO_USEC(usec, samples, clock_rate) \ 2190 do { \ 2191 if (samples <= 4294) \ 2192 usec = samples * 1000000 / clock_rate; \ 2193 else { \ 2194 usec = samples * 1000 / clock_rate; \ 2195 usec *= 1000; \ 2196 } \ 2197 } while(0) 2198 2199 # define PRINT_VOIP_MTC_VAL(s, v) \ 2200 if (v == 127) \ 2201 sprintf(s, "(na)"); \ 2202 else \ 2203 sprintf(s, "%d", v) 2204 2205 # define VALIDATE_PRINT_BUF() \ 2206 if (len < 1 || len > end-p) { *p = '\0'; return; } \ 2207 p += len; *p++ = '\n'; *p = '\0' 2208 2209 2210 do { 2211 char loss[16], dup[16]; 2212 char jitter[80]; 2213 char toh[80]; 2214 char plc[16], jba[16], jbr[16]; 2215 char signal_lvl[16], noise_lvl[16], rerl[16]; 2216 char r_factor[16], ext_r_factor[16], mos_lq[16], mos_cq[16]; 2217 pjmedia_rtcp_xr_stat xr_stat; 2218 unsigned clock_rate; 2219 2220 if (pjmedia_session_get_stream_stat_xr(session, i, &xr_stat) != 2221 PJ_SUCCESS) 2222 { 2223 break; 2224 } 2225 2226 clock_rate = info.stream_info[i].fmt.clock_rate; 2227 2228 len = pj_ansi_snprintf(p, end-p, "\n%s Extended reports:", indent); 2229 VALIDATE_PRINT_BUF(); 2230 2231 /* Statistics Summary */ 2232 len = pj_ansi_snprintf(p, end-p, "%s Statistics Summary", indent); 2233 VALIDATE_PRINT_BUF(); 2234 2235 if (xr_stat.rx.stat_sum.l) 2236 sprintf(loss, "%d", xr_stat.rx.stat_sum.lost); 2237 else 2238 sprintf(loss, "(na)"); 2239 2240 if (xr_stat.rx.stat_sum.d) 2241 sprintf(dup, "%d", xr_stat.rx.stat_sum.dup); 2242 else 2243 sprintf(dup, "(na)"); 2244 2245 if (xr_stat.rx.stat_sum.j) { 2246 unsigned jmin, jmax, jmean, jdev; 2247 2248 SAMPLES_TO_USEC(jmin, xr_stat.rx.stat_sum.jitter.min, 2249 clock_rate); 2250 SAMPLES_TO_USEC(jmax, xr_stat.rx.stat_sum.jitter.max, 2251 clock_rate); 2252 SAMPLES_TO_USEC(jmean, xr_stat.rx.stat_sum.jitter.mean, 2253 clock_rate); 2254 SAMPLES_TO_USEC(jdev, 2255 pj_math_stat_get_stddev(&xr_stat.rx.stat_sum.jitter), 2256 clock_rate); 2257 sprintf(jitter, "%7.3f %7.3f %7.3f %7.3f", 2258 jmin/1000.0, jmean/1000.0, jmax/1000.0, jdev/1000.0); 2259 } else 2260 sprintf(jitter, "(report not available)"); 2261 2262 if (xr_stat.rx.stat_sum.t) { 2263 sprintf(toh, "%11d %11d %11d %11d", 2264 xr_stat.rx.stat_sum.toh.min, 2265 xr_stat.rx.stat_sum.toh.mean, 2266 xr_stat.rx.stat_sum.toh.max, 2267 pj_math_stat_get_stddev(&xr_stat.rx.stat_sum.toh)); 2268 } else 2269 sprintf(toh, "(report not available)"); 2270 2271 if (xr_stat.rx.stat_sum.update.sec == 0) 2272 strcpy(last_update, "never"); 2273 else { 2274 pj_gettimeofday(&now); 2275 PJ_TIME_VAL_SUB(now, xr_stat.rx.stat_sum.update); 2276 sprintf(last_update, "%02ldh:%02ldm:%02ld.%03lds ago", 2277 now.sec / 3600, 2278 (now.sec % 3600) / 60, 2279 now.sec % 60, 2280 now.msec); 2281 } 2282 2283 len = pj_ansi_snprintf(p, end-p, 2284 "%s RX last update: %s\n" 2285 "%s begin seq=%d, end seq=%d\n" 2286 "%s pkt loss=%s, dup=%s\n" 2287 "%s (msec) min avg max dev\n" 2288 "%s jitter : %s\n" 2289 "%s toh : %s", 2290 indent, last_update, 2291 indent, 2292 xr_stat.rx.stat_sum.begin_seq, xr_stat.rx.stat_sum.end_seq, 2293 indent, loss, dup, 2294 indent, 2295 indent, jitter, 2296 indent, toh 2297 ); 2298 VALIDATE_PRINT_BUF(); 2299 2300 if (xr_stat.tx.stat_sum.l) 2301 sprintf(loss, "%d", xr_stat.tx.stat_sum.lost); 2302 else 2303 sprintf(loss, "(na)"); 2304 2305 if (xr_stat.tx.stat_sum.d) 2306 sprintf(dup, "%d", xr_stat.tx.stat_sum.dup); 2307 else 2308 sprintf(dup, "(na)"); 2309 2310 if (xr_stat.tx.stat_sum.j) { 2311 unsigned jmin, jmax, jmean, jdev; 2312 2313 SAMPLES_TO_USEC(jmin, xr_stat.tx.stat_sum.jitter.min, 2314 clock_rate); 2315 SAMPLES_TO_USEC(jmax, xr_stat.tx.stat_sum.jitter.max, 2316 clock_rate); 2317 SAMPLES_TO_USEC(jmean, xr_stat.tx.stat_sum.jitter.mean, 2318 clock_rate); 2319 SAMPLES_TO_USEC(jdev, 2320 pj_math_stat_get_stddev(&xr_stat.tx.stat_sum.jitter), 2321 clock_rate); 2322 sprintf(jitter, "%7.3f %7.3f %7.3f %7.3f", 2323 jmin/1000.0, jmean/1000.0, jmax/1000.0, jdev/1000.0); 2324 } else 2325 sprintf(jitter, "(report not available)"); 2326 2327 if (xr_stat.tx.stat_sum.t) { 2328 sprintf(toh, "%11d %11d %11d %11d", 2329 xr_stat.tx.stat_sum.toh.min, 2330 xr_stat.tx.stat_sum.toh.mean, 2331 xr_stat.tx.stat_sum.toh.max, 2332 pj_math_stat_get_stddev(&xr_stat.rx.stat_sum.toh)); 2333 } else 2334 sprintf(toh, "(report not available)"); 2335 2336 if (xr_stat.tx.stat_sum.update.sec == 0) 2337 strcpy(last_update, "never"); 2338 else { 2339 pj_gettimeofday(&now); 2340 PJ_TIME_VAL_SUB(now, xr_stat.tx.stat_sum.update); 2341 sprintf(last_update, "%02ldh:%02ldm:%02ld.%03lds ago", 2342 now.sec / 3600, 2343 (now.sec % 3600) / 60, 2344 now.sec % 60, 2345 now.msec); 2346 } 2347 2348 len = pj_ansi_snprintf(p, end-p, 2349 "%s TX last update: %s\n" 2350 "%s begin seq=%d, end seq=%d\n" 2351 "%s pkt loss=%s, dup=%s\n" 2352 "%s (msec) min avg max dev\n" 2353 "%s jitter : %s\n" 2354 "%s toh : %s", 2355 indent, last_update, 2356 indent, 2357 xr_stat.tx.stat_sum.begin_seq, xr_stat.tx.stat_sum.end_seq, 2358 indent, loss, dup, 2359 indent, 2360 indent, jitter, 2361 indent, toh 2362 ); 2363 VALIDATE_PRINT_BUF(); 2364 2365 2366 /* VoIP Metrics */ 2367 len = pj_ansi_snprintf(p, end-p, "%s VoIP Metrics", indent); 2368 VALIDATE_PRINT_BUF(); 2369 2370 PRINT_VOIP_MTC_VAL(signal_lvl, xr_stat.rx.voip_mtc.signal_lvl); 2371 PRINT_VOIP_MTC_VAL(noise_lvl, xr_stat.rx.voip_mtc.noise_lvl); 2372 PRINT_VOIP_MTC_VAL(rerl, xr_stat.rx.voip_mtc.rerl); 2373 PRINT_VOIP_MTC_VAL(r_factor, xr_stat.rx.voip_mtc.r_factor); 2374 PRINT_VOIP_MTC_VAL(ext_r_factor, xr_stat.rx.voip_mtc.ext_r_factor); 2375 PRINT_VOIP_MTC_VAL(mos_lq, xr_stat.rx.voip_mtc.mos_lq); 2376 PRINT_VOIP_MTC_VAL(mos_cq, xr_stat.rx.voip_mtc.mos_cq); 2377 2378 switch ((xr_stat.rx.voip_mtc.rx_config>>6) & 3) { 2379 case PJMEDIA_RTCP_XR_PLC_DIS: 2380 sprintf(plc, "DISABLED"); 2381 break; 2382 case PJMEDIA_RTCP_XR_PLC_ENH: 2383 sprintf(plc, "ENHANCED"); 2384 break; 2385 case PJMEDIA_RTCP_XR_PLC_STD: 2386 sprintf(plc, "STANDARD"); 2387 break; 2388 case PJMEDIA_RTCP_XR_PLC_UNK: 2389 default: 2390 sprintf(plc, "UNKNOWN"); 2391 break; 2392 } 2393 2394 switch ((xr_stat.rx.voip_mtc.rx_config>>4) & 3) { 2395 case PJMEDIA_RTCP_XR_JB_FIXED: 2396 sprintf(jba, "FIXED"); 2397 break; 2398 case PJMEDIA_RTCP_XR_JB_ADAPTIVE: 2399 sprintf(jba, "ADAPTIVE"); 2400 break; 2401 default: 2402 sprintf(jba, "UNKNOWN"); 2403 break; 2404 } 2405 2406 sprintf(jbr, "%d", xr_stat.rx.voip_mtc.rx_config & 0x0F); 2407 2408 if (xr_stat.rx.voip_mtc.update.sec == 0) 2409 strcpy(last_update, "never"); 2410 else { 2411 pj_gettimeofday(&now); 2412 PJ_TIME_VAL_SUB(now, xr_stat.rx.voip_mtc.update); 2413 sprintf(last_update, "%02ldh:%02ldm:%02ld.%03lds ago", 2414 now.sec / 3600, 2415 (now.sec % 3600) / 60, 2416 now.sec % 60, 2417 now.msec); 2418 } 2419 2420 len = pj_ansi_snprintf(p, end-p, 2421 "%s RX last update: %s\n" 2422 "%s packets : loss rate=%d (%.2f%%), discard rate=%d (%.2f%%)\n" 2423 "%s burst : density=%d (%.2f%%), duration=%d%s\n" 2424 "%s gap : density=%d (%.2f%%), duration=%d%s\n" 2425 "%s delay : round trip=%d%s, end system=%d%s\n" 2426 "%s level : signal=%s%s, noise=%s%s, RERL=%s%s\n" 2427 "%s quality : R factor=%s, ext R factor=%s\n" 2428 "%s MOS LQ=%s, MOS CQ=%s\n" 2429 "%s config : PLC=%s, JB=%s, JB rate=%s, Gmin=%d\n" 2430 "%s JB delay : cur=%d%s, max=%d%s, abs max=%d%s", 2431 indent, 2432 last_update, 2433 /* packets */ 2434 indent, 2435 xr_stat.rx.voip_mtc.loss_rate, xr_stat.rx.voip_mtc.loss_rate*100.0/256, 2436 xr_stat.rx.voip_mtc.discard_rate, xr_stat.rx.voip_mtc.discard_rate*100.0/256, 2437 /* burst */ 2438 indent, 2439 xr_stat.rx.voip_mtc.burst_den, xr_stat.rx.voip_mtc.burst_den*100.0/256, 2440 xr_stat.rx.voip_mtc.burst_dur, "ms", 2441 /* gap */ 2442 indent, 2443 xr_stat.rx.voip_mtc.gap_den, xr_stat.rx.voip_mtc.gap_den*100.0/256, 2444 xr_stat.rx.voip_mtc.gap_dur, "ms", 2445 /* delay */ 2446 indent, 2447 xr_stat.rx.voip_mtc.rnd_trip_delay, "ms", 2448 xr_stat.rx.voip_mtc.end_sys_delay, "ms", 2449 /* level */ 2450 indent, 2451 signal_lvl, "dB", 2452 noise_lvl, "dB", 2453 rerl, "", 2454 /* quality */ 2455 indent, 2456 r_factor, ext_r_factor, 2457 indent, 2458 mos_lq, mos_cq, 2459 /* config */ 2460 indent, 2461 plc, jba, jbr, xr_stat.rx.voip_mtc.gmin, 2462 /* JB delay */ 2463 indent, 2464 xr_stat.rx.voip_mtc.jb_nom, "ms", 2465 xr_stat.rx.voip_mtc.jb_max, "ms", 2466 xr_stat.rx.voip_mtc.jb_abs_max, "ms" 2467 ); 2468 VALIDATE_PRINT_BUF(); 2469 2470 PRINT_VOIP_MTC_VAL(signal_lvl, xr_stat.tx.voip_mtc.signal_lvl); 2471 PRINT_VOIP_MTC_VAL(noise_lvl, xr_stat.tx.voip_mtc.noise_lvl); 2472 PRINT_VOIP_MTC_VAL(rerl, xr_stat.tx.voip_mtc.rerl); 2473 PRINT_VOIP_MTC_VAL(r_factor, xr_stat.tx.voip_mtc.r_factor); 2474 PRINT_VOIP_MTC_VAL(ext_r_factor, xr_stat.tx.voip_mtc.ext_r_factor); 2475 PRINT_VOIP_MTC_VAL(mos_lq, xr_stat.tx.voip_mtc.mos_lq); 2476 PRINT_VOIP_MTC_VAL(mos_cq, xr_stat.tx.voip_mtc.mos_cq); 2477 2478 switch ((xr_stat.tx.voip_mtc.rx_config>>6) & 3) { 2479 case PJMEDIA_RTCP_XR_PLC_DIS: 2480 sprintf(plc, "DISABLED"); 2481 break; 2482 case PJMEDIA_RTCP_XR_PLC_ENH: 2483 sprintf(plc, "ENHANCED"); 2484 break; 2485 case PJMEDIA_RTCP_XR_PLC_STD: 2486 sprintf(plc, "STANDARD"); 2487 break; 2488 case PJMEDIA_RTCP_XR_PLC_UNK: 2489 default: 2490 sprintf(plc, "unknown"); 2491 break; 2492 } 2493 2494 switch ((xr_stat.tx.voip_mtc.rx_config>>4) & 3) { 2495 case PJMEDIA_RTCP_XR_JB_FIXED: 2496 sprintf(jba, "FIXED"); 2497 break; 2498 case PJMEDIA_RTCP_XR_JB_ADAPTIVE: 2499 sprintf(jba, "ADAPTIVE"); 2500 break; 2501 default: 2502 sprintf(jba, "unknown"); 2503 break; 2504 } 2505 2506 sprintf(jbr, "%d", xr_stat.tx.voip_mtc.rx_config & 0x0F); 2507 2508 if (xr_stat.tx.voip_mtc.update.sec == 0) 2509 strcpy(last_update, "never"); 2510 else { 2511 pj_gettimeofday(&now); 2512 PJ_TIME_VAL_SUB(now, xr_stat.tx.voip_mtc.update); 2513 sprintf(last_update, "%02ldh:%02ldm:%02ld.%03lds ago", 2514 now.sec / 3600, 2515 (now.sec % 3600) / 60, 2516 now.sec % 60, 2517 now.msec); 2518 } 2519 2520 len = pj_ansi_snprintf(p, end-p, 2521 "%s TX last update: %s\n" 2522 "%s packets : loss rate=%d (%.2f%%), discard rate=%d (%.2f%%)\n" 2523 "%s burst : density=%d (%.2f%%), duration=%d%s\n" 2524 "%s gap : density=%d (%.2f%%), duration=%d%s\n" 2525 "%s delay : round trip=%d%s, end system=%d%s\n" 2526 "%s level : signal=%s%s, noise=%s%s, RERL=%s%s\n" 2527 "%s quality : R factor=%s, ext R factor=%s\n" 2528 "%s MOS LQ=%s, MOS CQ=%s\n" 2529 "%s config : PLC=%s, JB=%s, JB rate=%s, Gmin=%d\n" 2530 "%s JB delay : cur=%d%s, max=%d%s, abs max=%d%s", 2531 indent, 2532 last_update, 2533 /* pakcets */ 2534 indent, 2535 xr_stat.tx.voip_mtc.loss_rate, xr_stat.tx.voip_mtc.loss_rate*100.0/256, 2536 xr_stat.tx.voip_mtc.discard_rate, xr_stat.tx.voip_mtc.discard_rate*100.0/256, 2537 /* burst */ 2538 indent, 2539 xr_stat.tx.voip_mtc.burst_den, xr_stat.tx.voip_mtc.burst_den*100.0/256, 2540 xr_stat.tx.voip_mtc.burst_dur, "ms", 2541 /* gap */ 2542 indent, 2543 xr_stat.tx.voip_mtc.gap_den, xr_stat.tx.voip_mtc.gap_den*100.0/256, 2544 xr_stat.tx.voip_mtc.gap_dur, "ms", 2545 /* delay */ 2546 indent, 2547 xr_stat.tx.voip_mtc.rnd_trip_delay, "ms", 2548 xr_stat.tx.voip_mtc.end_sys_delay, "ms", 2549 /* level */ 2550 indent, 2551 signal_lvl, "dB", 2552 noise_lvl, "dB", 2553 rerl, "", 2554 /* quality */ 2555 indent, 2556 r_factor, ext_r_factor, 2557 indent, 2558 mos_lq, mos_cq, 2559 /* config */ 2560 indent, 2561 plc, jba, jbr, xr_stat.tx.voip_mtc.gmin, 2562 /* JB delay */ 2563 indent, 2564 xr_stat.tx.voip_mtc.jb_nom, "ms", 2565 xr_stat.tx.voip_mtc.jb_max, "ms", 2566 xr_stat.tx.voip_mtc.jb_abs_max, "ms" 2567 ); 2568 VALIDATE_PRINT_BUF(); 2569 2570 2571 /* RTT delay (by receiver side) */ 2572 len = pj_ansi_snprintf(p, end-p, 2573 "%s RTT (from recv) min avg max last dev", 2574 indent); 2575 VALIDATE_PRINT_BUF(); 2576 len = pj_ansi_snprintf(p, end-p, 2577 "%s RTT msec : %7.3f %7.3f %7.3f %7.3f %7.3f", 2578 indent, 2579 xr_stat.rtt.min / 1000.0, 2580 xr_stat.rtt.mean / 1000.0, 2581 xr_stat.rtt.max / 1000.0, 2582 xr_stat.rtt.last / 1000.0, 2583 pj_math_stat_get_stddev(&xr_stat.rtt) / 1000.0 2584 ); 2585 VALIDATE_PRINT_BUF(); 2586 } while(0); 2587 #endif 2588 2187 2589 } 2188 2590 }
Note: See TracChangeset
for help on using the changeset viewer.