Ticket #817: pjsip-2421-sip_inv-on_rx_reinvite.patch

File pjsip-2421-sip_inv-on_rx_reinvite.patch, 2.9 KB (added by bennylp, 15 years ago)

Patch to add the callback (thanks Ruud Klaver)

  • pjsip/include/pjsip-ua/sip_inv.h

     
    161161                        const pjmedia_sdp_session *offer); 
    162162 
    163163    /** 
     164     * This callback is optional, and is called when the invite session has 
     165     * received a re-INVITe from the peer. It overrides the on_rx_offer 
     166     * callback and works only for re-INVITEs. It allows more fine-grained 
     167     * control over the response to a re-INVITE, e.g. sending a provisional 
     168     * response first. Since UPDATE requests need to be answered immediately, 
     169     * any SDP offer received wihtin an UPDATE request still gets sent to 
     170     * on_rx_offer. Application may send a reply using the 
     171     * #pjsip_inv_initial_answer() and #pjsip_inv_answer() functions, as with 
     172     * the initial INVITE. 
     173     * 
     174     * @param inv       The invite session. 
     175     * @param offer     Remote offer. 
     176     * @param rdata The received re-INVITE request. 
     177     */ 
     178    void (*on_rx_reinvite)(pjsip_inv_session *inv, 
     179                const pjmedia_sdp_session *offer, pjsip_rx_data *rdata); 
     180 
     181    /** 
    164182     * This callback is optional, and it is used to ask the application 
    165183     * to create a fresh offer, when the invite session has received  
    166184     * re-INVITE without offer. This offer then will be sent in the 
     
    602620                                                pjsip_tx_data **p_tdata); 
    603621 
    604622/** 
    605  * Create a response message to the initial INVITE request. This function 
    606  * can only be called for the initial INVITE request, as subsequent 
    607  * re-INVITE request will be answered automatically. 
     623 * Create a response message to an INVITE request. 
    608624 * 
    609625 * @param inv           The UAS invite session. 
    610626 * @param st_code       The st_code contains the status code to be sent,  
  • pjsip/src/pjsip-ua/sip_inv.c

     
    15681568 
    15691569        /* Inform application about remote offer. */ 
    15701570 
    1571         if (mod_inv.cb.on_rx_offer && inv->notify) { 
     1571        if (mod_inv.cb.on_rx_reinvite && inv->notify && 
     1572                        msg->type == PJSIP_REQUEST_MSG && 
     1573            msg->line.req.method.id == PJSIP_INVITE_METHOD) { 
     1574                (*mod_inv.cb.on_rx_reinvite)(inv, rem_sdp, rdata); 
     1575        } 
     1576    else if (mod_inv.cb.on_rx_offer && inv->notify) { 
    15721577 
    15731578            (*mod_inv.cb.on_rx_offer)(inv, rem_sdp); 
    15741579 
     
    17641769 
    17651770/* 
    17661771 * Answer initial INVITE 
    1767  * Re-INVITE will be answered automatically, and will not use this function. 
    17681772 */  
    17691773PJ_DEF(pj_status_t) pjsip_inv_answer(   pjsip_inv_session *inv, 
    17701774                                        int st_code, 
     
    35963600                return; 
    35973601            } 
    35983602 
     3603        if (rdata->msg_info.msg->body != NULL && mod_inv.cb.on_rx_reinvite 
     3604                        && inv->notify) { 
     3605                return; 
     3606        } 
     3607 
     3608 
    35993609            /* Create 2xx ANSWER */ 
    36003610            status = pjsip_dlg_create_response(dlg, rdata, 200, NULL, &tdata); 
    36013611            if (status != PJ_SUCCESS)