tester.c 36 KB
Newer Older
1
 /*
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 tester - liblinphone test suite
 Copyright (C) 2013  Belledonne Communications SARL

 This program is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <stdio.h>
20
#include <stdlib.h>
21
#include "linphone/core.h"
22
#include "liblinphone_tester.h"
23
#include <bctoolbox/tester.h>
Benjamin REIS's avatar
Benjamin REIS committed
24
#include "tester_utils.h"
25

26 27 28
#if _WIN32
#define unlink _unlink
#endif
29

30

31
static int liblinphone_tester_keep_accounts_flag = 0;
32 33 34
static bool_t liblinphone_tester_keep_record_files = FALSE;
static bool_t liblinphone_tester_leak_detector_disabled = FALSE;
bool_t liblinphone_tester_keep_uuid = FALSE;
35
bool_t liblinphone_tester_tls_support_disabled = FALSE;
36
int manager_count = 0;
37
int leaked_objects_count = 0;
38 39
const MSAudioDiffParams audio_cmp_params = {10,2000};

40 41 42
const char* test_domain="sipopen.example.org";
const char* auth_domain="sip.example.org";
const char* test_username="liblinphone_tester";
43
const char* test_sha_username="liblinphone_sha_tester";
44 45 46
const char* test_password="secret";
const char* test_route="sip2.linphone.org";
const char *userhostsfile = "tester_hosts";
47 48
bool_t liblinphonetester_ipv6 = TRUE;
bool_t liblinphonetester_show_account_manager_logs = FALSE;
49 50 51
int liblinphonetester_transport_timeout = 9000; /*milliseconds. it is set to such low value to workaround a problem with our Freebox v6 when connecting to Ipv6 addresses.
			It was found that the freebox sometimes block SYN-ACK packets, which prevents connection to be succesful.
			Thanks to the timeout, it will fallback to IPv4*/
52

53 54
const char *liblinphone_tester_mire_id="Mire: Mire (synthetic moving picture)";

55
static void network_reachable(LinphoneCore *lc, bool_t reachable) {
56 57 58 59 60 61 62 63
	stats* counters;
	ms_message("Network reachable [%s]",reachable?"TRUE":"FALSE");
	counters = get_stats(lc);
	if (reachable)
		counters->number_of_NetworkReachableTrue++;
	else
		counters->number_of_NetworkReachableFalse++;
}
64 65 66 67 68 69 70 71 72 73 74 75
void liblinphone_tester_clock_start(MSTimeSpec *start){
	ms_get_cur_time(start);
}

bool_t liblinphone_tester_clock_elapsed(const MSTimeSpec *start, int value_ms){
	MSTimeSpec current;
	ms_get_cur_time(&current);
	if ((((current.tv_sec-start->tv_sec)*1000LL) + ((current.tv_nsec-start->tv_nsec)/1000000LL))>=value_ms)
		return TRUE;
	return FALSE;
}

76

77
LinphoneAddress * create_linphone_address(const char * domain) {
78 79 80 81
	return create_linphone_address_for_algo(domain,NULL);
}

LinphoneAddress * create_linphone_address_for_algo(const char * domain, const char* username) {
82 83 84 85 86 87 88 89 90 91 92 93 94 95
	LinphoneAddress *addr = linphone_address_new(NULL);
	if (!BC_ASSERT_PTR_NOT_NULL(addr)) return NULL;
	/* For clients who support different algorithms, their usernames must be differnet for having diffrent forms of password */
	if (username) linphone_address_set_username(addr,username);
	else linphone_address_set_username(addr,test_username);
	if (username) BC_ASSERT_STRING_EQUAL(username, linphone_address_get_username(addr));
	else BC_ASSERT_STRING_EQUAL(test_username, linphone_address_get_username(addr));
	if (!domain) domain = test_route;
	linphone_address_set_domain(addr,domain);
	BC_ASSERT_STRING_EQUAL(domain, linphone_address_get_domain(addr));
	linphone_address_set_display_name(addr, NULL);
	linphone_address_set_display_name(addr, "Mr Tester");
	BC_ASSERT_STRING_EQUAL("Mr Tester", linphone_address_get_display_name(addr));
	return addr;
96 97
}

98
static void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username, const char *domain) {
99
	stats* counters;
100
	ms_message("Auth info requested  for user id [%s] at realm [%s]\n", username, realm);
101 102 103 104 105
	counters = get_stats(lc);
	counters->number_of_auth_info_requested++;
}

void reset_counters( stats* counters) {
106
	if (counters->last_received_chat_message) linphone_chat_message_unref(counters->last_received_chat_message);
107
	if (counters->last_received_info_message) linphone_info_message_unref(counters->last_received_info_message);
108 109 110
	memset(counters,0,sizeof(stats));
}

