Commit 5c30c2a3 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩
Browse files

Merge remote-tracking branch 'origin/belle-sip' into wp

Conflicts:
	coreapi/bellesip_sal/sal_impl.c
	coreapi/misc.c
	tester/call_tester.c
	tester/liblinphone_tester.c
parents ed4ef8a7 d4a36148
......@@ -419,8 +419,6 @@ AC_DEFINE_UNQUOTED(PACKAGE_SOUND_DIR, "${package_prefix}/${DATADIRNAME}/sounds/l
dnl check if we have the getifaddrs() sytem call
AC_CHECK_FUNCS(getifaddrs)
dnl check for osip2
LP_CHECK_OSIP2
dnl conditionnal build for ssl
AC_ARG_ENABLE(ssl,
......@@ -436,8 +434,6 @@ AC_ARG_ENABLE(ssl,
if test "$build_ssl" = "true"; then
PKG_CHECK_MODULES(OPENSSL, libssl >= 0.9.8)
fi
dnl setup flags for exosip library
LP_SETUP_EXOSIP
dnl check exosip support of DSCP in exosip
AC_MSG_CHECKING([for DSCP support in exosip])
......@@ -685,6 +681,10 @@ if test $USE_BELLESIP_TRUE !='#' ; then
SIPSTACK_LIBS=$BELLESIP_LIBS
AC_DEFINE(USE_BELLESIP,1,[Defined when bellesip is used])
else
dnl check for osip2
LP_CHECK_OSIP2
dnl setup flags for exosip library
LP_SETUP_EXOSIP
SIPSTACK_CFLAGS=$EXOSIP_CFLAGS $OSIP_CFLAGS
SIPSTACK_LIBS=$EXOSIP_LIBS $OSIP_LIBS
fi
......
......@@ -244,6 +244,8 @@ static LPC_COMMAND commands[] = {
"'firewall none' : use direct connection.\n"
"'firewall nat' : use nat address given with the 'nat' command.\n"
"'firewall stun' : use stun server given with the 'stun' command.\n"
"'firewall ice' : use ice.\n"
"'firewall upnp' : use uPnP IGD.\n"
},
{ "call-logs", lpc_cmd_call_logs, "Calls history", NULL },
{ "friend", lpc_cmd_friend, "Manage friends",
......@@ -850,6 +852,10 @@ lpc_cmd_firewall(LinphoneCore *lc, char *args)
{
linphone_core_set_firewall_policy(lc,LinphonePolicyNoFirewall);
}
else if (strcmp(args,"upnp")==0)
{
linphone_core_set_firewall_policy(lc,LinphonePolicyUseUpnp);
}
else if (strcmp(args,"ice")==0)
{
setting = linphone_core_get_stun_server(lc);
......
......@@ -181,6 +181,9 @@ static void process_request_event(void *sal, const belle_sip_request_event_t *ev
sal_op_set_remote_ua(op,BELLE_SIP_MESSAGE(req));
}
if (!op->base.call_id) {
op->base.call_id=ms_strdup(belle_sip_header_call_id_get_call_id(BELLE_SIP_HEADER_CALL_ID(belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(req), belle_sip_header_call_id_t))));
}
if (op->callbacks.process_request_event) {
op->callbacks.process_request_event(op,event);
} else {
......@@ -219,7 +222,9 @@ static void process_response_event(void *user_ctx, const belle_sip_response_even
if (!op->base.remote_ua) {
sal_op_set_remote_ua(op,BELLE_SIP_MESSAGE(response));
}
if (!op->base.call_id) {
op->base.call_id=ms_strdup(belle_sip_header_call_id_get_call_id(BELLE_SIP_HEADER_CALL_ID(belle_sip_message_get_header_by_type(BELLE_SIP_MESSAGE(response), belle_sip_header_call_id_t))));
}
if (op->callbacks.process_response_event) {
if (op->base.root->nat_helper_enabled) {
......@@ -378,7 +383,10 @@ Sal * sal_init(){
sal->nat_helper_enabled=TRUE;
snprintf(stack_string,sizeof(stack_string)-1,"(belle-sip/%s)",belle_sip_version_to_string());
sal->user_agent=belle_sip_header_user_agent_new();
belle_sip_header_user_agent_add_product(sal->user_agent, LINPHONE_PACKAGE_NAME "/" LINPHONE_VERSION);
#if defined(PACKAGE_NAME) && defined(LINPHONE_VERSION)
belle_sip_header_user_agent_add_product(sal->user_agent, PACKAGE_NAME "/" LINPHONE_VERSION);
#endif
belle_sip_header_user_agent_add_product(sal->user_agent,stack_string);
belle_sip_object_ref(sal->user_agent);
belle_sip_set_log_handler(_belle_sip_log);
......@@ -575,8 +583,8 @@ MSList * sal_get_pending_auths(Sal *sal){
/*misc*/
void sal_get_default_local_ip(Sal *sal, int address_family, char *ip, size_t iplen){
ms_fatal("sal_get_default_local_ip not implemented yet");
return ;
strncpy(ip,address_family==AF_INET6 ? "::1" : "127.0.0.1",iplen);
ms_error("Could not find default routable ip address !");
}
const char *sal_get_root_ca(Sal* ctx) {
......@@ -604,3 +612,9 @@ void sal_nat_helper_enable(Sal *sal,bool_t enable) {
bool_t sal_nat_helper_enabled(Sal *sal) {
return sal->nat_helper_enabled;
}
void sal_set_dns_timeout(Sal* sal,int timeout) {
belle_sip_stack_set_dns_timeout(sal->stack, timeout);
}
int sal_get_dns_timeout(const Sal* sal) {
return belle_sip_stack_get_dns_timeout(sal->stack);
}
......@@ -81,7 +81,14 @@ static int set_sdp_from_desc(belle_sip_message_t *msg, const SalMediaDescription
}
static void call_process_io_error(void *user_ctx, const belle_sip_io_error_event_t *event){
ms_error("call_process_io_error not implemented yet");
SalOp* op=(SalOp*)user_ctx;
if (!op->dialog) {
/*call terminated very early*/
op->base.root->callbacks.call_failure(op,SalErrorNoResponse,SalReasonUnknown,"Service Unavailable",503);
op->state=SalOpStateTerminated;
} else {
/*dialog will terminated shortly, nothing to do*/
}
}
static void process_dialog_terminated(void *ctx, const belle_sip_dialog_terminated_event_t *event) {
SalOp* op=(SalOp*)ctx;
......
......@@ -169,7 +169,7 @@ static int _sal_op_send_request_with_contact(SalOp* op, belle_sip_request_t* req
}
int sal_op_send_request(SalOp* op, belle_sip_request_t* request) {
bool_t need_ack=FALSE;
bool_t need_contact=FALSE;
/*
Header field where proxy ACK BYE CAN INV OPT REG
___________________________________________________________
......@@ -179,9 +179,9 @@ int sal_op_send_request(SalOp* op, belle_sip_request_t* request) {
||strcmp(belle_sip_request_get_method(request),"REGISTER")==0
||strcmp(belle_sip_request_get_method(request),"SUBSCRIBE")==0
||strcmp(belle_sip_request_get_method(request),"OPTION")==0)
need_ack=TRUE;
need_contact=TRUE;
return _sal_op_send_request_with_contact(op, request,need_ack);
return _sal_op_send_request_with_contact(op, request,need_contact);
}
......
......@@ -47,11 +47,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <net/if.h>
#include <ifaddrs.h>
#endif
#if _MSC_VER
#define snprintf _snprintf
#define popen _popen
#define pclose _pclose
#include <math.h>
#if _MSC_VER
#define snprintf _snprintf
#define popen _popen
#define pclose _pclose
#endif
#if !defined(WIN32)
......@@ -253,7 +253,7 @@ static double get_audio_payload_bandwidth(LinphoneCore *lc, const PayloadType *p
}
void linphone_core_update_allocated_audio_bandwidth_in_call(LinphoneCall *call, const PayloadType *pt){
call->audio_bw=(int)(get_audio_payload_bandwidth(call->core,pt)/1000.0);
call->audio_bw=(int)(ceil(get_audio_payload_bandwidth(call->core,pt)/1000.0)); /*rounding codec bandwidth should be avoid, specially for AMR*/
ms_message("Audio bandwidth for this call is %i",call->audio_bw);
}
......
......@@ -313,10 +313,9 @@ int offer_answer_initiate_incoming(const SalMediaDescription *local_capabilities
}else ms_warning("Unknown protocol for mline %i, declining",i);
if (ls){
initiate_incoming(ls,rs,&result->streams[i],one_matching_codec);
result->n_active_streams++;
}
else {
/* create an inactive stream for the answer, as there where no matching stream a local capability */
if (result->streams[i].rtp_port!=0) result->n_active_streams++;
}else {
/* create an inactive stream for the answer, as there where no matching stream in local capabilities */
result->streams[i].dir=SalStreamInactive;
result->streams[i].rtp_port=0;
result->streams[i].type=rs->type;
......
......@@ -309,15 +309,14 @@ void linphone_upnp_context_destroy(UpnpContext *lupnp) {
ms_message("uPnP IGD: Wait all pending port bindings ...");
ms_cond_wait(&lupnp->empty_cond, &lupnp->mutex);
}
ms_mutex_unlock(&lupnp->mutex);
if(lupnp->upnp_igd_ctxt != NULL) {
// upnp_igd_destroy is synchronous so the callbacks will be called in the same thread.
// So release the mutex before upnp_igd_destroy call.
ms_mutex_unlock(&lupnp->mutex);
upnp_igd_destroy(lupnp->upnp_igd_ctxt);
ms_mutex_lock(&lupnp->mutex);
lupnp->upnp_igd_ctxt = NULL;
}
/* No more multi threading here */
/* Run one more time configuration update and proxy */
linphone_upnp_update_config(lupnp);
......@@ -345,8 +344,6 @@ void linphone_upnp_context_destroy(UpnpContext *lupnp) {
ms_list_for_each(lupnp->pending_bindings,(void (*)(void*))linphone_upnp_port_binding_release);
lupnp->pending_bindings = ms_list_free(lupnp->pending_bindings);
ms_mutex_unlock(&lupnp->mutex);
ms_mutex_destroy(&lupnp->mutex);
ms_cond_destroy(&lupnp->empty_cond);
......
......@@ -525,4 +525,7 @@ LINPHONE_PUBLIC void sal_set_recv_error(Sal *sal,int value);
/*enable contact fixing*/
void sal_nat_helper_enable(Sal *sal,bool_t enable);
bool_t sal_nat_helper_enabled(Sal *sal);
void sal_set_dns_timeout(Sal* sal,int timeout);
int sal_get_dns_timeout(const Sal* sal);
#endif
mediastreamer2 @ 8d85a5de
Subproject commit 7a11d31f5cab97ff0de373d617720bb651d19b7d
Subproject commit 8d85a5ded3b18e2d3d4ba22ee75e0f1ef9c0f739
......@@ -4,7 +4,7 @@ if BUILD_CUNIT_TESTS
noinst_PROGRAMS=liblinphone_tester
TESTS=$(noinst_PROGRAMS)
liblinphone_tester_SOURCES= liblinphone_tester.c register_tester.c message_tester.c call_tester.c presence_tester.c
liblinphone_tester_SOURCES= liblinphone_tester.c setup_tester.c register_tester.c message_tester.c call_tester.c presence_tester.c
#liblinphone_tester_CFLAGS=$(CUNIT_CFLAGS)
......
......@@ -15,6 +15,7 @@
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>
#include "CUnit/Basic.h"
#include "linphonecore.h"
......@@ -22,13 +23,6 @@
#include "liblinphone_tester.h"
static int init(void) {
return 0;
}
static int uninit(void) {
return 0;
}
void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg){
char* to=linphone_address_as_string(linphone_call_get_call_log(call)->to);
char* from=linphone_address_as_string(linphone_call_get_call_log(call)->from);
......@@ -60,6 +54,7 @@ void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState
CU_FAIL("unexpected event");break;
}
}
void linphone_transfer_state_changed(LinphoneCore *lc, LinphoneCall *transfered, LinphoneCallState new_call_state) {
char* to=linphone_address_as_string(linphone_call_get_call_log(transfered)->to);
char* from=linphone_address_as_string(linphone_call_get_call_log(transfered)->from);
......@@ -80,6 +75,7 @@ void linphone_transfer_state_changed(LinphoneCore *lc, LinphoneCall *transfered,
CU_FAIL("unexpected event");break;
}
}
static void linphone_call_cb(LinphoneCall *call,void * user_data) {
char* to=linphone_address_as_string(linphone_call_get_call_log(call)->to);
char* from=linphone_address_as_string(linphone_call_get_call_log(call)->from);
......@@ -91,6 +87,7 @@ static void linphone_call_cb(LinphoneCall *call,void * user_data) {
counters = (stats*)linphone_core_get_user_data(lc);
counters->number_of_IframeDecoded++;
}
static bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_mgr) {
LinphoneProxyConfig* proxy;
int retry=0;
......@@ -142,7 +139,8 @@ static bool_t call(LinphoneCoreManager* caller_mgr,LinphoneCoreManager* callee_m
wait_for(callee_mgr->lc,caller_mgr->lc,&callee_mgr->stat.number_of_LinphoneCallStreamsRunning,initial_callee.number_of_LinphoneCallStreamsRunning+1);
}
static void simple_call() {
static void simple_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
......@@ -182,7 +180,8 @@ static void simple_call() {
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void call_canceled() {
static void cancelled_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
......@@ -199,7 +198,23 @@ static void call_canceled() {
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void call_ringing_canceled() {
static void call_with_dns_time_out(void) {
LinphoneCoreManager* marie = linphone_core_manager_new(NULL);
LCSipTransports transport = {9773,0,0,0};
linphone_core_set_sip_transports(marie->lc,&transport);
linphone_core_iterate(marie->lc);
sal_set_dns_timeout(marie->lc->sal,0);
linphone_core_invite(marie->lc,"sip:toto@toto.com");
linphone_core_iterate(marie->lc);
linphone_core_iterate(marie->lc);
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallOutgoingInit,1);
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallOutgoingProgress,1);
CU_ASSERT_EQUAL(marie->stat.number_of_LinphoneCallError,1);
linphone_core_manager_destroy(marie);
}
static void cancelled_ringing_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
......@@ -217,7 +232,7 @@ static void call_ringing_canceled() {
linphone_core_manager_destroy(pauline);
}
static void call_early_declined() {
static void early_declined_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
LinphoneCall* in_call;
......@@ -238,7 +253,7 @@ static void call_early_declined() {
linphone_core_manager_destroy(pauline);
}
static void call_terminated_by_caller() {
static void call_terminated_by_caller(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
......@@ -252,7 +267,7 @@ static void call_terminated_by_caller() {
linphone_core_manager_destroy(pauline);
}
static void call_paused_resumed() {
static void call_paused_resumed(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
LinphoneCall* call_obj;
......@@ -289,7 +304,8 @@ static bool_t pause_call_1(LinphoneCoreManager* mgr_1,LinphoneCall* call_1,Linph
CU_ASSERT_EQUAL(linphone_call_get_state(call_2),LinphoneCallPausedByRemote);
return linphone_call_get_state(call_1) == LinphoneCallPaused && linphone_call_get_state(call_2)==LinphoneCallPausedByRemote;
}
static void call_paused_resumed_from_callee() {
static void call_paused_resumed_from_callee(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
LinphoneCall* call_obj;
......@@ -315,7 +331,7 @@ static void call_paused_resumed_from_callee() {
linphone_core_manager_destroy(pauline);
}
static void call_with_video_added() {
static void call_with_video_added(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
LinphoneCall* call_obj;
......@@ -357,7 +373,8 @@ static void call_with_video_added() {
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void simple_conference() {
static void simple_conference(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
stats initial_marie_stat;
stats initial_pauline_stat;
......@@ -414,8 +431,7 @@ static void simple_conference() {
ms_list_free(lcs);
}
static void call_srtp() {
static void srtp_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
......@@ -436,7 +452,7 @@ static void call_srtp() {
linphone_core_manager_destroy(pauline);
}
static void call_early_media() {
static void early_media_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_early_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
......@@ -454,10 +470,11 @@ static void call_early_media() {
linphone_core_manager_destroy(pauline);
}
static void simple_call_transfer() {
static void simple_call_transfer(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
LinphoneCoreManager* laure = linphone_core_manager_new("./tester/laure_rc");
LinphoneCall* pauline_called_by_marie;
LinphoneCall* marie_call_pauline;
LinphoneCall* pauline_called_by_marie;
......@@ -469,7 +486,6 @@ static void simple_call_transfer() {
CU_ASSERT_TRUE(call(marie,pauline));
marie_call_pauline=linphone_core_get_current_call(marie->lc);
pauline_called_by_marie=linphone_core_get_current_call(pauline->lc);
reset_counters(&marie->stat);
......@@ -506,7 +522,7 @@ static void simple_call_transfer() {
ms_list_free(lcs);
}
static void call_transfer_existing_call_outgoing_call() {
static void call_transfer_existing_call_outgoing_call(void) {
LinphoneCoreManager* marie = linphone_core_manager_new("./tester/marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new("./tester/pauline_rc");
LinphoneCoreManager* laure = linphone_core_manager_new("./tester/laure_rc");
......@@ -580,49 +596,31 @@ static void call_transfer_existing_call_outgoing_call() {
ms_list_free(lcs);
}
int call_test_suite () {
CU_pSuite pSuite = CU_add_suite("Call", init, uninit);
if (NULL == CU_add_test(pSuite, "call_early_declined", call_early_declined)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "call_canceled", call_canceled)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "call_ringing_canceled", call_ringing_canceled)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "simple_call", simple_call)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "call_early_media", call_early_media)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "call_terminated_by_caller", call_terminated_by_caller)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "call_paused_resumed", call_paused_resumed)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "call_paused_resumed_from_callee", call_paused_resumed_from_callee)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "call_srtp", call_srtp)) {
return CU_get_error();
}
#ifdef VIDEO_ENABLED
if (NULL == CU_add_test(pSuite, "call_with_video_added", call_with_video_added)) {
return CU_get_error();
}
#endif
if (NULL == CU_add_test(pSuite, "simple_conference", simple_conference)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "simple_call_transfer", simple_call_transfer)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "call_transfer_existing_call_outgoing_call", call_transfer_existing_call_outgoing_call)) {
return CU_get_error();
}
return 0;
}
test_t call_tests[] = {
{ "Early declined call", early_declined_call },
{ "Cancelled call", cancelled_call },
{ "Call with DNS timeout", call_with_dns_time_out },
{ "Cancelled ringing call", cancelled_ringing_call },
{ "Simple call", simple_call },
{ "Early-media call", early_media_call },
{ "Call terminated by caller", call_terminated_by_caller },
{ "Call paused resumed", call_paused_resumed },
{ "Call paused resumed from callee", call_paused_resumed_from_callee },
{ "SRTP call", srtp_call },
{ "Call with video added", call_with_video_added },
{ "Simple conference", simple_conference },
{ "Simple call transfer", simple_call_transfer },
{ "Call transfer existing call outgoing call", call_transfer_existing_call_outgoing_call }
};
test_suite_t call_test_suite = {
"Call",
NULL,
NULL,
sizeof(call_tests) / sizeof(call_tests[0]),
call_tests
};
......@@ -22,25 +22,21 @@
#include "liblinphone_tester.h"
static test_suite_t **test_suite = NULL;
static int nb_test_suites = 0;
#if HAVE_CU_CURSES
static unsigned char curses = 0;
#endif
static stats global_stat;
const char* test_domain="sipopen.example.org";
const char* auth_domain="sip.example.org";
const char* test_username="liblinphone_tester";
const char* test_password="secret";
static int init(void) {
return 0;
}
static int uninit(void) {
return 0;
}
static void core_init_test(void) {
LinphoneCoreVTable v_table;
LinphoneCore* lc;
memset (&v_table,0,sizeof(v_table));
lc = linphone_core_new(&v_table,NULL,NULL,NULL);
CU_ASSERT_PTR_NOT_NULL_FATAL(lc);
linphone_core_destroy(lc);
}
LinphoneAddress * create_linphone_address(const char * domain) {
LinphoneAddress *addr = linphone_address_new(NULL);
......@@ -55,23 +51,14 @@ LinphoneAddress * create_linphone_address(const char * domain) {
CU_ASSERT_STRING_EQUAL("Mr Tester",linphone_address_get_display_name(addr));
return addr;
}
static void linphone_address_test(void) {
linphone_address_destroy(create_linphone_address(NULL));
}
static stats global_stat;
void auth_info_requested(LinphoneCore *lc, const char *realm, const char *username) {
stats* counters;
LinphoneAuthInfo *info;
ms_message("Auth info requested for user id [%s] at realm [%s]\n"
,username
,realm);
counters = (stats*)linphone_core_get_user_data(lc);
stats* counters = (stats*)linphone_core_get_user_data(lc);
counters->number_of_auth_info_requested++;
info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain); /*create authentication structure from identity*/
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain); /*create authentication structure from identity*/
linphone_core_add_auth_info(lc,info); /*add authentication info to LinphoneCore*/
}
......@@ -96,10 +83,9 @@ void reset_counters( stats* counters) {
LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* file,int proxy_count) {
LinphoneCore* lc;
int retry=0;
stats* counters;
lc = linphone_core_new(v_table,NULL,file,NULL);
lc = linphone_core_new(v_table,NULL,file,NULL);
linphone_core_set_user_data(lc,&global_stat);
counters = (stats*)linphone_core_get_user_data(lc);
stats* counters = (stats*)linphone_core_get_user_data(lc);
linphone_core_set_ring(lc,"./share/rings/oldphone.wav");
linphone_core_set_ringback(lc,"./share/ringback.wav");
......@@ -114,19 +100,18 @@ LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* file,in
return lc;
}
bool_t wait_for(LinphoneCore* lc_1, LinphoneCore* lc_2,int* counter,int value) {
MSList* lcs=NULL;
bool_t result;
if (lc_1)
lcs=ms_list_append(lcs,lc_1);
bool_t result;
if (lc_2)
lcs=ms_list_append(lcs,lc_2);
result=wait_for_list(lcs,counter,value,2000);
ms_list_free(lcs);
return result;
}
bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) {
int retry=0;
MSList* iterator;
......@@ -139,19 +124,19 @@ bool_t wait_for_list(MSList* lcs,int* counter,int value,int timeout_ms) {
if(*counter<value) return FALSE;
else return TRUE;
}
static void enable_codec(LinphoneCore* lc,const char* type,int rate) {
MSList* codecs=ms_list_copy(linphone_core_get_audio_codecs(lc));
MSList* codecs_it;
PayloadType* pt;
for (codecs_it=codecs;codecs_it!=NULL;codecs_it=codecs_it->next) {
linphone_core_enable_payload_type(lc,(PayloadType*)codecs_it->data,0);
}
PayloadType* pt;
if((pt = linphone_core_find_payload_type(lc,type,rate,1))) {
linphone_core_enable_payload_type(lc,pt, 1);
}
}
LinphoneCoreManager* linphone_core_manager_new(const char* rc_file) {
LinphoneCoreManager* mgr= malloc(sizeof(LinphoneCoreManager));
LinphoneProxyConfig* proxy;
......@@ -163,59 +148,170 @@ LinphoneCoreManager* linphone_core_manager_new(const char* rc_file) {
mgr->v_table.new_subscription_request=new_subscribtion_request;
mgr->v_table.notify_presence_recv=notify_presence_received;
mgr->v_table.transfer_state_changed=linphone_transfer_state_changed;
mgr->lc=configure_lc_from(&mgr->v_table,rc_file,1);
mgr->lc=configure_lc_from(&mgr->v_table,rc_file,rc_file?1:0);
enable_codec(mgr->lc,"PCMU",8000);
linphone_core_set_user_data(mgr->lc,&mgr->stat);
linphone_core_get_default_proxy(mgr->lc,&proxy);