Commit 1a6849c1 authored by jehan's avatar jehan

Merge branch 'master' of git.linphone.org:linphone-private

parents 3f875141 80150859
This diff is collapsed.
......@@ -39,7 +39,6 @@ INSTALL
Specfile
.anjuta/
.anjuta_sym_db.db
coreapi/help/doxygen.dox
gtk-glade/version_date.h
share/linphone.desktop
......@@ -3,13 +3,20 @@
# let make re-run automake upon need
ACLOCAL_AMFLAGS = -I m4 $(ACLOCAL_MACOS_FLAGS)
if EXTERNAL_MEDIASTREAMER
MS2_DIR=
else
MS2_DIR=mediastreamer2
endif
if EXTERNAL_ORTP
ORTP_DIR =
ORTP_DIR=
else
ORTP_DIR = oRTP
ORTP_DIR=oRTP
endif
SUBDIRS = m4 pixmaps po $(ORTP_DIR) mediastreamer2\
SUBDIRS = m4 pixmaps po $(ORTP_DIR) $(MS2_DIR) \
coreapi console gtk share scripts
......@@ -42,6 +49,7 @@ SDK_EXCLUDED= \
GTK_PREFIX=/usr
GTK_THEME=Outcrop
GTK_FILELIST=gtk+-2.18.5.filelist
GTK_FILELIST_PATH=$(shell cd $(top_srcdir) && pwd)/$(GTK_FILELIST)
LINPHONEDEPS_FILELIST=linphone-deps.filelist
......@@ -113,7 +121,8 @@ gtk-cherrypick:
cp $$file $(INSTALLDIR_WITH_PREFIX)/$$file ;\
fi \
done && \
cp -rf share/themes $(INSTALLDIR_WITH_PREFIX)/share/.
mkdir -p $(INSTALLDIR_WITH_PREFIX)/share/themes && \
cp -rf share/themes/$(GTK_THEME) $(INSTALLDIR_WITH_PREFIX)/share/themes/.
zip:
rm -f $(ZIPFILE)
......
......@@ -57,7 +57,10 @@ LOCAL_CFLAGS += \
-DLOG_DOMAIN=\"Linphone\"
LOCAL_CFLAGS += -DIN_LINPHONE
#LOCAL_CFLAGS += -DVIDEO_ENABLED -DIN_LINPHONE
ifeq ($(LINPHONE_VIDEO),1)
LOCAL_CFLAGS += -DVIDEO_ENABLED
endif
LOCAL_C_INCLUDES += \
$(LOCAL_PATH) \
......@@ -67,7 +70,7 @@ LOCAL_C_INCLUDES += \
$(LOCAL_PATH)/../../externals/exosip/include \
$(LOCAL_PATH)/../../externals/osip/include
LOCAL_LDLIBS += -llog
LOCAL_LDLIBS += -llog -ldl
LOCAL_STATIC_LIBRARIES := \
libmediastreamer2 \
......@@ -76,6 +79,15 @@ LOCAL_STATIC_LIBRARIES := \
libeXosip2 \
libosip2 \
libgsm
ifeq ($(LINPHONE_VIDEO),1)
LOCAL_STATIC_LIBRARIES += \
libavcodec \
libswscale \
libavcore \
libavutil
endif
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
LOCAL_CFLAGS += -DHAVE_ILBC=1
LOCAL_STATIC_LIBRARIES += libmsilbc
......
dnl Process this file with autoconf to produce a configure script.
AC_INIT([linphone],[3.3.99.2],[linphone-developers@nongnu.org])
AC_INIT([linphone],[3.3.99.9],[linphone-developers@nongnu.org])
AC_CANONICAL_SYSTEM
AC_CONFIG_SRCDIR([coreapi/linphonecore.c])
dnl Source packaging numbers
......@@ -28,7 +29,8 @@ AC_SUBST(LINPHONE_VERSION)
AC_MSG_NOTICE([$PACKAGE_NAME-$PACKAGE_VERSION A full featured audio/video sip phone.])
AC_MSG_NOTICE([licensed under the terms of the General Public License (GPL)])
AM_INIT_AUTOMAKE([tar-ustar])
AM_INIT_AUTOMAKE
AC_SUBST([LIBTOOL_DEPS])
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])],)
AC_CONFIG_HEADER(config.h)
AC_CONFIG_MACRO_DIR([m4])
......@@ -67,7 +69,8 @@ AC_SUBST(CONSOLE_FLAGS)
AC_SUBST(GUI_FLAGS)
dnl localization tools
ifdef([IT_PROG_INTLTOOL],[IT_PROG_INTLTOOL],[AC_PROG_INTLTOOL])
IT_PROG_INTLTOOL([0.40], [no-xml])
dnl Initialize libtool
AC_LIBTOOL_WIN32_DLL
AC_PROG_LIBTOOL
......@@ -290,11 +293,19 @@ AC_ARG_WITH( ffmpeg,
[ --with-ffmpeg Sets the installation prefix of ffmpeg, needed for video support. [default=/usr] ],
[ ffmpegdir=${withval}],[ ffmpegdir=/usr ])
AC_ARG_WITH( sdl,
[ --with-sdl Sets the installation prefix of libSDL, needed for video support. [default=/usr] ],
[ libsdldir=${withval}],[ libsdldir=/usr ])
AC_ARG_ENABLE(x11,
[ --disable-x11 Disable X11 support],
[case "${enableval}" in
yes) enable_x11=true ;;
no) enable_x11=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --disable-x11) ;;
esac],[enable_x11=true])
if test "$video" = "true"; then
if test "$enable_x11" = "true"; then
AC_CHECK_HEADERS(X11/Xlib.h)
fi
AC_DEFINE(VIDEO_ENABLED,1,[defined if video support is available])
fi
......@@ -362,15 +373,40 @@ fi
AC_SUBST(STRICT_OPTIONS)
AC_CONFIG_SUBDIRS( mediastreamer2 )
top_srcdir=`dirname $0`
AC_ARG_ENABLE([external-mediastreamer],
[AS_HELP_STRING([--enable-external-mediastreamer],[Use external mediastreamer library])],,
[enable_external_mediastreamer=no])
AS_CASE($enable_external_mediastreamer,
[yes],[
PKG_CHECK_MODULES([MEDIASTREAMER], [mediastreamer])
MS2_VERSION=`$PKG_CONFIG --modversion mediastreamer`
AM_CONDITIONAL(EXTERNAL_MEDIASTREAMER, [true])],
[no],[
AC_CONFIG_SUBDIRS( mediastreamer2 )
MEDIASTREAMER_DIR=${top_srcdir}/mediastreamer2
MEDIASTREAMER_CFLAGS="-I\$(top_srcdir)/mediastreamer2/include"
MEDIASTREAMER_LIBS="\$(top_builddir)/mediastreamer2/src/libmediastreamer.la"
dnl need to temporary change quotes to allow square brackets
changequote(<<, >>)
MS2_VERSION=`grep -e '^.C_INIT(' $MEDIASTREAMER_DIR/configure.ac | sed -e 's:\([^(]\+\)(\[mediastreamer\],\[\(.*\)\]):\2:g'`
changequote([, ])
AM_CONDITIONAL(EXTERNAL_MEDIASTREAMER, [false])],
[AC_MSG_ERROR([bad value '${enable_external_mediastreamer}' for --enable-external-mediastreamer])])
AC_SUBST(MEDIASTREAMER_CFLAGS)
AC_SUBST(MEDIASTREAMER_LIBS)
AC_SUBST([MS2_VERSION])
dnl check for db2html (docbook) to generate html user manual
AC_CHECK_PROG(have_sgmltools,sgmltools, yes, no)
AM_CONDITIONAL(ENABLE_MANUAL, test x$have_sgmltools$build_manual = xyesyes )
dnl for external use of linphone libs
LINPHONE_CFLAGS="-I${includedir} -I${includedir}/linphone "
LINPHONE_LIBS="-L${libdir} -llinphone"
LINPHONE_CFLAGS="-I${includedir} -I${includedir}/linphone"
LINPHONE_LIBS="-L${libdir} -llinphone"
if test x$mingw_found = xyes ; then
LINPHONE_LIBS="$LINPHONE_LIBS $OSIP_LIBS"
......@@ -378,7 +414,6 @@ fi
AC_SUBST(LINPHONE_CFLAGS)
AC_SUBST(LINPHONE_LIBS)
AC_DEFINE_UNQUOTED(LINPHONE_VERSION,"$PACKAGE_VERSION",[Linphone's version number])
AC_DEFINE_UNQUOTED(LINPHONE_PLUGINS_DIR, "${package_prefix}/lib/liblinphone/plugins" ,[path of liblinphone plugins, not mediastreamer2 plugins])
......@@ -394,7 +429,8 @@ AC_ARG_ENABLE(external-ortp,
esac],[external_ortp=false])
if test "$external_ortp" = 'true'; then
LP_CHECK_ORTP
PKG_CHECK_MODULES([ORTP], [ortp])
ORTP_VERSION=`$PKG_CONFIG --modversion ortp`
else
AC_CONFIG_SUBDIRS( oRTP )
ORTP_CFLAGS="-I\$(top_srcdir)/oRTP/include"
......@@ -402,22 +438,16 @@ else
if test x$ac_cv_c_bigendian = xyes ; then
ORTP_CFLAGS="$ORTP_CFLAGS -DORTP_BIGENDIAN"
fi
changequote(<<, >>)
ORTP_VERSION=`grep -E ^[AC]+_INIT ${top_srcdir}/oRTP/configure.ac | sed -e 's:^.*_INIT(.*,\[\(.*\)\]):\1:g'`
changequote([, ])
fi
AC_SUBST(ORTP_CFLAGS)
AC_SUBST(ORTP_LIBS)
AC_SUBST([ORTP_VERSION])
AM_CONDITIONAL(EXTERNAL_ORTP, [test "$external_ortp" = 'true'])
dnl Packaging: Pick oRTP version from ${top_srcdir}/oRTP/configure.ac
dnl Feel free to propose an alternative & cleaner version...
top_srcdir=`dirname $0`
changequote(, )dnl
ORTP_VERSION=`grep -E ^[AC]+_INIT ${top_srcdir}/oRTP/configure.ac | sed -e 's:^.*_INIT(.*,\[\(.*\)\]):\1:g'`
MS2_VERSION=`grep -E ^[AC]+_INIT ${top_srcdir}/mediastreamer2/configure.ac | sed -e 's:^.*_INIT(.*,\[\(.*\)\]):\1:g'`
changequote([, ])dnl
AC_SUBST([ORTP_VERSION])
AC_SUBST([MS2_VERSION])
dnl ##################################################
dnl # Check for doxygen
dnl ##################################################
......@@ -429,12 +459,11 @@ AM_CONDITIONAL(HAVE_DOXYGEN, test $DOXYGEN != false)
AC_OUTPUT([
Makefile
m4/Makefile
po/Makefile.in
po/Makefile.in
pixmaps/Makefile
coreapi/Makefile
coreapi/help/Makefile
coreapi/help/Doxyfile
coreapi/help/doxygen.dox
gtk/Makefile
console/Makefile
share/Makefile
......
......@@ -9,9 +9,7 @@ INCLUDES = \
-I$(top_srcdir)/coreapi\
$(ORTP_CFLAGS) \
-I$(top_srcdir)/exosip \
-I$(top_srcdir)/mediastreamer2/include
$(MEDIASTREAMER_CFLAGS)
bin_PROGRAMS = linphonec linphonecsh
......@@ -22,7 +20,7 @@ endif
linphonec_SOURCES = linphonec.c linphonec.h commands.c
linphonec_CFLAGS=$(COMMON_CFLAGS) $(CONSOLE_FLAGS)
linphonec_LDADD = $(top_builddir)/coreapi/liblinphone.la $(READLINE_LIBS) \
$(top_builddir)/mediastreamer2/src/libmediastreamer.la \
$(MEDIASTREAMER_LIBS) \
$(ORTP_LIBS) \
$(SPEEX_LIBS) \
$(OSIP_LIBS)
......@@ -41,7 +39,7 @@ sipomatic_CFLAGS= $(COMMON_CFLAGS) $(CONSOLE_FLAGS)
sipomatic_LDADD= $(INTLLIBS) \
$(top_builddir)/coreapi/liblinphone.la \
$(top_builddir)/mediastreamer2/src/libmediastreamer.la \
$(MEDIASTREAMER_LIBS) \
$(ORTP_LIBS) \
$(SPEEX_LIBS) \
$(OSIP_LIBS)
......@@ -53,6 +51,3 @@ linphonecsh_LDADD = $(ORTP_LIBS)
endif
This diff is collapsed.
......@@ -77,6 +77,11 @@
#define PACKAGE_DIR ""
#endif
#ifdef HAVE_X11_XLIB_H
#include <X11/Xlib.h>
#include <SDL/SDL_syswm.h>
#endif
/***************************************************************************
*
* Types
......@@ -125,7 +130,7 @@ static void linphonec_new_unknown_subscriber(LinphoneCore *lc,
LinphoneFriend *lf, const char *url);
static void linphonec_text_received(LinphoneCore *lc, LinphoneChatRoom *cr,
const char *from, const char *msg);
const LinphoneAddress *from, const char *msg);
static void linphonec_display_status (LinphoneCore * lc, const char *something);
static void linphonec_dtmf_received(LinphoneCore *lc, LinphoneCall *call, int dtmf);
static void print_prompt(LinphoneCore *opm);
......@@ -155,6 +160,7 @@ LPC_AUTH_STACK auth_stack;
static int trace_level = 0;
static char *logfile_name = NULL;
static char configfile_name[PATH_MAX];
static const char *factory_configfile_name=NULL;
static char *sipAddr = NULL; /* for autocall */
#if !defined(_WIN32_WCE)
static ortp_pipe_t client_sock=ORTP_PIPE_INVALID;
......@@ -168,6 +174,9 @@ static bool_t pipe_reader_run=FALSE;
static ortp_pipe_t server_sock;
#endif /*_WIN32_WCE*/
bool_t linphonec_camera_enabled=TRUE;
void linphonec_call_identify(LinphoneCall* call){
static long callid=1;
......@@ -183,7 +192,7 @@ LinphoneCall *linphonec_get_call(long id){
return call;
}
}
linphonec_out("Sorry, no call with id %i exists at this time.",id);
linphonec_out("Sorry, no call with id %i exists at this time.\n",id);
return NULL;
}
......@@ -199,7 +208,7 @@ LinphoneCall *linphonec_get_call(long id){
static void
linphonec_display_refer (LinphoneCore * lc, const char *refer_to)
{
linphonec_out("Receiving out of call refer to %s", refer_to);
linphonec_out("Receiving out of call refer to %s\n", refer_to);
}
/*
......@@ -306,6 +315,13 @@ linphonec_new_unknown_subscriber(LinphoneCore *lc, LinphoneFriend *lf,
}
static void linphonec_call_updated(LinphoneCall *call){
const LinphoneCallParams *cp=linphone_call_get_current_params(call);
if (!linphone_call_camera_enabled (call) && linphone_call_params_video_enabled (cp)){
linphonec_out("Far end requests to share video.\nType 'camera on' if you agree.\n");
}
}
static void linphonec_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState st, const char *msg){
char *from=linphone_call_get_remote_address_as_string(call);
long id=(long)linphone_call_get_user_pointer (call);
......@@ -330,16 +346,20 @@ static void linphonec_call_state_changed(LinphoneCore *lc, LinphoneCall *call, L
break;
case LinphoneCallIncomingReceived:
linphonec_call_identify(call);
linphone_call_enable_camera (call,linphonec_camera_enabled);
id=(long)linphone_call_get_user_pointer (call);
linphonec_set_caller(from);
if ( auto_answer) {
answer_call=TRUE;
}
linphonec_out("Receiving new incoming call from %s, assigned id %i", from,id);
linphonec_out("Receiving new incoming call from %s, assigned id %i\n", from,id);
break;
case LinphoneCallOutgoingInit:
linphonec_call_identify(call);
break;
case LinphoneCallUpdatedByRemote:
linphonec_call_updated(call);
break;
default:
break;
}
......@@ -351,9 +371,9 @@ static void linphonec_call_state_changed(LinphoneCore *lc, LinphoneCall *call, L
*/
static void
linphonec_text_received(LinphoneCore *lc, LinphoneChatRoom *cr,
const char *from, const char *msg)
const LinphoneAddress *from, const char *msg)
{
printf("%s: %s\n", from, msg);
printf("%s: %s\n", linphone_address_as_string(from), msg);
// TODO: provide mechanism for answering.. ('say' command?)
}
......@@ -578,7 +598,7 @@ main (int argc, char *argv[]) {
#endif
linphonec_vtable.call_state_changed=linphonec_call_state_changed;
linphonec_vtable.notify_presence_recv = linphonec_notify_presence_received;
linphonec_vtable.new_unknown_subscriber = linphonec_new_unknown_subscriber;
linphonec_vtable.new_subscription_request = linphonec_new_unknown_subscriber;
linphonec_vtable.auth_info_requested = linphonec_prompt_for_auth;
linphonec_vtable.display_status = linphonec_display_status;
linphonec_vtable.display_message=linphonec_display_something;
......@@ -676,8 +696,7 @@ linphonec_init(int argc, char **argv)
/*
* Initialize linphone core
*/
linphonec=linphone_core_new (&linphonec_vtable, configfile_name, NULL,
NULL);
linphonec=linphone_core_new (&linphonec_vtable, configfile_name, factory_configfile_name, NULL);
linphone_core_enable_video(linphonec,vcap_enabled,display_enabled);
linphone_core_enable_video_preview(linphonec,preview_enabled);
if (!(vcap_enabled || display_enabled)) printf("Warning: video is disabled in linphonec, use -V or -C or -D to enable.\n");
......@@ -709,6 +728,10 @@ void linphonec_main_loop_exit(void){
void
linphonec_finish(int exit_status)
{
// Do not allow concurrent destroying to prevent glibc errors
static bool_t terminating=FALSE;
if (terminating) return;
terminating=TRUE;
linphonec_out("Terminating...\n");
/* Terminate any pending call */
......@@ -727,7 +750,7 @@ linphonec_finish(int exit_status)
{
fclose (mylogfile);
}
printf("\n");
exit(exit_status);
}
......@@ -827,6 +850,7 @@ print_usage (int exit_status)
usage: linphonec [-c file] [-s sipaddr] [-a] [-V] [-d level ] [-l logfile]\n\
linphonec -v\n\
\n\
-b file specify path of readonly factory configuration file.\n\
-c file specify path of configuration file.\n\
-d level be verbose. 0 is no output. 6 is all output\n\
-l logfile specify the log file for your SIP phone\n\
......@@ -841,6 +865,75 @@ usage: linphonec [-c file] [-s sipaddr] [-a] [-V] [-d level ] [-l logfile]\n\
exit(exit_status);
}
#ifdef VIDEO_ENABLED
#ifdef HAVE_X11_XLIB_H
static void x11_apply_video_params(VideoParams *params, Window window){
XWindowChanges wc;
unsigned int flags=0;
static Display *display = NULL;
const char *dname=getenv("DISPLAY");
if (display==NULL && dname!=NULL){
display=XOpenDisplay(dname);
}
if (display==NULL){
ms_error("Could not open display %s",dname);
return;
}
memset(&wc,0,sizeof(wc));
wc.x=params->x;
wc.y=params->y;
wc.width=params->w;
wc.height=params->h;
if (params->x!=-1 ){
flags|=CWX|CWY;
}
if (params->w!=-1){
flags|=CWWidth|CWHeight;
}
/*printf("XConfigureWindow x=%i,y=%i,w=%i,h=%i\n",
wc.x, wc.y ,wc.width, wc.height);*/
XConfigureWindow(display,window,flags,&wc);
if (params->show)
XMapWindow(display,window);
else
XUnmapWindow(display,window);
XSync(display,FALSE);
}
#endif
static void lpc_apply_video_params(){
static unsigned long old_wid=0,old_pwid=0;
unsigned long wid=linphone_core_get_native_video_window_id (linphonec);
unsigned long pwid=linphone_core_get_native_preview_window_id (linphonec);
if (wid!=0 && (lpc_video_params.refresh || old_wid!=wid)){
lpc_video_params.refresh=FALSE;
#ifdef HAVE_X11_XLIB_H
if (lpc_video_params.wid==0){ // do not manage window if embedded
x11_apply_video_params(&lpc_video_params,wid);
}
#endif
}
old_wid=wid;
if (pwid!=0 && (lpc_preview_params.refresh || old_pwid!=pwid)){
lpc_preview_params.refresh=FALSE;
#ifdef HAVE_X11_XLIB_H
/*printf("wid=%lu pwid=%lu\n",wid,pwid);*/
if (lpc_preview_params.wid==0){ // do not manage window if embedded
printf("Refreshing\n");
x11_apply_video_params(&lpc_preview_params,pwid);
}
#endif
}
old_pwid=pwid;
}
#endif
/*
*
......@@ -882,6 +975,10 @@ linphonec_idle_call ()
#endif
}
#ifdef VIDEO_ENABLED
lpc_apply_video_params();
#endif
return 0;
}
......@@ -1054,6 +1151,20 @@ linphonec_parse_cmdline(int argc, char **argv)
#endif /*_WIN32_WCE*/
snprintf(configfile_name, PATH_MAX, "%s", argv[arg_num]);
}
else if (strncmp ("-b", argv[arg_num], 2) == 0)
{
if ( ++arg_num >= argc ) print_usage(EXIT_FAILURE);
#if !defined(_WIN32_WCE)
if (access(argv[arg_num],F_OK)!=0 )
{
fprintf (stderr,
"Cannot open config file %s.\n",
argv[arg_num]);
exit(EXIT_FAILURE);
}
#endif /*_WIN32_WCE*/
factory_configfile_name = argv[arg_num];
}
else if (strncmp ("-s", argv[arg_num], 2) == 0)
{
arg_num++;
......
......@@ -97,6 +97,17 @@ typedef struct {
char *doc; /* Long description. */
} LPC_COMMAND;
typedef struct {
int x,y,w,h;
unsigned long wid;
bool_t show;
bool_t refresh;
} VideoParams;
extern VideoParams lpc_video_params;
extern VideoParams lpc_preview_params;
/***************************************************************************
*
* Forward declarations
......@@ -115,6 +126,8 @@ void linphonec_set_caller(const char *caller);
LinphoneCall *linphonec_get_call(long id);
void linphonec_call_identify(LinphoneCall* call);
extern bool_t linphonec_camera_enabled;
#endif /* def LINPHONEC_H */
/****************************************************************************
......
......@@ -6,11 +6,11 @@ EXTRA_DIST=linphonecore_jni.cc
## Process this file with automake to produce Makefile.in
linphone_includedir=$(includedir)/linphone
linphone_include_HEADERS=linphonecore.h linphonecore_utils.h ../config.h lpconfig.h sipsetup.h
linphone_include_HEADERS=linphonecore.h linphonefriend.h linphonecore_utils.h ../config.h lpconfig.h sipsetup.h
INCLUDES = \
-I$(top_srcdir)\
-I$(top_srcdir)/mediastreamer2/include
$(MEDIASTREAMER_CFLAGS)
lib_LTLIBRARIES=liblinphone.la
......@@ -42,7 +42,7 @@ liblinphone_la_LDFLAGS= -version-info $(LIBLINPHONE_SO_VERSION) -no-undefined
liblinphone_la_LIBADD= \
$(EXOSIP_LIBS) \
$(top_builddir)/mediastreamer2/src/libmediastreamer.la \
$(MEDIASTREAMER_LIBS) \
$(ORTP_LIBS)
if BUILD_WIN32
......@@ -53,11 +53,14 @@ noinst_PROGRAMS=test_lsd
test_lsd_SOURCES=test_lsd.c
test_lsd_LDADD=liblinphone.la
test_lsd_LDADD=liblinphone.la \
$(MEDIASTREAMER_LIBS) \
$(ORTP_LIBS)
AM_CFLAGS=$(STRICT_OPTIONS) -DIN_LINPHONE \
$(ORTP_CFLAGS) \
$(OSIP_CFLAGS) \
$(MEDIASTREAMER_CFLAGS) \
$(EXOSIP_CFLAGS) \
-DENABLE_TRACE \
-DLOG_DOMAIN=\"LinphoneCore\" \
......
......@@ -129,6 +129,29 @@ char *linphone_address_as_string_uri_only(const LinphoneAddress *u){
return sal_address_as_string_uri_only(u);
}
static bool_t strings_equals(const char *s1, const char *s2){
if (s1==NULL && s2==NULL) return TRUE;
if (s1!=NULL && s2!=NULL && strcmp(s1,s2)==0) return TRUE;
return FALSE;
}
/**
* Compare two LinphoneAddress ignoring tags and headers, basically just domain, username, and port.
* Returns TRUE if they are equal.
**/
bool_t linphone_address_weak_equal(const LinphoneAddress *a1, const LinphoneAddress *a2){
const char *u1,*u2;
const char *h1,*h2;
int p1,p2;
u1=linphone_address_get_username(a1);
u2=linphone_address_get_username(a2);
p1=linphone_address_get_port_int(a1);
p2=linphone_address_get_port_int(a2);
h1=linphone_address_get_domain(a1);
h2=linphone_address_get_domain(a2);
return strings_equals(u1,u2) && strings_equals(h1,h2) && p1==p2;
}
/**
* Destroys a LinphoneAddress object.
**/
......@@ -139,6 +162,7 @@ void linphone_address_destroy(LinphoneAddress *u){
int linphone_address_get_port_int(const LinphoneAddress *u) {
return sal_address_get_port_int(u);
}
const char* linphone_address_get_port(const LinphoneAddress *u) {
return sal_address_get_port(u);
}
......
......@@ -23,7 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "linphonecore.h"
#include "private.h"
#include "mediastreamer2/mediastream.h"
#include "lpconfig.h"
static void register_failure(SalOp *op, SalError error, SalReason reason, const char *details);
static void linphone_connect_incoming(LinphoneCore *lc, LinphoneCall *call){
if (lc->ringstream!=NULL){
......@@ -33,6 +35,18 @@ static void linphone_connect_incoming(LinphoneCore *lc, LinphoneCall *call){
linphone_call_start_media_streams(call);
}
static bool_t is_duplicate_call(LinphoneCore *lc, const LinphoneAddress *from, const LinphoneAddress *to){
MSList *elem;
for(elem=lc->calls;elem!=NULL;elem=elem->next){
LinphoneCall *call=(LinphoneCall*)elem->data;
if (linphone_address_weak_equal(call->log->from,from) &&
linphone_address_weak_equal(call->log->to, to)){
return TRUE;
}
}
return FALSE;
}
static void call_received(SalOp *h){
LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
char *barmesg;
......@@ -40,7 +54,9 @@ static void call_received(SalOp *h){
const char *from,*to;
char *tmp;
LinphoneAddress *from_parsed;
LinphoneAddress *from_addr, *to_addr;
const char * early_media=linphone_core_get_remote_ringback_tone (lc);
/* first check if we can answer successfully to this invite */
if (lc->presence_mode==LinphoneStatusBusy ||
lc->presence_mode==LinphoneStatusOffline ||
......@@ -64,9 +80,18 @@ static void call_received(SalOp *h){
}
from=sal_op_get_from(h);
to=sal_op_get_to(h);
from_addr=linphone_address_new(from);
to_addr=linphone_address_new(to);
if (is_duplicate_call(lc,from_addr,to_addr)){
ms_warning("Receiving duplicated call, refusing this one.");
sal_call_decline(h,SalReasonBusy,NULL);
linphone_address_destroy(from_addr);
linphone_address_destroy(to_addr);
return;
}
call=linphone_call_new_incoming(lc,linphone_address_new(from),linphone_address_new(to),h);
call=linphone_call_new_incoming(lc,from_addr,to_addr,h);
sal_call_set_local_media_description(h,call->localdesc);
call->resultdesc=sal_call_get_final_media_description(h);
if (call->resultdesc)
......@@ -76,19 +101,15 @@ static void call_received(SalOp *h){
linphone_call_unref(call);
return;
}
/* the call is acceptable so we can now add it to our list */
if(linphone_core_add_call(lc,call)!= 0)
{
ms_warning("we cannot handle anymore call\n");
sal_call_decline(h,SalReasonMedia,NULL);
linphone_call_unref(call);
return;
}
linphone_core_add_call(lc,call);
from_parsed=linphone_address_new(sal_op_get_from(h));
linphone_address_clean(from_parsed);
tmp=linphone_address_as_string(from_parsed);
linphone_address_destroy(from_parsed);
linphone_call_set_state(call,LinphoneCallIncomingReceived,"Incoming call");
barmesg=ortp_strdup_printf("%s %s%s",tmp,_("is contacting you"),
(sal_call_autoanswer_asked(h)) ?_(" and asked autoanswer."):_("."));
if (lc->vtable.show) lc->vtable.show(lc);
......@@ -115,12 +136,20 @@ static void call_received(SalOp *h){
}else{
/*TODO : play a tone within the context of the current call */
}
sal_call_notify_ringing(h);
sal_call_notify_ringing(h,early_media!=NULL);
#if !(__IPHONE_OS_VERSION_MIN_REQUIRED >= 40000)
linphone_call_init_media_streams(call);
if (early_media!=NULL){
linphone_call_start_early_media (call);
}
#endif
ms_free(barmesg);
ms_free(tmp);
linphone_call_set_state(call,LinphoneCallIncomingReceived,"Incoming call");
if (sal_call_get_replaces(call->op)!=NULL && lp_config_get_int(lc->config,"sip","auto_answer_replacing_calls",1)){
linphone_core_accept_call(lc,call);
}
}
static void call_ringing(SalOp *h){
......@@ -272,6 +301,8 @@ static void call_ack(SalOp *op){
static void call_updating(SalOp *op){
LinphoneCore *