From ded4d06469fe4d5498ad756768926c3b31b370d5 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 13 Dec 2013 17:33:46 +0100 Subject: [PATCH] add linphone_core_start_refered_call() to allow application to control how to execute an incoming call transfer belle-sip upgrade required. --- coreapi/callbacks.c | 13 +++--------- coreapi/linphonecore.c | 46 ++++++++++++++++++++++++++++------------ coreapi/linphonecore.h | 2 ++ coreapi/private.h | 2 +- tester/eventapi_tester.c | 6 ++++-- 5 files changed, 42 insertions(+), 27 deletions(-) diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index e1a32f56c..e73a60fa9 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -363,7 +363,7 @@ static void call_accepted(SalOp *op){ linphone_core_update_streams (lc,call,md); linphone_call_set_state(call,LinphoneCallPaused,"Call paused"); if (call->refer_pending) - linphone_core_start_refered_call(lc,call); + linphone_core_start_refered_call(lc,call,NULL); }else if (sal_media_description_has_dir(md,SalStreamRecvOnly)){ /*we are put on hold when the call is initially accepted */ if (lc->vtable.display_status){ @@ -536,7 +536,7 @@ static void call_terminated(SalOp *op, const char *from){ } ms_message("Current call terminated..."); if (call->refer_pending){ - linphone_core_start_refered_call(lc,call); + linphone_core_start_refered_call(lc,call,NULL); } //we stop the call only if we have this current call or if we are in call if (lc->ringstream!=NULL && ( (ms_list_size(lc->calls) == 1) || linphone_core_in_call(lc) )) { @@ -808,14 +808,7 @@ static void refer_received(Sal *sal, SalOp *op, const char *referto){ lc->vtable.display_status(lc,msg); ms_free(msg); } - if (call->state!=LinphoneCallPaused){ - ms_message("Automatically pausing current call to accept transfer."); - _linphone_core_pause_call(lc,call); - call->was_automatically_paused=TRUE; - /*then we will start the refered when the pause is accepted, in order to serialize transactions within the dialog. - * Indeed we need to avoid to send a NOTIFY to inform about of state of the refered call while the pause isn't completed. - **/ - }else linphone_core_start_refered_call(lc,call); + if (call->refer_pending) linphone_core_start_refered_call(lc,call,NULL); }else if (lc->vtable.refer_received){ lc->vtable.refer_received(lc,referto); } diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 511178c4c..c9cd717a2 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2364,21 +2364,39 @@ const char * linphone_core_get_route(LinphoneCore *lc){ return route; } -void linphone_core_start_refered_call(LinphoneCore *lc, LinphoneCall *call){ - if (call->refer_pending){ - LinphoneCallParams *cp=linphone_core_create_default_call_parameters(lc); - LinphoneCall *newcall; - cp->has_video = call->current_params.has_video; /*start the call to refer-target with video enabled if original call had video*/ - cp->referer=call; - ms_message("Starting new call to refered address %s",call->refer_to); - call->refer_pending=FALSE; - newcall=linphone_core_invite_with_params(lc,call->refer_to,cp); - linphone_call_params_destroy(cp); - if (newcall) { - call->transfer_target=linphone_call_ref(newcall); - linphone_core_notify_refer_state(lc,call,newcall); - } +/** + * Start a new call as a consequence of a transfer request received from a call. + * This function is for advanced usage: the execution of transfers is automatically managed by the LinphoneCore. However if an application + * wants to have control over the call parameters for the new call, it should call this function immediately during the LinphoneCallRefered notification. + * @see LinphoneCoreVTable::call_state_changed + * @param lc the LinphoneCore + * @param call a call that has just been notified about LinphoneCallRefered state event. + * @param params the call parameters to be applied to the new call. + * @return a LinphoneCall corresponding to the new call that is attempted to the transfer destination. +**/ +LinphoneCall * linphone_core_start_refered_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params){ + LinphoneCallParams *cp=params ? linphone_call_params_copy(params) : linphone_core_create_default_call_parameters(lc); + LinphoneCall *newcall; + + if (call->state!=LinphoneCallPaused){ + ms_message("Automatically pausing current call to accept transfer."); + _linphone_core_pause_call(lc,call); + call->was_automatically_paused=TRUE; } + + if (!params){ + cp->has_video = call->current_params.has_video; /*start the call to refer-target with video enabled if original call had video*/ + } + cp->referer=call; + ms_message("Starting new call to refered address %s",call->refer_to); + call->refer_pending=FALSE; + newcall=linphone_core_invite_with_params(lc,call->refer_to,cp); + linphone_call_params_destroy(cp); + if (newcall) { + call->transfer_target=linphone_call_ref(newcall); + linphone_core_notify_refer_state(lc,call,newcall); + } + return newcall; } void linphone_core_notify_refer_state(LinphoneCore *lc, LinphoneCall *referer, LinphoneCall *newcall){ diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index d083b07c8..ae7998db6 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -1286,6 +1286,8 @@ LINPHONE_PUBLIC int linphone_core_transfer_call(LinphoneCore *lc, LinphoneCall * LINPHONE_PUBLIC int linphone_core_transfer_call_to_another(LinphoneCore *lc, LinphoneCall *call, LinphoneCall *dest); +LINPHONE_PUBLIC LinphoneCall * linphone_core_start_refered_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params); + LINPHONE_PUBLIC bool_t linphone_core_inc_invite_pending(LinphoneCore*lc); LINPHONE_PUBLIC bool_t linphone_core_in_call(const LinphoneCore *lc); diff --git a/coreapi/private.h b/coreapi/private.h index b5799632a..76181edc2 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -367,7 +367,7 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call); int linphone_core_restart_invite(LinphoneCore *lc, LinphoneCall *call); int linphone_core_start_update_call(LinphoneCore *lc, LinphoneCall *call); int linphone_core_start_accept_call_update(LinphoneCore *lc, LinphoneCall *call); -void linphone_core_start_refered_call(LinphoneCore *lc, LinphoneCall *call); +void linphone_core_start_refered_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params); void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call); bool_t linphone_core_incompatible_security(LinphoneCore *lc, SalMediaDescription *md); extern SalCallbacks linphone_sal_callbacks; diff --git a/tester/eventapi_tester.c b/tester/eventapi_tester.c index acd1d3010..9dfaf2af7 100644 --- a/tester/eventapi_tester.c +++ b/tester/eventapi_tester.c @@ -137,9 +137,11 @@ static void subscribe_test_with_args(bool_t terminated_by_subscriber, RefreshTes int expires= refresh_type!=NoRefresh ? 4 : 600; MSList* lcs=ms_list_append(NULL,marie->lc); - lcs=ms_list_append(lcs,pauline->lc); + if (refresh_type==ManualRefresh){ + lp_config_set_int(marie->lc->config,"sip","refresh_generic_subscribe",0); + } content.type="application"; content.subtype="somexml"; @@ -212,7 +214,7 @@ static void publish_test_with_args(bool_t refresh){ content.data=(char*)subscribe_content; content.size=strlen(subscribe_content); - lp_config_set_int(marie->lc->config,"sip","refresh_generic_publish",!refresh); + lp_config_set_int(marie->lc->config,"sip","refresh_generic_publish",refresh); lev=linphone_core_publish(marie->lc,pauline->identity,"dodo",5,&content); linphone_event_ref(lev);