diff options
-rw-r--r-- | pjsip/include/pjsua-lib/pjsua.h | 25 | ||||
-rw-r--r-- | pjsip/include/pjsua2/call.hpp | 32 | ||||
-rw-r--r-- | pjsip/include/pjsua2/endpoint.hpp | 3 | ||||
-rw-r--r-- | pjsip/src/pjsua-lib/pjsua_call.c | 8 | ||||
-rw-r--r-- | pjsip/src/pjsua2/endpoint.cpp | 20 |
5 files changed, 87 insertions, 1 deletions
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h index 7ffd7062..c47d4c3c 100644 --- a/pjsip/include/pjsua-lib/pjsua.h +++ b/pjsip/include/pjsua-lib/pjsua.h @@ -910,6 +910,31 @@ typedef struct pjsua_callback pjsip_status_code *code, pjsua_call_setting *opt); + + /** + * Notify application when call has received INVITE with no SDP offer. + * Application can update the call setting (e.g: add audio/video), or + * enable/disable codecs, or update other media session settings from + * within the callback, however, as mandated by the standard (RFC3261 + * section 14.2), it must ensure that the update overlaps with the + * existing media session (in codecs, transports, or other parameters) + * that require support from the peer, this is to avoid the need for + * the peer to reject the offer. + * + * When this callback is not defined, the default behavior is to send + * SDP offer using current active media session (with all enabled codecs + * on each media type). + * + * @param call_id The call index. + * @param reserved Reserved param, currently not used. + * @param opt The current call setting, application can update + * this setting for generating the offer. + */ + void (*on_call_tx_offer)(pjsua_call_id call_id, + void *reserved, + pjsua_call_setting *opt); + + /** * Notify application when registration or unregistration has been * initiated. Note that this only notifies the initial registration diff --git a/pjsip/include/pjsua2/call.hpp b/pjsip/include/pjsua2/call.hpp index 917965e5..bd0b1ee1 100644 --- a/pjsip/include/pjsua2/call.hpp +++ b/pjsip/include/pjsua2/call.hpp @@ -851,6 +851,19 @@ struct OnCallRxOfferParam }; /** + * This structure contains parameters for Call::onCallTxOffer() callback. + */ +struct OnCallTxOfferParam +{ + /** + * The current call setting, application can update this setting for + * generating the offer. Note that application should maintain any + * active media to avoid the need for the peer to reject the offer. + */ + CallSetting opt; +}; + +/** * This structure contains parameters for Call::onCallRedirected() callback. */ struct OnCallRedirectedParam @@ -1603,6 +1616,25 @@ public: { PJ_UNUSED_ARG(prm); } /** + * Notify application when call has received INVITE with no SDP offer. + * Application can update the call setting (e.g: add audio/video), or + * enable/disable codecs, or update other media session settings from + * within the callback, however, as mandated by the standard (RFC3261 + * section 14.2), it must ensure that the update overlaps with the + * existing media session (in codecs, transports, or other parameters) + * that require support from the peer, this is to avoid the need for + * the peer to reject the offer. + * + * When this callback is not implemented, the default behavior is to send + * SDP offer using current active media session (with all enabled codecs + * on each media type). + * + * @param prm Callback parameter. + */ + virtual void onCallTxOffer(OnCallTxOfferParam &prm) + { PJ_UNUSED_ARG(prm); } + + /** * Notify application on incoming MESSAGE request. * * @param prm Callback parameter. diff --git a/pjsip/include/pjsua2/endpoint.hpp b/pjsip/include/pjsua2/endpoint.hpp index e4039874..3d650bd1 100644 --- a/pjsip/include/pjsua2/endpoint.hpp +++ b/pjsip/include/pjsua2/endpoint.hpp @@ -1358,6 +1358,9 @@ private: void *reserved, pjsip_status_code *code, pjsua_call_setting *opt); + static void on_call_tx_offer(pjsua_call_id call_id, + void *reserved, + pjsua_call_setting *opt); static pjsip_redirect_op on_call_redirected(pjsua_call_id call_id, const pjsip_uri *target, const pjsip_event *e); diff --git a/pjsip/src/pjsua-lib/pjsua_call.c b/pjsip/src/pjsua-lib/pjsua_call.c index 0c8e872a..c1bea3b0 100644 --- a/pjsip/src/pjsua-lib/pjsua_call.c +++ b/pjsip/src/pjsua-lib/pjsua_call.c @@ -4181,8 +4181,14 @@ static void pjsua_call_on_create_offer(pjsip_inv_session *inv, } #endif + if (pjsua_var.ua_cfg.cb.on_call_tx_offer) { + cleanup_call_setting_flag(&call->opt); + (*pjsua_var.ua_cfg.cb.on_call_tx_offer)(call->index, NULL, + &call->opt); + } + /* We may need to re-initialize media before creating SDP */ - if (call->med_prov_cnt == 0) { + if (call->med_prov_cnt == 0 || pjsua_var.ua_cfg.cb.on_call_tx_offer) { status = apply_call_setting(call, &call->opt, NULL); if (status != PJ_SUCCESS) goto on_return; diff --git a/pjsip/src/pjsua2/endpoint.cpp b/pjsip/src/pjsua2/endpoint.cpp index 96023af1..4fdc8dd6 100644 --- a/pjsip/src/pjsua2/endpoint.cpp +++ b/pjsip/src/pjsua2/endpoint.cpp @@ -1073,6 +1073,25 @@ void Endpoint::on_call_rx_offer(pjsua_call_id call_id, *opt = prm.opt.toPj(); } +void Endpoint::on_call_tx_offer(pjsua_call_id call_id, + void *reserved, + pjsua_call_setting *opt) +{ + PJ_UNUSED_ARG(reserved); + + Call *call = Call::lookup(call_id); + if (!call) { + return; + } + + OnCallTxOfferParam prm; + prm.opt.fromPj(*opt); + + call->onCallTxOffer(prm); + + *opt = prm.opt.toPj(); +} + pjsip_redirect_op Endpoint::on_call_redirected(pjsua_call_id call_id, const pjsip_uri *target, const pjsip_event *e) @@ -1272,6 +1291,7 @@ void Endpoint::libInit(const EpConfig &prmEpConfig) throw(Error) ua_cfg.cb.on_call_replace_request2 = &Endpoint::on_call_replace_request2; ua_cfg.cb.on_call_replaced = &Endpoint::on_call_replaced; ua_cfg.cb.on_call_rx_offer = &Endpoint::on_call_rx_offer; + ua_cfg.cb.on_call_tx_offer = &Endpoint::on_call_tx_offer; ua_cfg.cb.on_call_redirected = &Endpoint::on_call_redirected; ua_cfg.cb.on_call_media_transport_state = &Endpoint::on_call_media_transport_state; |