LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *from, LinphoneAddress *to, SalOp *op){ LinphoneCall *call=ms_new0(LinphoneCall,1); char *from_str; call->dir=LinphoneCallIncoming; sal_op_set_user_pointer(op,call); call->op=op; call->core=lc; if (lc->sip_conf.ping_with_options){ /*the following sends an option request back to the caller so that we get a chance to discover our nat'd address before answering.*/ call->ping_op=sal_op_new(lc->sal); 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,linphone_core_find_best_identity(lc,from,NULL),from_str); ms_free(from_str); } linphone_address_clean(from); linphone_core_get_local_ip(lc,linphone_address_get_domain(from),call->localip); linphone_call_init_common(call, from, to); call->params.has_video=linphone_core_video_enabled(lc); call->localdesc=create_local_media_description (lc,call); call->camera_active=call->params.has_video; if (linphone_core_get_firewall_policy(call->core)==LinphonePolicyUseStun) linphone_core_run_stun_tests(call->core,call); discover_mtu(lc,linphone_address_get_domain(from)); return call; }
static void linphone_stun_test_grab_ip(void) { LinphoneCoreManager* lc_stun = linphone_core_manager_new2( "stun_rc", FALSE); LinphoneCall dummy_call; int ping_time; int tmp=0; memset(&dummy_call, 0, sizeof(LinphoneCall)); dummy_call.main_audio_stream_index = 0; dummy_call.main_video_stream_index = 1; dummy_call.main_text_stream_index = 2; dummy_call.media_ports[dummy_call.main_audio_stream_index].rtp_port = 7078; dummy_call.media_ports[dummy_call.main_video_stream_index].rtp_port = 9078; dummy_call.media_ports[dummy_call.main_text_stream_index].rtp_port = 11078; linphone_core_set_stun_server(lc_stun->lc, stun_address); BC_ASSERT_STRING_EQUAL(stun_address, linphone_core_get_stun_server(lc_stun->lc)); wait_for(lc_stun->lc,lc_stun->lc,&tmp,1); ping_time = linphone_core_run_stun_tests(lc_stun->lc, &dummy_call); BC_ASSERT(ping_time != -1); ms_message("Round trip to STUN: %d ms", ping_time); BC_ASSERT( dummy_call.ac.addr[0] != '\0'); BC_ASSERT( dummy_call.ac.port != 0); #ifdef VIDEO_ENABLED BC_ASSERT( dummy_call.vc.addr[0] != '\0'); BC_ASSERT( dummy_call.vc.port != 0); #endif BC_ASSERT( dummy_call.tc.addr[0] != '\0'); BC_ASSERT( dummy_call.tc.port != 0); ms_message("STUN test result: local audio port maps to %s:%i", dummy_call.ac.addr, dummy_call.ac.port); #ifdef VIDEO_ENABLED ms_message("STUN test result: local video port maps to %s:%i", dummy_call.vc.addr, dummy_call.vc.port); #endif ms_message("STUN test result: local text port maps to %s:%i", dummy_call.tc.addr, dummy_call.tc.port); linphone_core_manager_destroy(lc_stun); }
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,linphone_address_get_domain(to),call->localip); linphone_call_init_common(call,from,to); call->params=*params; call->localdesc=create_local_media_description (lc,call); call->camera_active=params->has_video; if (linphone_core_get_firewall_policy(call->core)==LinphonePolicyUseStun) linphone_core_run_stun_tests(call->core,call); discover_mtu(lc,linphone_address_get_domain (to)); if (params->referer){ sal_call_set_referer (call->op,params->referer->op); } return call; }