111 112 113
LinphoneCore *configure_lc_from(LinphoneCoreCbs *cbs, const char *path, const char *file, void *user_data) {
	LinphoneCore *lc;
	LinphoneConfig *config = NULL;
114 115 116 117 118 119
	char *filepath         = NULL;
	char *ringpath         = NULL;
	char *ringbackpath     = NULL;
	char *rootcapath       = NULL;
	char *dnsuserhostspath = NULL;
	char *nowebcampath     = NULL;
120

121 122
	if (!path)
		path = ".";
123 124

	if (file){
125 126
		filepath = bctbx_strdup_printf("%s/%s", path, file);
		if (bctbx_file_exist(filepath) != 0) {
127 128
			ms_fatal("Could not find file %s in path %s, did you configured resources directory correctly?", file, path);
		}
129
		config = lp_config_new_with_factory(NULL, filepath);
130 131
	}

132 133 134 135 136
	// setup dynamic-path assets
	ringpath         = ms_strdup_printf("%s/sounds/oldphone.wav",path);
	ringbackpath     = ms_strdup_printf("%s/sounds/ringback.wav", path);
	nowebcampath     = ms_strdup_printf("%s/images/nowebcamCIF.jpg", path);
	rootcapath       = ms_strdup_printf("%s/certificates/cn/cafile.pem", path);
137
	dnsuserhostspath = userhostsfile[0]=='/' ? ms_strdup(userhostsfile) : ms_strdup_printf("%s/%s", path, userhostsfile);
138

139
	if (config) {
140 141 142
		lp_config_set_string(config, "sound", "remote_ring", ringbackpath);
		lp_config_set_string(config, "sound", "local_ring" , ringpath);
		lp_config_set_string(config, "sip",   "root_ca"    , rootcapath);
143
		lc = linphone_factory_create_core_with_config_3(linphone_factory_get(), config, NULL);
144
	} else {
145
		lc = linphone_factory_create_core_3(linphone_factory_get(), NULL, (filepath && (filepath[0] != '\0')) ? filepath : NULL, NULL);
146 147 148 149
		linphone_core_set_ring(lc, ringpath);
		linphone_core_set_ringback(lc, ringbackpath);
		linphone_core_set_root_ca(lc,rootcapath);
	}
150 151 152
	linphone_core_set_user_data(lc, user_data);
	if (cbs)
		linphone_core_add_callbacks(lc, cbs);
153

154
	linphone_core_enable_ipv6(lc, liblinphonetester_ipv6);
155
	linphone_core_set_sip_transport_timeout(lc, liblinphonetester_transport_timeout);
156

157 158
	sal_enable_test_features(linphone_core_get_sal(lc),TRUE);
	sal_set_dns_user_hosts_file(linphone_core_get_sal(lc), dnsuserhostspath);
159
#ifdef VIDEO_ENABLED
160
	linphone_core_set_static_picture(lc,nowebcampath);
161
#endif
162 163 164 165 166 167 168

	ms_free(ringpath);
	ms_free(ringbackpath);
	ms_free(nowebcampath);
	ms_free(rootcapath);
	ms_free(dnsuserhostspath);

169 170
	if (filepath)
		bctbx_free(filepath);
171

172 173
	if (config)
		linphone_config_unref(config);
174

175 176 177 178 179
	return lc;
}


bool_t wait_for_until(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value,int timout) {
180
	bctbx_list_t* lcs=NULL;
181 182
	bool_t result;
	if (lc_1)
183
		lcs=bctbx_list_append(lcs,lc_1);
184
	if (lc_2)
185
		lcs=bctbx_list_append(lcs,lc_2);
186
	result=wait_for_list(lcs,counter,value,timout);
187
	bctbx_list_free(lcs);
188 189 190 191
	return result;
}

bool_t wait_for(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value) {
192
	return wait_for_until(lc_1, lc_2,counter,value,10000);
193 194
}

195 196
bool_t wait_for_list(bctbx_list_t* lcs,int* counter,int value,int timeout_ms) {
	bctbx_list_t* iterator;
197
	MSTimeSpec start;
198

199 200 201 202 203
	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));
		}
204
#ifdef LINPHONE_WINDOWS_DESKTOP
205 206 207 208 209 210 211 212
		{
			MSG msg;
			while (PeekMessage(&msg, NULL, 0, 0,1)){
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
#endif
213
		ms_usleep(20000);
214 215 216 217 218
	}
	if(counter && *counter<value) return FALSE;
	else return TRUE;
}

219 220 221 222
bool_t wait_for_stun_resolution(LinphoneCoreManager *m) {
	MSTimeSpec start;
	int timeout_ms = 10000;
	liblinphone_tester_clock_start(&start);
Ghislain MARY's avatar
Ghislain MARY committed
223
	while (linphone_core_get_stun_server_addrinfo(m->lc) == NULL && !liblinphone_tester_clock_elapsed(&start,timeout_ms)) {
224 225 226
		linphone_core_iterate(m->lc);
		ms_usleep(20000);
	}
Ghislain MARY's avatar
Ghislain MARY committed
227
	return linphone_core_get_stun_server_addrinfo(m->lc) != NULL;
228 229
}

230
static void set_codec_enable(LinphoneCore* lc,const char* type,int rate,bool_t enable) {
231 232
	bctbx_list_t* codecs=bctbx_list_copy(linphone_core_get_audio_codecs(lc));
	bctbx_list_t* codecs_it;
233 234
	PayloadType* pt;
	for (codecs_it=codecs;codecs_it!=NULL;codecs_it=codecs_it->next) {
235
		linphone_core_enable_payload_type(lc,(PayloadType*)codecs_it->data,0);
236
	}
237
	if ((pt = linphone_core_find_payload_type(lc,type,rate,1))) {
238 239
		linphone_core_enable_payload_type(lc,pt, enable);
	}
240
	bctbx_list_free(codecs);
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
}

static void enable_codec(LinphoneCore* lc,const char* type,int rate) {
	set_codec_enable(lc,type,rate,TRUE);
}
stats * get_stats(LinphoneCore *lc){
	LinphoneCoreManager *manager=(LinphoneCoreManager *)linphone_core_get_user_data(lc);
	return &manager->stat;
}

LinphoneCoreManager *get_manager(LinphoneCore *lc){
	LinphoneCoreManager *manager=(LinphoneCoreManager *)linphone_core_get_user_data(lc);
	return manager;
}

256
bool_t transport_supported(LinphoneTransportType transport) {
257 258 259 260 261 262 263 264 265
	if ((transport == LinphoneTransportDtls || transport == LinphoneTransportTls) && liblinphone_tester_tls_support_disabled == TRUE) {
		return FALSE;
	} else {
		Sal *sal = sal_init(NULL);
		bool_t supported = sal_transport_available(sal,(SalTransport)transport);
		if (!supported) ms_message("TLS transport not supported, falling back to TCP if possible otherwise skipping test.");
		sal_uninit(sal);
		return  supported;
	}
266 267
}

