From 2cd3d0a31158de5e4e7bc49188d2c7ffb59ca462 Mon Sep 17 00:00:00 2001 From: Sauw Ming Date: Wed, 16 Aug 2017 04:53:44 +0000 Subject: [PATCH] Fixed #2037: Add on_rx_offer2() callback for SIP invite Thanks to Andrey Kovalenko for the suggestion and the initial version of the patch. git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@5641 74dad513-b988-da41-8d7b-12977e46ad98 --- pjsip/include/pjsip-ua/sip_inv.h | 26 +++++++++++++++++++++++++- pjsip/src/pjsip-ua/sip_inv.c | 10 +++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/pjsip/include/pjsip-ua/sip_inv.h b/pjsip/include/pjsip-ua/sip_inv.h index 8e458bca3..1bb7b8adc 100644 --- a/pjsip/include/pjsip-ua/sip_inv.h +++ b/pjsip/include/pjsip-ua/sip_inv.h @@ -96,6 +96,17 @@ typedef enum pjsip_inv_state PJSIP_INV_STATE_DISCONNECTED, /**< Session is terminated. */ } pjsip_inv_state; +/** + * Structure to hold parameters when calling the callback + * #on_rx_offer2(). + */ +struct pjsip_inv_on_rx_offer_cb_param +{ + const pjmedia_sdp_session *offer; /** Remote offer. */ + const pjsip_rx_data *rdata; /** The received request. */ +}; + + /** * This structure contains callbacks to be registered by application to * receieve notifications from the framework about various events in @@ -154,11 +165,24 @@ typedef struct pjsip_inv_callback * this SDP answer will be negotiated with the offer, and the result * will be sent with the SIP message. * + * Note: if callback #on_rx_offer2() is implemented, this callback will + * not be called. + * * @param inv The invite session. * @param offer Remote offer. */ void (*on_rx_offer)(pjsip_inv_session *inv, - const pjmedia_sdp_session *offer); + const pjmedia_sdp_session *offer); + + /** + * This callback is called when the invite session has received + * new offer from peer. Variant of #on_rx_offer() callback. + * + * @param inv The invite session. + * @param param The callback parameters. + */ + void (*on_rx_offer2)(pjsip_inv_session *inv, + struct pjsip_inv_on_rx_offer_cb_param *param); /** * This callback is optional, and is called when the invite session has diff --git a/pjsip/src/pjsip-ua/sip_inv.c b/pjsip/src/pjsip-ua/sip_inv.c index 3cb16af7e..c9686a088 100644 --- a/pjsip/src/pjsip-ua/sip_inv.c +++ b/pjsip/src/pjsip-ua/sip_inv.c @@ -2103,10 +2103,14 @@ static pj_status_t inv_check_sdp_in_incoming_msg( pjsip_inv_session *inv, } /* Inform application about remote offer. */ - if (mod_inv.cb.on_rx_offer && inv->notify) { - - (*mod_inv.cb.on_rx_offer)(inv, sdp_info->sdp); + if (mod_inv.cb.on_rx_offer2 && inv->notify) { + struct pjsip_inv_on_rx_offer_cb_param param; + param.offer = sdp_info->sdp; + param.rdata = rdata; + (*mod_inv.cb.on_rx_offer2)(inv, ¶m); + } else if (mod_inv.cb.on_rx_offer && inv->notify) { + (*mod_inv.cb.on_rx_offer)(inv, sdp_info->sdp); } /* application must have supplied an answer at this point. */