Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 1 | /* $Id$ */ |
| 2 | /* |
Benny Prijono | 32177c0 | 2008-06-20 22:44:47 +0000 | [diff] [blame] | 3 | * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org> |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | */ |
| 19 | |
| 20 | |
| 21 | /* |
| 22 | * DO NOT COMPILE THIS FILE ON ITS OWN! |
| 23 | * |
| 24 | * This file is included by siprtp.c to implement the reporting capability |
| 25 | * to a separate file, so that user can implement different reporting |
| 26 | * functionality (such as writing to XML file). |
| 27 | */ |
| 28 | |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 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[128]; |
| 38 | char duration[80], last_update[80]; |
| 39 | char bps[16], ipbps[16], packets[16], bytes[16], ipbytes[16]; |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 40 | unsigned decor; |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 41 | pj_time_val now; |
| 42 | |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 43 | |
| 44 | decor = pj_log_get_decor(); |
| 45 | pj_log_set_decor(PJ_LOG_HAS_NEWLINE); |
| 46 | |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 47 | pj_gettimeofday(&now); |
| 48 | |
Benny Prijono | fcb3672 | 2006-05-18 18:34:21 +0000 | [diff] [blame] | 49 | if (app.report_filename) |
| 50 | puts(app.report_filename); |
| 51 | |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 52 | /* Print duration */ |
Benny Prijono | 65382db | 2006-05-14 18:50:09 +0000 | [diff] [blame] | 53 | if (inv->state >= PJSIP_INV_STATE_CONFIRMED && call->connect_time.sec) { |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 54 | |
| 55 | PJ_TIME_VAL_SUB(now, call->connect_time); |
| 56 | |
| 57 | sprintf(duration, " [duration: %02ld:%02ld:%02ld.%03ld]", |
| 58 | now.sec / 3600, |
| 59 | (now.sec % 3600) / 60, |
| 60 | (now.sec % 60), |
| 61 | now.msec); |
| 62 | |
| 63 | } else { |
| 64 | duration[0] = '\0'; |
| 65 | } |
| 66 | |
| 67 | |
| 68 | |
| 69 | /* Call number and state */ |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 70 | PJ_LOG(3, (THIS_FILE, |
| 71 | "Call #%d: %s%s", |
| 72 | call_index, pjsip_inv_state_name(inv->state), |
| 73 | duration)); |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 74 | |
| 75 | |
| 76 | |
| 77 | /* Call identification */ |
| 78 | len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); |
| 79 | if (len < 1) |
| 80 | pj_ansi_strcpy(userinfo, "<--uri too long-->"); |
| 81 | else |
| 82 | userinfo[len] = '\0'; |
| 83 | |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 84 | PJ_LOG(3, (THIS_FILE, " %s", userinfo)); |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 85 | |
| 86 | |
| 87 | if (call->inv == NULL || call->inv->state < PJSIP_INV_STATE_CONFIRMED || |
| 88 | call->connect_time.sec == 0) |
| 89 | { |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 90 | pj_log_set_decor(decor); |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 91 | return; |
| 92 | } |
| 93 | |
| 94 | |
| 95 | /* Signaling quality */ |
| 96 | { |
| 97 | char pdd[64], connectdelay[64]; |
| 98 | pj_time_val t; |
| 99 | |
| 100 | if (call->response_time.sec) { |
| 101 | t = call->response_time; |
| 102 | PJ_TIME_VAL_SUB(t, call->start_time); |
| 103 | sprintf(pdd, "got 1st response in %ld ms", PJ_TIME_VAL_MSEC(t)); |
| 104 | } else { |
| 105 | pdd[0] = '\0'; |
| 106 | } |
| 107 | |
| 108 | if (call->connect_time.sec) { |
| 109 | t = call->connect_time; |
| 110 | PJ_TIME_VAL_SUB(t, call->start_time); |
| 111 | sprintf(connectdelay, ", connected after: %ld ms", |
| 112 | PJ_TIME_VAL_MSEC(t)); |
| 113 | } else { |
| 114 | connectdelay[0] = '\0'; |
| 115 | } |
| 116 | |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 117 | PJ_LOG(3, (THIS_FILE, |
| 118 | " Signaling quality: %s%s", pdd, connectdelay)); |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 122 | PJ_LOG(3, (THIS_FILE, |
| 123 | " Stream #0: audio %.*s@%dHz, %dms/frame, %sB/s (%sB/s +IP hdr)", |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 124 | (int)audio->si.fmt.encoding_name.slen, |
| 125 | audio->si.fmt.encoding_name.ptr, |
| 126 | audio->clock_rate, |
| 127 | audio->samples_per_frame * 1000 / audio->clock_rate, |
| 128 | good_number(bps, audio->bytes_per_frame * audio->clock_rate / audio->samples_per_frame), |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 129 | good_number(ipbps, (audio->bytes_per_frame+32) * audio->clock_rate / audio->samples_per_frame))); |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 130 | |
| 131 | if (audio->rtcp.stat.rx.update_cnt == 0) |
| 132 | strcpy(last_update, "never"); |
| 133 | else { |
| 134 | pj_gettimeofday(&now); |
| 135 | PJ_TIME_VAL_SUB(now, audio->rtcp.stat.rx.update); |
| 136 | sprintf(last_update, "%02ldh:%02ldm:%02ld.%03lds ago", |
| 137 | now.sec / 3600, |
| 138 | (now.sec % 3600) / 60, |
| 139 | now.sec % 60, |
| 140 | now.msec); |
| 141 | } |
| 142 | |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 143 | PJ_LOG(3, (THIS_FILE, |
| 144 | " RX stat last update: %s\n" |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 145 | " total %s packets %sB received (%sB +IP hdr)%s\n" |
| 146 | " pkt loss=%d (%3.1f%%), dup=%d (%3.1f%%), reorder=%d (%3.1f%%)%s\n" |
| 147 | " (msec) min avg max last\n" |
| 148 | " loss period: %7.3f %7.3f %7.3f %7.3f%s\n" |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 149 | " jitter : %7.3f %7.3f %7.3f %7.3f%s", |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 150 | last_update, |
| 151 | good_number(packets, audio->rtcp.stat.rx.pkt), |
| 152 | good_number(bytes, audio->rtcp.stat.rx.bytes), |
| 153 | good_number(ipbytes, audio->rtcp.stat.rx.bytes + audio->rtcp.stat.rx.pkt * 32), |
| 154 | "", |
| 155 | audio->rtcp.stat.rx.loss, |
Benny Prijono | f901651 | 2006-06-29 09:41:34 +0000 | [diff] [blame] | 156 | audio->rtcp.stat.rx.loss * 100.0 / (audio->rtcp.stat.rx.pkt + audio->rtcp.stat.rx.loss), |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 157 | audio->rtcp.stat.rx.dup, |
Benny Prijono | b12106f | 2006-06-29 14:45:17 +0000 | [diff] [blame] | 158 | audio->rtcp.stat.rx.dup * 100.0 / (audio->rtcp.stat.rx.pkt + audio->rtcp.stat.rx.loss), |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 159 | audio->rtcp.stat.rx.reorder, |
Benny Prijono | b12106f | 2006-06-29 14:45:17 +0000 | [diff] [blame] | 160 | audio->rtcp.stat.rx.reorder * 100.0 / (audio->rtcp.stat.rx.pkt + audio->rtcp.stat.rx.loss), |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 161 | "", |
| 162 | audio->rtcp.stat.rx.loss_period.min / 1000.0, |
Nanang Izzuddin | 2d4ee7d | 2008-05-17 14:54:18 +0000 | [diff] [blame] | 163 | audio->rtcp.stat.rx.loss_period.mean / 1000.0, |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 164 | audio->rtcp.stat.rx.loss_period.max / 1000.0, |
| 165 | audio->rtcp.stat.rx.loss_period.last / 1000.0, |
| 166 | "", |
| 167 | audio->rtcp.stat.rx.jitter.min / 1000.0, |
Nanang Izzuddin | 2d4ee7d | 2008-05-17 14:54:18 +0000 | [diff] [blame] | 168 | audio->rtcp.stat.rx.jitter.mean / 1000.0, |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 169 | audio->rtcp.stat.rx.jitter.max / 1000.0, |
| 170 | audio->rtcp.stat.rx.jitter.last / 1000.0, |
| 171 | "" |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 172 | )); |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 173 | |
| 174 | |
| 175 | if (audio->rtcp.stat.tx.update_cnt == 0) |
| 176 | strcpy(last_update, "never"); |
| 177 | else { |
| 178 | pj_gettimeofday(&now); |
| 179 | PJ_TIME_VAL_SUB(now, audio->rtcp.stat.tx.update); |
| 180 | sprintf(last_update, "%02ldh:%02ldm:%02ld.%03lds ago", |
| 181 | now.sec / 3600, |
| 182 | (now.sec % 3600) / 60, |
| 183 | now.sec % 60, |
| 184 | now.msec); |
| 185 | } |
| 186 | |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 187 | PJ_LOG(3, (THIS_FILE, |
| 188 | " TX stat last update: %s\n" |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 189 | " total %s packets %sB sent (%sB +IP hdr)%s\n" |
| 190 | " pkt loss=%d (%3.1f%%), dup=%d (%3.1f%%), reorder=%d (%3.1f%%)%s\n" |
| 191 | " (msec) min avg max last\n" |
| 192 | " loss period: %7.3f %7.3f %7.3f %7.3f%s\n" |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 193 | " jitter : %7.3f %7.3f %7.3f %7.3f%s", |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 194 | last_update, |
| 195 | good_number(packets, audio->rtcp.stat.tx.pkt), |
| 196 | good_number(bytes, audio->rtcp.stat.tx.bytes), |
| 197 | good_number(ipbytes, audio->rtcp.stat.tx.bytes + audio->rtcp.stat.tx.pkt * 32), |
| 198 | "", |
| 199 | audio->rtcp.stat.tx.loss, |
Benny Prijono | f901651 | 2006-06-29 09:41:34 +0000 | [diff] [blame] | 200 | audio->rtcp.stat.tx.loss * 100.0 / (audio->rtcp.stat.tx.pkt + audio->rtcp.stat.tx.loss), |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 201 | audio->rtcp.stat.tx.dup, |
Benny Prijono | b12106f | 2006-06-29 14:45:17 +0000 | [diff] [blame] | 202 | audio->rtcp.stat.tx.dup * 100.0 / (audio->rtcp.stat.tx.pkt + audio->rtcp.stat.tx.loss), |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 203 | audio->rtcp.stat.tx.reorder, |
Benny Prijono | b12106f | 2006-06-29 14:45:17 +0000 | [diff] [blame] | 204 | audio->rtcp.stat.tx.reorder * 100.0 / (audio->rtcp.stat.tx.pkt + audio->rtcp.stat.tx.loss), |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 205 | "", |
| 206 | audio->rtcp.stat.tx.loss_period.min / 1000.0, |
Nanang Izzuddin | 2d4ee7d | 2008-05-17 14:54:18 +0000 | [diff] [blame] | 207 | audio->rtcp.stat.tx.loss_period.mean / 1000.0, |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 208 | audio->rtcp.stat.tx.loss_period.max / 1000.0, |
| 209 | audio->rtcp.stat.tx.loss_period.last / 1000.0, |
| 210 | "", |
| 211 | audio->rtcp.stat.tx.jitter.min / 1000.0, |
Nanang Izzuddin | 2d4ee7d | 2008-05-17 14:54:18 +0000 | [diff] [blame] | 212 | audio->rtcp.stat.tx.jitter.mean / 1000.0, |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 213 | audio->rtcp.stat.tx.jitter.max / 1000.0, |
| 214 | audio->rtcp.stat.tx.jitter.last / 1000.0, |
| 215 | "" |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 216 | )); |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 217 | |
| 218 | |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 219 | PJ_LOG(3, (THIS_FILE, |
| 220 | " RTT delay : %7.3f %7.3f %7.3f %7.3f%s\n", |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 221 | audio->rtcp.stat.rtt.min / 1000.0, |
Nanang Izzuddin | 2d4ee7d | 2008-05-17 14:54:18 +0000 | [diff] [blame] | 222 | audio->rtcp.stat.rtt.mean / 1000.0, |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 223 | audio->rtcp.stat.rtt.max / 1000.0, |
| 224 | audio->rtcp.stat.rtt.last / 1000.0, |
| 225 | "" |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 226 | )); |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 227 | |
Benny Prijono | 258ece9 | 2006-07-22 12:53:04 +0000 | [diff] [blame] | 228 | pj_log_set_decor(decor); |
Benny Prijono | 16a6b0e | 2006-05-12 10:20:03 +0000 | [diff] [blame] | 229 | } |
| 230 | |