268
void linphone_core_manager_configure (LinphoneCoreManager *mgr) {
269
	LinphoneImNotifPolicy *im_notif_policy;
jehan's avatar
jehan committed
270
	char *hellopath = bc_tester_res("sounds/hello8000.wav");
271

272
	mgr->lc = configure_lc_from(mgr->cbs, bc_tester_get_resource_dir_prefix(), mgr->rc_path, mgr);
273
	linphone_core_manager_check_accounts(mgr);
274
	im_notif_policy = linphone_core_get_im_notif_policy(mgr->lc);
275 276 277 278 279 280
	if (im_notif_policy != NULL) {
		/* The IM notification policy can be NULL at this point in case of remote provisioning. */
		linphone_im_notif_policy_clear(im_notif_policy);
		linphone_im_notif_policy_set_send_is_composing(im_notif_policy, TRUE);
		linphone_im_notif_policy_set_recv_is_composing(im_notif_policy, TRUE);
	}
281

Guillaume BIENKOWSKI's avatar
Guillaume BIENKOWSKI committed
282
#if TARGET_OS_IPHONE
283 284
	linphone_core_set_ringer_device( mgr->lc, "AQ: Audio Queue Device");
	linphone_core_set_ringback(mgr->lc, NULL);
285 286
#elif __QNX__
	linphone_core_set_playback_device(mgr->lc, "QSA: voice");
287 288
#endif

289 290 291 292
#ifdef VIDEO_ENABLED
	{
		MSWebCam *cam;

293
		cam = ms_web_cam_manager_get_cam(ms_factory_get_web_cam_manager(linphone_core_get_ms_factory(mgr->lc)), "Mire: Mire (synthetic moving picture)");
294 295

		if (cam == NULL) {
Simon Morlat's avatar
Simon Morlat committed
296 297 298
			MSWebCamDesc *desc = ms_mire_webcam_desc_get();
			if (desc){
				cam=ms_web_cam_new(desc);
299
				ms_web_cam_manager_add_cam(ms_factory_get_web_cam_manager(linphone_core_get_ms_factory(mgr->lc)), cam);
Simon Morlat's avatar
Simon Morlat committed
300
			}
301 302 303 304
		}
	}
#endif

jehan's avatar
jehan committed
305

306 307
	linphone_core_set_play_file(mgr->lc,hellopath); /*is also used when in pause*/
	ms_free(hellopath);
308

309
	if( manager_count >= 2){
310
		char *recordpath = ms_strdup_printf("%s/record_for_lc_%p.wav",bc_tester_get_writable_dir_prefix(),mgr->lc);
311
		ms_message("Manager for '%s' using files", mgr->rc_path ? mgr->rc_path : "--");
312
		linphone_core_set_use_files(mgr->lc, TRUE);
313 314
		linphone_core_set_record_file(mgr->lc,recordpath);
		ms_free(recordpath);
315
	}
316

317
	linphone_core_set_user_certificates_path(mgr->lc,bc_tester_get_writable_dir_prefix());
318
	/*for now, we need the periodical updates facility to compute bandwidth measurements correctly during tests*/
319
	linphone_core_enable_send_call_stats_periodical_updates(mgr->lc, TRUE);
320

321
	LinphoneConfig *config = linphone_core_get_config(mgr->lc);
322 323 324
	linphone_config_set_string(config, "storage", "backend", "sqlite3");
	linphone_config_set_string(config, "storage", "uri", mgr->database_path);
}
325

326
static void generate_random_database_path (LinphoneCoreManager *mgr) {
327 328 329 330 331 332 333
	char random_id[32];
	belle_sip_random_token(random_id, sizeof random_id);
	char *database_path_format = bctbx_strdup_printf("linphone_%s.db", random_id);
	mgr->database_path = bc_tester_file(database_path_format);
	bctbx_free(database_path_format);
}

334 335 336 337 338 339 340 341 342 343
#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
#pragma GCC diagnostic push
#endif
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#else
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
void linphone_core_manager_init(LinphoneCoreManager *mgr, const char* rc_file, const char* phone_alias) {
	mgr->number_of_bcunit_error_at_creation =  bc_get_number_of_failures();
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362
	mgr->cbs = linphone_factory_create_core_cbs(linphone_factory_get());
	linphone_core_cbs_set_registration_state_changed(mgr->cbs, registration_state_changed);
	linphone_core_cbs_set_auth_info_requested(mgr->cbs, auth_info_requested);
	linphone_core_cbs_set_call_state_changed(mgr->cbs, call_state_changed);
	linphone_core_cbs_set_message_received(mgr->cbs, message_received);
	linphone_core_cbs_set_is_composing_received(mgr->cbs, is_composing_received);
	linphone_core_cbs_set_new_subscription_requested(mgr->cbs, new_subscription_requested);
	linphone_core_cbs_set_notify_presence_received(mgr->cbs, notify_presence_received);
	linphone_core_cbs_set_notify_presence_received_for_uri_or_tel(mgr->cbs, notify_presence_received_for_uri_or_tel);
	linphone_core_cbs_set_transfer_state_changed(mgr->cbs, linphone_transfer_state_changed);
	linphone_core_cbs_set_info_received(mgr->cbs, info_message_received);
	linphone_core_cbs_set_subscription_state_changed(mgr->cbs, linphone_subscription_state_change);
	linphone_core_cbs_set_notify_received(mgr->cbs, linphone_notify_received);
	linphone_core_cbs_set_publish_state_changed(mgr->cbs, linphone_publish_state_changed);
	linphone_core_cbs_set_configuring_status(mgr->cbs, linphone_configuration_status);
	linphone_core_cbs_set_call_encryption_changed(mgr->cbs, linphone_call_encryption_changed);
	linphone_core_cbs_set_network_reachable(mgr->cbs, network_reachable);
	linphone_core_cbs_set_dtmf_received(mgr->cbs, dtmf_received);
	linphone_core_cbs_set_call_stats_updated(mgr->cbs, call_stats_updated);
363 364 365 366

	mgr->phone_alias = phone_alias ? ms_strdup(phone_alias) : NULL;

	reset_counters(&mgr->stat);
367
	if (rc_file) mgr->rc_path = ms_strdup_printf("rcfiles/%s", rc_file);
368 369 370

	manager_count++;

371
	generate_random_database_path(mgr);
372
	linphone_core_manager_configure(mgr);
373
}
374 375 376
#if __clang__ || ((__GNUC__ == 4 && __GNUC_MINOR__ >= 6) || __GNUC__ > 4)
#pragma GCC diagnostic pop
#endif
Guillaume BIENKOWSKI's avatar
Guillaume BIENKOWSKI committed
377

