Changeset 2370 for pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
- Timestamp:
- Nov 27, 2008 12:06:46 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c
r2316 r2370 63 63 pjsua_transport_config udp_cfg; 64 64 pjsua_transport_config rtp_cfg; 65 pjsip_redirect_op redir_op; 65 66 66 67 unsigned acc_cnt; … … 279 280 puts (" --use-compact-form Minimize SIP message size"); 280 281 puts (" --no-force-lr Allow strict-route to be used (i.e. do not force lr)"); 282 puts (" --accept-redirect=N Specify how to handle call redirect (3xx) response."); 283 puts (" 0: reject, 1: follow automatically (default), 2: ask"); 281 284 282 285 puts (""); … … 304 307 pjsua_transport_config_default(&cfg->rtp_cfg); 305 308 cfg->rtp_cfg.port = 4000; 309 cfg->redir_op = PJSIP_REDIRECT_ACCEPT; 306 310 cfg->duration = NO_LIMIT; 307 311 cfg->wav_id = PJSUA_INVALID_ID; … … 473 477 OPT_NEXT_ACCOUNT, OPT_NEXT_CRED, OPT_MAX_CALLS, 474 478 OPT_DURATION, OPT_NO_TCP, OPT_NO_UDP, OPT_THREAD_CNT, 475 OPT_NOREFERSUB, 479 OPT_NOREFERSUB, OPT_ACCEPT_REDIRECT, 476 480 OPT_USE_TLS, OPT_TLS_CA_FILE, OPT_TLS_CERT_FILE, OPT_TLS_PRIV_FILE, 477 481 OPT_TLS_PASSWORD, OPT_TLS_VERIFY_SERVER, OPT_TLS_VERIFY_CLIENT, … … 516 520 { "auto-update-nat", 1, 0, OPT_AUTO_UPDATE_NAT}, 517 521 { "use-compact-form", 0, 0, OPT_USE_COMPACT_FORM}, 522 { "accept-redirect", 1, 0, OPT_ACCEPT_REDIRECT}, 518 523 { "no-force-lr",0, 0, OPT_NO_FORCE_LR}, 519 524 { "realm", 1, 0, OPT_REALM}, … … 841 846 break; 842 847 848 case OPT_ACCEPT_REDIRECT: 849 cfg->redir_op = my_atoi(pj_optarg); 850 if (cfg->redir_op<0 || cfg->redir_op>PJSIP_REDIRECT_STOP) { 851 PJ_LOG(1,(THIS_FILE, 852 "Error: accept-redirect value '%s' ", pj_optarg)); 853 return PJ_EINVAL; 854 } 855 break; 856 843 857 case OPT_NO_FORCE_LR: 844 858 cfg->cfg.force_lr = PJ_FALSE; … … 1786 1800 } 1787 1801 1802 /* accept-redirect */ 1803 if (config->redir_op != PJSIP_REDIRECT_ACCEPT) { 1804 pj_ansi_sprintf(line, "--accept-redirect %d\n", 1805 config->redir_op); 1806 pj_strcat2(&cfg, line); 1807 } 1808 1788 1809 /* Max calls. */ 1789 1810 pj_ansi_sprintf(line, "--max-calls %d\n", … … 1841 1862 * as the logger can accept. 1842 1863 */ 1843 static void log_call_dump(int call_id) { 1864 static void log_call_dump(int call_id) 1865 { 1844 1866 unsigned call_dump_len; 1845 1867 unsigned part_len; … … 2367 2389 { 2368 2390 PJ_LOG(3,(THIS_FILE, "Incoming DTMF on call %d: %c", call_id, dtmf)); 2391 } 2392 2393 /* 2394 * Redirection handler. 2395 */ 2396 static void call_on_redirected(pjsua_call_id call_id, const pjsip_uri *target, 2397 pjsip_redirect_op *cmd, const pjsip_event *e) 2398 { 2399 *cmd = app_config.redir_op; 2400 2401 PJ_UNUSED_ARG(e); 2402 2403 if (*cmd == PJSIP_REDIRECT_PENDING) { 2404 char uristr[PJSIP_MAX_URL_SIZE]; 2405 int len; 2406 2407 len = pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, target, uristr, 2408 sizeof(uristr)); 2409 if (len < 1) { 2410 pj_ansi_strcpy(uristr, "--URI too long--"); 2411 } 2412 2413 PJ_LOG(3,(THIS_FILE, "Call %d is being redirected to %.*s. " 2414 "Press 'Ra' to accept, 'Rr' to reject, or 'Rd' to " 2415 "disconnect.", 2416 call_id, len, uristr)); 2417 } 2369 2418 } 2370 2419 … … 3916 3965 3917 3966 3967 case 'R': 3968 if (!pjsua_call_is_active(current_call)) { 3969 PJ_LOG(1,(THIS_FILE, "Call %d has gone", current_call)); 3970 } else if (menuin[1] == 'a') { 3971 pjsua_call_process_redirect(current_call, 3972 PJSIP_REDIRECT_ACCEPT); 3973 } else if (menuin[1] == 'r') { 3974 pjsua_call_process_redirect(current_call, 3975 PJSIP_REDIRECT_REJECT); 3976 } else { 3977 pjsua_call_process_redirect(current_call, 3978 PJSIP_REDIRECT_STOP); 3979 } 3980 break; 3981 3918 3982 default: 3919 3983 if (menuin[0] != '\n' && menuin[0] != '\r') { … … 3963 4027 app_config.cfg.cb.on_call_tsx_state = &on_call_tsx_state; 3964 4028 app_config.cfg.cb.on_dtmf_digit = &call_on_dtmf_callback; 4029 app_config.cfg.cb.on_call_redirected = &call_on_redirected; 3965 4030 app_config.cfg.cb.on_reg_state = &on_reg_state; 3966 4031 app_config.cfg.cb.on_incoming_subscribe = &on_incoming_subscribe;
Note: See TracChangeset
for help on using the changeset viewer.