mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-20 20:48:07 +00:00
add new linphonec command to test call redirection
This commit is contained in:
parent
2c44eb885d
commit
2c2126aaa7
5 changed files with 1643 additions and 16 deletions
|
|
@ -60,6 +60,7 @@ static int lpc_cmd_chat(LinphoneCore *, char *);
|
|||
static int lpc_cmd_answer(LinphoneCore *, char *);
|
||||
static int lpc_cmd_autoanswer(LinphoneCore *, char *);
|
||||
static int lpc_cmd_terminate(LinphoneCore *, char *);
|
||||
static int lpc_cmd_redirect(LinphoneCore *, char *);
|
||||
static int lpc_cmd_call_logs(LinphoneCore *, char *);
|
||||
static int lpc_cmd_ipv6(LinphoneCore *, char *);
|
||||
static int lpc_cmd_transfer(LinphoneCore *, char *);
|
||||
|
|
@ -337,6 +338,9 @@ static LPC_COMMAND advanced_commands[] = {
|
|||
"'ringback <path of mono .wav file>'\t: Specifies a ringback tone to be played to remote end during incoming calls\n"
|
||||
"'ringback disable'\t: Disable playing of ringback tone to callers\n"
|
||||
},
|
||||
{ "redirect", lpc_cmd_redirect, "Redirect an incoming call",
|
||||
"'redirect <redirect-uri>'\t: Redirect all pending incoming calls to the <redirect-uri>\n"
|
||||
},
|
||||
{ NULL,NULL,NULL,NULL}
|
||||
};
|
||||
|
||||
|
|
@ -734,6 +738,30 @@ lpc_cmd_terminate(LinphoneCore *lc, char *args)
|
|||
|
||||
}
|
||||
|
||||
static int
|
||||
lpc_cmd_redirect(LinphoneCore *lc, char *args){
|
||||
const MSList *elem;
|
||||
int didit=0;
|
||||
if (!args) return 0;
|
||||
if ((elem=linphone_core_get_calls(lc))==NULL){
|
||||
linphonec_out("No active calls.\n");
|
||||
return 1;
|
||||
}
|
||||
while(elem!=NULL){
|
||||
LinphoneCall *call=(LinphoneCall*)elem->data;
|
||||
if (linphone_call_get_state(call)==LinphoneCallIncomingReceived){
|
||||
linphone_core_redirect_call(lc,call,args);
|
||||
didit=1;
|
||||
/*as the redirection closes the call, we need to re-check the call list that is invalidated.*/
|
||||
elem=linphone_core_get_calls(lc);
|
||||
}else elem=elem->next;
|
||||
}
|
||||
if (didit==0){
|
||||
linphonec_out("There is no pending incoming call to redirect.");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
lpc_cmd_answer(LinphoneCore *lc, char *args){
|
||||
if (!args)
|
||||
|
|
|
|||
|
|
@ -191,7 +191,6 @@ LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddr
|
|||
LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op){
|
||||
LinphoneCall *call=ms_new0(LinphoneCall,1);
|
||||
char *to_str;
|
||||
char *from_str;
|
||||
|
||||
call->dir=LinphoneCallIncoming;
|
||||
sal_op_set_user_pointer(op,call);
|
||||
|
|
@ -203,12 +202,10 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
|
|||
we get a chance to discover our nat'd address before answering.*/
|
||||
call->ping_op=sal_op_new(lc->sal);
|
||||
to_str=linphone_address_as_string(to);
|
||||
from_str=linphone_address_as_string(from);
|
||||
sal_op_set_route(call->ping_op,sal_op_get_network_origin(call->op));
|
||||
sal_op_set_user_pointer(call->ping_op,call);
|
||||
sal_ping(call->ping_op,to_str,from_str);
|
||||
sal_ping(call->ping_op,to_str,linphone_core_find_best_identity(lc,from,NULL));
|
||||
ms_free(to_str);
|
||||
ms_free(from_str);
|
||||
}
|
||||
|
||||
linphone_address_clean(from);
|
||||
|
|
|
|||
|
|
@ -1883,7 +1883,7 @@ const char *linphone_core_find_best_identity(LinphoneCore *lc, const LinphoneAdd
|
|||
if (cfg==NULL)
|
||||
linphone_core_get_default_proxy (lc,&cfg);
|
||||
if (cfg!=NULL){
|
||||
*route=linphone_proxy_config_get_route(cfg);
|
||||
if (route) *route=linphone_proxy_config_get_route(cfg);
|
||||
return linphone_proxy_config_get_identity (cfg);
|
||||
}
|
||||
return linphone_core_get_primary_contact (lc);
|
||||
|
|
@ -2337,6 +2337,33 @@ int linphone_core_abort_call(LinphoneCore *lc, LinphoneCall *call, const char *e
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void terminate_call(LinphoneCore *lc, LinphoneCall *call){
|
||||
if (call->state==LinphoneCallIncomingReceived){
|
||||
call->reason=LinphoneReasonDeclined;
|
||||
}
|
||||
/*stop ringing*/
|
||||
if (lc->ringstream!=NULL) {
|
||||
ring_stop(lc->ringstream);
|
||||
lc->ringstream=NULL;
|
||||
}
|
||||
linphone_call_stop_media_streams(call);
|
||||
if (lc->vtable.display_status!=NULL)
|
||||
lc->vtable.display_status(lc,_("Call ended") );
|
||||
}
|
||||
|
||||
int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char *redirect_uri){
|
||||
if (call->state==LinphoneCallIncomingReceived){
|
||||
sal_call_decline(call->op,SalReasonRedirect,redirect_uri);
|
||||
call->reason=LinphoneReasonDeclined;
|
||||
terminate_call(lc,call);
|
||||
linphone_call_set_state(call,LinphoneCallEnd,"Call terminated");
|
||||
}else{
|
||||
ms_error("Bad state for call redirection.");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Terminates a call.
|
||||
|
|
@ -2362,17 +2389,8 @@ int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *the_call)
|
|||
call = the_call;
|
||||
}
|
||||
sal_call_terminate(call->op);
|
||||
if (call->state==LinphoneCallIncomingReceived){
|
||||
call->reason=LinphoneReasonDeclined;
|
||||
}
|
||||
/*stop ringing*/
|
||||
if (lc->ringstream!=NULL) {
|
||||
ring_stop(lc->ringstream);
|
||||
lc->ringstream=NULL;
|
||||
}
|
||||
linphone_call_stop_media_streams(call);
|
||||
if (lc->vtable.display_status!=NULL)
|
||||
lc->vtable.display_status(lc,_("Call ended") );
|
||||
terminate_call(lc,call);
|
||||
|
||||
linphone_call_set_state(call,LinphoneCallEnd,"Call terminated");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -663,6 +663,8 @@ int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call);
|
|||
|
||||
int linphone_core_terminate_call(LinphoneCore *lc, LinphoneCall *call);
|
||||
|
||||
int linphone_core_redirect_call(LinphoneCore *lc, LinphoneCall *call, const char *redirect_uri);
|
||||
|
||||
int linphone_core_terminate_all_calls(LinphoneCore *lc);
|
||||
|
||||
int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call);
|
||||
|
|
|
|||
1582
po/zh_TW.po
Normal file
1582
po/zh_TW.po
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue