diff options
author | Benny Prijono <bennylp@teluu.com> | 2007-10-12 12:14:27 +0000 |
---|---|---|
committer | Benny Prijono <bennylp@teluu.com> | 2007-10-12 12:14:27 +0000 |
commit | b0f62471ea72f5767d859f18e41d4326f57b85c5 (patch) | |
tree | 5be22dd454663b8e8daee9e322ed794ccf54e8c4 /pjsip-apps/src/pjsua/pjsua_app.c | |
parent | 9ca491d9d373e4f9114b429bcd61b72b1ff97048 (diff) |
Ticket #399: Initial implementation of tool to perform NAT type detection/classification
git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@1495 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'pjsip-apps/src/pjsua/pjsua_app.c')
-rw-r--r-- | pjsip-apps/src/pjsua/pjsua_app.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/pjsip-apps/src/pjsua/pjsua_app.c b/pjsip-apps/src/pjsua/pjsua_app.c index 919a1907..cc3cacac 100644 --- a/pjsip-apps/src/pjsua/pjsua_app.c +++ b/pjsip-apps/src/pjsua/pjsua_app.c @@ -19,7 +19,7 @@ #include <pjsua-lib/pjsua.h> -#define THIS_FILE "pjsua.c" +#define THIS_FILE "pjsua_app.c" #define NO_LIMIT (int)0x7FFFFFFF //#define STEREO_DEMO @@ -2307,6 +2307,33 @@ static void manage_codec_prio(void) } +/* Callback upon NAT detection completion */ +static void nat_detect_cb(void *user_data, + const pj_stun_nat_detect_result *res) +{ + PJ_UNUSED_ARG(user_data); + + if (res->status != PJ_SUCCESS) { + pjsua_perror(THIS_FILE, "NAT detection failed", res->status); + } else { + PJ_LOG(3, (THIS_FILE, "NAT detected as %s", res->nat_type_name)); + } +} + + +/* + * Detect NAT type. + */ +static void detect_nat_type(void) +{ + pj_status_t status; + + status = pjsua_detect_nat_type(NULL, &nat_detect_cb); + if (status != PJ_SUCCESS) + pjsua_perror(THIS_FILE, "Error", status); +} + + /* * Main "user interface" loop. */ @@ -2420,6 +2447,10 @@ void console_app_main(const pj_str_t *uri_to_call) } break; + case 'n': + detect_nat_type(); + break; + case 'i': /* Send instant messaeg */ @@ -3473,6 +3504,9 @@ pj_status_t app_main(void) return status; } + if (app_config.cfg.stun_domain.slen || app_config.cfg.stun_host.slen) + detect_nat_type(); + console_app_main(&uri_arg); return PJ_SUCCESS; |