static void subscribe_test_declined(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_tcp_rc"); LinphoneContent* content; LinphoneEvent *lev; const LinphoneErrorInfo *ei; MSList* lcs=ms_list_append(NULL,marie->lc); lcs=ms_list_append(lcs,pauline->lc); content = linphone_core_create_content(marie->lc); linphone_content_set_type(content,"application"); linphone_content_set_subtype(content,"somexml"); linphone_content_set_buffer(content,subscribe_content,strlen(subscribe_content)); pauline->decline_subscribe=TRUE; lev=linphone_core_subscribe(marie->lc,pauline->identity,"dodo",600,content); linphone_event_ref(lev); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,3000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionError,1,21000));/*yes flexisip may wait 20 secs in case of forking*/ ei=linphone_event_get_error_info(lev); BC_ASSERT_PTR_NOT_NULL(ei); if (ei){ BC_ASSERT_EQUAL(linphone_error_info_get_protocol_code(ei),603, int, "%d"); BC_ASSERT_PTR_NOT_NULL(linphone_error_info_get_phrase(ei)); } BC_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000)); linphone_content_unref(content); linphone_event_unref(lev); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
static void io_recv_error_late_recovery(){ LinphoneCoreManager *mgr; LinphoneCore* lc; int register_ok; stats* counters ; int number_of_udp_proxy=0; MSList* lcs; mgr=linphone_core_manager_new2( "multi_account_lrc",FALSE); /*to make sure iterates are not call yet*/ lc=mgr->lc; sal_set_refresher_retry_after(lc->sal,1000); counters=&mgr->stat; CU_ASSERT_TRUE(wait_for(mgr->lc,mgr->lc,&counters->number_of_LinphoneRegistrationOk,ms_list_size(linphone_core_get_proxy_config_list(mgr->lc)))); counters = get_stats(lc); register_ok=counters->number_of_LinphoneRegistrationOk; number_of_udp_proxy=get_number_of_udp_proxy(lc); /*simulate a general socket error*/ sal_set_recv_error(lc->sal, 0); sal_set_send_error(lc->sal, -1); CU_ASSERT_TRUE(wait_for(lc,NULL,&counters->number_of_LinphoneRegistrationProgress,(register_ok-number_of_udp_proxy)+register_ok /*because 1 udp*/)); CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0) CU_ASSERT_TRUE(wait_for_list(lcs=ms_list_append(NULL,lc),&counters->number_of_LinphoneRegistrationFailed,(register_ok-number_of_udp_proxy),sal_get_refresher_retry_after(lc->sal)+1000)); sal_set_recv_error(lc->sal, 1); /*reset*/ sal_set_send_error(lc->sal, 0); CU_ASSERT_TRUE(wait_for_list(lcs=ms_list_append(NULL,lc),&counters->number_of_LinphoneRegistrationOk,register_ok-number_of_udp_proxy +register_ok,sal_get_refresher_retry_after(lc->sal)+1000)); linphone_core_manager_destroy(mgr); }
static void subscribe_test_declined(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); LinphoneContent content; MSList* lcs=ms_list_append(NULL,marie->lc); lcs=ms_list_append(lcs,pauline->lc); content.type="application"; content.subtype="somexml"; content.data=(char*)subscribe_content; content.size=strlen(subscribe_content); pauline->decline_subscribe=TRUE; linphone_core_subscribe(marie->lc,pauline->identity,"dodo",600,&content); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionError,1,21000));/*yes flexisip may wait 20 secs in case of forking*/ CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000)); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
void linphone_core_setup_local_rtp_profile(LinphoneCore *lc) { int i; MSList *audiopt,*videopt; PayloadType *payload; bool_t prepend; lc->local_profile=rtp_profile_clone_full(&av_profile); /* first look at the list given by configuration file to see if it is correct */ audiopt=fix_codec_list(lc->local_profile,lc->codecs_conf.audio_codecs); videopt=fix_codec_list(lc->local_profile,lc->codecs_conf.video_codecs); /* now find and add payloads that are not listed in the configuration codec list */ for (i=0;i<127;i++) { payload=rtp_profile_get_payload(lc->local_profile,i); if (payload!=NULL){ if (payload_type_get_user_data(payload)!=NULL) continue; /* find a mediastreamer codec for this payload type */ if (ms_filter_codec_supported(payload->mime_type)){ MSFilterDesc *desc=ms_filter_get_encoder(payload->mime_type); ms_message("Adding new codec %s/%i",payload->mime_type,payload->clock_rate); payload_type_set_enable(payload,1); payload_type_set_user_data(payload,(void *)desc->text); prepend=FALSE; /* by default, put speex and theora on top of list*/ if (strcmp(payload->mime_type,"speex")==0) prepend=TRUE; if (strcmp(payload->mime_type,"theora")==0) prepend=TRUE; switch (payload->type){ case PAYLOAD_AUDIO_CONTINUOUS: case PAYLOAD_AUDIO_PACKETIZED: if (prepend) audiopt=ms_list_prepend(audiopt,(void *)payload); else audiopt=ms_list_append(audiopt,(void *)payload); break; case PAYLOAD_VIDEO: if (prepend) videopt=ms_list_prepend(videopt,(void *)payload); else videopt=ms_list_append(videopt,(void *)payload); break; default: ms_error("Unsupported rtp media type."); } } } } ms_list_for_each(lc->codecs_conf.audio_codecs,(void (*)(void*))payload_type_destroy); ms_list_for_each(lc->codecs_conf.video_codecs,(void (*)(void *))payload_type_destroy); ms_list_free(lc->codecs_conf.audio_codecs); ms_list_free(lc->codecs_conf.video_codecs); /* set the fixed lists instead:*/ lc->codecs_conf.audio_codecs=audiopt; lc->codecs_conf.video_codecs=videopt; }
static void subscribe_forking(void) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_tcp"); LinphoneCoreManager* pauline2 = linphone_core_manager_new( "pauline_rc_tcp"); LinphoneContent content={0}; LinphoneEvent *lev; int expires= 600; MSList* lcs=ms_list_append(NULL,marie->lc); lcs=ms_list_append(lcs,pauline->lc); lcs=ms_list_append(lcs,pauline2->lc); content.type="application"; content.subtype="somexml"; content.data=(char*)liblinphone_tester_get_subscribe_content(); content.size=strlen(liblinphone_tester_get_subscribe_content()); lev=linphone_core_subscribe(marie->lc,pauline->identity,"dodo",expires,&content); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline2->stat.number_of_LinphoneSubscriptionIncomingReceived,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,1,1000)); /*make sure marie receives first notification before terminating*/ CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,1,1000)); linphone_event_terminate(lev); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(pauline2); ms_list_free(lcs); }
bool_t wait_for_until(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value,int timout) { MSList* lcs=NULL; bool_t result; if (lc_1) lcs=ms_list_append(lcs,lc_1); if (lc_2) lcs=ms_list_append(lcs,lc_2); result=wait_for_list(lcs,counter,value,timout); ms_list_free(lcs); return result; }
static void call_forking_declined(bool_t declined_globaly){ LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_tcp"); LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); MSList* lcs=ms_list_append(NULL,pauline->lc); lcs=ms_list_append(lcs,marie->lc); lcs=ms_list_append(lcs,marie2->lc); lcs=ms_list_append(lcs,marie3->lc); linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie3->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL); linphone_core_invite_address(pauline->lc,marie->identity); /*pauline should hear ringback*/ CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,3000)); /*all devices from Marie should be ringing*/ CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallIncomingReceived,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallIncomingReceived,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallIncomingReceived,1,1000)); /*marie1 finally declines the call*/ linphone_core_decline_call(marie->lc,linphone_core_get_current_call(marie->lc), declined_globaly ? LinphoneReasonDeclined : LinphoneReasonBusy ); if (declined_globaly){ CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); /*all devices should stop ringing*/ CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallEnd,1,1000)); }else{ /*pauline should continue ringing and be able to hear a call taken by marie2 */ linphone_core_accept_call(marie2->lc, linphone_core_get_current_call(marie2->lc)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,2000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallStreamsRunning,1,2000)); liblinphone_tester_check_rtcp(pauline,marie2); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallEnd,1,1000)); linphone_core_terminate_call(marie2->lc,linphone_core_get_current_call(marie2->lc)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); } linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(marie3); ms_list_free(lcs); }
bool_t wait_for_three_cores(LinphoneCore *lc1, LinphoneCore *lc2, LinphoneCore *lc3, int timeout) { MSList *lcs = NULL; bool_t result; int dummy = 0; if (lc1) lcs = ms_list_append(lcs, lc1); if (lc2) lcs = ms_list_append(lcs, lc2); if (lc3) lcs = ms_list_append(lcs, lc3); result = wait_for_list(lcs, &dummy, 1, timeout); ms_list_free(lcs); return result; }
static void call_forking_with_push_notification_multiple(void){ LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_tcp"); LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); MSList* lcs=ms_list_append(NULL,pauline->lc); lcs=ms_list_append(lcs,marie->lc); lcs=ms_list_append(lcs,marie2->lc); linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL); /*unfortunately marie gets unreachable due to crappy 3G operator or iOS bug...*/ linphone_core_set_network_reachable(marie2->lc,FALSE); linphone_core_invite_address(pauline->lc,marie->identity); /*marie1 will ring*/ CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallIncomingReceived,1,1000)); /*pauline should hear ringback as well*/ CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,1000)); /*the server is expected to send a push notification to marie2, this will wake up linphone, that will reconnect:*/ linphone_core_set_network_reachable(marie2->lc,TRUE); /*Marie shall receive the call immediately*/ CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallIncomingReceived,1,1000)); /*marie2 accepts the call*/ linphone_core_accept_call(marie2->lc,linphone_core_get_current_call(marie2->lc)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallConnected,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallStreamsRunning,1,1000)); /*call to marie1 should be cancelled*/ CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); liblinphone_tester_check_rtcp(pauline,marie2); linphone_core_terminate_call(pauline->lc,linphone_core_get_current_call(pauline->lc)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); }
static void test_presence_list_subscribe_before_publish(void) { LinphoneCoreManager *laure = linphone_core_manager_new("laure_tcp_rc"); LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); const char *rls_uri = "sip:[email protected]"; LinphoneFriendList *lfl; LinphoneFriend *lf; const char *pauline_identity; MSList* lcs = NULL; int dummy = 0; pauline_identity = get_identity(pauline); linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityVacation, NULL)); lfl = linphone_core_create_friend_list(laure->lc); linphone_friend_list_set_rls_uri(lfl, rls_uri); lf = linphone_core_create_friend_with_address(laure->lc, pauline_identity); linphone_friend_list_add_friend(lfl, lf); lf = linphone_core_create_friend_with_address(laure->lc, "sip:[email protected]"); linphone_friend_list_add_friend(lfl, lf); linphone_core_remove_friend_list(laure->lc, linphone_core_get_default_friend_list(laure->lc)); linphone_core_add_friend_list(laure->lc, lfl); linphone_friend_list_unref(lfl); linphone_core_set_presence_model(laure->lc, linphone_core_create_presence_model_with_activity(laure->lc, LinphonePresenceActivityOnline, NULL)); linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(laure->lc), NULL, FALSE); lcs = ms_list_append(lcs, laure->lc); lcs = ms_list_append(lcs, pauline->lc); wait_for_list(lcs, &dummy, 1, 2000); /* Wait a little bit for the subscribe to happen */ enable_publish(pauline, TRUE); wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 1, 4000); BC_ASSERT_GREATER(laure->stat.number_of_NotifyPresenceReceived, 1, int, "%d"); BC_ASSERT_GREATER(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d"); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusVacation, int, "%d"); BC_ASSERT_TRUE(lf->presence_received); BC_ASSERT_TRUE(lf->subscribe_active); lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), "sip:[email protected]"); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); BC_ASSERT_FALSE(lf->presence_received); BC_ASSERT_TRUE(lf->subscribe_active); enable_publish(laure, FALSE); enable_publish(pauline, FALSE); linphone_core_manager_destroy(laure); linphone_core_manager_destroy(pauline); }
static void message_forking_with_all_recipients_unreachable(void) { LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_tcp"); LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); MSList* lcs=ms_list_append(NULL,marie->lc); char* to = linphone_address_as_string(marie->identity); LinphoneChatRoom* chat_room = linphone_core_create_chat_room(pauline->lc,to); LinphoneChatMessage* message = linphone_chat_room_create_message(chat_room,"Bli bli bli \n blu"); lcs=ms_list_append(lcs,pauline->lc); lcs=ms_list_append(lcs,marie2->lc); lcs=ms_list_append(lcs,marie3->lc); /*All marie's device go offline*/ linphone_core_set_network_reachable(marie->lc,FALSE); linphone_core_set_network_reachable(marie2->lc,FALSE); linphone_core_set_network_reachable(marie3->lc,FALSE); linphone_chat_room_send_message2(chat_room,message,liblinphone_tester_chat_message_state_change,pauline->lc); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneMessageInProgress,1,1000)); /*flexisip will accept the message with 202 after 16 seconds*/ CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneMessageDelivered,1,18000)); CU_ASSERT_TRUE( marie->stat.number_of_LinphoneMessageReceived==0); CU_ASSERT_TRUE( marie2->stat.number_of_LinphoneMessageReceived==0); CU_ASSERT_TRUE( marie3->stat.number_of_LinphoneMessageReceived==0); /*marie 1 goes online */ linphone_core_set_network_reachable(marie->lc,TRUE); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneMessageReceived,1,1000)); /*marie 2 goes online */ linphone_core_set_network_reachable(marie2->lc,TRUE); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneMessageReceived,1,1000)); /*wait a long time so that all transactions are expired*/ wait_for_list(lcs,NULL,0,32000); /*marie 3 goes online now*/ linphone_core_set_network_reachable(marie3->lc,TRUE); CU_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneMessageReceived,1,1000)); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(pauline); ms_free(to); ms_list_free(lcs); }
static LinphoneLDAPContactSearch* linphone_ldap_contact_provider_begin_search ( LinphoneLDAPContactProvider* obj, const char* predicate, ContactSearchCallback cb, void* cb_data ) { bool_t connected = obj->connected; LinphoneLDAPContactSearch* request; // if we're not yet connected, bind if( !connected ) { if( !obj->bind_thread ) linphone_ldap_contact_provider_bind(obj); } request = linphone_ldap_contact_search_create( obj, predicate, cb, cb_data ); if( connected ){ int ret = linphone_ldap_contact_provider_perform_search(obj, request); ms_message ( "Created search %d for '%s', msgid %d, @%p", obj->req_count, predicate, request->msgid, request ); if( ret != LDAP_SUCCESS ){ belle_sip_object_unref(request); request = NULL; } } else { ms_message("Delayed search, wait for connection"); } if( request != NULL ) { obj->requests = ms_list_append ( obj->requests, request ); obj->req_count++; } return request; }
/** * Adds authentication information to the LinphoneCore. * * This information will be used during all SIP transacations that require authentication. **/ void linphone_core_add_auth_info(LinphoneCore *lc, const LinphoneAuthInfo *info) { LinphoneAuthInfo *ai; MSList *elem; MSList *l; /* find if we are attempting to modify an existing auth info */ ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,info->realm,info->username); if (ai!=NULL){ lc->auth_info=ms_list_remove(lc->auth_info,ai); linphone_auth_info_destroy(ai); } lc->auth_info=ms_list_append(lc->auth_info,linphone_auth_info_clone(info)); /* retry pending authentication operations */ for(l=elem=sal_get_pending_auths(lc->sal);elem!=NULL;elem=elem->next){ const char *username,*realm; SalOp *op=(SalOp*)elem->data; LinphoneAuthInfo *ai; sal_op_get_auth_requested(op,&realm,&username); ai=(LinphoneAuthInfo*)linphone_core_find_auth_info(lc,realm,username); if (ai){ SalAuthInfo sai; sai.username=ai->username; sai.userid=ai->userid; sai.realm=ai->realm; sai.password=ai->passwd; sal_op_authenticate(op,&sai); ai->usecount++; } } ms_list_free(l); write_auth_infos(lc); }
MSList* linphone_friend_get_addresses(LinphoneFriend *lf) { LinphoneVcard *vcard = NULL; MSList *sipAddresses = NULL; MSList *addresses = NULL; MSList *iterator = NULL; if (!lf) { return NULL; } vcard = linphone_friend_get_vcard(lf); if (!vcard) { return NULL; } sipAddresses = linphone_vcard_get_sip_addresses(vcard); iterator = sipAddresses; while (iterator) { const char *sipAddress = (const char *)iterator->data; LinphoneAddress *addr = linphone_address_new(sipAddress); if (addr) { addresses = ms_list_append(addresses, addr); } iterator = ms_list_next(iterator); } if (sipAddresses) ms_list_free(sipAddresses); return addresses; }
static void find_filters(MSList **filters, MSFilter *f ) { int i,found; MSQueue *link; if (f==NULL) ms_fatal("Bad graph."); /*ms_message("seeing %s, seen=%i",f->desc->name,f->seen);*/ if (f->seen) { return; } f->seen=TRUE; *filters=ms_list_append(*filters,f); /* go upstream */ for(i=0; i<f->desc->ninputs; i++) { link=f->inputs[i]; if (link!=NULL) find_filters(filters,link->prev.filter); } /* go downstream */ for(i=0,found=0; i<f->desc->noutputs; i++) { link=f->outputs[i]; if (link!=NULL) { found++; find_filters(filters,link->next.filter); } } if (f->desc->noutputs>=1 && found==0) { ms_fatal("Bad graph: filter %s has %i outputs, none is connected.",f->desc->name,f->desc->noutputs); } }
MSList *ms_list_insert_sorted(MSList *list, void *data, int (*compare_func)(const void *, const void*)){ MSList *it,*previt=NULL; MSList *nelem; MSList *ret=list; if (list==NULL) return ms_list_append(list,data); else{ nelem=ms_list_new(data); for(it=list;it!=NULL;it=it->next){ previt=it; if (compare_func(data,it->data)<=0){ nelem->prev=it->prev; nelem->next=it; if (it->prev!=NULL) it->prev->next=nelem; else{ ret=nelem; } it->prev=nelem; return ret; } } previt->next=nelem; nelem->prev=previt; } return ret; }
void sipomatic_iterate(Sipomatic *obj) { MSList *elem; MSList *to_be_destroyed=NULL; Call *call; double elapsed; eXosip_event_t *ev; while((ev=eXosip_event_wait(0,0))!=NULL){ sipomatic_process_event(obj,ev); } elem=obj->calls; while(elem!=NULL){ call=(Call*)elem->data; elapsed=time(NULL)-call->time; switch(call->state){ case CALL_STATE_INIT: if (elapsed>obj->acceptance_time){ call_accept(call); } break; case CALL_STATE_RUNNING: if (elapsed>obj->max_call_time || call->eof){ call_release(call); to_be_destroyed=ms_list_append(to_be_destroyed,call); } break; } elem=ms_list_next(elem); } for(;to_be_destroyed!=NULL; to_be_destroyed=ms_list_next(to_be_destroyed)){ call_destroy((Call*)to_be_destroyed->data); } }
/* DB layout: * | 0 | storage_id * | 1 | from * | 2 | to * | 3 | direction flag * | 4 | duration * | 5 | start date time (time_t) * | 6 | connected date time (time_t) * | 7 | status * | 8 | video enabled (1 or 0) * | 9 | quality * | 10 | call_id * | 11 | refkey */ static int create_call_log(void *data, int argc, char **argv, char **colName) { MSList **list = (MSList **)data; LinphoneAddress *from; LinphoneAddress *to; LinphoneCallDir dir; LinphoneCallLog *log; unsigned int storage_id = atoi(argv[0]); from = linphone_address_new(argv[1]); to = linphone_address_new(argv[2]); dir = (LinphoneCallDir) atoi(argv[3]); log = linphone_call_log_new(dir, from, to); log->storage_id = storage_id; log->duration = atoi(argv[4]); log->start_date_time = (time_t)atol(argv[5]); log->connected_date_time = (time_t)atol(argv[6]); log->status = (LinphoneCallStatus) atoi(argv[7]); log->video_enabled = atoi(argv[8]) == 1; log->quality = atof(argv[9]); if (argc > 10) { if (argv[10] != NULL) { log->call_id = ms_strdup(argv[10]); } if (argv[10] != NULL) { log->refkey = ms_strdup(argv[11]); } } *list = ms_list_append(*list, log); return 0; }
int linphone_conference_add_local_webcam(LinphoneConference *conf, ConfWebCam *localcam){ ConfVideoPort *video_port = find_free_video_slot(conf->conf_stream); if(!conf || !localcam || !video_port) return -1; int tmp = video_port->index; if(conf->conf_stream->auto_layout)//自动布局模式下只开启 0 号端口的静态图片 { if(tmp==0) ms_filter_call_method(conf->conf_stream->video_static_image_tee,MS_TEE_MUTE,&tmp); }else{ ms_filter_call_method(conf->conf_stream->video_static_image_tee,MS_TEE_MUTE,&tmp); } ms_message("Add Local Camera: conf_stream [%d] <----> local_webcam !!",video_port->index); video_port->sink_connected = TRUE; ms_filter_call_method(video_port->video_itc_source,MS_CONF_ITC_SOURCE_CONNECT,&video_port->slotq_in); ms_filter_call_method(localcam->itc_sink,MS_CONF_ITC_SINK_CONNECT,&video_port->slotq_in); video_port->source_connected = TRUE; localcam->video_port_index = video_port->index; conf->local_webcams = ms_list_append(conf->local_webcams,localcam); }
static void sdp_parse_payload_types(belle_sdp_media_description_t *media_desc, SalStreamDescription *stream) { PayloadType *pt; PayloadTypeAvpfParams avpf_params; belle_sip_list_t* mime_param_it=NULL; belle_sdp_mime_parameter_t* mime_param; belle_sip_list_t* mime_params=belle_sdp_media_description_build_mime_parameters ( media_desc ); memset(&avpf_params, 0, sizeof(avpf_params)); for ( mime_param_it=mime_params ; mime_param_it!=NULL ; mime_param_it=mime_param_it->next ) { mime_param=BELLE_SDP_MIME_PARAMETER ( mime_param_it->data ); pt=payload_type_new(); payload_type_set_number ( pt,belle_sdp_mime_parameter_get_media_format ( mime_param ) ); pt->clock_rate=belle_sdp_mime_parameter_get_rate ( mime_param ); pt->mime_type=ms_strdup ( belle_sdp_mime_parameter_get_type ( mime_param ) ); pt->channels=belle_sdp_mime_parameter_get_channel_count ( mime_param ); payload_type_set_send_fmtp ( pt,belle_sdp_mime_parameter_get_parameters ( mime_param ) ); payload_type_set_avpf_params(pt, avpf_params); stream->payloads=ms_list_append ( stream->payloads,pt ); stream->ptime=belle_sdp_mime_parameter_get_ptime ( mime_param ); ms_message ( "Found payload %s/%i fmtp=%s",pt->mime_type,pt->clock_rate, pt->send_fmtp ? pt->send_fmtp : "" ); } if ( mime_params ) belle_sip_list_free_with_data ( mime_params,belle_sip_object_unref ); }
/* DB layout: * | 0 | storage_id * | 1 | friend_list_id * | 2 | sip_uri * | 3 | subscribe_policy * | 4 | send_subscribe * | 5 | ref_key * | 6 | vCard * | 7 | vCard eTag * | 8 | vCard URL * | 9 | presence_received */ static int create_friend(void *data, int argc, char **argv, char **colName) { MSList **list = (MSList **)data; LinphoneFriend *lf = NULL; LinphoneVcard *vcard = NULL; unsigned int storage_id = atoi(argv[0]); vcard = linphone_vcard_new_from_vcard4_buffer(argv[6]); if (vcard) { linphone_vcard_set_etag(vcard, argv[7]); linphone_vcard_set_url(vcard, argv[8]); lf = linphone_friend_new_from_vcard(vcard); } if (!lf) { LinphoneAddress *addr = linphone_address_new(argv[2]); lf = linphone_friend_new(); linphone_friend_set_address(lf, addr); linphone_address_unref(addr); } linphone_friend_set_inc_subscribe_policy(lf, atoi(argv[3])); linphone_friend_send_subscribe(lf, atoi(argv[4])); linphone_friend_set_ref_key(lf, ms_strdup(argv[5])); lf->presence_received = atoi(argv[9]); lf->storage_id = storage_id; *list = ms_list_append(*list, linphone_friend_ref(lf)); linphone_friend_unref(lf); return 0; }
LinphoneAddress *account_manager_check_account(AccountManager *m, LinphoneProxyConfig *cfg){ LinphoneCore *lc=linphone_proxy_config_get_core(cfg); const char *identity=linphone_proxy_config_get_identity(cfg); LinphoneAddress *id_addr=linphone_address_new(identity); Account *account=account_manager_get_account(m,id_addr); LinphoneAuthInfo *ai; char *tmp; bool_t create_account=FALSE; if (!account){ account=account_new(id_addr,m->unique_id); ms_message("No account for %s exists, going to create one.",identity); create_account=TRUE; m->accounts=ms_list_append(m->accounts,account); } /*modify the username of the identity of the proxy config*/ linphone_address_set_username(id_addr, linphone_address_get_username(account->modified_identity)); tmp=linphone_address_as_string(id_addr); linphone_proxy_config_set_identity(cfg,tmp); ms_free(tmp); if (create_account){ account_create_on_server(account,cfg); } ai=linphone_auth_info_new(linphone_address_get_username(account->modified_identity), NULL, account->password,NULL,NULL,linphone_address_get_domain(account->modified_identity)); linphone_core_add_auth_info(lc,ai); linphone_auth_info_destroy(ai); linphone_address_unref(id_addr); return account->modified_identity; }
MSList *fix_codec_list(RtpProfile *prof, MSList *conflist) { MSList *elem; MSList *newlist=NULL; PayloadType *payload,*confpayload; for (elem=conflist;elem!=NULL;elem=ms_list_next(elem)) { confpayload=(PayloadType*)elem->data; payload=rtp_profile_find_payload(prof,confpayload->mime_type, confpayload->clock_rate,-1); if (payload!=NULL){ if (ms_filter_codec_supported(confpayload->mime_type)){ MSFilterDesc *desc=ms_filter_get_encoder(confpayload->mime_type); if (payload_type_get_user_data(payload)==NULL){ payload_type_set_user_data(payload,(void*)desc->text); payload_type_set_enable(payload,payload_type_enabled(confpayload)); newlist=ms_list_append(newlist,payload); }/*else this is a duplicate */ } } else{ ms_warning("Cannot support %s/%i: does not exist.",confpayload->mime_type, confpayload->clock_rate); } } return newlist; }
void sal_add_supported_tag(Sal *ctx, const char* tag){ MSList *elem=ms_list_find_custom(ctx->supported_tags,(MSCompareFunc)strcasecmp,tag); if (!elem){ ctx->supported_tags=ms_list_append(ctx->supported_tags,ms_strdup(tag)); make_supported_header(ctx); } }
MSList *ms_list_copy(const MSList *list){ MSList *copy=NULL; const MSList *iter; for(iter=list;iter!=NULL;iter=ms_list_next(iter)){ copy=ms_list_append(copy,iter->data); } return copy; }
void sal_op_add_route_address(SalOp *op, const SalAddress *address){ SalOpBase* op_base = (SalOpBase*)op; if (op_base->route_addresses) { op_base->route_addresses=ms_list_append(op_base->route_addresses,(void*)sal_address_clone(address)); } else { sal_op_set_route_address(op,address); } }
MSList *ms_list_copy_with_data(const MSList *list, void *(*copyfunc)(void *)){ MSList *copy=NULL; const MSList *iter; for(iter=list;iter!=NULL;iter=ms_list_next(iter)){ copy=ms_list_append(copy,copyfunc(iter->data)); } return copy; }
static void subscribe_test_with_args(bool_t terminated_by_subscriber, bool_t test_refreshing) { LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); LinphoneContent content; LinphoneEvent *lev; int expires= test_refreshing ? 4 : 600; MSList* lcs=ms_list_append(NULL,marie->lc); lcs=ms_list_append(lcs,pauline->lc); content.type="application"; content.subtype="somexml"; content.data=(char*)subscribe_content; content.size=strlen(subscribe_content); lev=linphone_core_subscribe(marie->lc,pauline->identity,"dodo",expires,&content); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionOutgoingInit,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionIncomingReceived,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionActive,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionActive,1,1000)); /*make sure marie receives first notification before terminating*/ CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_NotifyReceived,1,1000)); if (test_refreshing){ wait_for_list(lcs,NULL,0,6000); CU_ASSERT_TRUE(linphone_event_get_subscription_state(pauline->lev)==LinphoneSubscriptionActive); } if (terminated_by_subscriber){ linphone_event_terminate(lev); }else{ CU_ASSERT_PTR_NOT_NULL_FATAL(pauline->lev); linphone_event_terminate(pauline->lev); } CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneSubscriptionTerminated,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneSubscriptionTerminated,1,1000)); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); }
static void call_forking(void){ LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc_tcp"); LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie2 = linphone_core_manager_new( "marie_rc"); LinphoneCoreManager* marie3 = linphone_core_manager_new( "marie_rc"); MSList* lcs=ms_list_append(NULL,pauline->lc); lcs=ms_list_append(lcs,marie->lc); lcs=ms_list_append(lcs,marie2->lc); lcs=ms_list_append(lcs,marie3->lc); linphone_core_set_user_agent(marie->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie2->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(marie3->lc,"Natted Linphone",NULL); linphone_core_set_user_agent(pauline->lc,"Natted Linphone",NULL); linphone_core_invite_address(pauline->lc,marie->identity); /*pauline should hear ringback*/ CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallOutgoingRinging,1,1000)); /*all devices from Marie should be ringing*/ CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallIncomingReceived,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallIncomingReceived,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallIncomingReceived,1,1000)); /*marie accepts the call on its first device*/ linphone_core_accept_call(marie->lc,linphone_core_get_current_call(marie->lc)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallConnected,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallStreamsRunning,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallConnected,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallStreamsRunning,1,1000)); /*other devices should stop ringing*/ CU_ASSERT_TRUE(wait_for_list(lcs,&marie2->stat.number_of_LinphoneCallEnd,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie3->stat.number_of_LinphoneCallEnd,1,1000)); linphone_core_terminate_call(pauline->lc,linphone_core_get_current_call(pauline->lc)); CU_ASSERT_TRUE(wait_for_list(lcs,&pauline->stat.number_of_LinphoneCallEnd,1,1000)); CU_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneCallEnd,1,1000)); linphone_core_manager_destroy(pauline); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(marie2); linphone_core_manager_destroy(marie3); ms_list_free(lcs); }
void _linphone_core_set_call_error_tone(LinphoneCore *lc, LinphoneReason reason, LinphoneToneID id, const char *audiofile){ LinphoneToneDescription *tone=linphone_core_get_call_error_tone(lc,reason); if (tone){ lc->tones=ms_list_remove(lc->tones,tone); linphone_tone_description_destroy(tone); } tone=linphone_tone_description_new(reason,id,audiofile); lc->tones=ms_list_append(lc->tones,tone); }