test_ecc.c 1.95 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
linphone
Copyright (C) 2011 Belledonne Communications SARL
Author: Simon MORLAT (simon.morlat@linphone.org)

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, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#include "linphonecore.h"
#include "linphonecore_utils.h"
Sylvain Berfini's avatar
Sylvain Berfini committed
23 24 25
#if _MSC_VER
#include <io.h>
#endif
26

27 28 29 30
static void calibration_finished(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay, void *data) {
	ms_message("echo calibration finished %s.", status == LinphoneEcCalibratorDone ? "successfully" : "with faillure");
	if (status == LinphoneEcCalibratorDone)
		ms_message("Measured delay is %i", delay);
31 32
}

33
static char config_file[1024];
34
void parse_args(int argc, char *argv[]) {
Sylvain Berfini's avatar
Sylvain Berfini committed
35 36 37
#ifndef F_OK
#define F_OK 4
#endif
38
	if (argc != 3 || strncmp("-c", argv[1], 2) || access(argv[2], F_OK) != 0) {
39 40 41
		printf("Usage: test_ecc [-c config_file] where config_file will be written with the detected value\n");
		exit(-1);
	}
42
	strncpy(config_file, argv[2], 1024);
43 44
}

45 46 47
int main(int argc, char *argv[]) {
	int count = 0;
	LinphoneCoreVTable vtable = {0};
Sylvain Berfini's avatar
Sylvain Berfini committed
48
	LinphoneCore *lc;
49 50 51 52
	if (argc > 1)
		parse_args(argc, argv);
	lc = linphone_core_new(&vtable, config_file, NULL, NULL);

53 54
	linphone_core_enable_logs(NULL);

55 56 57
	linphone_core_start_echo_calibration(lc, calibration_finished, NULL, NULL, NULL);

	while (count++ < 1000) {
58 59 60 61 62 63
		linphone_core_iterate(lc);
		ms_usleep(10000);
	}
	linphone_core_destroy(lc);
	return 0;
}