コード例 #1
0
ファイル: vcard_tester.c プロジェクト: CTA/linphone
static void linphone_vcard_import_export_friends_test(void) {
	LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE);
	LinphoneFriendList *lfl = linphone_core_get_default_friend_list(manager->lc);
	const bctbx_list_t *friends = linphone_friend_list_get_friends(lfl);
	char *import_filepath = bc_tester_res("vcards/vcards.vcf");
	char *export_filepath = bc_tester_file("export_vcards.vcf");
	int count = 0;
	BC_ASSERT_EQUAL(bctbx_list_size(friends), 0, int, "%d");
	
	count = linphone_friend_list_import_friends_from_vcard4_file(lfl, import_filepath);
	BC_ASSERT_EQUAL(count, 3, int, "%d");
	friends = linphone_friend_list_get_friends(lfl);
	BC_ASSERT_EQUAL(bctbx_list_size(friends), 3, int, "%d");

	linphone_friend_list_export_friends_as_vcard4_file(lfl, export_filepath);

	lfl = linphone_core_create_friend_list(manager->lc);
	count = linphone_friend_list_import_friends_from_vcard4_file(lfl, export_filepath);
	BC_ASSERT_EQUAL(count, 3, int, "%d");
	friends = linphone_friend_list_get_friends(lfl);
	BC_ASSERT_EQUAL(bctbx_list_size(friends), 3, int, "%d");
	linphone_friend_list_unref(lfl);

	remove(export_filepath);
	ms_free(import_filepath);
	ms_free(export_filepath);
	linphone_core_manager_destroy(manager);
}
コード例 #2
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);
}
コード例 #3
0
ファイル: vcard_tester.c プロジェクト: CTA/linphone
static void carddav_sync_4(void) {
	LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
	LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
	LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:[email protected]\r\nEND:VCARD\r\n");
	LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
	LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
	LinphoneCardDavContext *c = NULL;

	linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
	linphone_core_add_friend_list(manager->lc, lfl);
	linphone_friend_list_unref(lfl);
	c = linphone_carddav_context_new(lfl);
	BC_ASSERT_PTR_NOT_NULL(c);

	linphone_carddav_set_user_data(c, stats);
	linphone_carddav_set_synchronization_done_callback(c, carddav_sync_done);
	linphone_carddav_set_new_contact_callback(c, carddav_new_contact);
	linphone_carddav_set_removed_contact_callback(c, carddav_removed_contact);
	linphone_carddav_set_updated_contact_callback(c, carddav_updated_contact);

	BC_ASSERT_PTR_NULL(linphone_vcard_get_uid(lvc));
	linphone_carddav_put_vcard(c, lf);
	BC_ASSERT_PTR_NOT_NULL(linphone_vcard_get_uid(lvc));
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i");

	linphone_carddav_delete_vcard(c, lf);
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 2, 5000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 2, int, "%i");

	linphone_friend_unref(lf);
	ms_free(stats);
	linphone_carddav_context_destroy(c);
	linphone_core_manager_destroy(manager);
}
コード例 #4
0
ファイル: vcard_tester.c プロジェクト: Accontech/linphone
static void carddav_server_to_client_and_client_to_sever_sync(void) {
	LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
	LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
	LinphoneFriendListCbs *cbs = linphone_friend_list_get_callbacks(lfl);
	LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
	LinphoneVcard *lvc1 = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Margaux Clerc\r\nIMPP;TYPE=work:sip:[email protected]\r\nEND:VCARD\r\n");
	LinphoneFriend *lf1 = linphone_friend_new_from_vcard(lvc1);
	LinphoneVcard *lvc2 = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Ghislain Mary\r\nIMPP;TYPE=work:sip:[email protected]\r\nEND:VCARD\r\n");
	LinphoneFriend *lf2 = linphone_friend_new_from_vcard(lvc2);
	
	linphone_friend_list_cbs_set_user_data(cbs, stats);
	linphone_friend_list_cbs_set_contact_created(cbs, carddav_contact_created);
	linphone_friend_list_cbs_set_contact_deleted(cbs, carddav_contact_deleted);
	linphone_friend_list_cbs_set_contact_updated(cbs, carddav_contact_updated);
	linphone_friend_list_cbs_set_sync_status_changed(cbs, carddav_sync_status_changed);
	linphone_core_add_friend_list(manager->lc, lfl);
	linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
	
	linphone_friend_list_add_friend(lfl, lf1);
	linphone_friend_list_synchronize_friends_from_server(lfl);
	linphone_friend_list_add_friend(lfl, lf2);
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 3, 15000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 3, int, "%i");

	ms_free(stats);
	linphone_friend_unref(lf1);
	linphone_friend_unref(lf2);
	linphone_friend_list_unref(lfl);
	linphone_core_manager_destroy(manager);
}
コード例 #5
0
ファイル: upnp_tester.c プロジェクト: Distrotech/linphone
static void upnp_check_state(void) {
	int tmp = 0;
	LinphoneCoreManager* lc_upnp = linphone_core_manager_new2( "upnp_rc", FALSE);
	wait_for(lc_upnp->lc,lc_upnp->lc,&tmp,1);
	BC_ASSERT_EQUAL(linphone_core_get_upnp_state(lc_upnp->lc), LinphoneUpnpStateOk, int, "%d");
	linphone_core_manager_destroy(lc_upnp);
}
コード例 #6
0
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);
}
コード例 #7
0
ファイル: setup_tester.c プロジェクト: Accontech/linphone
static void devices_reload_test(void) {
	char *devid1;
	char *devid2;
	LinphoneCoreManager *mgr = linphone_core_manager_new2("empty_rc", FALSE);

	devid1 = ms_strdup(linphone_core_get_capture_device(mgr->lc));
	linphone_core_reload_sound_devices(mgr->lc);
	devid2 = ms_strdup(linphone_core_get_capture_device(mgr->lc));
	BC_ASSERT_STRING_EQUAL(devid1, devid2);
	ms_free(devid1);
	ms_free(devid2);

	devid1 = ms_strdup(linphone_core_get_video_device(mgr->lc));
	linphone_core_reload_video_devices(mgr->lc);
	devid2 = ms_strdup(linphone_core_get_video_device(mgr->lc));

	if (devid1 && devid2) {
		BC_ASSERT_STRING_EQUAL(devid1, devid2);
	} else {
		BC_ASSERT_PTR_NULL(devid1);
		BC_ASSERT_PTR_NULL(devid2);
	}
	ms_free(devid1);
	ms_free(devid2);

	linphone_core_manager_destroy(mgr);
}
コード例 #8
0
static void upnp_check_state(void) {
	int tmp = 0;
	LinphoneCoreManager* lc_upnp = linphone_core_manager_new2( "upnp_rc", FALSE);
	wait_for(lc_upnp->lc,lc_upnp->lc,&tmp,1);
	CU_ASSERT_TRUE(linphone_core_get_upnp_state(lc_upnp->lc) == LinphoneUpnpStateOk);
	linphone_core_manager_destroy(lc_upnp);
}
コード例 #9
0
ファイル: vcard_tester.c プロジェクト: CTA/linphone
static void carddav_sync(void) {
	LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
	LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
	LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
	LinphoneCardDavContext *c = NULL;

	linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
	linphone_core_add_friend_list(manager->lc, lfl);
	linphone_friend_list_unref(lfl);
	c = linphone_carddav_context_new(lfl);
	BC_ASSERT_PTR_NOT_NULL(c);

	linphone_carddav_set_user_data(c, stats);
	linphone_carddav_set_synchronization_done_callback(c, carddav_sync_done);
	linphone_carddav_set_new_contact_callback(c, carddav_new_contact);
	linphone_carddav_set_removed_contact_callback(c, carddav_removed_contact);
	linphone_carddav_set_updated_contact_callback(c, carddav_updated_contact);
	linphone_carddav_synchronize(c);

	wait_for_until(manager->lc, NULL, &stats->new_contact_count, 1, 5000);
	BC_ASSERT_EQUAL(stats->new_contact_count, 1, int, "%i");
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i");

	ms_free(stats);
	linphone_carddav_context_destroy(c);
	linphone_core_manager_destroy(manager);
}
コード例 #10
0
ファイル: vcard_tester.c プロジェクト: CTA/linphone
static void carddav_multiple_sync(void) {
	LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
	LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
	LinphoneFriendListCbs *cbs = linphone_friend_list_get_callbacks(lfl);
	LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);

	linphone_friend_list_cbs_set_user_data(cbs, stats);
	linphone_friend_list_cbs_set_contact_created(cbs, carddav_contact_created);
	linphone_friend_list_cbs_set_contact_deleted(cbs, carddav_contact_deleted);
	linphone_friend_list_cbs_set_contact_updated(cbs, carddav_contact_updated);
	linphone_friend_list_cbs_set_sync_status_changed(cbs, carddav_sync_status_changed);
	linphone_core_add_friend_list(manager->lc, lfl);
	linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);

	linphone_friend_list_synchronize_friends_from_server(lfl);
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i");
	linphone_friend_list_synchronize_friends_from_server(lfl);
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 2, 5000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 2, int, "%i");
	linphone_friend_list_synchronize_friends_from_server(lfl);
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 3, 5000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 3, int, "%i");
	BC_ASSERT_EQUAL(stats->removed_contact_count, 0, int, "%i");

	ms_free(stats);
	linphone_friend_list_unref(lfl);
	linphone_core_manager_destroy(manager);
}
コード例 #11
0
static void upnp_check_ipaddress(void) {
	int tmp = 0;
	LinphoneCoreManager* lc_upnp = linphone_core_manager_new2( "upnp_rc", FALSE);
	wait_for(lc_upnp->lc,lc_upnp->lc,&tmp,1);
	const char *addr = linphone_core_get_upnp_external_ipaddress(lc_upnp->lc);
	CU_ASSERT_TRUE(addr != NULL && strlen(addr)>=7);
	linphone_core_manager_destroy(lc_upnp);
}
コード例 #12
0
static void remote_provisioning_transient(void) {
	LinphoneCoreManager* marie = linphone_core_manager_new2("marie_transient_remote_rc", FALSE);
	CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphoneConfiguringSuccessful,1));
	CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphoneRegistrationOk,1));
	CU_ASSERT_TRUE(linphone_core_is_provisioning_transient(marie->lc) == TRUE);
	CU_ASSERT_TRUE(linphone_core_get_provisioning_uri(marie->lc) == NULL);
	linphone_core_manager_destroy(marie);
}
コード例 #13
0
ファイル: vcard_tester.c プロジェクト: CTA/linphone
static void linphone_vcard_phone_numbers_and_sip_addresses(void) {
	LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE);
	LinphoneVcard *lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:[email protected]\r\nIMPP;TYPE=home:sip:[email protected]\r\nTEL;TYPE=work:0952636505\r\nEND:VCARD\r\n");
	LinphoneFriend *lf = linphone_friend_new_from_vcard(lvc);
	bctbx_list_t *sip_addresses = linphone_friend_get_addresses(lf);
	bctbx_list_t *phone_numbers = linphone_friend_get_phone_numbers(lf);
	LinphoneAddress *addr = NULL;

	BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 2, int, "%i");
	BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 1, int, "%i");
	if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);
	if (phone_numbers) bctbx_list_free(phone_numbers);
	linphone_friend_unref(lf);

	lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nTEL;TYPE=work:0952636505\r\nTEL:0476010203\r\nEND:VCARD\r\n");
	lf = linphone_friend_new_from_vcard(lvc);
	sip_addresses = linphone_friend_get_addresses(lf);
	phone_numbers = linphone_friend_get_phone_numbers(lf);

	BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 0, int, "%i");
	BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 2, int, "%i");
	if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);
	if (phone_numbers) bctbx_list_free(phone_numbers);

	addr = linphone_address_new("sip:[email protected]");
	linphone_friend_add_address(lf, addr);
	linphone_address_unref(addr);
	sip_addresses = linphone_friend_get_addresses(lf);
	BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 1, int, "%i");
	if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);

	linphone_friend_remove_phone_number(lf, "0952636505");
	phone_numbers = linphone_friend_get_phone_numbers(lf);
	BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 1, int, "%i");
	if (phone_numbers) bctbx_list_free(phone_numbers);

	linphone_friend_remove_phone_number(lf, "0476010203");
	phone_numbers = linphone_friend_get_phone_numbers(lf);
	BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 0, int, "%i");
	if (phone_numbers) bctbx_list_free(phone_numbers);

	addr = linphone_address_new("sip:[email protected]");
	linphone_friend_remove_address(lf, addr);
	linphone_address_unref(addr);
	sip_addresses = linphone_friend_get_addresses(lf);
	BC_ASSERT_EQUAL(bctbx_list_size(sip_addresses), 0, int, "%i");
	if (sip_addresses) bctbx_list_free_with_data(sip_addresses, (void (*)(void *))linphone_address_unref);

	linphone_friend_add_phone_number(lf, "+33952636505");
	phone_numbers = linphone_friend_get_phone_numbers(lf);
	BC_ASSERT_EQUAL(bctbx_list_size(phone_numbers), 1, int, "%i");
	if (phone_numbers) bctbx_list_free(phone_numbers);

	linphone_friend_unref(lf);
	lf = NULL;
	lvc = NULL;
	linphone_core_manager_destroy(manager);
}
コード例 #14
0
static void upnp_start_n_stop(void) {
	int tmp = 0;
	LinphoneCoreManager* lc_upnp = linphone_core_manager_new2( "upnp_rc", FALSE);
	wait_for(lc_upnp->lc,lc_upnp->lc,&tmp,1);
#ifdef BUILD_UPNP
	CU_ASSERT_TRUE(lc_upnp->lc->upnp != NULL);
#endif
	linphone_core_manager_destroy(lc_upnp);
}
コード例 #15
0
static LinphoneCoreManager* presence_linphone_core_manager_new(char* username) {
	LinphoneCoreManager* mgr= linphone_core_manager_new2( "empty_rc", FALSE);
	char* identity_char;
	mgr->identity= linphone_core_get_primary_contact_parsed(mgr->lc);
	linphone_address_set_username(mgr->identity,username);
	identity_char=linphone_address_as_string(mgr->identity);
	linphone_core_set_primary_contact(mgr->lc,identity_char);
	return mgr;
}
コード例 #16
0
static void remote_provisioning_file(void) {
	LinphoneCoreManager* marie;
	const LpConfig* conf;
#if TARGET_OS_IPHONE
	ms_message("Skipping remote provisioning from file on iOS");
	return;
#elif defined(ANDROID)
	marie = linphone_core_manager_new2("marie_remote_localfile_android_rc", FALSE);
#else
	marie = linphone_core_manager_new2("marie_remote_localfile_rc", FALSE);
#endif
	CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphoneConfiguringSuccessful,1));

	conf = linphone_core_get_config( marie->lc );
	CU_ASSERT_EQUAL( lp_config_get_int(conf,"misc","tester_file_ok", 0), 1 );

	linphone_core_manager_destroy(marie);
}
コード例 #17
0
ファイル: upnp_tester.c プロジェクト: Distrotech/linphone
static void upnp_check_ipaddress(void) {
	int tmp = 0;
	const char *addr;
	LinphoneCoreManager* lc_upnp = linphone_core_manager_new2( "upnp_rc", FALSE);
	wait_for(lc_upnp->lc,lc_upnp->lc,&tmp,1);
	addr = linphone_core_get_upnp_external_ipaddress(lc_upnp->lc);
	BC_ASSERT_PTR_NOT_NULL(addr);
	if (addr!=NULL) {
		BC_ASSERT_GREATER((int)strlen(addr),7,int,"%d");
	}
コード例 #18
0
ファイル: setup_tester.c プロジェクト: abdfaye/linphone
/*this test checks default codec list, assuming VP8 and H264 are both supported.
 * - with an empty config, the order must be as expected: VP8 first, H264 second.
 * - with a config that references only H264, VP8 must be added automatically as first codec.
 * - with a config that references only VP8, H264 must be added in second position.
**/
static void codec_setup(void){
	LinphoneCoreManager *mgr = linphone_core_manager_new2("empty_rc", FALSE);
	PayloadType *vp8, *h264;
	const MSList *codecs;
	if ((vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1)) == NULL ||
		(h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1)) == NULL){
		linphone_core_manager_destroy(mgr);
		ms_error("H264 or VP8 not available, test skipped.");
		BC_PASS("H264 or VP8 not available, test skipped.");
		return;
	}
	codecs = linphone_core_get_video_codecs(mgr->lc);
	BC_ASSERT_TRUE(ms_list_size(codecs)>=2);
	BC_ASSERT_TRUE(codecs->data == vp8);
	BC_ASSERT_TRUE(codecs->next->data == h264);
	linphone_core_manager_destroy(mgr);
	
	mgr = linphone_core_manager_new2("marie_h264_rc", FALSE);
	vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1);
	h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1);
	codecs = linphone_core_get_video_codecs(mgr->lc);
	BC_ASSERT_TRUE(ms_list_size(codecs)>=2);
	BC_ASSERT_PTR_NOT_NULL(vp8);
	BC_ASSERT_PTR_NOT_NULL(h264);
	BC_ASSERT_TRUE(codecs->data == vp8);
	BC_ASSERT_TRUE(codecs->next->data == h264);
	linphone_core_manager_destroy(mgr);
	
	mgr = linphone_core_manager_new2("marie_rc", FALSE);
	vp8 = linphone_core_find_payload_type(mgr->lc, "VP8", 90000, -1);
	h264 = linphone_core_find_payload_type(mgr->lc, "H264", 90000, -1);
	codecs = linphone_core_get_video_codecs(mgr->lc);
	BC_ASSERT_TRUE(ms_list_size(codecs)>=2);
	BC_ASSERT_PTR_NOT_NULL(vp8);
	BC_ASSERT_PTR_NOT_NULL(h264);
	BC_ASSERT_TRUE(codecs->data == vp8);
	BC_ASSERT_TRUE(codecs->next->data == h264);
	linphone_core_manager_destroy(mgr);
	
}
コード例 #19
0
static void linphone_vcard_import_a_lot_of_friends_test(void) {
	LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE);
	LinphoneFriendList *lfl = linphone_core_get_default_friend_list(manager->lc);
	char *import_filepath = bc_tester_res("vcards/thousand_vcards.vcf");
	clock_t start, end;
	double elapsed = 0;
	const bctbx_list_t *friends = NULL;
	FILE    *infile = NULL;
	char    *buffer = NULL;
	long    numbytes = 0;
	size_t readbytes;

	start = clock();
	linphone_friend_list_import_friends_from_vcard4_file(lfl, import_filepath);
	end = clock();

	friends = linphone_friend_list_get_friends(lfl);
	BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(friends), 1000, unsigned int, "%u"); // Now that we accept Friends without a SIP URI, the result must be equal to 1000

	elapsed = (double)(end - start);
	ms_message("Imported a thousand of vCards from file in %f seconds", elapsed / CLOCKS_PER_SEC);

	lfl = linphone_core_create_friend_list(manager->lc);
	infile = fopen(import_filepath, "rb");
	BC_ASSERT_PTR_NOT_NULL(infile);
	if (infile) {
		fseek(infile, 0L, SEEK_END);
		numbytes = ftell(infile);
		fseek(infile, 0L, SEEK_SET);
		buffer = (char*)ms_malloc((numbytes + 1) * sizeof(char));
		readbytes = fread(buffer, sizeof(char), numbytes, infile);
		fclose(infile);
		buffer[readbytes] = '\0';

		start = clock();
		linphone_friend_list_import_friends_from_vcard4_buffer(lfl, buffer);
		end = clock();
		ms_free(buffer);
	}

	friends = linphone_friend_list_get_friends(lfl);
	BC_ASSERT_EQUAL((unsigned int)bctbx_list_size(friends), 1000, unsigned int, "%u"); // Now that we accept Friends without a SIP URI, the result must be equal to 1000

	elapsed = (double)(end - start);
	ms_message("Imported a thousand of vCards from buffer in %f seconds", elapsed / CLOCKS_PER_SEC);

	linphone_friend_list_unref(lfl);

	ms_free(import_filepath);
	linphone_core_manager_destroy(manager);
}
コード例 #20
0
static void tls_wildcard_register(){
	LinphoneCoreManager* mgr;
	LinphoneCore *lc;
	char rootcapath[256];
	
	mgr=linphone_core_manager_new2("pauline_wild_rc",FALSE);
	lc=mgr->lc;
	snprintf(rootcapath,sizeof(rootcapath), "%s/certificates/cacert.pem", liblinphone_tester_file_prefix);
	linphone_core_set_root_ca(mgr->lc,rootcapath);
	linphone_core_refresh_registers(mgr->lc);
	CU_ASSERT_TRUE(wait_for(lc,lc,&mgr->stat.number_of_LinphoneRegistrationOk,1));
	CU_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationFailed,0);
	linphone_core_destroy(mgr->lc);
}
コード例 #21
0
ファイル: vcard_tester.c プロジェクト: Accontech/linphone
static void linphone_vcard_import_a_lot_of_friends_test(void) {
	LinphoneCoreManager* manager = linphone_core_manager_new2("empty_rc", FALSE);
	LinphoneFriendList *lfl = linphone_core_get_default_friend_list(manager->lc);
	char *import_filepath = bc_tester_res("vcards/thousand_vcards.vcf");
	clock_t start, end;
	double elapsed = 0;
	const MSList *friends = NULL;
	FILE    *infile = NULL;
	char    *buffer = NULL;
	long    numbytes = 0;

	start = clock();
	linphone_friend_list_import_friends_from_vcard4_file(lfl, import_filepath);
	end = clock();

	friends = linphone_friend_list_get_friends(lfl);
	BC_ASSERT_EQUAL(ms_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI

	elapsed = (double)(end - start);
	ms_error("Imported a thousand of vCards from file (only %i friends with SIP address found) in %f seconds", ms_list_size(friends), elapsed / CLOCKS_PER_SEC);

	lfl = linphone_core_create_friend_list(manager->lc);
	infile = fopen(import_filepath, "rb");
	BC_ASSERT_PTR_NOT_NULL(infile);
	if (infile) {
		fseek(infile, 0L, SEEK_END);
		numbytes = ftell(infile);
		fseek(infile, 0L, SEEK_SET);
		buffer = (char*)ms_malloc(numbytes * sizeof(char));
		numbytes = fread(buffer, sizeof(char), numbytes, infile);
		fclose(infile);

		start = clock();
		linphone_friend_list_import_friends_from_vcard4_buffer(lfl, buffer);
		end = clock();
		ms_free(buffer);
	}

	friends = linphone_friend_list_get_friends(lfl);
	BC_ASSERT_EQUAL(ms_list_size(friends), 482, int, "%i"); // Thousand vcards contains 482 contacts with a SIP URI

	elapsed = (double)(end - start);
	ms_error("Imported a thousand of vCards from buffer (only %i friends with SIP address found) in %f seconds", ms_list_size(friends), elapsed / CLOCKS_PER_SEC);

	linphone_friend_list_unref(lfl);

	ms_free(import_filepath);
	linphone_core_manager_destroy(manager);
}
コード例 #22
0
/*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);
}
コード例 #23
0
ファイル: stun_tester.c プロジェクト: Distrotech/linphone
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);
}
コード例 #24
0
ファイル: vcard_tester.c プロジェクト: CTA/linphone
static void carddav_clean(void) {  // This is to ensure the content of the test addressbook is in the correct state for the following tests
	LinphoneCoreManager *manager = linphone_core_manager_new2("carddav_rc", FALSE);
	LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
	LinphoneFriendListCbs *cbs = linphone_friend_list_get_callbacks(lfl);
	LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
	bctbx_list_t *friends = NULL;
	bctbx_list_t *friends_iterator = NULL;
	LinphoneFriend *lf = NULL;
	LinphoneVcard *lvc = NULL;

	linphone_friend_list_cbs_set_user_data(cbs, stats);
	linphone_friend_list_cbs_set_contact_created(cbs, carddav_contact_created);
	linphone_friend_list_cbs_set_contact_deleted(cbs, carddav_contact_deleted);
	linphone_friend_list_cbs_set_contact_updated(cbs, carddav_contact_updated);
	linphone_friend_list_cbs_set_sync_status_changed(cbs, carddav_sync_status_changed);
	linphone_core_add_friend_list(manager->lc, lfl);
	linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);

	linphone_friend_list_synchronize_friends_from_server(lfl);
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i");
	stats->sync_done_count = 0;

	friends = bctbx_list_copy(lfl->friends);
	friends_iterator = friends;
	while (friends_iterator) {
		LinphoneFriend *lf = (LinphoneFriend *)friends_iterator->data;
		linphone_friend_list_remove_friend(lfl, lf);
		wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000);
		BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i");
		stats->sync_done_count = 0;
		stats->removed_contact_count = 0;
		friends_iterator = bctbx_list_next(friends_iterator);
	}
	bctbx_list_free(friends);

	lvc = linphone_vcard_context_get_vcard_from_buffer(manager->lc->vcard_context, "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:[email protected]\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
	linphone_vcard_set_url(lvc, "http://dav.linphone.org/card.php/addressbooks/tester/default/me.vcf");
	lf = linphone_friend_new_from_vcard(lvc);
	linphone_friend_list_add_friend(lfl, lf);
	wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 5000);
	BC_ASSERT_EQUAL(stats->sync_done_count, 1, int, "%i");

	ms_free(stats);
	linphone_friend_unref(lf);
	linphone_friend_list_unref(lfl);
	linphone_core_manager_destroy(manager);
}
コード例 #25
0
static LinphoneCoreManager* setup(bool_t enable_logs)  {
	LinphoneCoreManager *marie;
	int timeout = 300;

	collect_init();
	linphone_core_enable_log_collection(enable_logs);

	marie = linphone_core_manager_new2( "marie_rc", 0);
	// wait a few seconds to generate some traffic
	while (--timeout){
		// Generate some logs - error logs because we must ensure that
		// even if user did not enable logs, we will see them
		ms_error("(test error)Timeout in %d...", timeout);
	}
	return marie;
}
コード例 #26
0
static void remote_provisioning_default_values(void) {
	LinphoneProxyConfig *lpc;
	LinphoneCoreManager* marie = linphone_core_manager_new2("marie_remote_default_values_rc", FALSE);
	CU_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphoneConfiguringSuccessful,1));
	lpc = linphone_core_create_proxy_config(marie->lc);
	CU_ASSERT_TRUE(lpc->reg_sendregister == TRUE);
	CU_ASSERT_TRUE(lpc->expires == 604800);
	CU_ASSERT_STRING_EQUAL(lpc->reg_proxy, "<sip:sip.linphone.org:5223;transport=tls>");
	CU_ASSERT_STRING_EQUAL(lpc->reg_route, "<sip:sip.linphone.org:5223;transport=tls>");
	CU_ASSERT_STRING_EQUAL(lpc->reg_identity, "sip:[email protected]");
	{
		LpConfig* lp = linphone_core_get_config(marie->lc);
		CU_ASSERT_STRING_EQUAL(lp_config_get_string(lp,"app","toto","empty"),"titi");
	}

	linphone_core_manager_destroy(marie);
}
コード例 #27
0
ファイル: setup_tester.c プロジェクト: Accontech/ace-ios
static void linphone_lpconfig_from_xml_zerolen_value(){
	const char* zero_xml_file = "remote_zero_length_params_rc";
	char* xml_path = ms_strdup_printf("%s/rcfiles/%s", bc_tester_read_dir_prefix, zero_xml_file);
	LpConfig* conf;

	LinphoneCoreManager* mgr = linphone_core_manager_new2("empty_rc",FALSE);

	BC_ASSERT_EQUAL(linphone_remote_provisioning_load_file(mgr->lc, xml_path), 0, int, "%d");

	conf = mgr->lc->config;

	BC_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","zero_len","LOL"),"LOL");
	BC_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","non_zero_len",""),"test");

	lp_config_set_string(conf, "test", "non_zero_len", ""); /* should remove "non_zero_len" */
	BC_ASSERT_STRING_EQUAL(lp_config_get_string(conf,"test","non_zero_len","LOL"), "LOL");

	linphone_core_manager_destroy(mgr);
	ms_free(xml_path);
}
コード例 #28
0
static void tls_certificate_failure(){
	LinphoneCoreManager* mgr;
	LinphoneCore *lc;
	char rootcapath[256];
	
	mgr=linphone_core_manager_new2("pauline_rc",FALSE);
	lc=mgr->lc;
	snprintf(rootcapath,sizeof(rootcapath), "%s/certificates/agent.pem", liblinphone_tester_file_prefix); /*bad root ca*/
	linphone_core_set_root_ca(mgr->lc,rootcapath);
	linphone_core_set_network_reachable(lc,TRUE);
	CU_ASSERT_TRUE(wait_for(mgr->lc,mgr->lc,&mgr->stat.number_of_LinphoneRegistrationFailed,1));
	linphone_core_set_root_ca(mgr->lc,NULL); /*no root ca*/
	linphone_core_refresh_registers(mgr->lc);
	CU_ASSERT_TRUE(wait_for(lc,lc,&mgr->stat.number_of_LinphoneRegistrationFailed,2));
	snprintf(rootcapath,sizeof(rootcapath), "%s/certificates/cacert.pem", liblinphone_tester_file_prefix); /*goot root ca*/
	linphone_core_set_root_ca(mgr->lc,rootcapath);
	linphone_core_refresh_registers(mgr->lc);
	CU_ASSERT_TRUE(wait_for(lc,lc,&mgr->stat.number_of_LinphoneRegistrationOk,1));
	CU_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationFailed,2);
	linphone_core_destroy(mgr->lc);
}
コード例 #29
0
/*the purpose of this test is to check that will not block the proxy config during SSL handshake for entire life in case of mistaken configuration*/
static void tls_with_non_tls_server(){
	LinphoneCoreManager *mgr;
	LinphoneProxyConfig* proxy_cfg;
	LinphoneAddress* addr;
	char tmp[256];
	LinphoneCore *lc;
	
	mgr=linphone_core_manager_new2( "marie_rc", 0);
	lc=mgr->lc;
	sal_set_transport_timeout(lc->sal,3000);
	linphone_core_get_default_proxy(lc,&proxy_cfg);
	linphone_proxy_config_edit(proxy_cfg);
	addr=linphone_address_new(linphone_proxy_config_get_addr(proxy_cfg));
	snprintf(tmp,sizeof(tmp),"sip:%s:%i;transport=tls"	,linphone_address_get_domain(addr)
			,(linphone_address_get_port(addr)>0?linphone_address_get_port(addr):5060));
	linphone_proxy_config_set_server_addr(proxy_cfg,tmp);
	linphone_proxy_config_done(proxy_cfg);
	linphone_address_destroy(addr);
	CU_ASSERT_TRUE(wait_for_until(lc,lc,&mgr->stat.number_of_LinphoneRegistrationFailed,1,5000));
	linphone_core_manager_destroy(mgr);
}
コード例 #30
0
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);
}