Changeset 1533


Ignore:
Timestamp:
Oct 31, 2007 8:59:29 AM (16 years ago)
Author:
bennylp
Message:

More ticket #399: added PJSUA API to retrieve the remote NAT type

Location:
pjproject/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/build.symbian/pjsua_libU.def

    r1504 r1533  
    3333        pjsua_call_get_info                      @ 32 NONAME 
    3434        pjsua_call_get_max_count                 @ 33 NONAME 
    35         pjsua_call_get_user_data                 @ 34 NONAME 
    36         pjsua_call_hangup                        @ 35 NONAME 
    37         pjsua_call_hangup_all                    @ 36 NONAME 
    38         pjsua_call_has_media                     @ 37 NONAME 
    39         pjsua_call_is_active                     @ 38 NONAME 
    40         pjsua_call_make_call                     @ 39 NONAME 
    41         pjsua_call_reinvite                      @ 40 NONAME 
    42         pjsua_call_send_im                       @ 41 NONAME 
    43         pjsua_call_send_request                  @ 42 NONAME 
    44         pjsua_call_send_typing_ind               @ 43 NONAME 
    45         pjsua_call_set_hold                      @ 44 NONAME 
    46         pjsua_call_set_user_data                 @ 45 NONAME 
    47         pjsua_call_update                        @ 46 NONAME 
    48         pjsua_call_xfer                          @ 47 NONAME 
    49         pjsua_call_xfer_replaces                 @ 48 NONAME 
    50         pjsua_codec_get_param                    @ 49 NONAME 
    51         pjsua_codec_set_param                    @ 50 NONAME 
    52         pjsua_codec_set_priority                 @ 51 NONAME 
    53         pjsua_conf_add_port                      @ 52 NONAME 
    54         pjsua_conf_adjust_rx_level               @ 53 NONAME 
    55         pjsua_conf_adjust_tx_level               @ 54 NONAME 
    56         pjsua_conf_connect                       @ 55 NONAME 
    57         pjsua_conf_disconnect                    @ 56 NONAME 
    58         pjsua_conf_get_active_ports              @ 57 NONAME 
    59         pjsua_conf_get_max_ports                 @ 58 NONAME 
    60         pjsua_conf_get_port_info                 @ 59 NONAME 
    61         pjsua_conf_get_signal_level              @ 60 NONAME 
    62         pjsua_conf_remove_port                   @ 61 NONAME 
    63         pjsua_config_default                     @ 62 NONAME 
    64         pjsua_config_dup                         @ 63 NONAME 
    65         pjsua_create                             @ 64 NONAME 
    66         pjsua_destroy                            @ 65 NONAME 
    67         pjsua_detect_nat_type                    @ 66 NONAME 
    68         pjsua_dump                               @ 67 NONAME 
    69         pjsua_enum_accs                          @ 68 NONAME 
    70         pjsua_enum_buddies                       @ 69 NONAME 
    71         pjsua_enum_calls                         @ 70 NONAME 
    72         pjsua_enum_codecs                        @ 71 NONAME 
    73         pjsua_enum_conf_ports                    @ 72 NONAME 
    74         pjsua_enum_snd_devs                      @ 73 NONAME 
    75         pjsua_enum_transports                    @ 74 NONAME 
    76         pjsua_get_buddy_count                    @ 75 NONAME 
    77         pjsua_get_ec_tail                        @ 76 NONAME 
    78         pjsua_get_nat_type                       @ 77 NONAME 
    79         pjsua_get_pjmedia_endpt                  @ 78 NONAME 
    80         pjsua_get_pjsip_endpt                    @ 79 NONAME 
    81         pjsua_get_pool_factory                   @ 80 NONAME 
    82         pjsua_get_snd_dev                        @ 81 NONAME 
    83         pjsua_handle_events                      @ 82 NONAME 
    84         pjsua_im_send                            @ 83 NONAME 
    85         pjsua_im_typing                          @ 84 NONAME 
    86         pjsua_init                               @ 85 NONAME 
    87         pjsua_logging_config_default             @ 86 NONAME 
    88         pjsua_logging_config_dup                 @ 87 NONAME 
    89         pjsua_media_config_default               @ 88 NONAME 
    90         pjsua_media_transports_create            @ 89 NONAME 
    91         pjsua_msg_data_init                      @ 90 NONAME 
    92         pjsua_perror                             @ 91 NONAME 
    93         pjsua_player_create                      @ 92 NONAME 
    94         pjsua_player_destroy                     @ 93 NONAME 
    95         pjsua_player_get_conf_port               @ 94 NONAME 
    96         pjsua_player_get_port                    @ 95 NONAME 
    97         pjsua_player_set_pos                     @ 96 NONAME 
    98         pjsua_playlist_create                    @ 97 NONAME 
    99         pjsua_pool_create                        @ 98 NONAME 
    100         pjsua_pres_dump                          @ 99 NONAME 
    101         pjsua_reconfigure_logging                @ 100 NONAME 
    102         pjsua_recorder_create                    @ 101 NONAME 
    103         pjsua_recorder_destroy                   @ 102 NONAME 
    104         pjsua_recorder_get_conf_port             @ 103 NONAME 
    105         pjsua_recorder_get_port                  @ 104 NONAME 
    106         pjsua_set_ec                             @ 105 NONAME 
    107         pjsua_set_no_snd_dev                     @ 106 NONAME 
    108         pjsua_set_null_snd_dev                   @ 107 NONAME 
    109         pjsua_set_snd_dev                        @ 108 NONAME 
    110         pjsua_start                              @ 109 NONAME 
    111         pjsua_transport_close                    @ 110 NONAME 
    112         pjsua_transport_config_default           @ 111 NONAME 
    113         pjsua_transport_config_dup               @ 112 NONAME 
    114         pjsua_transport_create                   @ 113 NONAME 
    115         pjsua_transport_get_info                 @ 114 NONAME 
    116         pjsua_transport_register                 @ 115 NONAME 
    117         pjsua_transport_set_enable               @ 116 NONAME 
    118         pjsua_verify_sip_url                     @ 117 NONAME 
     35        pjsua_call_get_rem_nat_type              @ 34 NONAME 
     36        pjsua_call_get_user_data                 @ 35 NONAME 
     37        pjsua_call_hangup                        @ 36 NONAME 
     38        pjsua_call_hangup_all                    @ 37 NONAME 
     39        pjsua_call_has_media                     @ 38 NONAME 
     40        pjsua_call_is_active                     @ 39 NONAME 
     41        pjsua_call_make_call                     @ 40 NONAME 
     42        pjsua_call_reinvite                      @ 41 NONAME 
     43        pjsua_call_send_im                       @ 42 NONAME 
     44        pjsua_call_send_request                  @ 43 NONAME 
     45        pjsua_call_send_typing_ind               @ 44 NONAME 
     46        pjsua_call_set_hold                      @ 45 NONAME 
     47        pjsua_call_set_user_data                 @ 46 NONAME 
     48        pjsua_call_update                        @ 47 NONAME 
     49        pjsua_call_xfer                          @ 48 NONAME 
     50        pjsua_call_xfer_replaces                 @ 49 NONAME 
     51        pjsua_codec_get_param                    @ 50 NONAME 
     52        pjsua_codec_set_param                    @ 51 NONAME 
     53        pjsua_codec_set_priority                 @ 52 NONAME 
     54        pjsua_conf_add_port                      @ 53 NONAME 
     55        pjsua_conf_adjust_rx_level               @ 54 NONAME 
     56        pjsua_conf_adjust_tx_level               @ 55 NONAME 
     57        pjsua_conf_connect                       @ 56 NONAME 
     58        pjsua_conf_disconnect                    @ 57 NONAME 
     59        pjsua_conf_get_active_ports              @ 58 NONAME 
     60        pjsua_conf_get_max_ports                 @ 59 NONAME 
     61        pjsua_conf_get_port_info                 @ 60 NONAME 
     62        pjsua_conf_get_signal_level              @ 61 NONAME 
     63        pjsua_conf_remove_port                   @ 62 NONAME 
     64        pjsua_config_default                     @ 63 NONAME 
     65        pjsua_config_dup                         @ 64 NONAME 
     66        pjsua_create                             @ 65 NONAME 
     67        pjsua_destroy                            @ 66 NONAME 
     68        pjsua_detect_nat_type                    @ 67 NONAME 
     69        pjsua_dump                               @ 68 NONAME 
     70        pjsua_enum_accs                          @ 69 NONAME 
     71        pjsua_enum_buddies                       @ 70 NONAME 
     72        pjsua_enum_calls                         @ 71 NONAME 
     73        pjsua_enum_codecs                        @ 72 NONAME 
     74        pjsua_enum_conf_ports                    @ 73 NONAME 
     75        pjsua_enum_snd_devs                      @ 74 NONAME 
     76        pjsua_enum_transports                    @ 75 NONAME 
     77        pjsua_get_buddy_count                    @ 76 NONAME 
     78        pjsua_get_ec_tail                        @ 77 NONAME 
     79        pjsua_get_nat_type                       @ 78 NONAME 
     80        pjsua_get_pjmedia_endpt                  @ 79 NONAME 
     81        pjsua_get_pjsip_endpt                    @ 80 NONAME 
     82        pjsua_get_pool_factory                   @ 81 NONAME 
     83        pjsua_get_snd_dev                        @ 82 NONAME 
     84        pjsua_get_var                            @ 83 NONAME 
     85        pjsua_handle_events                      @ 84 NONAME 
     86        pjsua_im_send                            @ 85 NONAME 
     87        pjsua_im_typing                          @ 86 NONAME 
     88        pjsua_init                               @ 87 NONAME 
     89        pjsua_logging_config_default             @ 88 NONAME 
     90        pjsua_logging_config_dup                 @ 89 NONAME 
     91        pjsua_media_config_default               @ 90 NONAME 
     92        pjsua_media_transports_create            @ 91 NONAME 
     93        pjsua_msg_data_init                      @ 92 NONAME 
     94        pjsua_perror                             @ 93 NONAME 
     95        pjsua_player_create                      @ 94 NONAME 
     96        pjsua_player_destroy                     @ 95 NONAME 
     97        pjsua_player_get_conf_port               @ 96 NONAME 
     98        pjsua_player_get_port                    @ 97 NONAME 
     99        pjsua_player_set_pos                     @ 98 NONAME 
     100        pjsua_playlist_create                    @ 99 NONAME 
     101        pjsua_pool_create                        @ 100 NONAME 
     102        pjsua_pres_dump                          @ 101 NONAME 
     103        pjsua_reconfigure_logging                @ 102 NONAME 
     104        pjsua_recorder_create                    @ 103 NONAME 
     105        pjsua_recorder_destroy                   @ 104 NONAME 
     106        pjsua_recorder_get_conf_port             @ 105 NONAME 
     107        pjsua_recorder_get_port                  @ 106 NONAME 
     108        pjsua_set_ec                             @ 107 NONAME 
     109        pjsua_set_no_snd_dev                     @ 108 NONAME 
     110        pjsua_set_null_snd_dev                   @ 109 NONAME 
     111        pjsua_set_snd_dev                        @ 110 NONAME 
     112        pjsua_start                              @ 111 NONAME 
     113        pjsua_transport_close                    @ 112 NONAME 
     114        pjsua_transport_config_default           @ 113 NONAME 
     115        pjsua_transport_config_dup               @ 114 NONAME 
     116        pjsua_transport_create                   @ 115 NONAME 
     117        pjsua_transport_get_info                 @ 116 NONAME 
     118        pjsua_transport_register                 @ 117 NONAME 
     119        pjsua_transport_set_enable               @ 118 NONAME 
     120        pjsua_verify_sip_url                     @ 119 NONAME 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r1520 r1533  
    990990 
    991991    /** 
    992      * Include local endpoint's NAT type in the SDP to assist troubleshooting. 
    993      * The valid values are: 
    994      *  - 0: no information will be added in SDP. 
     992     * Support for adding and parsing NAT type in the SDP to assist  
     993     * troubleshooting. The valid values are: 
     994     *  - 0: no information will be added in SDP, and parsing is disabled. 
    995995     *  - 1: only the NAT type number is added. 
    996996     *  - 2: add both NAT type number and name. 
    997997     * 
    998      * Default: 2 
     998     * Default: 1 
    999999     */ 
    10001000    int             nat_type_in_sdp; 
     
    13661366 *                      value. Other return values indicate error and 
    13671367 *                      \a type will be set to PJ_STUN_NAT_TYPE_ERR_UNKNOWN. 
     1368 * 
     1369 * @see pjsua_call_get_rem_nat_type() 
    13681370 */ 
    13691371PJ_DECL(pj_status_t) pjsua_get_nat_type(pj_stun_nat_type *type); 
     
    27302732PJ_DECL(void*) pjsua_call_get_user_data(pjsua_call_id call_id); 
    27312733 
     2734 
     2735/** 
     2736 * Get the NAT type of remote's endpoint. This is a proprietary feature 
     2737 * of PJSUA-LIB which sends its NAT type in the SDP when \a nat_type_in_sdp 
     2738 * is set in #pjsua_config. 
     2739 * 
     2740 * This function can only be called after SDP has been received from remote, 
     2741 * which means for incoming call, this function can be called as soon as 
     2742 * call is received as long as incoming call contains SDP, and for outgoing 
     2743 * call, this function can be called only after SDP is received (normally in 
     2744 * 200/OK response to INVITE). As a general case, application should call  
     2745 * this function after or in \a on_call_media_state() callback. 
     2746 * 
     2747 * @param call_id       Call identification. 
     2748 * @param p_type        Pointer to store the NAT type. Application can then 
     2749 *                      retrieve the string description of the NAT type 
     2750 *                      by calling pj_stun_get_nat_name(). 
     2751 * 
     2752 * @return              PJ_SUCCESS on success. 
     2753 * 
     2754 * @see pjsua_get_nat_type(), nat_type_in_sdp 
     2755 */ 
     2756PJ_DECL(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id, 
     2757                                                 pj_stun_nat_type *p_type); 
    27322758 
    27332759/** 
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua_internal.h

    r1529 r1533  
    5353    pj_timer_entry       refresh_tm;/**< Timer to send re-INVITE.           */ 
    5454    pj_timer_entry       hangup_tm; /**< Timer to hangup call.              */ 
     55    pj_stun_nat_type     rem_nat_type; /**< NAT type of remote endpoint.    */ 
    5556 
    5657    char    last_text_buf_[128];    /**< Buffer for last_text.              */ 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_call.c

    r1477 r1533  
    9999    call->res_time.sec = 0; 
    100100    call->res_time.msec = 0; 
     101    call->rem_nat_type = PJ_STUN_NAT_TYPE_UNKNOWN; 
    101102} 
    102103 
     
    427428    PJSUA_UNLOCK(); 
    428429    return status; 
     430} 
     431 
     432 
     433/* Get the NAT type information in remote's SDP */ 
     434static void update_remote_nat_type(pjsua_call *call,  
     435                                   const pjmedia_sdp_session *sdp) 
     436{ 
     437    const pjmedia_sdp_attr *xnat; 
     438 
     439    xnat = pjmedia_sdp_attr_find2(sdp->attr_count, sdp->attr, "X-nat", NULL); 
     440    if (xnat) { 
     441        call->rem_nat_type = (pj_stun_nat_type) (xnat->value.ptr[0] - '0'); 
     442    } else { 
     443        call->rem_nat_type = PJ_STUN_NAT_TYPE_UNKNOWN; 
     444    } 
     445 
     446    PJ_LOG(5,(THIS_FILE, "Call %d: remote NAT type is %d (%s)", call->index, 
     447              call->rem_nat_type, pj_stun_get_nat_name(call->rem_nat_type))); 
    429448} 
    430449 
     
    659678    } 
    660679 
     680    /* Update NAT type of remote endpoint */ 
     681    if (pjsua_var.ua_cfg.nat_type_in_sdp) { 
     682        const pjmedia_sdp_session *remote_sdp; 
     683 
     684        if (pjmedia_sdp_neg_get_neg_remote(inv->neg, &remote_sdp)==PJ_SUCCESS) 
     685            update_remote_nat_type(call, remote_sdp); 
     686    } 
    661687 
    662688    /* Create and attach pjsua_var data to the dialog: */ 
     
    10201046                     NULL); 
    10211047    return pjsua_var.calls[call_id].user_data; 
     1048} 
     1049 
     1050 
     1051/* 
     1052 * Get remote's NAT type. 
     1053 */ 
     1054PJ_DEF(pj_status_t) pjsua_call_get_rem_nat_type(pjsua_call_id call_id, 
     1055                                                pj_stun_nat_type *p_type) 
     1056{ 
     1057    PJ_ASSERT_RETURN(call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls, 
     1058                     PJ_EINVAL); 
     1059    PJ_ASSERT_RETURN(p_type != NULL, PJ_EINVAL); 
     1060 
     1061    *p_type = pjsua_var.calls[call_id].rem_nat_type; 
     1062    return PJ_SUCCESS; 
    10221063} 
    10231064 
     
    22682309    } 
    22692310 
    2270  
    22712311    status = pjmedia_sdp_neg_get_active_remote(call->inv->neg, &remote_sdp); 
    22722312    if (status != PJ_SUCCESS) { 
     
    22792319    } 
    22802320 
     2321    /* Update remote's NAT type */ 
     2322    if (pjsua_var.ua_cfg.nat_type_in_sdp) { 
     2323        update_remote_nat_type(call, remote_sdp); 
     2324    } 
     2325 
     2326    /* Update media channel with the new SDP */ 
    22812327    status = pjsua_media_channel_update(call->index, local_sdp, remote_sdp); 
    22822328    if (status != PJ_SUCCESS) { 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r1529 r1533  
    8787    cfg->max_calls = 4; 
    8888    cfg->thread_cnt = 1; 
    89     cfg->nat_type_in_sdp = 2; 
     89    cfg->nat_type_in_sdp = 1; 
    9090} 
    9191 
Note: See TracChangeset for help on using the changeset viewer.