int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; LinphoneCore *lc; LinphoneCall *call=NULL; signal(SIGINT,stop); printf("Version: %s\n",linphone_core_get_version()); #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif /* Fill the LinphoneCoreVTable with application callbacks. All are optional. Here we only use the call_state_changed callbacksestablished in order to get notifications about the progress of the call. */ vtable.call_state_changed=call_state_changed; //vtable.text_received=text_received; /* Instanciate a LinphoneCore object given the LinphoneCoreVTable */ //linphone_core_disable_logs(); lc=linphone_core_new(&vtable,NULL,NULL,NULL); linphone_core_set_sip_port(lc, 9999); const char** devs = linphone_core_get_sound_devices(lc); printf("DEVICE: %s\n",devs[0]); printf("DEVICE: %s\n",devs[1]); //linphone_core_set_playback_device(lc,devs[1]); //linphone_core_set_capture_device(lc,devs[1]); linphone_core_iterate(lc); //LinphoneChatRoom* chat_room = linphone_core_create_chat_room(lc,"sip:[email protected]:9998"); //linphone_chat_room_send_message(chat_room,"Welcome in room!\n"); /* main loop for receiving notifications and doing background linphonecore work: */ while(running){ linphone_core_iterate(lc); ms_usleep(50000); } if (call && linphone_call_get_state(call)!=LinphoneCallEnd){ /* terminate the call */ printf("Terminating the call...\n"); linphone_core_terminate_call(lc,call); /*at this stage we don't need the call object */ linphone_call_unref(call); } end: printf("Shutting down...\n"); linphone_core_destroy(lc); printf("Exited\n"); return 0; }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; LinphoneCore *lc; signal(SIGINT,stop); #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif /* Fill the LinphoneCoreVTable with application callbacks. All are optional. Here we only use the call_state_changed callbacks in order to get notifications about the progress of the call. */ vtable.call_state_changed=call_state_changed; /*to receive incoming call*/ vtable.message_received=message_received; /*to receive committed messages*/ vtable.is_composing_received=is_composing_received; /*to receive char in real time*/ /* Instanciate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,NULL); /* main loop for receiving notifications and doing background linphonecore work: */ while(running){ linphone_core_iterate(lc); ms_usleep(50000); } printf("Shutting down...\n"); linphone_core_destroy(lc); printf("Exited\n"); return 0; }
void SipClient::shutdown() { qDebug() << __PRETTY_FUNCTION__; if (m_authInfo) { linphone_auth_info_destroy(m_authInfo); // Get default proxy config linphone_core_get_default_proxy(lc, &m_proxyCfg); // start editing proxy configuration linphone_proxy_config_edit(m_proxyCfg); // De-activate registration for this proxy config linphone_proxy_config_enable_register(m_proxyCfg, FALSE); linphone_proxy_config_done(m_proxyCfg); while (linphone_proxy_config_get_state(m_proxyCfg) != LinphoneRegistrationCleared) { //...to make sure we receive call backs before shutting down linphone_core_iterate(lc); ms_usleep(50000); } m_authInfo = 0; } // delete m_loopTimer; if (lc) { linphone_core_destroy(lc); lc = 0; } }
static void sip_update_within_icoming_reinvite_with_no_sdp(void) { LinphoneCoreManager *mgr; char *identity_char; char *scen; FILE * sipp_out; /*currently we use direct connection because sipp do not properly set ACK request uri*/ mgr= linphone_core_manager_new2( "empty_rc", FALSE); mgr->identity= linphone_core_get_primary_contact_parsed(mgr->lc); linphone_address_set_username(mgr->identity,"marie"); identity_char=linphone_address_as_string(mgr->identity); linphone_core_set_primary_contact(mgr->lc,identity_char); linphone_core_iterate(mgr->lc); scen = bc_tester_res("sipp/sip_update_within_icoming_reinvite_with_no_sdp.xml"); sipp_out = sip_start(scen, linphone_address_get_username(mgr->identity),NULL, mgr->identity); if (sipp_out) { BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallIncomingReceived, 1)); linphone_core_accept_call(mgr->lc, linphone_core_get_current_call(mgr->lc)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 2)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); pclose(sipp_out); } linphone_core_manager_destroy(mgr); }
bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) { MSList* iterator; MSTimeSpec start; liblinphone_tester_clock_start(&start); while ((counter==NULL || *counter<value) && !liblinphone_tester_clock_elapsed(&start,timeout_ms)) { for (iterator=lcs;iterator!=NULL;iterator=iterator->next) { #ifdef HAVE_GTK gdk_threads_enter(); gtk_main_iteration_do(FALSE); gdk_threads_leave(); #endif linphone_core_iterate((LinphoneCore*)(iterator->data)); } #ifdef WIN32 { MSG msg; while (PeekMessage(&msg, NULL, 0, 0,1)){ TranslateMessage(&msg); DispatchMessage(&msg); } } #endif ms_usleep(20000); } if(counter && *counter<value) return FALSE; else return TRUE; }
static void wait_core(LinphoneCore *core) { int i; for (i = 0; i < 10; i++) { linphone_core_iterate(core); ms_usleep(100000); } }
static void wait_a_bit(LinphoneCore *lc, int seconds){ time_t orig=ms_time(NULL); while(ms_time(NULL)-orig<seconds){ /* we need to call iterate to receive notifications */ linphone_core_iterate(lc); ms_usleep (50000); } }
static void register_with_refresh_base_3(LinphoneCore* lc , bool_t refresh ,const char* domain ,const char* route ,bool_t late_auth_info ,LCSipTransports transport ,LinphoneRegistrationState expected_final_state) { int retry=0; char* addr; LinphoneProxyConfig* proxy_cfg; stats* counters; LinphoneAddress *from; const char* server_addr; LinphoneAuthInfo *info; BC_ASSERT_PTR_NOT_NULL(lc); if (!lc) return; counters = get_stats(lc); reset_counters(counters); linphone_core_set_sip_transports(lc,&transport); proxy_cfg = linphone_proxy_config_new(); from = create_linphone_address(domain); linphone_proxy_config_set_identity(proxy_cfg,addr=linphone_address_as_string(from)); ms_free(addr); server_addr = linphone_address_get_domain(from); linphone_proxy_config_enable_register(proxy_cfg,TRUE); linphone_proxy_config_set_expires(proxy_cfg,1); if (route) { linphone_proxy_config_set_route(proxy_cfg,route); linphone_proxy_config_set_server_addr(proxy_cfg,route); } else { linphone_proxy_config_set_server_addr(proxy_cfg,server_addr); } linphone_address_destroy(from); linphone_core_add_proxy_config(lc,proxy_cfg); linphone_core_set_default_proxy(lc,proxy_cfg); while (counters->number_of_LinphoneRegistrationOk<1+(refresh!=0) && retry++ <(1100 /*only wait 11 s if final state is progress*/+(expected_final_state==LinphoneRegistrationProgress?0:2000))) { linphone_core_iterate(lc); if (counters->number_of_auth_info_requested>0 && linphone_proxy_config_get_state(proxy_cfg) == LinphoneRegistrationFailed && late_auth_info) { if (!linphone_core_get_auth_info_list(lc)) { BC_ASSERT_EQUAL(linphone_proxy_config_get_error(proxy_cfg),LinphoneReasonUnauthorized, int, "%d"); info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/ linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/ } } if (linphone_proxy_config_get_error(proxy_cfg) == LinphoneReasonBadCredentials || (counters->number_of_auth_info_requested>2 &&linphone_proxy_config_get_error(proxy_cfg) == LinphoneReasonUnauthorized)) /*no need to continue if auth cannot be found*/ break; /*no need to continue*/ ms_usleep(10000); }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; LinphoneCore *lc; LinphoneCall *call=NULL; const char *dest=NULL; /* take the destination sip uri from the command line arguments */ if (argc>1){ dest=argv[1]; } signal(SIGINT,stop); #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif /* Fill the LinphoneCoreVTable with application callbacks. All are optional. Here we only use the call_state_changed callbacks in order to get notifications about the progress of the call. */ vtable.call_state_changed=call_state_changed; /* Instanciate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,NULL); if (dest){ /* Place an outgoing call */ call=linphone_core_invite(lc,dest); if (call==NULL){ printf("Could not place call to %s\n",dest); goto end; }else printf("Call to %s is in progress...",dest); linphone_call_ref(call); } /* main loop for receiving notifications and doing background linphonecore work: */ while(running){ linphone_core_iterate(lc); ms_usleep(50000); } if (call && linphone_call_get_state(call)!=LinphoneCallEnd){ /* terminate the call */ printf("Terminating the call...\n"); linphone_core_terminate_call(lc,call); /*at this stage we don't need the call object */ linphone_call_unref(call); } end: printf("Shutting down...\n"); linphone_core_destroy(lc); printf("Exited\n"); return 0; }
void QLinPhoneCore::update() { /* Main loop for receiving notifications and doing background * linphonecore work: */ if (m_lc) { linphone_core_iterate(m_lc); } }
static void unsubscribe_while_subscribing(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneFriend* friend = linphone_friend_new_with_address("sip:[email protected]"); /*any unexisting address*/ linphone_friend_edit(friend); linphone_friend_enable_subscribes(friend,TRUE); linphone_friend_done(friend); linphone_core_add_friend(marie->lc,friend); linphone_core_iterate(marie->lc); linphone_core_manager_destroy(marie); }
void ipphone_iterate(LinphoneCore *lc){ linphone_core_iterate(lc); if (auth_stack.nitems){ ipphone_auth_final(lc); } if (lp_config_needs_commit(lc->config)){ lp_config_sync(lc->config); printf("back-up\n"); } }
bool_t wait_for_stun_resolution(LinphoneCoreManager *m) { MSTimeSpec start; int timeout_ms = 10000; liblinphone_tester_clock_start(&start); while (m->lc->net_conf.stun_addrinfo == NULL && !liblinphone_tester_clock_elapsed(&start,timeout_ms)) { linphone_core_iterate(m->lc); ms_usleep(20000); } return m->lc->net_conf.stun_addrinfo != NULL; }
static void register_with_refresh_base_2(LinphoneCore* lc, bool_t refresh,const char* domain,const char* route,bool_t late_auth_info,LCSipTransports transport) { int retry=0; char* addr; LinphoneProxyConfig* proxy_cfg; stats* counters; LinphoneAddress *from; const char* server_addr; LinphoneAuthInfo *info; CU_ASSERT_PTR_NOT_NULL(lc); if (!lc) return; counters = get_stats(lc); reset_counters(counters); linphone_core_set_sip_transports(lc,&transport); proxy_cfg = linphone_proxy_config_new(); from = create_linphone_address(domain); linphone_proxy_config_set_identity(proxy_cfg,addr=linphone_address_as_string(from)); ms_free(addr); server_addr = linphone_address_get_domain(from); linphone_proxy_config_enable_register(proxy_cfg,TRUE); linphone_proxy_config_expires(proxy_cfg,1); if (route) { linphone_proxy_config_set_route(proxy_cfg,route); linphone_proxy_config_set_server_addr(proxy_cfg,route); } else { linphone_proxy_config_set_server_addr(proxy_cfg,server_addr); } linphone_address_destroy(from); linphone_core_add_proxy_config(lc,proxy_cfg); linphone_core_set_default_proxy(lc,proxy_cfg); while (counters->number_of_LinphoneRegistrationOk<1+(refresh!=0) && retry++ <310) { linphone_core_iterate(lc); if (counters->number_of_auth_info_requested>0 && late_auth_info) { info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain); /*create authentication structure from identity*/ linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/ } ms_usleep(100000); } CU_ASSERT_TRUE(linphone_proxy_config_is_registered(proxy_cfg)); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationNone,0); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress,1); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationOk,1+(refresh!=0)); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,late_auth_info?1:0); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,0); }
static bool_t video_call_with_params(LinphoneCoreManager* caller_mgr, LinphoneCoreManager* callee_mgr, const LinphoneCallParams *caller_params, const LinphoneCallParams *callee_params, bool_t automatically_accept) { int retry = 0; stats initial_caller = caller_mgr->stat; stats initial_callee = callee_mgr->stat; bool_t result = TRUE; bool_t did_received_call; CU_ASSERT_PTR_NOT_NULL(linphone_core_invite_address_with_params(caller_mgr->lc, callee_mgr->identity, caller_params)); did_received_call = wait_for(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallIncomingReceived, initial_callee.number_of_LinphoneCallIncomingReceived + 1); if (!did_received_call) return 0; CU_ASSERT_EQUAL(caller_mgr->stat.number_of_LinphoneCallOutgoingProgress, initial_caller.number_of_LinphoneCallOutgoingProgress + 1); while (caller_mgr->stat.number_of_LinphoneCallOutgoingRinging != (initial_caller.number_of_LinphoneCallOutgoingRinging + 1) && caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia != (initial_caller.number_of_LinphoneCallOutgoingEarlyMedia + 1) && retry++ < 20) { linphone_core_iterate(caller_mgr->lc); linphone_core_iterate(callee_mgr->lc); ms_usleep(100000); } CU_ASSERT_TRUE((caller_mgr->stat.number_of_LinphoneCallOutgoingRinging == initial_caller.number_of_LinphoneCallOutgoingRinging + 1) || (caller_mgr->stat.number_of_LinphoneCallOutgoingEarlyMedia == initial_caller.number_of_LinphoneCallOutgoingEarlyMedia + 1)); CU_ASSERT_PTR_NOT_NULL(linphone_core_get_current_call_remote_address(callee_mgr->lc)); if(!linphone_core_get_current_call(caller_mgr->lc) || !linphone_core_get_current_call(callee_mgr->lc) || !linphone_core_get_current_call_remote_address(callee_mgr->lc)) { return 0; } if (automatically_accept == TRUE) { linphone_core_accept_call_with_params(callee_mgr->lc, linphone_core_get_current_call(callee_mgr->lc), callee_params); CU_ASSERT_TRUE(wait_for(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallConnected, initial_callee.number_of_LinphoneCallConnected + 1)); CU_ASSERT_TRUE(wait_for(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallConnected, initial_callee.number_of_LinphoneCallConnected + 1)); result = wait_for(callee_mgr->lc, caller_mgr->lc, &caller_mgr->stat.number_of_LinphoneCallStreamsRunning, initial_caller.number_of_LinphoneCallStreamsRunning + 1) && wait_for(callee_mgr->lc, caller_mgr->lc, &callee_mgr->stat.number_of_LinphoneCallStreamsRunning, initial_callee.number_of_LinphoneCallStreamsRunning + 1); } return result; }
void SipClient::update() { /* Main loop for receiving notifications and doing background * linphonecore work: */ if (lc) { linphone_core_iterate(lc); } if (!m_msg.isEmpty()) { qDebug() << "Mess:" << m_msg; m_msg.clear(); } }
bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) { MSList* iterator; MSTimeSpec start; liblinphone_tester_clock_start(&start); while ((counter==NULL || *counter<value) && !liblinphone_tester_clock_elapsed(&start,timeout_ms)) { for (iterator=lcs;iterator!=NULL;iterator=iterator->next) { linphone_core_iterate((LinphoneCore*)(iterator->data)); } ms_usleep(100000); } if(counter && *counter<value) return FALSE; else return TRUE; }
/*static void dest_server_server_resolved(void *data, const char *name, struct addrinfo *ai_list) { *(struct addrinfo **)data =ai_list; }*/ static void sip_update_within_icoming_reinvite_with_no_sdp(void) { LinphoneCoreManager *mgr; /* LinphoneProxyConfig *proxy = linphone_core_get_default_proxy_config(mgr->lc); LinphoneAddress *dest = linphone_address_new(linphone_proxy_config_get_route(proxy) ?linphone_proxy_config_get_route(proxy):linphone_proxy_config_get_server_addr(proxy)); struct addrinfo *addrinfo = NULL; char ipstring [INET6_ADDRSTRLEN]; int err; int port = linphone_address_get_port(dest);*/ char *identity_char; char *scen; FILE * sipp_out; /*currently we use direct connection because sipp do not properly set ACK request uri*/ mgr= linphone_core_manager_new2( "empty_rc", FALSE); mgr->identity= linphone_core_get_primary_contact_parsed(mgr->lc); linphone_address_set_username(mgr->identity,"marie"); identity_char=linphone_address_as_string(mgr->identity); linphone_core_set_primary_contact(mgr->lc,identity_char); linphone_core_iterate(mgr->lc); /* sal_resolve_a( mgr->lc->sal ,linphone_address_get_domain(dest) ,linphone_address_get_port(dest) ,AF_INET ,(SalResolverCallback)dest_server_server_resolved ,&addrinfo); linphone_address_destroy(dest); dest=linphone_address_new(NULL); wait_for(mgr->lc, mgr->lc, (int*)&addrinfo, 1); err=getnameinfo((struct sockaddr *)addrinfo->ai_addr,addrinfo->ai_addrlen,ipstring,INET6_ADDRSTRLEN,NULL,0,NI_NUMERICHOST); linphone_address_set_domain(dest, ipstring); if (port > 0) linphone_address_set_port(dest, port); */ scen = bc_tester_res("sipp/sip_update_within_icoming_reinvite_with_no_sdp.xml"); sipp_out = sip_start(scen, linphone_address_get_username(mgr->identity), mgr->identity); if (sipp_out) { BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallIncomingReceived, 1)); linphone_core_accept_call(mgr->lc, linphone_core_get_current_call(mgr->lc)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 2)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); pclose(sipp_out); } linphone_core_manager_destroy(mgr); }
/* * * Called every second from main read loop. * * Will use the following globals: * * - LinphoneCore linphonec * - LPC_AUTH_STACK auth_stack; * */ static int linphonec_idle_call () { LinphoneCore *opm=linphonec; /* Uncomment the following to verify being called */ /* printf(".\n"); */ linphone_core_iterate(opm); if (answer_call){ fprintf (stdout, "-------auto answering to call-------\n" ); linphone_core_accept_call(opm,NULL); answer_call=FALSE; } /* auto call handling */ if (sip_addr_to_call != NULL ) { char buf[512]; snprintf (buf, sizeof(buf),"call %s", sip_addr_to_call); sip_addr_to_call=NULL; linphonec_parse_command_line(linphonec, buf); } if ( auth_stack.nitems ) { /* * Inhibit command completion * during password prompts */ #ifdef HAVE_READLINE rl_inhibit_completion=1; #endif linphonec_prompt_for_auth_final(opm); #ifdef HAVE_READLINE rl_inhibit_completion=0; #endif } #ifdef VIDEO_ENABLED lpc_apply_video_params(); #endif return 0; }
LinphoneCoreManager* setup(bool_t enable_logs) { LinphoneCoreManager *marie; int timeout_ms = 3000; linphone_core_enable_log_collection(enable_logs); // linphone_core_set_log_collection_size(10); marie = linphone_core_manager_new( "marie_rc"); // wait a few seconds to generate some traffic while (timeout_ms > 0){ linphone_core_iterate(marie->lc); ms_usleep(100000); //100 ms sleep timeout_ms -= 100; // Generate some logs ms_message("Time left: %d", timeout_ms); } return marie; }
static void call_with_multiple_video_mline_in_sdp(void) { LinphoneCoreManager *mgr; char *identity_char; char *scen; FILE * sipp_out; LinphoneCall *call = NULL; /*currently we use direct connection because sipp do not properly set ACK request uri*/ mgr= linphone_core_manager_new2( "empty_rc", FALSE); mgr->identity = linphone_core_get_primary_contact_parsed(mgr->lc); linphone_address_set_username(mgr->identity,"marie"); identity_char = linphone_address_as_string(mgr->identity); linphone_core_set_primary_contact(mgr->lc,identity_char); linphone_core_iterate(mgr->lc); scen = bc_tester_res("sipp/call_with_multiple_video_mline_in_sdp.xml"); sipp_out = sip_start(scen, linphone_address_get_username(mgr->identity), NULL, mgr->identity); if (sipp_out) { BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallIncomingReceived, 1)); call = linphone_core_get_current_call(mgr->lc); BC_ASSERT_PTR_NOT_NULL(call); if (call) { linphone_core_accept_call(mgr->lc, call); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallStreamsRunning, 1)); BC_ASSERT_EQUAL(call->main_audio_stream_index, 0, int, "%d"); BC_ASSERT_EQUAL(call->main_video_stream_index, 1, int, "%d"); BC_ASSERT_TRUE(call->main_text_stream_index > 3); BC_ASSERT_TRUE(linphone_call_log_video_enabled(linphone_call_get_call_log(call))); check_rtcp(call); } BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); pclose(sipp_out); } linphone_core_manager_destroy(mgr); }
static void enable_disable_camera_after_camera_switches() { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); const char *currentCamId = (char*)linphone_core_get_video_device(marie->lc); const char **cameras=linphone_core_get_video_devices(marie->lc); const char *newCamId=NULL; int i; video_call_base_2(marie,pauline,FALSE,LinphoneMediaEncryptionNone,TRUE,TRUE); for (i=0;cameras[i]!=NULL;++i){ if (strcmp(cameras[i],currentCamId)!=0){ newCamId=cameras[i]; break; } } if (newCamId){ LinphoneCall *call = linphone_core_get_current_call(marie->lc); ms_message("Switching from [%s] to [%s]", currentCamId, newCamId); linphone_core_set_video_device(marie->lc, newCamId); if(call != NULL) { linphone_core_update_call(marie->lc, call, NULL); } BC_ASSERT_STRING_EQUAL(newCamId,ms_web_cam_get_string_id(linphone_call_get_video_device(call))); linphone_call_enable_camera(call,FALSE); linphone_core_iterate(marie->lc); linphone_call_enable_camera(call,TRUE); BC_ASSERT_STRING_EQUAL(newCamId,ms_web_cam_get_string_id(linphone_call_get_video_device(call))); } linphone_core_terminate_all_calls(pauline->lc); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1)); BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1)); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
static void register_with_refresh_with_send_error() { int retry=0; LinphoneCoreManager* lcm = create_lcm_with_auth(1); stats* counters = &lcm->stat; LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain); /*create authentication structure from identity*/ char route[256]; sprintf(route,"sip:%s",test_route); linphone_core_add_auth_info(lcm->lc,info); /*add authentication info to LinphoneCore*/ register_with_refresh_base(lcm->lc,TRUE,auth_domain,route); /*simultate a network error*/ sal_set_send_error(lcm->lc->sal, -1); while (counters->number_of_LinphoneRegistrationProgress<2 && retry++ <20) { linphone_core_iterate(lcm->lc); ms_usleep(100000); } CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress,2); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,0); linphone_core_manager_destroy(lcm); }
static void call_invite_200ok_without_contact_header(void) { LinphoneCoreManager *mgr; char *identity_char; char *scen; FILE * sipp_out; LinphoneCall *call = NULL; /*currently we use direct connection because sipp do not properly set ACK request uri*/ mgr= linphone_core_manager_new2("empty_rc", FALSE); mgr->identity = linphone_core_get_primary_contact_parsed(mgr->lc); linphone_address_set_username(mgr->identity,"marie"); identity_char = linphone_address_as_string(mgr->identity); linphone_core_set_primary_contact(mgr->lc,identity_char); linphone_core_iterate(mgr->lc); scen = bc_tester_res("sipp/call_invite_200ok_without_contact_header.xml"); sipp_out = sip_start_recv(scen); if (sipp_out) { call = linphone_core_invite(mgr->lc, "[email protected]"); BC_ASSERT_PTR_NOT_NULL(call); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallOutgoingInit, 1)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallOutgoingProgress, 1)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallOutgoingRinging, 1)); /*assert that the call never gets connected nor terminated*/ BC_ASSERT_FALSE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallConnected, 1)); BC_ASSERT_EQUAL(mgr->stat.number_of_LinphoneCallEnd, 0, int, "%d"); BC_ASSERT_EQUAL(mgr->stat.number_of_LinphoneCallError, 0, int, "%d"); linphone_core_terminate_call(mgr->lc, call); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallEnd, 1)); BC_ASSERT_TRUE(wait_for(mgr->lc, mgr->lc, &mgr->stat.number_of_LinphoneCallReleased, 1)); pclose(sipp_out); } linphone_core_manager_destroy(mgr); }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; LinphoneCore *lc; LinphoneVideoPolicy policy; int i; LinphoneAddress *addr=NULL; LCSipTransports tp; char * tmp = NULL; LpConfig * lp_config = lp_config_new(NULL); int max_call_duration=3600; static const char *media_file = NULL; policy.automatically_accept=TRUE; signal(SIGINT,stop); #ifndef _WIN32 signal(SIGUSR1,stats); signal(SIGUSR2,dump_call_logs); #endif for(i = 1; i < argc; ++i) { if (strcmp(argv[i], "--verbose") == 0) { linphone_core_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL); } else if (strcmp(argv[i], "--max-call-duration") == 0){ max_call_duration = atoi(argv[++i]); } else if (strcmp(argv[i], "--listening-uri") == 0){ addr = linphone_address_new(argv[++i]); if (!addr) { printf("Error, bad sip uri"); helper(argv[0]); } /* switch(linphone_address_get_transport(addr)) { case LinphoneTransportUdp: case LinphoneTransportTcp: break; default: ms_error("Error, bad sip uri [%s] transport, should be udp | tcp",argv[i]); helper(); break; }*/ } else if (strcmp(argv[i], "--media-file") == 0){ i++; if (i<argc){ media_file = argv[i]; }else helper(argv[0]); } else { helper(argv[0]); } } if (!addr) { addr = linphone_address_new("sip:[email protected]:5060"); } lp_config_set_string(lp_config,"sip","bind_address",linphone_address_get_domain(addr)); lp_config_set_string(lp_config,"rtp","bind_address",linphone_address_get_domain(addr)); lp_config_set_int(lp_config,"misc","history_max_size",100000); vtable.call_state_changed=call_state_changed; lc=linphone_core_new_with_config(&vtable,lp_config,NULL); linphone_core_enable_video_capture(lc,TRUE); linphone_core_enable_video_display(lc,FALSE); linphone_core_set_video_policy(lc,&policy); linphone_core_enable_keep_alive(lc,FALSE); /*instead of using sound capture card, a file is played to the calling party*/ linphone_core_set_use_files(lc,TRUE); linphone_core_enable_echo_cancellation(lc, FALSE); /*no need for local echo cancellation when playing files*/ if (!media_file){ linphone_core_set_play_file(lc,PACKAGE_DATA_DIR "/sounds/linphone/hello16000.wav"); linphone_core_set_preferred_framerate(lc,5); }else{ PayloadType *pt = linphone_core_find_payload_type(lc, "opus", 48000, -1); /*if opus is present, give it a bitrate for good quality with music, and stereo enabled*/ if (pt){ linphone_core_set_payload_type_bitrate(lc, pt, 150); payload_type_set_send_fmtp(pt, "stereo=1"); payload_type_set_recv_fmtp(pt, "stereo=1"); } linphone_core_set_play_file(lc, media_file); linphone_core_set_preferred_video_size_by_name(lc, "720p"); } { MSWebCamDesc *desc = ms_mire_webcam_desc_get(); if (desc){ ms_web_cam_manager_add_cam(ms_factory_get_web_cam_manager(linphone_core_get_ms_factory(lc)),ms_web_cam_new(desc)); linphone_core_set_video_device(lc,"Mire: Mire (synthetic moving picture)"); } } memset(&tp,0,sizeof(LCSipTransports)); tp.udp_port = linphone_address_get_port(addr); tp.tcp_port = linphone_address_get_port(addr); linphone_core_set_sip_transports(lc,&tp); linphone_core_set_audio_port_range(lc,1024,65000); linphone_core_set_video_port_range(lc,1024,65000); linphone_core_set_primary_contact(lc,tmp=linphone_address_as_string(addr)); ms_free(tmp); /* main loop for receiving notifications and doing background linphonecore work: */ while(running){ const bctbx_list_t * iterator; linphone_core_iterate(lc); ms_usleep(50000); if (print_stats) { ms_message("*********************************"); ms_message("*Current number of calls [%10u] *", (unsigned int)bctbx_list_size(linphone_core_get_calls(lc))); ms_message("*Number of calls until now [%10u] *", (unsigned int)bctbx_list_size(linphone_core_get_call_logs(lc))); ms_message("*********************************"); print_stats=FALSE; } if (dump_stats) { ms_message("*********************************"); for (iterator=linphone_core_get_call_logs(lc);iterator!=NULL;iterator=iterator->next) { LinphoneCallLog *call_log=(LinphoneCallLog *)iterator->data; char * tmp_str = linphone_call_log_to_str(call_log); ms_message("\n%s",tmp_str); ms_free(tmp_str); } dump_stats=FALSE; ms_message("*********************************"); } for (iterator=linphone_core_get_calls(lc);iterator!=NULL;iterator=iterator->next) { LinphoneCall *call=(LinphoneCall *)iterator->data; if (linphone_call_get_duration(call) > max_call_duration) { ms_message("Terminating call [%p] after [%i] s",call,linphone_call_get_duration(call)); linphone_core_terminate_call(lc,call); break; } } } ms_message("Shutting down...\n"); linphone_core_destroy(lc); ms_message("Exited\n"); return 0; }
void QLinphoneCore::iterate() { linphone_core_iterate(lc); }
// Implementation of the iterate method. void PhpLinphoneCore::iterate() { this->lock(); linphone_core_iterate(this->_core); this->unlock(); ms_usleep(50000); }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; LinphoneCore *lc; LinphoneCall *call=NULL; LinphoneChatRoom *chat_room; LinphoneChatMessage *chat_message=NULL; const char *dest=NULL; LCSipTransports tp; tp.udp_port=LC_SIP_TRANSPORT_RANDOM; tp.tcp_port=LC_SIP_TRANSPORT_RANDOM; tp.tls_port=LC_SIP_TRANSPORT_RANDOM; /* take the destination sip uri from the command line arguments */ if (argc>1){ dest=argv[1]; } signal(SIGINT,stop); #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif /* Instanciate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,NULL); linphone_core_set_sip_transports(lc,&tp); /*to avoid port colliding with receiver*/ if (dest){ /* Place an outgoing call with rtt enabled */ LinphoneCallParams *cp = linphone_core_create_call_params(lc, NULL); linphone_call_params_enable_realtime_text(cp,TRUE); /*enable real time text*/ call=linphone_core_invite_with_params(lc,dest,cp); linphone_call_params_destroy(cp); if (call==NULL){ printf("Could not place call to %s\n",dest); goto end; }else printf("Call to %s is in progress...",dest); linphone_call_ref(call); } /*wait for call to be established*/ while (running && (linphone_call_get_state(call) == LinphoneCallOutgoingProgress || linphone_call_get_state(call) == LinphoneCallOutgoingInit)) { linphone_core_iterate(lc); ms_usleep(50000); } /*check if call is established*/ switch (linphone_call_get_state(call)) { case LinphoneCallError: case LinphoneCallReleased: case LinphoneCallEnd: printf("Could not place call to %s\n",dest); goto end; break; default: break; /*continue*/ } chat_room=linphone_call_get_chat_room(call); /*create a chat room associated to this call*/ /* main loop for sending message and doing background linphonecore work: */ while(running){ char character; /*to disable terminal buffering*/ if (system ("/bin/stty raw") == -1){ ms_error("/bin/stty error"); } character = getchar(); if (system("/bin/stty cooked") == -1){ ms_error("/bin/stty error"); } if (character==0x03) {/*CTRL C*/ running=0; break; } if (character != EOF) { /* user has typed something*/ if (chat_message == NULL) { /*create a new message*/ chat_message = linphone_chat_room_create_message(chat_room,""); /*create an empty message*/ } if (character == '\r') { /*new line, committing message*/ linphone_chat_room_send_chat_message(chat_room,chat_message); chat_message = NULL; /*reset message*/ } else { linphone_chat_message_put_char(chat_message,character); /*send char in realtime*/ } } linphone_core_iterate(lc); ms_usleep(50000); } if (call && linphone_call_get_state(call)!=LinphoneCallEnd){ /* terminate the call */ printf("Terminating the call...\n"); linphone_core_terminate_call(lc,call); /*at this stage we don't need the call object */ linphone_call_unref(call); } end: printf("Shutting down...\n"); linphone_core_destroy(lc); printf("Exited\n"); return 0; }
bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, LinphoneIceState state) { LinphoneCall *c1,*c2; bool_t audio_success=FALSE; bool_t video_success=FALSE; bool_t text_success=FALSE; bool_t video_enabled, realtime_text_enabled; MSTimeSpec ts; c1=linphone_core_get_current_call(caller->lc); c2=linphone_core_get_current_call(callee->lc); BC_ASSERT_PTR_NOT_NULL(c1); BC_ASSERT_PTR_NOT_NULL(c2); if (!c1 || !c2) return FALSE; linphone_call_ref(c1); linphone_call_ref(c2); BC_ASSERT_EQUAL(linphone_call_params_video_enabled(linphone_call_get_current_params(c1)),linphone_call_params_video_enabled(linphone_call_get_current_params(c2)), int, "%d"); BC_ASSERT_EQUAL(linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c1)),linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c2)), int, "%d"); video_enabled=linphone_call_params_video_enabled(linphone_call_get_current_params(c1)); realtime_text_enabled=linphone_call_params_realtime_text_enabled(linphone_call_get_current_params(c1)); liblinphone_tester_clock_start(&ts); do{ if ((c1 != NULL) && (c2 != NULL)) { if (linphone_call_get_audio_stats(c1)->ice_state==state && linphone_call_get_audio_stats(c2)->ice_state==state ){ audio_success=TRUE; check_ice_from_rtp(c1,c2,LinphoneStreamTypeAudio); check_ice_from_rtp(c2,c1,LinphoneStreamTypeAudio); break; } linphone_core_iterate(caller->lc); linphone_core_iterate(callee->lc); } ms_usleep(20000); }while(!liblinphone_tester_clock_elapsed(&ts,10000)); if (video_enabled){ liblinphone_tester_clock_start(&ts); do{ if ((c1 != NULL) && (c2 != NULL)) { if (linphone_call_get_video_stats(c1)->ice_state==state && linphone_call_get_video_stats(c2)->ice_state==state ){ video_success=TRUE; check_ice_from_rtp(c1,c2,LinphoneStreamTypeVideo); check_ice_from_rtp(c2,c1,LinphoneStreamTypeVideo); break; } linphone_core_iterate(caller->lc); linphone_core_iterate(callee->lc); } ms_usleep(20000); }while(!liblinphone_tester_clock_elapsed(&ts,10000)); } if (realtime_text_enabled){ liblinphone_tester_clock_start(&ts); do{ if ((c1 != NULL) && (c2 != NULL)) { if (linphone_call_get_text_stats(c1)->ice_state==state && linphone_call_get_text_stats(c2)->ice_state==state ){ text_success=TRUE; check_ice_from_rtp(c1,c2,LinphoneStreamTypeText); check_ice_from_rtp(c2,c1,LinphoneStreamTypeText); break; } linphone_core_iterate(caller->lc); linphone_core_iterate(callee->lc); } ms_usleep(20000); }while(!liblinphone_tester_clock_elapsed(&ts,10000)); } /*make sure encryption mode are preserved*/ if (c1) { const LinphoneCallParams* call_param = linphone_call_get_current_params(c1); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(caller->lc), int, "%d"); } if (c2) { const LinphoneCallParams* call_param = linphone_call_get_current_params(c2); BC_ASSERT_EQUAL(linphone_call_params_get_media_encryption(call_param),linphone_core_get_media_encryption(callee->lc), int, "%d"); } linphone_call_unref(c1); linphone_call_unref(c2); return video_enabled ? (realtime_text_enabled ? text_success && audio_success && video_success : audio_success && video_success) : realtime_text_enabled ? text_success && audio_success : audio_success; }
int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; const char* dest_friend=NULL; int i; const char* big_file_content="big file"; LinphoneChatRoom* chat_room; LinphoneContent* content; LinphoneChatMessage* chat_message; LinphoneChatMessageCbs *cbs; /*seting dummy file content to something*/ for (i=0;i<sizeof(big_file);i+=strlen(big_file_content)) memcpy(big_file+i, big_file_content, strlen(big_file_content)); big_file[0]=*"S"; big_file[sizeof(big_file)-1]=*"E"; signal(SIGINT,stop); //#define DEBUG #ifdef DEBUG linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/ #endif vtable.message_received=message_received; /* Instantiate a LinphoneCore object given the LinphoneCoreVTable */ lc=linphone_core_new(&vtable,NULL,NULL,NULL); dest_friend = linphone_core_get_primary_contact(lc); printf("Send message to me : %s\n", dest_friend); /** * Globally configure an http file transfer server. */ //linphone_core_set_file_transfer_server(lc,"http://npasc.al/lft.php"); linphone_core_set_file_transfer_server(lc,"https://www.linphone.org:444/lft.php"); /*Next step is to create a chat room*/ chat_room = linphone_core_get_chat_room_from_uri(lc,dest_friend); content = linphone_core_create_content(lc); linphone_content_set_type(content,"text"); linphone_content_set_subtype(content,"plain"); linphone_content_set_size(content,sizeof(big_file)); /*total size to be transfered*/ linphone_content_set_name(content,"bigfile.txt"); /*now create a chat message with custom content*/ chat_message = linphone_chat_room_create_file_transfer_message(chat_room,content); if (chat_message == NULL) { printf("returned message is null\n"); } /** * Fill the application callbacks. The file_transfer_received callback is used in order to get notifications * about incoming file reception, file_transfer_send to feed file to be transfered and * file_transfer_progress_indication to print progress. */ cbs = linphone_chat_message_get_callbacks(chat_message); linphone_chat_message_cbs_set_file_transfer_recv(cbs, file_transfer_received); linphone_chat_message_cbs_set_file_transfer_send(cbs, file_transfer_send); linphone_chat_message_cbs_set_file_transfer_progress_indication(cbs, file_transfer_progress_indication); /*initiating file transfer*/ linphone_chat_room_send_chat_message(chat_room, chat_message); /* main loop for receiving incoming messages and doing background linphone core work: */ while(running){ linphone_core_iterate(lc); ms_usleep(50000); } printf("Shutting down...\n"); linphone_content_unref(content); linphone_core_destroy(lc); printf("Exited\n"); return 0; }