378
void linphone_core_manager_start(LinphoneCoreManager *mgr, bool_t check_for_proxies) {
379 380
	LinphoneProxyConfig* proxy;
	int proxy_count;
381

382 383
	linphone_core_start(mgr->lc);

384
	/*BC_ASSERT_EQUAL(bctbx_list_size(linphone_core_get_proxy_config_list(lc)),proxy_count, int, "%d");*/
385
	if (check_for_proxies){ /**/
386
		proxy_count=(int)bctbx_list_size(linphone_core_get_proxy_config_list(mgr->lc));
387
	}else{
388
		proxy_count=0;
389 390 391
		/*this is to prevent registration to go on*/
		linphone_core_set_network_reachable(mgr->lc, FALSE);
	}
392

393 394 395
	if (proxy_count){
#define REGISTER_TIMEOUT 20 /* seconds */
		int success = wait_for_until(mgr->lc,NULL,&mgr->stat.number_of_LinphoneRegistrationOk,
Guillaume BIENKOWSKI's avatar
Guillaume BIENKOWSKI committed
396
									proxy_count,(REGISTER_TIMEOUT * 1000 * proxy_count));
397 398 399 400
		if( !success ){
			ms_error("Did not register after %d seconds for %d proxies", REGISTER_TIMEOUT, proxy_count);
		}
	}
401
	BC_ASSERT_EQUAL(mgr->stat.number_of_LinphoneRegistrationOk,proxy_count, int, "%d");
402 403
	enable_codec(mgr->lc,"PCMU",8000);

404
	proxy = linphone_core_get_default_proxy_config(mgr->lc);
405
	if (proxy) {
406
		if (mgr->identity){
Simon Morlat's avatar
Simon Morlat committed
407
			linphone_address_unref(mgr->identity);
408
		}
409
		mgr->identity = linphone_address_clone(linphone_proxy_config_get_identity_address(proxy));
410 411
		linphone_address_clean(mgr->identity);
	}
412

413
	linphone_core_manager_wait_for_stun_resolution(mgr);
414 415 416 417
	if (!check_for_proxies){
		/*now that stun server resolution is done, we can start registering*/
		linphone_core_set_network_reachable(mgr->lc, TRUE);
	}
418

419 420
}

421
LinphoneCoreManager* linphone_core_manager_create2(const char* rc_file, const char* phone_alias) {
422
	LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1);
423
	linphone_core_manager_init(manager, rc_file, phone_alias);
424 425 426 427 428 429 430
	return manager;
}

LinphoneCoreManager* linphone_core_manager_create(const char* rc_file) {
	return linphone_core_manager_create2(rc_file, NULL);
}

431
LinphoneCoreManager* linphone_core_manager_new3(const char* rc_file, bool_t check_for_proxies, const char* phone_alias) {
432
	LinphoneCoreManager *manager = linphone_core_manager_create2(rc_file, phone_alias);
433
	linphone_core_manager_start(manager, check_for_proxies);
434 435 436
	return manager;
}

437
LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, bool_t check_for_proxies) {
438
	return linphone_core_manager_new3(rc_file, check_for_proxies, NULL);
439 440
}

441 442 443 444 445
LinphoneCoreManager* linphone_core_manager_new( const char* rc_file) {
	return linphone_core_manager_new2(rc_file, TRUE);
}


446 447
void linphone_core_manager_stop(LinphoneCoreManager *mgr){
	if (mgr->lc) {
448
		const char *record_file = linphone_core_get_record_file(mgr->lc);
449
		if (!liblinphone_tester_keep_record_files && record_file && ortp_file_exist(record_file)==0) {
450 451 452 453 454 455 456
			if ((bc_get_number_of_failures() - mgr->number_of_bcunit_error_at_creation)>0) {
				ms_error("Test has failed, keeping recorded file [%s]", record_file);
			}
			else {
				unlink(record_file);
			}
		}
457
		linphone_core_unref(mgr->lc);
458
		mgr->lc = NULL;
459 460 461
	}
}

462 463
void linphone_core_manager_reinit(LinphoneCoreManager *mgr) {
	char *uuid = NULL;
464
	if (mgr->lc) {
465 466
		if (lp_config_get_string(linphone_core_get_config(mgr->lc), "misc", "uuid", NULL))
			uuid = bctbx_strdup(lp_config_get_string(linphone_core_get_config(mgr->lc), "misc", "uuid", NULL));
467
		linphone_core_unref(mgr->lc);
468
	}
469 470
	linphone_core_manager_configure(mgr);
	reset_counters(&mgr->stat);
471 472
	// Make sure gruu is preserved
	lp_config_set_string(linphone_core_get_config(mgr->lc), "misc", "uuid", uuid);
473
	if (uuid)
474
		bctbx_free(uuid);
475 476 477
}

void linphone_core_manager_restart(LinphoneCoreManager *mgr, bool_t check_for_proxies) {
478
	linphone_core_manager_reinit(mgr);
479 480 481
	linphone_core_manager_start(mgr, check_for_proxies);
}

