Changeset 3213 for pjproject/trunk


Ignore:
Timestamp:
Jun 20, 2010 8:58:26 AM (14 years ago)
Author:
bennylp
Message:

Fixed #1086 (New option to update the Contact URI in a single REGISTER request): added contact_rewrite_method account config to control this. Default is to use the new mechanism, i.e. the single REGISTER method.

Location:
pjproject/trunk/pjsip
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsua-lib/pjsua.h

    r3212 r3213  
    19011901 
    19021902/** 
     1903 * This macro specifies the default value for \a contact_rewrite_method 
     1904 * field in pjsua_acc_config. I specifies  how Contact update will be 
     1905 * done with the registration, if \a allow_contact_rewrite is enabled in 
     1906 *  the account config. 
     1907 * 
     1908 * If set to 1, the Contact update will be done by sending unregistration 
     1909 * to the currently registered Contact, while simultaneously sending new 
     1910 * registration (with different Call-ID) for the updated Contact. 
     1911 * 
     1912 * If set to 2, the Contact update will be done in a single, current 
     1913 * registration session, by removing the current binding (by setting its 
     1914 * Contact's expires parameter to zero) and adding a new Contact binding, 
     1915 * all done in a single request. 
     1916 * 
     1917 * Value 1 is the legacy behavior. 
     1918 * 
     1919 * Default value: 2 
     1920 */ 
     1921#ifndef PJSUA_CONTACT_REWRITE_METHOD 
     1922#   define PJSUA_CONTACT_REWRITE_METHOD         2 
     1923#endif 
     1924 
     1925 
     1926/** 
    19031927 * This structure describes account configuration to be specified when 
    19041928 * adding a new account with #pjsua_acc_add(). Application MUST initialize 
     
    21072131     * configured.  
    21082132     * 
     2133     * See also contact_rewrite_method field. 
     2134     * 
    21092135     * Default: 1 (yes) 
    21102136     */ 
    21112137    pj_bool_t allow_contact_rewrite; 
     2138 
     2139    /** 
     2140     * Specify how Contact update will be done with the registration, if 
     2141     * \a allow_contact_rewrite is enabled. 
     2142     * 
     2143     * If set to 1, the Contact update will be done by sending unregistration 
     2144     * to the currently registered Contact, while simultaneously sending new 
     2145     * registration (with different Call-ID) for the updated Contact. 
     2146     * 
     2147     * If set to 2, the Contact update will be done in a single, current 
     2148     * registration session, by removing the current binding (by setting its 
     2149     * Contact's expires parameter to zero) and adding a new Contact binding, 
     2150     * all done in a single request. 
     2151     * 
     2152     * Value 1 is the legacy behavior. 
     2153     * 
     2154     * Default value: PJSUA_CONTACT_REWRITE_METHOD (2) 
     2155     */ 
     2156    int              contact_rewrite_method; 
    21122157 
    21132158    /** 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_acc.c

    r3190 r3213  
    10991099 
    11001100    PJ_LOG(3,(THIS_FILE, "IP address change detected for account %d " 
    1101                          "(%.*s:%d --> %.*s:%d). Updating registration..", 
     1101                         "(%.*s:%d --> %.*s:%d). Updating registration " 
     1102                         "(using method %d)", 
    11021103                         acc->index, 
    11031104                         (int)uri->host.slen, 
     
    11061107                         (int)via_addr->slen, 
    11071108                         via_addr->ptr, 
    1108                          rport)); 
    1109  
    1110     /* Unregister current contact */ 
    1111     pjsua_acc_set_registration(acc->index, PJ_FALSE); 
    1112     if (acc->regc != NULL) { 
    1113         pjsip_regc_destroy(acc->regc); 
    1114         acc->regc = NULL; 
    1115         acc->contact.slen = 0; 
    1116     } 
    1117  
    1118     /* Update account's Contact header */ 
     1109                         rport, 
     1110                         acc->cfg.contact_rewrite_method)); 
     1111 
     1112    pj_assert(acc->cfg.contact_rewrite_method == 1 || 
     1113              acc->cfg.contact_rewrite_method == 2); 
     1114 
     1115    if (acc->cfg.contact_rewrite_method == 1) { 
     1116        /* Unregister current contact */ 
     1117        pjsua_acc_set_registration(acc->index, PJ_FALSE); 
     1118        if (acc->regc != NULL) { 
     1119            pjsip_regc_destroy(acc->regc); 
     1120            acc->regc = NULL; 
     1121            acc->contact.slen = 0; 
     1122        } 
     1123    } 
     1124 
     1125    /* 
     1126     * Build new Contact header 
     1127     */ 
    11191128    { 
    11201129        char *tmp; 
     
    11521161        } 
    11531162        pj_strdup2_with_null(acc->pool, &acc->contact, tmp); 
    1154     } 
    1155  
    1156     /* Always update, by http://trac.pjsip.org/repos/ticket/864. */ 
    1157     pj_strdup_with_null(tp->pool, &tp->local_name.host, via_addr); 
    1158     tp->local_name.port = rport; 
     1163 
     1164        /* Always update, by http://trac.pjsip.org/repos/ticket/864. */ 
     1165        pj_strdup_with_null(tp->pool, &tp->local_name.host, via_addr); 
     1166        tp->local_name.port = rport; 
     1167 
     1168    } 
     1169 
     1170    if (acc->cfg.contact_rewrite_method == 2 && acc->regc != NULL) { 
     1171        pjsip_regc_update_contact(acc->regc, 1, &acc->contact); 
     1172    } 
    11591173 
    11601174    /* Perform new registration */ 
  • pjproject/trunk/pjsip/src/pjsua-lib/pjsua_core.c

    r3172 r3213  
    179179#endif 
    180180    cfg->reg_retry_interval = PJSUA_REG_RETRY_INTERVAL; 
     181    cfg->contact_rewrite_method = PJSUA_CONTACT_REWRITE_METHOD; 
    181182} 
    182183 
Note: See TracChangeset for help on using the changeset viewer.