Changeset 169 for pjproject/trunk/pjsip/src/pjsua/main.c
- Timestamp:
- Feb 9, 2006 2:01:40 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua/main.c
r167 r169 26 26 static pjsip_inv_session *inv_session; 27 27 28 static const char *inv_state_names[] = 29 { 30 "NULL ", 31 "CALLING ", 32 "INCOMING ", 33 "EARLY ", 34 "CONNECTING", 35 "CONFIRMED ", 36 "DISCONNCTD", 37 "TERMINATED", 38 }; 39 28 40 /* 29 41 * Notify UI when invite state has changed. … … 31 43 void pjsua_ui_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e) 32 44 { 33 const char *state_names[] =34 {35 "NULL",36 "CALLING",37 "INCOMING",38 "EARLY",39 "CONNECTING",40 "CONFIRMED",41 "DISCONNECTED",42 "TERMINATED",43 };44 45 45 PJ_UNUSED_ARG(e); 46 46 47 PJ_LOG(3,(THIS_FILE, "INVITE session state changed to %s", state_names[inv->state])); 47 PJ_LOG(3,(THIS_FILE, "INVITE session state changed to %s", 48 inv_state_names[inv->state])); 48 49 49 50 if (inv->state == PJSIP_INV_STATE_DISCONNECTED) { … … 58 59 } 59 60 61 62 static void print_invite_session(const char *title, 63 struct pjsua_inv_data *inv_data, 64 char *buf, pj_size_t size) 65 { 66 int len; 67 pjsip_inv_session *inv = inv_data->inv; 68 pjsip_dialog *dlg = inv->dlg; 69 char userinfo[128]; 70 71 /* Dump invite sesion info. */ 72 73 len = pjsip_hdr_print_on(dlg->remote.info, userinfo, sizeof(userinfo)); 74 if (len < 1) 75 pj_native_strcpy(userinfo, "<--uri too long-->"); 76 else 77 userinfo[len] = '\0'; 78 79 len = pj_snprintf(buf, size, "%s[%s] %s", 80 title, 81 inv_state_names[inv->state], 82 userinfo); 83 if (len < 1 || len >= (int)size) { 84 pj_native_strcpy(buf, "<--uri too long-->"); 85 len = 18; 86 } else 87 buf[len] = '\0'; 88 } 89 90 static void dump_media_session(pjmedia_session *session) 91 { 92 unsigned i; 93 pjmedia_session_info info; 94 95 pjmedia_session_get_info(session, &info); 96 97 for (i=0; i<info.stream_cnt; ++i) { 98 pjmedia_stream_stat strm_stat; 99 const char *rem_addr; 100 int rem_port; 101 const char *dir; 102 103 pjmedia_session_get_stream_stat(session, i, &strm_stat); 104 rem_addr = pj_inet_ntoa(info.stream_info[i].rem_addr.sin_addr); 105 rem_port = pj_ntohs(info.stream_info[i].rem_addr.sin_port); 106 107 if (info.stream_info[i].dir == PJMEDIA_DIR_ENCODING) 108 dir = "sendonly"; 109 else if (info.stream_info[i].dir == PJMEDIA_DIR_DECODING) 110 dir = "recvonly"; 111 else if (info.stream_info[i].dir == PJMEDIA_DIR_ENCODING_DECODING) 112 dir = "sendrecv"; 113 else 114 dir = "inactive"; 115 116 117 PJ_LOG(3,(THIS_FILE, 118 "%s[Media strm#%d] %.*s, %s, peer=%s:%d", 119 " ", 120 i, 121 info.stream_info[i].fmt.encoding_name.slen, 122 info.stream_info[i].fmt.encoding_name.ptr, 123 dir, 124 rem_addr, rem_port)); 125 PJ_LOG(3,(THIS_FILE, 126 "%s tx {pkt=%u, bytes=%u} rx {pkt=%u, bytes=%u}", 127 " ", 128 strm_stat.enc.pkt, strm_stat.enc.bytes, 129 strm_stat.dec.pkt, strm_stat.dec.bytes)); 130 131 } 132 } 133 134 /* 135 * Dump application states. 136 */ 137 static void pjsua_dump(void) 138 { 139 struct pjsua_inv_data *inv_data; 140 char buf[128]; 141 unsigned log_decor; 142 143 log_decor = pj_log_get_decor(); 144 pj_log_set_decor(PJ_LOG_HAS_NEWLINE); 145 146 pjsip_endpt_dump(pjsua.endpt, 1); 147 pjsip_ua_dump(); 148 149 /* Dump all invite sessions: */ 150 PJ_LOG(3,(THIS_FILE, "Dumping invite sessions:")); 151 152 if (pj_list_empty(&pjsua.inv_list)) { 153 154 PJ_LOG(3,(THIS_FILE, " - no sessions -")); 155 156 } else { 157 158 inv_data = pjsua.inv_list.next; 159 160 while (inv_data != &pjsua.inv_list) { 161 162 print_invite_session(" ", inv_data, buf, sizeof(buf)); 163 PJ_LOG(3,(THIS_FILE, "%s", buf)); 164 165 if (inv_data->session) 166 dump_media_session(inv_data->session); 167 168 inv_data = inv_data->next; 169 } 170 } 171 172 pj_log_set_decor(log_decor); 173 } 174 175 176 /* 177 * Show a bit of help. 178 */ 60 179 static void ui_help(void) 61 180 { … … 63 182 puts("Console keys:"); 64 183 puts(" m Make a call/another call"); 184 puts(" d Dump application states"); 65 185 puts(" a Answer incoming call"); 66 186 puts(" h Hangup current call"); … … 122 242 break; 123 243 244 245 case 'd': 246 pjsua_dump(); 247 break; 124 248 125 249 case 'a':
Note: See TracChangeset
for help on using the changeset viewer.