482
void linphone_core_manager_uninit(LinphoneCoreManager *mgr) {
483
	int old_log_level = linphone_core_get_log_level_mask();
484
	linphone_core_set_log_level(ORTP_ERROR);
485 486 487
	if (mgr->phone_alias) {
		ms_free(mgr->phone_alias);
	}
488 489 490
	if (mgr->stat.last_received_chat_message) {
		linphone_chat_message_unref(mgr->stat.last_received_chat_message);
	}
491
	if (mgr->stat.last_received_info_message) linphone_info_message_unref(mgr->stat.last_received_info_message);
492
	if (mgr->identity) {
Simon Morlat's avatar
Simon Morlat committed
493
		linphone_address_unref(mgr->identity);
494
	}
495
	if (mgr->rc_path)
Ghislain MARY's avatar
Ghislain MARY committed
496
		bctbx_free(mgr->rc_path);
497 498 499 500 501
	if (mgr->database_path) {
		unlink(mgr->database_path);
		bctbx_free(mgr->database_path);
	}

502 503
	if (mgr->cbs)
		linphone_core_cbs_unref(mgr->cbs);
504

505
	manager_count--;
506
	linphone_core_set_log_level(old_log_level);
507
}
508

509 510 511 512 513 514 515 516 517 518
void linphone_core_manager_wait_for_stun_resolution(LinphoneCoreManager *mgr) {
	LinphoneNatPolicy *nat_policy = linphone_core_get_nat_policy(mgr->lc);
	if ((nat_policy != NULL) && (linphone_nat_policy_get_stun_server(nat_policy) != NULL) &&
		(linphone_nat_policy_stun_enabled(nat_policy) || linphone_nat_policy_turn_enabled(nat_policy)) &&
		(linphone_nat_policy_ice_enabled(nat_policy))) {
		/*before we go, ensure that the stun server is resolved, otherwise all ice related test will fail*/
		BC_ASSERT_TRUE(wait_for_stun_resolution(mgr));
	}
}

519
void linphone_core_manager_destroy(LinphoneCoreManager* mgr) {
520
	linphone_core_manager_stop(mgr);
521
	linphone_core_manager_uninit(mgr);
522 523 524
	ms_free(mgr);
}

525 526 527 528 529 530
void linphone_core_manager_delete_chat_room (LinphoneCoreManager *mgr, LinphoneChatRoom *cr, bctbx_list_t *coresList) {
	stats mgrStats = mgr->stat;
	linphone_core_delete_chat_room(mgr->lc, cr);
	BC_ASSERT_TRUE(wait_for_list(coresList, &mgr->stat.number_of_LinphoneChatRoomStateDeleted, mgrStats.number_of_LinphoneChatRoomStateDeleted + 1, 10000));
}

531
int liblinphone_tester_ipv6_available(void){
532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
	if (liblinphonetester_ipv6) {
		struct addrinfo *ai=bctbx_ip_address_to_addrinfo(AF_INET6,SOCK_STREAM,"2a01:e00::2",53);
		if (ai){
			struct sockaddr_storage ss;
			struct addrinfo src;
			socklen_t slen=sizeof(ss);
			char localip[128];
			int port=0;
			belle_sip_get_src_addr_for(ai->ai_addr,(socklen_t)ai->ai_addrlen,(struct sockaddr*) &ss,&slen,4444);
			src.ai_addr=(struct sockaddr*) &ss;
			src.ai_addrlen=slen;
			bctbx_addrinfo_to_ip_address(&src,localip, sizeof(localip),&port);
			freeaddrinfo(ai);
			return strcmp(localip,"::1")!=0;
		}
547 548 549 550
	}
	return FALSE;
}

551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569
int liblinphone_tester_ipv4_available(void){
	struct addrinfo *ai=bctbx_ip_address_to_addrinfo(AF_INET,SOCK_STREAM,"212.27.40.240",53);
	if (ai){
		struct sockaddr_storage ss;
		struct addrinfo src;
		socklen_t slen=sizeof(ss);
		char localip[128];
		int port=0;
		belle_sip_get_src_addr_for(ai->ai_addr,(socklen_t)ai->ai_addrlen,(struct sockaddr*) &ss,&slen,4444);
		src.ai_addr=(struct sockaddr*) &ss;
		src.ai_addrlen=slen;
		bctbx_addrinfo_to_ip_address(&src,localip, sizeof(localip),&port);
		freeaddrinfo(ai);
		return strcmp(localip,"127.0.0.1")!=0;
	}
	return FALSE;
}


570 571 572 573
void liblinphone_tester_keep_accounts( int keep ){
	liblinphone_tester_keep_accounts_flag = keep;
}

574 575 576 577
void liblinphone_tester_keep_recorded_files(int keep){
	liblinphone_tester_keep_record_files = keep;
}

578 579 580 581
void liblinphone_tester_disable_leak_detector(int disabled){
	liblinphone_tester_leak_detector_disabled = disabled;
}

582 583 584
void liblinphone_tester_clear_accounts(void){
	account_manager_destroy();
}
585 586 587 588

void liblinphone_tester_add_suites() {
	bc_tester_add_suite(&setup_test_suite);
	bc_tester_add_suite(&register_test_suite);
589
	bc_tester_add_suite(&tunnel_test_suite);
590 591
	bc_tester_add_suite(&offeranswer_test_suite);
	bc_tester_add_suite(&call_test_suite);
592
	bc_tester_add_suite(&call_video_test_suite);
593
	bc_tester_add_suite(&audio_bypass_suite);
594 595 596
	bc_tester_add_suite(&multi_call_test_suite);
	bc_tester_add_suite(&message_test_suite);
	bc_tester_add_suite(&presence_test_suite);
597
	bc_tester_add_suite(&presence_server_test_suite);
Erwan Croze's avatar
Erwan Croze committed
598
	bc_tester_add_suite(&account_creator_test_suite);
599 600
	bc_tester_add_suite(&stun_test_suite);
	bc_tester_add_suite(&event_test_suite);
601
	bc_tester_add_suite(&conference_event_test_suite);
602
	bc_tester_add_suite(&content_manager_test_suite);
603 604 605 606 607 608
	bc_tester_add_suite(&flexisip_test_suite);
	bc_tester_add_suite(&remote_provisioning_test_suite);
	bc_tester_add_suite(&quality_reporting_test_suite);
	bc_tester_add_suite(&log_collection_test_suite);
	bc_tester_add_suite(&player_test_suite);
	bc_tester_add_suite(&dtmf_test_suite);
Ronan's avatar
Ronan committed
609
	bc_tester_add_suite(&cpim_test_suite);
610
	bc_tester_add_suite(&multipart_test_suite);
611
	bc_tester_add_suite(&clonable_object_test_suite);
Ronan's avatar
Ronan committed
612
	bc_tester_add_suite(&main_db_test_suite);
613
	bc_tester_add_suite(&property_container_test_suite);
614 615 616
	#ifdef VIDEO_ENABLED
		bc_tester_add_suite(&video_test_suite);
	#endif // ifdef VIDEO_ENABLED
Ghislain MARY's avatar
Ghislain MARY committed
617
	bc_tester_add_suite(&multicast_call_test_suite);
618
	bc_tester_add_suite(&proxy_config_test_suite);
jehan's avatar
jehan committed
619 620 621
#if HAVE_SIPP
	bc_tester_add_suite(&complex_sip_call_test_suite);
#endif
622
#ifdef VCARD_ENABLED
623
	bc_tester_add_suite(&vcard_test_suite);
624
#endif
625
	bc_tester_add_suite(&group_chat_test_suite);
626
}
627

