lpc_cmd_call(LinphoneCore *lc, char *args)
{
if ( ! args || ! *args )
{
return 0;
}
{
LinphoneCall *call;
LinphoneCallParams *cp=linphone_core_create_default_call_parameters (lc);
char *opt1,*opt2;
if ( linphone_core_in_call(lc) )
{
linphonec_out("Terminate or hold on the current call first.\n");
return 1;
}
opt1=strstr(args,"--audio-only");//audio-only 是要语音的参数
opt2=strstr(args,"--early-media");//video-only 是要视频的参数
if (opt1){
opt1[0]='\0';
linphone_call_params_enable_video (cp,FALSE);
}
if (opt2){
opt2[0]='\0';
linphone_call_params_enable_early_media_sending(cp,TRUE);
}
if ( NULL == (call=linphone_core_invite_with_params(lc, args,cp)) )
{
linphonec_out("Error from linphone_core_invite.\n");
}
else
{
snprintf(callee_name,sizeof(callee_name),"%s",args);
}
linphone_call_params_destroy(cp);
}
return 1;
}
LinphoneCall * linphone_core_invite_with_params(LinphoneCore *lc, const char *url, const LinphoneCallParams *p){
LinphoneAddress *addr=linphone_core_interpret_url(lc,url); 字符串到LinphoneAddress 转换(to的地址)
if (addr){
LinphoneCall *call;
call=linphone_core_invite_address_with_params(lc,addr,p);
linphone_address_destroy(addr);
return call;
}
return NULL;
}
LinphoneCall * linphone_call_new_outgoing(struct _LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, const LinphoneCallParams *params)
{
LinphoneCall *call=ms_new0(LinphoneCall,1);
call->dir=LinphoneCallOutgoing;
call->op=sal_op_new(lc->sal);
sal_op_set_user_pointer(call->op,call);
call->core=lc;
linphone_core_get_local_ip(lc,NULL,call->localip);
linphone_call_init_common(call,from,to);//在这里计数:refcnt=1,设置引用基数.
_linphone_call_params_copy(&call->params,params); //本地媒体类型描述
sal_op_set_custom_header(call->op,call->params.custom_headers);
call->params.custom_headers=NULL;
if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseIce) {
call->ice_session = ice_session_new();
ice_session_set_role(call->ice_session, IR_Controlling);
}
if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseStun) {
call->ping_time=linphone_core_run_stun_tests(call->core,call);
}
#ifdef BUILD_UPNP
if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseUpnp) {
if(!lc->rtp_conf.disable_upnp) {
call->upnp_session = linphone_upnp_session_new(call);
}
}
#endif //BUILD_UPNP
call->camera_active=params->has_video;
discover_mtu(lc,linphone_address_get_domain (to));
if (params->referer){
sal_call_set_referer(call->op,params->referer->op);
call->referer=linphone_call_ref(params->referer);
} 是否是呼叫转移
return call;
}
LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const LinphoneAddress *addr, const LinphoneCallParams *params)
{
const char *route=NULL;