Ignore:
Timestamp:
Oct 16, 2007 1:34:14 AM (15 years ago)
Author:
bennylp
Message:

More ticket #399: added callback to report NAT detection result, and sends NAT type in SDP

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip-apps/src/pjsua/pjsua_app.c

    r1500 r1501  
    18861886 
    18871887/* 
     1888 * NAT type detection callback. 
     1889 */ 
     1890static void on_nat_detect(const pj_stun_nat_detect_result *res) 
     1891{ 
     1892    if (res->status != PJ_SUCCESS) { 
     1893        pjsua_perror(THIS_FILE, "NAT detection failed", res->status); 
     1894    } else { 
     1895        PJ_LOG(3, (THIS_FILE, "NAT detected as %s", res->nat_type_name)); 
     1896    } 
     1897} 
     1898 
     1899 
     1900/* 
    18881901 * Print buddy list. 
    18891902 */ 
     
    23132326 
    23142327 
    2315 /* Callback upon NAT detection completion */ 
    2316 static void nat_detect_cb(void *user_data, 
    2317                           const pj_stun_nat_detect_result *res) 
    2318 { 
    2319     PJ_UNUSED_ARG(user_data); 
    2320  
    2321     if (res->status != PJ_SUCCESS) { 
    2322         pjsua_perror(THIS_FILE, "NAT detection failed", res->status); 
    2323     } else { 
    2324         PJ_LOG(3, (THIS_FILE, "NAT detected as %s", res->nat_type_name)); 
    2325     } 
    2326 } 
    2327  
    2328  
    2329 /* 
    2330  * Detect NAT type. 
    2331  */ 
    2332 static void detect_nat_type(void) 
    2333 { 
    2334     pj_status_t status; 
    2335  
    2336     status = pjsua_detect_nat_type(NULL, &nat_detect_cb); 
    2337     if (status != PJ_SUCCESS) 
    2338         pjsua_perror(THIS_FILE, "Error", status); 
    2339 } 
    2340  
    2341  
    23422328/* 
    23432329 * Main "user interface" loop. 
     
    24542440 
    24552441        case 'n': 
    2456             detect_nat_type(); 
     2442            pjsua_detect_nat_type(); 
    24572443            break; 
    24582444 
     
    33083294    app_config.cfg.cb.on_call_transfer_status = &on_call_transfer_status; 
    33093295    app_config.cfg.cb.on_call_replaced = &on_call_replaced; 
     3296    app_config.cfg.cb.on_nat_detect = &on_nat_detect; 
    33103297 
    33113298    /* Initialize pjsua */ 
     
    35093496        return status; 
    35103497    } 
    3511  
    3512     if (app_config.cfg.stun_domain.slen || app_config.cfg.stun_host.slen) 
    3513         detect_nat_type(); 
    35143498 
    35153499    console_app_main(&uri_arg); 
Note: See TracChangeset for help on using the changeset viewer.