628
static int linphone_core_manager_get_max_audio_bw_base(const int array[],int array_size) {
629 630 631 632 633 634 635
	int i,result=0;
	for (i=0; i<array_size; i++) {
		result = MAX(result,array[i]);
	}
	return result;
}

636 637 638 639 640 641 642 643
static int linphone_core_manager_get_mean_audio_bw_base(const int array[],int array_size) {
	int i,result=0;
	for (i=0; i<array_size; i++) {
		result += array[i];
	}
	return result/array_size;
}

644 645 646 647 648 649 650 651
int linphone_core_manager_get_max_audio_down_bw(const LinphoneCoreManager *mgr) {
	return linphone_core_manager_get_max_audio_bw_base(mgr->stat.audio_download_bandwidth
			, sizeof(mgr->stat.audio_download_bandwidth)/sizeof(int));
}
int linphone_core_manager_get_max_audio_up_bw(const LinphoneCoreManager *mgr) {
	return linphone_core_manager_get_max_audio_bw_base(mgr->stat.audio_upload_bandwidth
			, sizeof(mgr->stat.audio_upload_bandwidth)/sizeof(int));
}
652

653 654 655 656 657 658 659 660 661
int linphone_core_manager_get_mean_audio_down_bw(const LinphoneCoreManager *mgr) {
	return linphone_core_manager_get_mean_audio_bw_base(mgr->stat.audio_download_bandwidth
			, sizeof(mgr->stat.audio_download_bandwidth)/sizeof(int));
}
int linphone_core_manager_get_mean_audio_up_bw(const LinphoneCoreManager *mgr) {
	return linphone_core_manager_get_mean_audio_bw_base(mgr->stat.audio_upload_bandwidth
			, sizeof(mgr->stat.audio_upload_bandwidth)/sizeof(int));
}

662
void liblinphone_tester_before_each(void) {
663 664 665 666
	if (!liblinphone_tester_leak_detector_disabled){
		belle_sip_object_enable_leak_detector(TRUE);
		leaked_objects_count = belle_sip_object_get_object_count();
	}
667 668
}

669 670
static char* all_leaks_buffer = NULL;

671
void liblinphone_tester_after_each(void) {
Simon Morlat's avatar
Simon Morlat committed
672
	linphone_factory_clean();
673 674 675
	if (!liblinphone_tester_leak_detector_disabled){
		int leaked_objects = belle_sip_object_get_object_count() - leaked_objects_count;
		if (leaked_objects > 0) {
676
			char* format = ms_strdup_printf("%d object%s leaked in suite [%s] test [%s], please fix that!",
677
											leaked_objects, leaked_objects>1?"s were":" was",
678
											bc_tester_current_suite_name(), bc_tester_current_test_name());
679
			belle_sip_object_dump_active_objects();
680
			belle_sip_object_flush_active_objects();
681
			bc_tester_printf(ORTP_MESSAGE, format);
682 683 684
			ms_error("%s", format);

			all_leaks_buffer = ms_strcat_printf(all_leaks_buffer, "\n%s", format);
Ghislain MARY's avatar
Ghislain MARY committed
685
			ms_free(format);
686
		}
687

688 689 690 691 692 693 694 695 696 697 698
		// prevent any future leaks
		{
			const char **tags = bc_tester_current_test_tags();
			int leaks_expected =
				(tags && ((tags[0] && !strcmp(tags[0], "LeaksMemory")) || (tags[1] && !strcmp(tags[1], "LeaksMemory"))));
			// if the test is NOT marked as leaking memory and it actually is, we should make it fail
			if (!leaks_expected && leaked_objects > 0) {
				BC_FAIL("This test is leaking memory!");
				// and reciprocally
			} else if (leaks_expected && leaked_objects == 0) {
				BC_FAIL("This test is not leaking anymore, please remove LeaksMemory tag!");
699
			}
700
		}
701 702
	}

703
	if (manager_count != 0) {
704
		ms_fatal("%d Linphone core managers are still alive!", manager_count);
705 706
	}
}
707

708 709 710
void liblinphone_tester_uninit(void) {
	// show all leaks that happened during the test
	if (all_leaks_buffer) {
711
		bc_tester_printf(ORTP_MESSAGE, all_leaks_buffer);
712
		ms_free(all_leaks_buffer);
713
		all_leaks_buffer = NULL;
714 715
	}
	bc_tester_uninit();
716
	bctbx_uninit_logger();
717
}
718

