| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
static void print_call(int call_index) |
| 31 |
{ |
| 32 |
struct call *call = &app.call[call_index]; |
| 33 |
int len; |
| 34 |
pjsip_inv_session *inv = call->inv; |
| 35 |
pjsip_dialog *dlg = inv->dlg; |
| 36 |
struct media_stream *audio = &call->media[0]; |
| 37 |
char userinfo[PJSIP_MAX_URL_SIZE]; |
| 38 |
char duration[80], last_update[80]; |
| 39 |
char bps[16], ipbps[16], packets[16], bytes[16], ipbytes[16]; |
| 40 |
unsigned decor; |
| 41 |
pj_time_val now; |
| 42 |
|
| 43 |
|
| 44 |
decor = pj_log_get_decor(); |
| 45 |
pj_log_set_decor(PJ_LOG_HAS_NEWLINE); |
| 46 |
|
| 47 |
pj_gettimeofday(&now); |
| 48 |
|
| 49 |
if (app.report_filename) |
| 50 |
puts(app.report_filename); |
| 51 |
|
| 52 |
|
| 53 |
if (inv->state >= PJSIP_INV_STATE_CONFIRMED && call->connect_time.sec) { |
| 54 |
|
| 55 |
PJ_TIME_VAL_SUB(now, call->connect_time); |
| 56 |
|
| 57 |
pj_ansi_snprintf(duration, sizeof(duration), |
| 58 |
" [duration: %02ld:%02ld:%02ld.%03ld]", |
| 59 |
now.sec / 3600, |
| 60 |
(now.sec % 3600) / 60, |
| 61 |
(now.sec % 60), |
| 62 |
now.msec); |
| 63 |
|
| 64 |
} else { |
| 65 |
duration[0] = '\0'; |
| 66 |
} |
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
PJ_LOG(3, (THIS_FILE, |
| 72 |
"Call #%d: %s%s", |
| 73 |
call_index, pjsip_inv_state_name(inv->state), |
| 74 |
duration)); |
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); |
| 80 |
if (len < 0) |
| 81 |
pj_ansi_strxcpy(userinfo, "<--uri too long-->", sizeof(userinfo)); |
| 82 |
else |
| 83 |
userinfo[len] = '\0'; |
| 84 |
|
| 85 |
PJ_LOG(3, (THIS_FILE, " %s", userinfo)); |
| 86 |
|
| 87 |
|
| 88 |
if (call->inv == NULL || call->inv->state < PJSIP_INV_STATE_CONFIRMED || |
| 89 |
call->connect_time.sec == 0) |
| 90 |
{ |
| 91 |
pj_log_set_decor(decor); |
| 92 |
return; |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
{ |
| 98 |
char pdd[64], connectdelay[64]; |
| 99 |
pj_time_val t; |
| 100 |
|
| 101 |
if (call->response_time.sec) { |
| 102 |
t = call->response_time; |
| 103 |
PJ_TIME_VAL_SUB(t, call->start_time); |
| 104 |
pj_ansi_snprintf(pdd, sizeof(pdd), |
| 105 |
"got 1st response in %ld ms", |
| 106 |
PJ_TIME_VAL_MSEC(t)); |
| 107 |
} else { |
| 108 |
pdd[0] = '\0'; |
| 109 |
} |
| 110 |
|
| 111 |
if (call->connect_time.sec) { |
| 112 |
t = call->connect_time; |
| 113 |
PJ_TIME_VAL_SUB(t, call->start_time); |
| 114 |
pj_ansi_snprintf(connectdelay, sizeof(connectdelay), |
| 115 |
", connected after: %ld ms", |
| 116 |
PJ_TIME_VAL_MSEC(t)); |
| 117 |
} else { |
| 118 |
connectdelay[0] = '\0'; |
| 119 |
} |
| 120 |
|
| 121 |
PJ_LOG(3, (THIS_FILE, |
| 122 |
" Signaling quality: %s%s", pdd, connectdelay)); |
| 123 |
} |
| 124 |
|
| 125 |
|
| 126 |
PJ_LOG(3, (THIS_FILE, |
| 127 |
" Stream #0: audio %.*s@%dHz, %dms/frame, %sB/s (%sB/s +IP hdr)", |
| 128 |
(int)audio->si.fmt.encoding_name.slen, |
| 129 |
audio->si.fmt.encoding_name.ptr, |
| 130 |
audio->clock_rate, |
| 131 |
audio->samples_per_frame * 1000 / audio->clock_rate, |
| 132 |
good_number(bps, sizeof(bps), audio->bytes_per_frame * audio->clock_rate / audio->samples_per_frame), |
| 133 |
good_number(ipbps, sizeof(ipbps), (audio->bytes_per_frame+32) * audio->clock_rate / audio->samples_per_frame))); |
| 134 |
|
| 135 |
if (audio->rtcp.stat.rx.update_cnt == 0) |
| 136 |
pj_ansi_strxcpy(last_update, "never", sizeof(last_update)); |
| 137 |
else { |
| 138 |
pj_gettimeofday(&now); |
| 139 |
PJ_TIME_VAL_SUB(now, audio->rtcp.stat.rx.update); |
| 140 |
pj_ansi_snprintf(last_update, sizeof(last_update), |
| 141 |
"%02ldh:%02ldm:%02ld.%03lds ago", |
| 142 |
now.sec / 3600, |
| 143 |
(now.sec % 3600) / 60, |
| 144 |
now.sec % 60, |
| 145 |
now.msec); |
| 146 |
} |
| 147 |
|
| 148 |
PJ_LOG(3, (THIS_FILE, |
| 149 |
" RX stat last update: %s\n" |
| 150 |
" total %s packets %sB received (%sB +IP hdr)%s\n" |
| 151 |
" pkt loss=%d (%3.1f%%), dup=%d (%3.1f%%), reorder=%d (%3.1f%%)%s\n" |
| 152 |
" (msec) min avg max last\n" |
| 153 |
" loss period: %7.3f %7.3f %7.3f %7.3f%s\n" |
| 154 |
" jitter : %7.3f %7.3f %7.3f %7.3f%s", |
| 155 |
last_update, |
| 156 |
good_number(packets, sizeof(packets), audio->rtcp.stat.rx.pkt), |
| 157 |
good_number(bytes, sizeof(bytes), audio->rtcp.stat.rx.bytes), |
| 158 |
good_number(ipbytes, sizeof(ipbytes), audio->rtcp.stat.rx.bytes + audio->rtcp.stat.rx.pkt * 32), |
| 159 |
"", |
| 160 |
audio->rtcp.stat.rx.loss, |
| 161 |
audio->rtcp.stat.rx.loss * 100.0 / (audio->rtcp.stat.rx.pkt + audio->rtcp.stat.rx.loss), |
| 162 |
audio->rtcp.stat.rx.dup, |
| 163 |
audio->rtcp.stat.rx.dup * 100.0 / (audio->rtcp.stat.rx.pkt + audio->rtcp.stat.rx.loss), |
| 164 |
audio->rtcp.stat.rx.reorder, |
| 165 |
audio->rtcp.stat.rx.reorder * 100.0 / (audio->rtcp.stat.rx.pkt + audio->rtcp.stat.rx.loss), |
| 166 |
"", |
| 167 |
audio->rtcp.stat.rx.loss_period.min / 1000.0, |
| 168 |
audio->rtcp.stat.rx.loss_period.mean / 1000.0, |
| 169 |
audio->rtcp.stat.rx.loss_period.max / 1000.0, |
| 170 |
audio->rtcp.stat.rx.loss_period.last / 1000.0, |
| 171 |
"", |
| 172 |
audio->rtcp.stat.rx.jitter.min / 1000.0, |
| 173 |
audio->rtcp.stat.rx.jitter.mean / 1000.0, |
| 174 |
audio->rtcp.stat.rx.jitter.max / 1000.0, |
| 175 |
audio->rtcp.stat.rx.jitter.last / 1000.0, |
| 176 |
"" |
| 177 |
)); |
| 178 |
|
| 179 |
|
| 180 |
if (audio->rtcp.stat.tx.update_cnt == 0) |
| 181 |
pj_ansi_strxcpy(last_update, "never", sizeof(last_update)); |
| 182 |
else { |
| 183 |
pj_gettimeofday(&now); |
| 184 |
PJ_TIME_VAL_SUB(now, audio->rtcp.stat.tx.update); |
| 185 |
pj_ansi_snprintf(last_update, sizeof(last_update), |
| 186 |
"%02ldh:%02ldm:%02ld.%03lds ago", |
| 187 |
now.sec / 3600, |
| 188 |
(now.sec % 3600) / 60, |
| 189 |
now.sec % 60, |
| 190 |
now.msec); |
| 191 |
} |
| 192 |
|
| 193 |
PJ_LOG(3, (THIS_FILE, |
| 194 |
" TX stat last update: %s\n" |
| 195 |
" total %s packets %sB sent (%sB +IP hdr)%s\n" |
| 196 |
" pkt loss=%d (%3.1f%%), dup=%d (%3.1f%%), reorder=%d (%3.1f%%)%s\n" |
| 197 |
" (msec) min avg max last\n" |
| 198 |
" loss period: %7.3f %7.3f %7.3f %7.3f%s\n" |
| 199 |
" jitter : %7.3f %7.3f %7.3f %7.3f%s", |
| 200 |
last_update, |
| 201 |
good_number(packets, sizeof(packets), audio->rtcp.stat.tx.pkt), |
| 202 |
good_number(bytes, sizeof(bytes), audio->rtcp.stat.tx.bytes), |
| 203 |
good_number(ipbytes, sizeof(ipbytes), audio->rtcp.stat.tx.bytes + audio->rtcp.stat.tx.pkt * 32), |
| 204 |
"", |
| 205 |
audio->rtcp.stat.tx.loss, |
| 206 |
audio->rtcp.stat.tx.loss * 100.0 / (audio->rtcp.stat.tx.pkt), |
| 207 |
audio->rtcp.stat.tx.dup, |
| 208 |
audio->rtcp.stat.tx.dup * 100.0 / (audio->rtcp.stat.tx.pkt), |
| 209 |
audio->rtcp.stat.tx.reorder, |
| 210 |
audio->rtcp.stat.tx.reorder * 100.0 / (audio->rtcp.stat.tx.pkt), |
| 211 |
"", |
| 212 |
audio->rtcp.stat.tx.loss_period.min / 1000.0, |
| 213 |
audio->rtcp.stat.tx.loss_period.mean / 1000.0, |
| 214 |
audio->rtcp.stat.tx.loss_period.max / 1000.0, |
| 215 |
audio->rtcp.stat.tx.loss_period.last / 1000.0, |
| 216 |
"", |
| 217 |
audio->rtcp.stat.tx.jitter.min / 1000.0, |
| 218 |
audio->rtcp.stat.tx.jitter.mean / 1000.0, |
| 219 |
audio->rtcp.stat.tx.jitter.max / 1000.0, |
| 220 |
audio->rtcp.stat.tx.jitter.last / 1000.0, |
| 221 |
"" |
| 222 |
)); |
| 223 |
|
| 224 |
|
| 225 |
PJ_LOG(3, (THIS_FILE, |
| 226 |
" RTT delay : %7.3f %7.3f %7.3f %7.3f%s\n", |
| 227 |
audio->rtcp.stat.rtt.min / 1000.0, |
| 228 |
audio->rtcp.stat.rtt.mean / 1000.0, |
| 229 |
audio->rtcp.stat.rtt.max / 1000.0, |
| 230 |
audio->rtcp.stat.rtt.last / 1000.0, |
| 231 |
"" |
| 232 |
)); |
| 233 |
|
| 234 |
pj_log_set_decor(decor); |
| 235 |
} |
| 236 |
|