Ignore:
Timestamp:
Jun 25, 2018 2:58:18 AM (6 years ago)
Author:
nanang
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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); 
Note: See TracChangeset for help on using the changeset viewer.