719
static void check_ice_from_rtp(LinphoneCall *c1, LinphoneCall *c2, LinphoneStreamType stream_type) {
720
	MediaStream *ms;
721
	LinphoneCallStats *stats;
722 723
	switch (stream_type) {
	case LinphoneStreamTypeAudio:
724
		ms=linphone_call_get_stream(c1, LinphoneStreamTypeAudio);
725
		break;
726
	case LinphoneStreamTypeVideo:
727
		ms=linphone_call_get_stream(c1, LinphoneStreamTypeVideo);
728 729
		break;
	case LinphoneStreamTypeText:
730
		ms=linphone_call_get_stream(c1, LinphoneStreamTypeText);
731 732 733 734 735
		break;
	default:
		ms_error("Unknown stream type [%s]",  linphone_stream_type_to_string(stream_type));
		BC_ASSERT_FALSE(stream_type >= LinphoneStreamTypeUnknown);
		return;
736
	}
737

738
	stats = linphone_call_get_audio_stats(c1);
739
	if (linphone_call_stats_get_ice_state(stats) == LinphoneIceStateHostConnection && media_stream_started(ms)) {
740 741 742 743 744 745
		struct sockaddr_storage remaddr;
		socklen_t remaddrlen = sizeof(remaddr);
		char ip[NI_MAXHOST] = { 0 };
		int port = 0;
		SalMediaDescription *result_desc;
		char *expected_addr = NULL;
746
		AudioStream *astream;
747 748 749

		const LinphoneCallParams *cp1 = linphone_call_get_current_params(c1);
		const LinphoneCallParams *cp2 = linphone_call_get_current_params(c2);
750
		if (linphone_call_params_get_update_call_when_ice_completed(cp1) && linphone_call_params_get_update_call_when_ice_completed(cp2)) {
751
			memset(&remaddr, 0, remaddrlen);
752
			result_desc = sal_call_get_final_media_description(linphone_call_get_op_as_sal_op(c2));
753 754
			expected_addr = result_desc->streams[0].rtp_addr;
			if (expected_addr[0] == '\0') expected_addr = result_desc->addr;
755 756 757
			astream = (AudioStream *)linphone_call_get_stream(c1, LinphoneStreamTypeAudio);
			if ((strchr(expected_addr, ':') == NULL) && (astream->ms.sessions.rtp_session->rtp.gs.rem_addr.ss_family == AF_INET6)) {
				bctbx_sockaddr_ipv6_to_ipv4((struct sockaddr *)&astream->ms.sessions.rtp_session->rtp.gs.rem_addr, (struct sockaddr *)&remaddr, &remaddrlen);
758
			} else {
759
				memcpy(&remaddr, &astream->ms.sessions.rtp_session->rtp.gs.rem_addr, astream->ms.sessions.rtp_session->rtp.gs.rem_addrlen);
760 761 762 763 764
			}
			bctbx_sockaddr_to_ip_address((struct sockaddr *)&remaddr, remaddrlen, ip, sizeof(ip), &port);

			BC_ASSERT_STRING_EQUAL(ip, expected_addr);
		}
765
	}
766
	linphone_call_stats_unref(stats);
767
}
768

769 770
bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee, LinphoneIceState state) {
	LinphoneCall *c1,*c2;
771
	bool_t global_success = TRUE;
772 773 774
	bool_t audio_success=FALSE;
	bool_t video_success=FALSE;
	bool_t text_success=FALSE;
775
	bool_t audio_enabled, video_enabled, realtime_text_enabled;
776
	MSTimeSpec ts;
777

778 779
	c1=linphone_core_get_current_call(caller->lc);
	c2=linphone_core_get_current_call(callee->lc);
780

781 782 783 784 785
	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);
786

787 788
	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");
789
	audio_enabled=linphone_call_params_audio_enabled(linphone_call_get_current_params(c1));
790 791
	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));
792 793
	if (audio_enabled) {
		liblinphone_tester_clock_start(&ts);
Ghislain MARY's avatar
Ghislain MARY committed
794 795 796
		LinphoneCallStats *stats1 = NULL;
		LinphoneCallStats *stats2 = NULL;
		do {
797
			if ((c1 != NULL) && (c2 != NULL)) {
Ghislain MARY's avatar
Ghislain MARY committed
798 799
				stats1 = linphone_call_get_audio_stats(c1);
				stats2 = linphone_call_get_audio_stats(c2);
800 801
				if (linphone_call_stats_get_ice_state(stats1)==state &&
					linphone_call_stats_get_ice_state(stats2)==state){
802 803 804 805 806 807 808
					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);
Ghislain MARY's avatar
Ghislain MARY committed
809 810 811
				linphone_call_stats_unref(stats1);
				linphone_call_stats_unref(stats2);
				stats1 = stats2 = NULL;
812
			}
813
			ms_usleep(20000);
Ghislain MARY's avatar
Ghislain MARY committed
814 815 816 817 818
		} while (!liblinphone_tester_clock_elapsed(&ts,10000));
		if (stats1)
			linphone_call_stats_unref(stats1);
		if (stats2)
			linphone_call_stats_unref(stats2);
819
	}
820

821 822
	if (video_enabled){
		liblinphone_tester_clock_start(&ts);
823 824 825
		LinphoneCallStats *stats1 = NULL;
		LinphoneCallStats *stats2 = NULL;
		do {
826
			if ((c1 != NULL) && (c2 != NULL)) {
827 828
				stats1 = linphone_call_get_video_stats(c1);
				stats2 = linphone_call_get_video_stats(c2);
829 830
				if (linphone_call_stats_get_ice_state(stats1)==state &&
					linphone_call_stats_get_ice_state(stats2)==state){
831
					video_success=TRUE;
832 833
					check_ice_from_rtp(c1,c2,LinphoneStreamTypeVideo);
					check_ice_from_rtp(c2,c1,LinphoneStreamTypeVideo);
834 835 836 837
					break;
				}
				linphone_core_iterate(caller->lc);
				linphone_core_iterate(callee->lc);
838 839
				linphone_call_stats_unref(stats1);
				linphone_call_stats_unref(stats2);
840 841
			}
			ms_usleep(20000);
842 843 844 845 846
		} while (!liblinphone_tester_clock_elapsed(&ts,10000));
		if (stats1)
			linphone_call_stats_unref(stats1);
		if (stats2)
			linphone_call_stats_unref(stats2);
847
	}
848

