Commit 9e6f05e4 authored by jehan's avatar jehan

first belle_sip implementation

parent 47999d7b
This diff is collapsed.
......@@ -23,7 +23,7 @@
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildArguments</key>
<value>CFLAGS=&quot;-g -Werror -Wall&quot;</value>
<value>CFLAGS=&quot;-g -Wall -Werror&quot;</value>
</dictionary>
<dictionary>
<key>org.eclipse.cdt.make.core.buildCommand</key>
......
......@@ -4,7 +4,7 @@
ACLOCAL_AMFLAGS = -I m4 $(ACLOCAL_MACOS_FLAGS)
SUBDIRS = build m4 pixmaps po @ORTP_DIR@ @MS2_DIR@ \
coreapi console gtk share scripts
coreapi console gtk share scripts tester
......@@ -229,4 +229,4 @@ clean-local:
rm -rf $(BUNDLEDIR)
discovery:
touch specs.cpp
$(CC) $(CFLAGS) $(MEDIASTREAMER2_CFLAGS) $(ORTP_CFLAGS) -E -P -v -dD specs.cpp
$(CC) $(CFLAGS) -include $(top_builddir)/config.h $(MEDIASTREAMER2_CFLAGS) $(ORTP_CFLAGS) $(SIPSTACK_CFLAGS) $(CUNIT_CFLAGS)-E -P -v -dD specs.cpp
......@@ -511,14 +511,28 @@ if test x$enable_tunnel = xtrue; then
AC_SUBST(TUNNEL_LIBS)
fi
SIPSTACK_CFLAGS=
SIPSTACK_LIBS=
AC_ARG_ENABLE([bellesip],
AS_HELP_STRING([--enable-bellesip], [Build with bellesip]))
PKG_CHECK_MODULES(BELLESIP, [belle-sip],[bellesip_found=yes],foo=bar)
AM_CONDITIONAL([USE_BELLESIP], [test "x$enable_bellesip" != "xno" && test "x$bellesip_found" == "xyes"])
if test $USE_BELLESIP_TRUE !='#' ; then
SIPSTACK_CFLAGS=$BELLESIP_CFLAGS
SIPSTACK_LIBS=$BELLESIP_LIBS
AC_DEFINE(USE_BELLESIP,1,[Defined when bellesip is used])
else
SIPSTACK_CFLAGS=$EXOSIP_CFLAGS $OSIP_CFLAGS
SIPSTACK_LIBS=$EXOSIP_LIBS $OSIP_LIBS
fi
AC_SUBST(SIPSTACK_CFLAGS)
AC_SUBST(SIPSTACK_LIBS)
dnl check for db2html (docbook) to generate html user manual
AC_CHECK_PROG(have_sgmltools,sgmltools, yes, no)
......@@ -568,14 +582,28 @@ AC_SUBST(ORTP_LIBS)
AC_SUBST([ORTP_VERSION])
AC_SUBST([ORTP_DIR])
AC_ARG_ENABLE(tests_enabled,
[ --disable-tests Disable compilation of tests],
[case "${enableval}" in
yes) tests_enabled=true ;;
no) tests_enabled=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-tests) ;;
esac],[tests_enabled=false])
AM_CONDITIONAL(ENABLE_TESTS, test x$tests_enabled = xyes)
AC_ARG_ENABLE([tests],
AS_HELP_STRING([--disable-tests], [Disable the tests]))
AM_CONDITIONAL([ENABLE_TESTS], [test "x$enable_tests" != "xno"])
PKG_CHECK_MODULES(CUNIT, cunit, [found_cunit=yes],[found_cunit=no])
if test "$found_cunit" = "no" ; then
AC_CHECK_HEADERS(CUnit/CUnit.h,
[
found_cunit=yes
CUNIT_LIBS="-lcunit"
])
fi
case "$target_os" in
*darwin*)
#hack for macport
CUNIT_LIBS+=" -lncurses"
;;
esac
AM_CONDITIONAL([BUILD_CUNIT_TESTS], [test x$found_cunit = xyes && test x$enable_tests != xno])
......@@ -596,6 +624,7 @@ m4/Makefile
po/Makefile.in
pixmaps/Makefile
coreapi/Makefile
tester/Makefile
coreapi/help/Makefile
coreapi/help/Doxyfile
gtk/Makefile
......@@ -626,6 +655,11 @@ printf "* zRTP encryption (GPLv3)\t%s\n" $zrtp
if test "$enable_tunnel" = "true" ; then
printf "* Tunnel support\t\ttrue\n"
fi
if test $USE_BELLESIP_TRUE !='#' ; then
printf "* bellesip stack\t\ttrue\n"
else
printf "* eXosip stack\t\ttrue\n"
fi
echo "Now type 'make' to compile, and then 'make install' as root to install it."
......@@ -22,9 +22,6 @@ liblinphone_la_SOURCES=\
linphonecore.c linphonecore.h private.h\
offeranswer.c offeranswer.h\
sal.c sal.h \
sal_eXosip2.c sal_eXosip2.h\
sal_eXosip2_sdp.c \
sal_eXosip2_presence.c \
callbacks.c \
misc.c \
address.c \
......@@ -42,7 +39,13 @@ liblinphone_la_SOURCES=\
ec-calibrator.c \
conference.c \
linphone_tunnel.cc
if USE_BELLESIP
liblinphone_la_SOURCES+= sal_bellesip.c
else
liblinphone_la_SOURCES+= sal_eXosip2.c sal_eXosip2.h\
sal_eXosip2_sdp.c \
sal_eXosip2_presence.c
endif
if BUILD_WIZARD
liblinphone_la_SOURCES+=sipwizard.c
endif
......@@ -56,7 +59,7 @@ endif
liblinphone_la_LDFLAGS= -version-info $(LIBLINPHONE_SO_VERSION) -no-undefined
liblinphone_la_LIBADD= \
$(EXOSIP_LIBS) \
$(SIPSTACK_LIBS) \
$(MEDIASTREAMER_LIBS) \
$(ORTP_LIBS) $(OPENSSL_LIBS) \
$(TUNNEL_LIBS) \
......@@ -78,8 +81,7 @@ endif
AM_CFLAGS=$(STRICT_OPTIONS) -DIN_LINPHONE \
$(ORTP_CFLAGS) \
$(MEDIASTREAMER_CFLAGS) \
$(OSIP_CFLAGS) \
$(EXOSIP_CFLAGS) \
$(SIPSTACK_CFLAGS) \
$(LIBSOUP_CFLAGS) \
-DENABLE_TRACE \
-DLOG_DOMAIN=\"LinphoneCore\" \
......
......@@ -306,6 +306,7 @@ void linphone_core_enable_logs(FILE *file){
if (file==NULL) file=stdout;
ortp_set_log_file(file);
ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
sal_enable_logs();
}
/**
......@@ -320,6 +321,7 @@ void linphone_core_enable_logs(FILE *file){
void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc){
ortp_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
ortp_set_log_handler(logfunc);
sal_enable_logs();
}
/**
......@@ -329,6 +331,7 @@ void linphone_core_enable_logs_with_cb(OrtpLogFunc logfunc){
**/
void linphone_core_disable_logs(){
ortp_set_log_level_mask(ORTP_ERROR|ORTP_FATAL);
sal_disable_logs();
}
......@@ -1462,14 +1465,14 @@ int linphone_core_get_sip_port(LinphoneCore *lc)
static char _ua_name[64]="Linphone";
static char _ua_version[64]=LINPHONE_VERSION;
#ifdef HAVE_EXOSIP_GET_VERSION
#if HAVE_EXOSIP_GET_VERSION && !USE_BELLESIP
extern const char *eXosip_get_version();
#endif
static void apply_user_agent(LinphoneCore *lc){
char ua_string[256];
snprintf(ua_string,sizeof(ua_string)-1,"%s/%s (eXosip2/%s)",_ua_name,_ua_version,
#ifdef HAVE_EXOSIP_GET_VERSION
#if HAVE_EXOSIP_GET_VERSION && !USE_BELLESIP
eXosip_get_version()
#else
"unknown"
......
......@@ -38,6 +38,7 @@ const char* sal_transport_to_string(SalTransport transport) {
}
SalTransport sal_transport_parse(const char* param) {
if (!param) return SalTransportUDP;
if (strcasecmp("udp",param)==0) return SalTransportUDP;
if (strcasecmp("tcp",param)==0) return SalTransportTCP;
if (strcasecmp("tls",param)==0) return SalTransportTLS;
......
......@@ -60,7 +60,7 @@ SalAddress * sal_address_new(const char *uri);
SalAddress * sal_address_clone(const SalAddress *addr);
const char *sal_address_get_scheme(const SalAddress *addr);
const char *sal_address_get_display_name(const SalAddress* addr);
char *sal_address_get_display_name_unquoted(const SalAddress *addr);
const char *sal_address_get_display_name_unquoted(const SalAddress *addr);
const char *sal_address_get_username(const SalAddress *addr);
const char *sal_address_get_domain(const SalAddress *addr);
const char * sal_address_get_port(const SalAddress *addr);
......@@ -371,6 +371,8 @@ int sal_ping(SalOp *op, const char *from, const char *to);
/*misc*/
void sal_get_default_local_ip(Sal *sal, int address_family, char *ip, size_t iplen);
void sal_enable_logs();
void sal_disable_logs();
/*internal API */
void __sal_op_init(SalOp *b, Sal *sal);
......
This diff is collapsed.
......@@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <wininet.h>
static int linphone_gtk_get_new_version(const char *version_url, char *version, size_t size){
static int linphone_gtk_create_version(const char *version_url, char *version, size_t size){
DWORD dwDownloaded = 0;
HINTERNET hSession = NULL, hConnect = NULL;
int ret=-1;
......@@ -55,7 +55,7 @@ static int linphone_gtk_get_new_version(const char *version_url, char *version,
#else
static int linphone_gtk_get_new_version(const char *url, char *version, size_t size){
static int linphone_gtk_create_version(const char *url, char *version, size_t size){
return -1;
}
......@@ -121,7 +121,7 @@ static int version_compare(const char *v1, const char *v2){
static void *check_for_new_version(void *d){
const char *version_url=(const char *)d;
char version[256];
if (linphone_gtk_get_new_version(version_url,version,sizeof(version))==0){
if (linphone_gtk_create_version(version_url,version,sizeof(version))==0){
if (version_compare(version,LINPHONE_VERSION)>0){
const char *download_site=linphone_gtk_get_ui_config("download_site",NULL);
if (download_site) {
......
if BUILD_CUNIT_TESTS
noinst_PROGRAMS=liblinphone_tester
TESTS=$(noinst_PROGRAMS)
liblinphone_tester_SOURCES= liblinphone_tester.c
#liblinphone_tester_CFLAGS=$(CUNIT_CFLAGS)
#liblinphone_tester_LDFLAGS=$(CUNIT_LIBS)
INCLUDES=-I$(top_srcdir)/include -I$(top_srcdir)/coreapi
LDADD=$(top_builddir)/coreapi/liblinphone.la
AM_LDFLAGS=$(CUNIT_LIBS)
AM_CFLAGS=$(STRICT_OPTIONS) -DIN_LINPHONE $(ORTP_CFLAGS) $(MEDIASTREAMER_CFLAGS) $(CUNIT_CFLAGS)
endif
/*
belle-sip - SIP (RFC3261) library.
Copyright (C) 2010 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 3 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>
#include "CUnit/Basic.h"
#include "linphonecore.h"
const char *test_domain="localhost";
static int init(void) {
return 0;
}
static int uninit(void) {
return 0;
}
static void core_init_test(void) {
LinphoneCoreVTable v_table;
memset (&v_table,0,sizeof(v_table));
LinphoneCore* lc = linphone_core_new(&v_table,NULL,NULL,NULL);
CU_ASSERT_PTR_NOT_NULL_FATAL(lc);
linphone_core_destroy(lc);
}
static LinphoneAddress * create_linphone_address(void) {
LinphoneAddress *addr = linphone_address_new(NULL);
CU_ASSERT_PTR_NOT_NULL_FATAL(addr);
linphone_address_set_username(addr,"tester");
CU_ASSERT_STRING_EQUAL("tester",linphone_address_get_username(addr));
linphone_address_set_domain(addr,test_domain);
CU_ASSERT_STRING_EQUAL(test_domain,linphone_address_get_domain(addr));
linphone_address_set_display_name(addr, NULL);
linphone_address_set_display_name(addr, "Mr Tester");
CU_ASSERT_STRING_EQUAL("Mr Tester",linphone_address_get_display_name(addr));
return addr;
}
static void linphone_address_test(void) {
ms_free(create_linphone_address());
}
static int number_of_LinphoneRegistrationNone=0;
static int number_of_LinphoneRegistrationProgress =0;
static int number_of_LinphoneRegistrationOk =0;
static int number_of_LinphoneRegistrationCleared =0;
static int number_of_LinphoneRegistrationFailed =0;
static void registration_state_changed(struct _LinphoneCore *lc, LinphoneProxyConfig *cfg, LinphoneRegistrationState cstate, const char *message){
ms_message("New registration state %s for user id [%s] at proxy [%s]\n"
,linphone_registration_state_to_string(cstate)
,linphone_proxy_config_get_identity(cfg)
,linphone_proxy_config_get_addr(cfg));
switch (cstate) {
case LinphoneRegistrationNone:number_of_LinphoneRegistrationNone++;break;
case LinphoneRegistrationProgress:number_of_LinphoneRegistrationProgress++;break;
case LinphoneRegistrationOk:number_of_LinphoneRegistrationOk++;break;
case LinphoneRegistrationCleared:number_of_LinphoneRegistrationCleared++;break;
case LinphoneRegistrationFailed:number_of_LinphoneRegistrationFailed++;break;
default:
CU_FAIL("unexpected event");break;
}
}
static void simple_register(void) {
LinphoneCoreVTable v_table;
int retry=0;
LCSipTransports transport = {5070,5070,0,5071};
memset (&v_table,0,sizeof(v_table));
v_table.registration_state_changed=registration_state_changed;
LinphoneCore* lc = linphone_core_new(&v_table,NULL,NULL,NULL);
CU_ASSERT_PTR_NOT_NULL_FATAL(lc);
linphone_core_set_sip_transports(lc,&transport);
LinphoneProxyConfig* proxy_cfg;
proxy_cfg = linphone_proxy_config_new();
LinphoneAddress *from = create_linphone_address();
linphone_proxy_config_set_identity(proxy_cfg,linphone_address_as_string(from));
const char* server_addr = linphone_address_get_domain(from);
linphone_proxy_config_set_server_addr(proxy_cfg,server_addr);
linphone_proxy_config_enable_register(proxy_cfg,TRUE);
linphone_proxy_config_expires(proxy_cfg,1);
linphone_address_destroy(from);
linphone_core_add_proxy_config(lc,proxy_cfg);
linphone_core_set_default_proxy(lc,proxy_cfg);
while (number_of_LinphoneRegistrationOk<1 && retry++ <20) {
linphone_core_iterate(lc);
ms_usleep(100000);
}
CU_ASSERT_TRUE(linphone_proxy_config_is_registered(proxy_cfg));
/*wait until refresh*/
while (number_of_LinphoneRegistrationOk<2 && retry++ <20) {
linphone_core_iterate(lc);
ms_usleep(100000);
}
linphone_core_destroy(lc);
CU_ASSERT_EQUAL(number_of_LinphoneRegistrationNone,0);
CU_ASSERT_EQUAL(number_of_LinphoneRegistrationProgress,2);
CU_ASSERT_EQUAL(number_of_LinphoneRegistrationOk,2);
CU_ASSERT_EQUAL(number_of_LinphoneRegistrationCleared,1);
CU_ASSERT_EQUAL(number_of_LinphoneRegistrationFailed,0);
}
int init_test_suite () {
CU_pSuite pSuite = CU_add_suite("liblinphone init test suite", init, uninit);
if (NULL == CU_add_test(pSuite, "linphone address tester", linphone_address_test)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "linphone core init/uninit tester", core_init_test)) {
return CU_get_error();
}
if (NULL == CU_add_test(pSuite, "simple register tester", simple_register)) {
return CU_get_error();
}
return 0;
}
int main (int argc, char *argv[]) {
int i;
for(i=1;i<argc;++i){
if (strcmp(argv[i],"--help")==0){
fprintf(stderr,"%s \t--help\n\t\t\t--verbose",argv[0]);
return 0;
}else if (strcmp(argv[i],"--verbose")==0){
linphone_core_enable_logs(NULL);
}else if (strcmp(argv[i],"--domain")==0){
i++;
test_domain=argv[i];
}
}
/* initialize the CUnit test registry */
if (CUE_SUCCESS != CU_initialize_registry())
return CU_get_error();
init_test_suite();
/* Run all tests using the CUnit Basic interface */
CU_basic_set_mode(CU_BRM_VERBOSE);
CU_basic_run_tests();
CU_cleanup_registry();
return CU_get_error();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment