Changeset 5812


Ignore:
Timestamp:
06/24/18 21:58:18 (3 months ago)
Author:
nanang
Message:

Close #2123: Follow SDP answer changes in 18x & 2xx responses on non-forking scenario.

Location:
pjproject/trunk/pjsip
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsip-ua/sip_inv.h

    r5641 r5812  
    443443                                                         forked media?      */ 
    444444    pj_atomic_t         *ref_cnt;                   /**< Reference counter. */ 
     445    pj_bool_t            updated_sdp_answer;        /**< SDP answer just been 
     446                                                         updated?           */ 
    445447}; 
    446448 
  • pjproject/trunk/pjsip/include/pjsip/sip_config.h

    r5716 r5812  
    171171        pj_bool_t use_compact_form; 
    172172 
     173        /** 
     174         * Accept multiple SDP answers on non-reliable 18X responses and the 2XX 
     175         * response when they are all received from the same source (same To tag). 
     176         * 
     177         * See also: 
     178         * https://tools.ietf.org/html/rfc6337#section-3.1.1 
     179         * 
     180         * Default is PJSIP_ACCEPT_MULTIPLE_SDP_ANSWERS. 
     181         */ 
     182        pj_bool_t accept_multiple_sdp_answers; 
     183 
    173184    } endpt; 
    174185 
     
    417428 
    418429/** 
     430 * Accept multiple SDP answers on non-reliable 18X responses and the 2XX 
     431 * response when they are all received from the same source (same To tag). 
     432 * 
     433 * This option can also be controlled at run-time by the 
     434 * \a accept_multiple_sdp_answers setting in pjsip_cfg_t. 
     435 * 
     436 * Default is PJ_FALSE. 
     437 */ 
     438#ifndef PJSIP_ACCEPT_MULTIPLE_SDP_ANSWERS 
     439#   define PJSIP_ACCEPT_MULTIPLE_SDP_ANSWERS        PJ_TRUE 
     440#endif 
     441 
     442 
     443/** 
    419444 * Specify whether "alias" param should be added to the Via header 
    420445 * in any outgoing request with connection oriented transport. 
  • pjproject/trunk/pjsip/src/pjsip-ua/sip_inv.c

    r5714 r5812  
    163163    pj_str_t             done_tag;  /* To tag in RX response with answer    */ 
    164164    pj_bool_t            done_early;/* Negotiation was done for early med?  */ 
     165    pj_bool_t            done_early_rel;/* Early med was realiable?         */ 
    165166    pj_bool_t            has_sdp;   /* Message with SDP?                    */ 
    166167}; 
     
    20012002    /* Initialize info that we are following forked media */ 
    20022003    inv->following_fork = PJ_FALSE; 
     2004    inv->updated_sdp_answer = PJ_FALSE; 
    20032005 
    20042006    /* MUST NOT do multiple SDP offer/answer in a single transaction, 
    2005      * EXCEPT if: 
    2006      *  - this is an initial UAC INVITE transaction (i.e. not re-INVITE), and 
    2007      *  - the previous negotiation was done on an early media (18x) and 
    2008      *    this response is a final/2xx response, and 
    2009      *  - the 2xx response has different To tag than the 18x response 
    2010      *    (i.e. the request has forked). 
     2007     * EXCEPT previous nego was in 18x (early media) and any of the following 
     2008     * condition is met: 
     2009     *  - Non-forking scenario: 
     2010     *    - 'accept_multiple_sdp_answers' is set, and 
     2011     *    - previous early response was not reliable (rfc6337 section 3.1.1). 
     2012     *  - Forking scenario: 
     2013     *    - This response has different To tag than the previous response, and 
     2014     *    - This response is 18x/2xx (early or final). If this is 18x, 
     2015     *      only do multiple SDP nego if 'follow_early_media_fork' is set. 
    20112016     * 
    2012      * The exception above is to add a rudimentary support for early media 
    2013      * forking (sample case: custom ringback). See this ticket for more 
    2014      * info: http://trac.pjsip.org/repos/ticket/657 
     2017     * See also tickets #657, #1644, #1764, and #2123 for more info. 
    20152018     */ 
    20162019    if (tsx_inv_data->sdp_done) { 
     
    20212024        st_code = rdata->msg_info.msg->line.status.code; 
    20222025 
    2023         /* Allow final/early response after SDP has been negotiated in early 
    2024          * media, IF this response is a final/early response with different 
    2025          * tag. 
    2026          * See ticket #1644 and #1764 for forked early media case. 
    2027          */ 
    2028         if (tsx->role == PJSIP_ROLE_UAC && 
    2029             (st_code/100 == 2 || 
    2030              (st_code/10 == 18 /* st_code == 18x */ 
    2031               && pjsip_cfg()->endpt.follow_early_media_fork)) && 
    2032             tsx_inv_data->done_early && 
    2033             pj_stricmp(&tsx_inv_data->done_tag, &res_tag)) 
     2026        if (tsx->role == PJSIP_ROLE_UAC && tsx_inv_data->done_early && 
     2027               ( 
     2028                   /* Non-forking scenario */ 
     2029                   ( 
     2030                       !tsx_inv_data->done_early_rel && 
     2031                       (st_code/100 == 2 || st_code/10 == 18) && 
     2032                       pjsip_cfg()->endpt.accept_multiple_sdp_answers && 
     2033                       !pj_stricmp(&tsx_inv_data->done_tag, &res_tag) 
     2034                   ) 
     2035                   || 
     2036                   /* Forking scenario */ 
     2037                   ( 
     2038                       (st_code/100 == 2 || 
     2039                           (st_code/10 == 18 && 
     2040                               pjsip_cfg()->endpt.follow_early_media_fork)) && 
     2041                       pj_stricmp(&tsx_inv_data->done_tag, &res_tag) 
     2042                   ) 
     2043               ) 
     2044           ) 
    20342045        { 
    20352046            const pjmedia_sdp_session *reoffer_sdp = NULL; 
    20362047 
    2037             PJ_LOG(4,(inv->obj_name, "Received forked %s response " 
     2048            PJ_LOG(4,(inv->obj_name, "Received %s response " 
    20382049                      "after SDP negotiation has been done in early " 
    20392050                      "media. Renegotiating SDP..", 
     
    20552066            } 
    20562067 
    2057             inv->following_fork = PJ_TRUE; 
     2068            inv->following_fork = !!pj_stricmp(&tsx_inv_data->done_tag, 
     2069                                               &res_tag); 
     2070            inv->updated_sdp_answer = PJ_TRUE; 
    20582071 
    20592072        } else { 
     
    21642177        status_code = rdata->msg_info.msg->line.status.code; 
    21652178        tsx_inv_data->done_early = (status_code/100==1); 
     2179        tsx_inv_data->done_early_rel = tsx_inv_data->done_early && 
     2180                                       pjsip_100rel_is_reliable(rdata); 
    21662181        pj_strdup(tsx->pool, &tsx_inv_data->done_tag,  
    21672182                  &rdata->msg_info.to->tag); 
  • pjproject/trunk/pjsip/src/pjsip/sip_config.c

    r5701 r5812  
    3636       PJSIP_RESOLVE_HOSTNAME_TO_GET_INTERFACE, 
    3737       0, 
    38        PJSIP_ENCODE_SHORT_HNAME 
     38       PJSIP_ENCODE_SHORT_HNAME, 
     39       PJSIP_ACCEPT_MULTIPLE_SDP_ANSWERS 
    3940    }, 
    4041 
Note: See TracChangeset for help on using the changeset viewer.