849 850
	if (realtime_text_enabled){
		liblinphone_tester_clock_start(&ts);
851 852 853
		LinphoneCallStats *stats1 = NULL;
		LinphoneCallStats *stats2 = NULL;
		do {
854
			if ((c1 != NULL) && (c2 != NULL)) {
855 856
				stats1 = linphone_call_get_text_stats(c1);
				stats2 = linphone_call_get_text_stats(c2);
857 858
				if (linphone_call_stats_get_ice_state(stats1)==state &&
					linphone_call_stats_get_ice_state(stats2)==state){
859
					text_success=TRUE;
860 861
					check_ice_from_rtp(c1,c2,LinphoneStreamTypeText);
					check_ice_from_rtp(c2,c1,LinphoneStreamTypeText);
862 863 864 865
					break;
				}
				linphone_core_iterate(caller->lc);
				linphone_core_iterate(callee->lc);
866 867
				linphone_call_stats_unref(stats1);
				linphone_call_stats_unref(stats2);
868 869
			}
			ms_usleep(20000);
870 871 872 873 874
		} while (!liblinphone_tester_clock_elapsed(&ts,10000));
		if (stats1)
			linphone_call_stats_unref(stats1);
		if (stats2)
			linphone_call_stats_unref(stats2);
875
	}
876

877 878 879 880 881 882 883 884 885 886 887
	/*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);
888 889 890 891
	if (audio_enabled) global_success = global_success && audio_success;
	if (video_enabled) global_success = global_success && video_success;
	if (realtime_text_enabled) global_success = global_success && text_success;
	return global_success;
892 893
}

894
static void linphone_conference_server_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg) {
895 896
	LinphoneCoreCbs *cbs = linphone_core_get_current_callbacks(lc);
	LinphoneConferenceServer *conf_srv = (LinphoneConferenceServer *)linphone_core_cbs_get_user_data(cbs);
897

898 899
	switch(cstate) {
		case LinphoneCallIncomingReceived:
900
			linphone_call_accept(call);
901
			break;
902

903 904 905 906
		case LinphoneCallStreamsRunning:
			if(linphone_call_get_conference(call) == NULL) {
				linphone_core_add_to_conference(lc, call);
				linphone_core_leave_conference(lc);
907
				if(conf_srv->first_call == NULL) conf_srv->first_call = call;
908 909
			}
			break;
910

911 912
		case LinphoneCallEnd:
			if(call == conf_srv->first_call) {
913 914 915
				if(linphone_core_get_conference(lc)) {
					linphone_core_terminate_conference(lc);
				}
916 917 918
				conf_srv->first_call = NULL;
			}
			break;
919

920 921 922 923
		default: break;
	}
}

924
static void linphone_conference_server_refer_received(LinphoneCore *core, const char *refer_to) {
925 926 927 928
	char method[20];
	LinphoneAddress *refer_to_addr = linphone_address_new(refer_to);
	char *uri;
	LinphoneCall *call;
929

930 931 932 933 934 935
	if(refer_to_addr == NULL) return;
	strncpy(method, linphone_address_get_method_param(refer_to_addr), sizeof(method));
	if(strcmp(method, "BYE") == 0) {
		linphone_address_clean(refer_to_addr);
		uri = linphone_address_as_string_uri_only(refer_to_addr);
		call = linphone_core_find_call_from_uri(core, uri);
936
		if(call) linphone_call_terminate(call);
937 938
		ms_free(uri);
	}
Simon Morlat's avatar
Simon Morlat committed
939
	linphone_address_unref(refer_to_addr);
940
}
941

942 943 944 945 946 947
static void linphone_conference_server_registration_state_changed(
	LinphoneCore *core,
	LinphoneProxyConfig *cfg,
	LinphoneRegistrationState cstate,
	const char *message
) {
948 949
	LinphoneCoreCbs *cbs = linphone_core_get_current_callbacks(core);
	LinphoneConferenceServer *m = (LinphoneConferenceServer *)linphone_core_cbs_get_user_data(cbs);
950 951 952 953 954 955
	if(cfg == linphone_core_get_default_proxy_config(core)) {
		m->reg_state = cstate;
	}
}

LinphoneConferenceServer* linphone_conference_server_new(const char *rc_file, bool_t do_registration) {
956 957
	LinphoneConferenceServer *conf_srv = (LinphoneConferenceServer *)ms_new0(LinphoneConferenceServer, 1);
	LinphoneCoreManager *lm = (LinphoneCoreManager *)conf_srv;
jehan's avatar
jehan committed
958
	LinphoneProxyConfig *proxy;
959 960 961 962 963
	conf_srv->cbs = linphone_factory_create_core_cbs(linphone_factory_get());
	linphone_core_cbs_set_call_state_changed(conf_srv->cbs, linphone_conference_server_call_state_changed);
	linphone_core_cbs_set_refer_received(conf_srv->cbs, linphone_conference_server_refer_received);
	linphone_core_cbs_set_registration_state_changed(conf_srv->cbs, linphone_conference_server_registration_state_changed);
	linphone_core_cbs_set_user_data(conf_srv->cbs, conf_srv);
964
	conf_srv->reg_state = LinphoneRegistrationNone;
965
	linphone_core_manager_init(lm, rc_file,NULL);
jehan's avatar
jehan committed
966 967 968 969 970 971
	if (!do_registration) {
		proxy = linphone_core_get_default_proxy_config(lm->lc);
		linphone_proxy_config_edit(proxy);
		linphone_proxy_config_enable_register(proxy,FALSE);
		linphone_proxy_config_done(proxy);
	}
972
	linphone_core_add_callbacks(lm->lc, conf_srv->cbs);
973
	linphone_core_manager_start(lm, do_registration);
974 975
	return conf_srv;
}
976

977
void linphone_conference_server_destroy(LinphoneConferenceServer *conf_srv) {
978
	linphone_core_cbs_unref(conf_srv->cbs);
jehan's avatar
jehan committed
979
	linphone_core_manager_destroy((LinphoneCoreManager *)conf_srv);
980
}