Commit ded4d064 authored by Simon Morlat's avatar Simon Morlat

add linphone_core_start_refered_call() to allow application to control how to...

add linphone_core_start_refered_call() to allow application to control how to execute an incoming call transfer
belle-sip upgrade required.
parent e79a8c4e
......@@ -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);
}
......
......@@ -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;
/**
* 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);
}
}
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){
......
......@@ -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);
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment