From 9c828b17277311835e6ca9ff58c0d8243fd0a322 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 3 Jun 2010 08:45:24 +0200 Subject: [PATCH 01/14] enable tcp transport --- coreapi/linphonecore.c | 24 +++++++++++++++++++++--- coreapi/private.h | 3 +++ coreapi/sal_eXosip2.c | 15 +++++++++++++-- m4/exosip.m4 | 9 +++++++++ 4 files changed, 46 insertions(+), 5 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index f62449e62..518d887b2 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -646,7 +646,18 @@ static void sip_config_read(LinphoneCore *lc) } linphone_core_enable_ipv6(lc,ipv6); port=lp_config_get_int(lc->config,"sip","sip_port",5060); - linphone_core_set_sip_port(lc,port); + + tmpstr=lp_config_get_string(lc->config,"sip","transport","udp"); + if (strcmp("udp",tmpstr) == 0 ) { + lc->sip_conf.transport=SalTransportDatagram; + } else if (strcmp("tcp",tmpstr) == 0) { + lc->sip_conf.transport=SalTransportStream; + } else { + lc->sip_conf.transport=SalTransportDatagram; + ms_warning("unsupported transport, using udp"); + } + /*start listening on port*/ + linphone_core_set_sip_port(lc,port); tmpstr=lp_config_get_string(lc->config,"sip","contact",NULL); if (tmpstr==NULL || linphone_core_set_primary_contact(lc,tmpstr)==-1) { @@ -697,6 +708,11 @@ static void sip_config_read(LinphoneCore *lc) break; } } + + + + + lc->sip_conf.sdp_200_ack=lp_config_get_int(lc->config,"sip","sdp_200_ack",0); /*for tuning or test*/ lc->sip_conf.sdp_200_ack=lp_config_get_int(lc->config,"sip","sdp_200_ack",0); @@ -1482,9 +1498,11 @@ void linphone_core_set_sip_port(LinphoneCore *lc,int port) anyaddr="::0"; else anyaddr="0.0.0.0"; - err=sal_listen_port (lc->sal,anyaddr,port, SalTransportDatagram,FALSE); + + + err=sal_listen_port (lc->sal,anyaddr,port, lc->sip_conf.transport,FALSE); if (err<0){ - char *msg=ortp_strdup_printf("UDP port %i seems already in use ! Cannot initialize.",port); + char *msg=ortp_strdup_printf("Port %i seems already in use ! Cannot initialize.",port); ms_warning(msg); lc->vtable.display_warning(lc,msg); ms_free(msg); diff --git a/coreapi/private.h b/coreapi/private.h index c3e2960a3..ff09be8d9 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -242,6 +242,7 @@ struct _LinphoneFriend{ bool_t inc_subscribe_pending; }; + typedef struct sip_config { char *contact; @@ -261,6 +262,8 @@ typedef struct sip_config bool_t ping_with_options; bool_t auto_net_state_mon; unsigned int keepalive_period; /* interval in ms between keep alive messages sent to the proxy server*/ + SalTransport transport; + } sip_config_t; typedef struct rtp_config diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 97cde63c2..463f0bcdb 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -314,6 +314,17 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i bool_t ipv6; int proto=IPPROTO_UDP; + switch (tr) { + case SalTransportDatagram: + proto=IPPROTO_UDP; + break; + case SalTransportStream: + proto= IPPROTO_TCP; + break; + default: + ms_warning("unexpected proto, using datagram"); + } + if (ctx->running){ eXosip_quit(); eXosip_init(); @@ -325,8 +336,8 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i ipv6=strchr(addr,':')!=NULL; eXosip_enable_ipv6(ipv6); - if (tr!=SalTransportDatagram || is_secure){ - ms_fatal("SIP over TCP or TLS or DTLS is not supported yet."); + if (is_secure){ + ms_fatal("SIP over TLS or DTLS is not supported yet."); return -1; } err=eXosip_listen_addr(proto, addr, port, ipv6 ? PF_INET6 : PF_INET, 0); diff --git a/m4/exosip.m4 b/m4/exosip.m4 index fc1775a42..fb75e6727 100644 --- a/m4/exosip.m4 +++ b/m4/exosip.m4 @@ -3,6 +3,13 @@ AC_DEFUN([LP_SETUP_EXOSIP],[ AC_REQUIRE([AC_CANONICAL_HOST]) AC_REQUIRE([LP_CHECK_OSIP2]) + +case $target_os in + *darwin*) + OSIP_LIBS="$OSIP_LIBS -framework CoreFoundation -framework CFNetwork " + ;; +esac + dnl eXosip embeded stuff EXOSIP_CFLAGS="$OSIP_CFLAGS -DOSIP_MT " EXOSIP_LIBS="$OSIP_LIBS -leXosip2 " @@ -12,6 +19,8 @@ CPPFLAGS="$OSIP_CFLAGS $CPPFLAGS" AC_CHECK_HEADER([eXosip2/eXosip.h], ,AC_MSG_ERROR([Could not find eXosip2 headers !])) CPPFLAGS=$CPPFLAGS_save + + dnl check for eXosip2 libs LDFLAGS_save=$LDFLAGS LDFLAGS="$OSIP_LIBS $LDFLAGS" From e66d04fa6825b807ea70d6a38ccb3f61c119764e Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 3 Jun 2010 11:33:45 +0200 Subject: [PATCH 02/14] new release: 3.3.1 --- NEWS | 8 ++++++++ configure.in | 2 +- mediastreamer2 | 2 +- oRTP | 2 +- po/POTFILES.in | 4 +++- 5 files changed, 14 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index 04d7ebc35..05b7a5ac6 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,11 @@ +linphone-3.3.1 -- June 3, 2010 + * fix bugs when carrying non ascii displaynames in SIP messages + * fix crash when codecs are incompatible + * fix bug with streams not restarted in case of reinvites + Requires: + mediastreamer2-2.5.0 + ortp-0.16.3 + linphone-3.3.0 -- May 19, 2010 * liblinphone is ported to iphoneOS and Google Android * Internal refactoring of liblinphone (code factorisation, encapsulation diff --git a/configure.in b/configure.in index 6e40e3105..10af6c770 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. -AC_INIT([linphone],[3.3.0],[linphone-developers@nongnu.org]) +AC_INIT([linphone],[3.3.1],[linphone-developers@nongnu.org]) AC_CANONICAL_SYSTEM dnl Source packaging numbers diff --git a/mediastreamer2 b/mediastreamer2 index a2a611927..ba988a9a4 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit a2a6119273226234ea7300742c34d46fa545fcd8 +Subproject commit ba988a9a44f837481ec3c6dec8a1acad56f0fa32 diff --git a/oRTP b/oRTP index b9b53eede..18eccd4f3 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit b9b53eedef812b44762976617840c2b98fca62b9 +Subproject commit 18eccd4f3af64f3bd5293d635a1a169dc77c92ad diff --git a/po/POTFILES.in b/po/POTFILES.in index 4c792a11f..2ca5440ea 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -68,5 +68,7 @@ mediastreamer2/src/void.c mediastreamer2/src/equalizer.c mediastreamer2/src/msdscap-mingw.cc mediastreamer2/src/drawdib-display.c - +mediastreamer2/src/audiomixer.c +mediastreamer2/src/chanadapt.c +mediastreamer2/src/itc.c From df7af48647e3f2819901ef3e1891ce99556d03e3 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 3 Jun 2010 12:07:17 +0200 Subject: [PATCH 03/14] add nortp mute feature --- console/commands.c | 54 +++++++++++++++++++++++++++++++++++++++--- coreapi/linphonecore.c | 35 +++++++++++++++++++++++++++ coreapi/linphonecore.h | 6 +++++ coreapi/private.h | 3 +++ mediastreamer2 | 2 +- 5 files changed, 96 insertions(+), 4 deletions(-) diff --git a/console/commands.c b/console/commands.c index d52a0e840..967e03578 100644 --- a/console/commands.c +++ b/console/commands.c @@ -78,6 +78,9 @@ static int lpc_cmd_ports(LinphoneCore *lc, char *args); static int lpc_cmd_speak(LinphoneCore *lc, char *args); static int lpc_cmd_codec(LinphoneCore *lc, char *args); static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args); +static int lpc_cmd_mute_mic(LinphoneCore *lc, char *args); +static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args); +static int lpc_cmd_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, char *args); /* Command handler helpers */ static void linphonec_proxy_add(LinphoneCore *lc); @@ -223,6 +226,14 @@ LPC_COMMAND commands[] = { "'ec on [] [] []' : turn EC on with given delay, tail length and framesize\n" "'ec off' : turn echo cancellation (EC) off\n" "'ec show' : show EC status" }, + { "mute", lpc_cmd_mute_mic, + "Mute microphone and suspend voice transmission."}, + { "unmute", lpc_cmd_unmute_mic, + "Unmute microphone and resume voice transmission."}, + { "nortp-on-audio-mute", lpc_cmd_rtp_no_xmit_on_audio_mute, + "Set the rtp_no_xmit_on_audio_mute configuration parameter", + " If set to 1 then rtp transmission will be muted when\n" + " audio is muted , otherwise rtp is always sent."}, { (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL } }; @@ -1606,9 +1617,11 @@ static int lpc_cmd_status(LinphoneCore *lc, char *args) linphonec_out("hook=offhook\n"); break; case GSTATE_CALL_OUT_CONNECTED: - linphonec_out("Call out, hook=%s duration=%i\n", linphonec_get_callee(), - linphone_core_get_current_call_duration(lc)); - break; + linphonec_out("Call out, hook=%s duration=%i, muted=%s rtp-xmit-muted=%s\n", linphonec_get_callee(), + linphone_core_get_current_call_duration(lc), + lc->audio_muted ? "yes" : "no", + linphone_core_is_rtp_muted(lc) ? "yes" : "no"); + break; case GSTATE_CALL_IN_CONNECTED: linphonec_out("hook=answered duration=%i\n" , linphone_core_get_current_call_duration(lc)); @@ -1820,6 +1833,41 @@ static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){ return 1; } +static int lpc_cmd_mute_mic(LinphoneCore *lc, char *args) +{ + if ( lc->call != NULL ) + linphone_core_mute_mic(lc, 1); + return 1; +} + +static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args) +{ + if ( lc->call != NULL ) + linphone_core_mute_mic(lc, 0); + return 1; +} + +static int lpc_cmd_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, char *args) +{ + bool_t rtp_xmit_off=FALSE; + char *status; + gstate_t call_state=linphone_core_get_state(lc,GSTATE_GROUP_CALL); + + if(args){ + if(strstr(args,"1"))rtp_xmit_off=TRUE; + if(call_state == GSTATE_CALL_IDLE) + linphone_core_set_rtp_no_xmit_on_audio_mute(lc,rtp_xmit_off); + else + linphonec_out("nortp-on-audio-mute: call in progress - cannot change state\n"); + } + rtp_xmit_off=linphone_core_get_rtp_no_xmit_on_audio_mute(lc); + if(rtp_xmit_off)status="off"; + else status="on"; + linphonec_out("rtp transmit %s when audio muted\n",status); + return 1; +} + + /*************************************************************************** * * Command table management funx diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 54de627f1..83d4c84a8 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -730,6 +730,8 @@ static void rtp_config_read(LinphoneCore *lc) int port; int jitt_comp; int nortp_timeout; + bool_t rtp_no_xmit_on_audio_mute; + port=lp_config_get_int(lc->config,"rtp","audio_rtp_port",7078); linphone_core_set_audio_port(lc,port); @@ -742,6 +744,8 @@ static void rtp_config_read(LinphoneCore *lc) jitt_comp=lp_config_get_int(lc->config,"rtp","video_jitt_comp",60); nortp_timeout=lp_config_get_int(lc->config,"rtp","nortp_timeout",30); linphone_core_set_nortp_timeout(lc,nortp_timeout); + rtp_no_xmit_on_audio_mute=lp_config_get_int(lc->config,"rtp","rtp_no_xmit_on_audio_mute",FALSE); + linphone_core_set_rtp_no_xmit_on_audio_mute(lc,rtp_no_xmit_on_audio_mute); } static PayloadType * find_payload(RtpProfile *prof, const char *mime_type, int clock_rate, const char *recv_fmtp){ @@ -1362,6 +1366,10 @@ int linphone_core_get_nortp_timeout(const LinphoneCore *lc){ return lc->rtp_conf.nortp_timeout; } +bool_t linphone_core_get_rtp_no_xmit_on_audio_mute(const LinphoneCore *lc){ + return lc->rtp_conf.rtp_no_xmit_on_audio_mute; +} + /** * Sets the nominal audio jitter buffer size in milliseconds. * @@ -1372,6 +1380,10 @@ void linphone_core_set_audio_jittcomp(LinphoneCore *lc, int value) lc->rtp_conf.audio_jitt_comp=value; } +void linphone_core_set_rtp_no_xmit_on_audio_mute(LinphoneCore *lc,bool_t rtp_no_xmit_on_audio_mute){ + lc->rtp_conf.rtp_no_xmit_on_audio_mute=rtp_no_xmit_on_audio_mute; +} + /** * Sets the UDP port used for audio streaming. * @@ -2154,6 +2166,7 @@ static void post_configure_audio_streams(LinphoneCore *lc){ float gain=lp_config_get_float(lc->config,"sound","mic_gain",-1); if (gain!=-1) audio_stream_set_mic_gain(st,gain); + lc->audio_muted=FALSE; float recv_gain = lc->sound_conf.soft_play_lev; if (recv_gain != 0) { linphone_core_set_soft_play_level(lc,recv_gain); @@ -2907,6 +2920,10 @@ void linphone_core_mute_mic(LinphoneCore *lc, bool_t val){ if (lc->audiostream!=NULL){ audio_stream_set_mic_gain(lc->audiostream, (val==TRUE) ? 0 : 1.0); + if ( linphone_core_get_rtp_no_xmit_on_audio_mute(lc) ){ + audio_stream_mute_rtp(lc->audiostream,val); + } + lc->audio_muted=val; } } @@ -2919,6 +2936,24 @@ bool_t linphone_core_is_mic_muted(LinphoneCore *lc) { return gain==0; } +// returns audio mute status for active stream +bool_t linphone_core_is_audio_muted(LinphoneCore *lc){ + if( lc->audiostream != NULL ) + return (lc->audio_muted); + return FALSE; +} + +// returns rtp transmission status for an active stream +// if audio is muted and config parameter rtp_no_xmit_on_audio_mute +// was set on then rtp transmission is also muted +bool_t linphone_core_is_rtp_muted(LinphoneCore *lc){ + if( (lc->audiostream != NULL) && + linphone_core_get_rtp_no_xmit_on_audio_mute(lc)){ + return lc->audio_muted; + } + return FALSE; +} + void linphone_core_enable_agc(LinphoneCore *lc, bool_t val){ lc->sound_conf.agc=val; } diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index d0f128da8..d1b2571d0 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -688,6 +688,12 @@ void linphone_core_mute_mic(LinphoneCore *lc, bool_t muted); **/ bool_t linphone_core_is_mic_muted(LinphoneCore *lc); +bool_t linphone_core_is_audio_muted(LinphoneCore *lc); +bool_t linphone_core_is_rtp_muted(LinphoneCore *lc); + +bool_t linphone_core_get_rtp_no_xmit_on_audio_mute(const LinphoneCore *lc); +void linphone_core_set_rtp_no_xmit_on_audio_mute(LinphoneCore *lc, bool_t val); + void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,const char *contact,LinphoneOnlineStatus os); LinphoneOnlineStatus linphone_core_get_presence_info(const LinphoneCore *lc); diff --git a/coreapi/private.h b/coreapi/private.h index ff09be8d9..e14e1644f 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -273,6 +273,8 @@ typedef struct rtp_config int audio_jitt_comp; /*jitter compensation*/ int video_jitt_comp; /*jitter compensation*/ int nortp_timeout; + bool_t rtp_no_xmit_on_audio_mute; + /* stop rtp xmit when audio muted */ }rtp_config_t; @@ -401,6 +403,7 @@ struct _LinphoneCore bool_t preview_finished; bool_t auto_net_state_mon; bool_t network_reachable; + bool_t audio_muted; }; #endif /* _PRIVATE_H */ diff --git a/mediastreamer2 b/mediastreamer2 index ba988a9a4..2c6506309 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit ba988a9a44f837481ec3c6dec8a1acad56f0fa32 +Subproject commit 2c65063096918cce1dfcc6f01c0cbf43c3232dc0 From 46a2704832e32f59b5c0b11cfbe9ca626018ab22 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 4 Jun 2010 11:44:11 +0200 Subject: [PATCH 04/14] do not make a double registration when using tcp (useless) improve account configuration box --- coreapi/sal_eXosip2.c | 6 +++++ gtk-glade/sip_account.glade | 52 +++++++++++++++++++++++-------------- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 463f0bcdb..bc097f94a 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -378,6 +378,12 @@ static int extract_received_rport(osip_message_t *msg, const char **received, in *received=NULL; osip_message_get_via(msg,0,&via); if (!via) return -1; + + /* it is useless to do that with tcp since client socket might have a different port + than the server socket. + */ + if (strcasecmp(via->protocol,"tcp")==0) return -1; + if (via->port && via->port[0]!='\0') *rportval=atoi(via->port); diff --git a/gtk-glade/sip_account.glade b/gtk-glade/sip_account.glade index 2828e3036..bb8862619 100644 --- a/gtk-glade/sip_account.glade +++ b/gtk-glade/sip_account.glade @@ -1,19 +1,20 @@ - - - + + + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK 5 Linphone - Configure a SIP account - GTK_WIN_POS_CENTER_ON_PARENT + center-on-parent linphone2.png - GDK_WINDOW_TYPE_HINT_DIALOG + dialog False True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical 2 @@ -29,6 +30,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + vertical True @@ -40,7 +42,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Your SIP identity: - GTK_JUSTIFY_RIGHT + right @@ -49,6 +51,8 @@ True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Looks like sip:<username>@<domain> + sip: 1 @@ -60,7 +64,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK SIP Proxy address: - GTK_JUSTIFY_RIGHT + right 1 @@ -72,6 +76,7 @@ True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + Looks like sip:<proxy hostname> sip: @@ -86,7 +91,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Route (optional): - GTK_JUSTIFY_RIGHT + right 2 @@ -111,7 +116,7 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK Registration duration (sec): - GTK_JUSTIFY_RIGHT + right 3 @@ -133,13 +138,16 @@ + + 0 + + Register at startup True True - Register at startup - 0 + False True True @@ -149,11 +157,11 @@ + Publish presence information True True + False GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - Publish presence information - 0 True @@ -185,38 +193,44 @@ True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - GTK_BUTTONBOX_END + end + gtk-ok True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-ok True - 0 + + False + False + 0 + + gtk-cancel True True True GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - gtk-cancel True - 0 + False + False 1 False - GTK_PACK_END + end + 0 From 6672dec459b7a007a6beffab76831d76b050a7a4 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 4 Jun 2010 17:42:12 +0200 Subject: [PATCH 05/14] add support in the api for multi transport find best contact at first register. multi-transport does not work because it is not implemented in eXosip --- coreapi/linphonecore.c | 133 ++++++++++++++++++++++++++++------------- coreapi/linphonecore.h | 15 ++++- coreapi/private.h | 8 +-- coreapi/proxy.c | 25 ++++++++ coreapi/sal.h | 1 + coreapi/sal_eXosip2.c | 15 +++-- coreapi/sal_eXosip2.h | 1 + mediastreamer2 | 2 +- 8 files changed, 147 insertions(+), 53 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 83d4c84a8..778494aa3 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -628,14 +628,14 @@ static void sip_config_read(LinphoneCore *lc) { char *contact; const char *tmpstr; - int port; + LCSipTransports tr; int i,tmp; int ipv6; - port=lp_config_get_int(lc->config,"sip","use_info",0); - linphone_core_set_use_info_for_dtmf(lc,port); + tmp=lp_config_get_int(lc->config,"sip","use_info",0); + linphone_core_set_use_info_for_dtmf(lc,tmp); - port=lp_config_get_int(lc->config,"sip","use_rfc2833",0); - linphone_core_set_use_rfc2833_for_dtmf(lc,port); + tmp=lp_config_get_int(lc->config,"sip","use_rfc2833",0); + linphone_core_set_use_rfc2833_for_dtmf(lc,tmp); ipv6=lp_config_get_int(lc->config,"sip","use_ipv6",-1); if (ipv6==-1){ @@ -645,19 +645,12 @@ static void sip_config_read(LinphoneCore *lc) } } linphone_core_enable_ipv6(lc,ipv6); - port=lp_config_get_int(lc->config,"sip","sip_port",5060); + memset(&tr,0,sizeof(tr)); + tr.udp_port=lp_config_get_int(lc->config,"sip","sip_port",5060); + tr.tcp_port=lp_config_get_int(lc->config,"sip","sip_tcp_port",0); - tmpstr=lp_config_get_string(lc->config,"sip","transport","udp"); - if (strcmp("udp",tmpstr) == 0 ) { - lc->sip_conf.transport=SalTransportDatagram; - } else if (strcmp("tcp",tmpstr) == 0) { - lc->sip_conf.transport=SalTransportStream; - } else { - lc->sip_conf.transport=SalTransportDatagram; - ms_warning("unsupported transport, using udp"); - } - /*start listening on port*/ - linphone_core_set_sip_port(lc,port); + /*start listening on ports*/ + linphone_core_set_sip_transports(lc,&tr); tmpstr=lp_config_get_string(lc->config,"sip","contact",NULL); if (tmpstr==NULL || linphone_core_set_primary_contact(lc,tmpstr)==-1) { @@ -1237,7 +1230,7 @@ static void update_primary_contact(LinphoneCore *lc){ lc->sip_conf.loopback_only=TRUE; }else lc->sip_conf.loopback_only=FALSE; linphone_address_set_domain(url,tmp); - linphone_address_set_port_int(url,lc->sip_conf.sip_port); + linphone_address_set_port_int(url,linphone_core_get_sip_port (lc)); guessed=linphone_address_as_string(url); lc->sip_conf.guessed_contact=guessed; linphone_address_destroy(url); @@ -1456,11 +1449,13 @@ void linphone_core_set_use_rfc2833_for_dtmf(LinphoneCore *lc,bool_t use_rfc2833) /** * Returns the UDP port used by SIP. * + * Deprecated: use linphone_core_get_sip_transports() instead. * @ingroup network_parameters **/ int linphone_core_get_sip_port(LinphoneCore *lc) { - return lc->sip_conf.sip_port; + LCSipTransports *tr=&lc->sip_conf.transports; + return tr->udp_port>0 ? tr->udp_port : tr->tcp_port; } static char _ua_name[64]="Linphone"; @@ -1492,35 +1487,89 @@ void linphone_core_set_user_agent(const char *name, const char *ver){ strncpy(_ua_version,ver,sizeof(_ua_version)); } -/** - * Sets the UDP port to be used by SIP. - * - * @ingroup network_parameters -**/ -void linphone_core_set_sip_port(LinphoneCore *lc,int port) -{ - const char *anyaddr; - int err=0; - if (port==lc->sip_conf.sip_port) return; - lc->sip_conf.sip_port=port; +static void transport_error(LinphoneCore *lc, const char* transport, int port){ + char *msg=ortp_strdup_printf("Could not start %s transport on port %i, maybe this port is already used.",transport,port); + ms_warning(msg); + if (lc->vtable.display_warning) + lc->vtable.display_warning(lc,msg); + ms_free(msg); +} + +static bool_t transports_unchanged(const LCSipTransports * tr1, const LCSipTransports * tr2){ + return + tr2->udp_port==tr1->udp_port && + tr2->tcp_port==tr1->tcp_port && + tr2->dtls_port==tr1->dtls_port && + tr2->tls_port==tr1->tls_port; +} + +static int apply_transports(LinphoneCore *lc){ + Sal *sal=lc->sal; + const char *anyaddr; + LCSipTransports *tr=&lc->sip_conf.transports; - if (lc->sal==NULL) return; - if (lc->sip_conf.ipv6_enabled) anyaddr="::0"; else anyaddr="0.0.0.0"; - - err=sal_listen_port (lc->sal,anyaddr,port, lc->sip_conf.transport,FALSE); - if (err<0){ - char *msg=ortp_strdup_printf("Port %i seems already in use ! Cannot initialize.",port); - ms_warning(msg); - lc->vtable.display_warning(lc,msg); - ms_free(msg); - return; + sal_unlisten_ports (sal); + if (tr->udp_port>0){ + if (sal_listen_port (sal,anyaddr,tr->udp_port,SalTransportDatagram,FALSE)!=0){ + transport_error(lc,"UDP",tr->udp_port); + return -1; + } + } + if (tr->tcp_port>0){ + if (sal_listen_port (sal,anyaddr,tr->tcp_port,SalTransportStream,FALSE)!=0){ + transport_error(lc,"TCP",tr->tcp_port); + } } apply_user_agent(lc); + return 0; +} + +/** + * Sets the ports to be used for each of transport (UDP or TCP) + * + * A zero value port for a given transport means the transport + * is not used. + * + * @ingroup network_parameters +**/ +int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports * tr){ + + if (transports_unchanged(tr,&lc->sip_conf.transports)) + return 0; + memcpy(&lc->sip_conf.transports,tr,sizeof(*tr)); + + if (lc->sal==NULL) return 0; + return apply_transports(lc); +} + +/** + * Retrieves the ports used for each transport (udp, tcp). + * A zero value port for a given transport means the transport + * is not used. + * @ingroup network_parameters +**/ +int linphone_core_get_sip_transport(LinphoneCore *lc, LCSipTransports *tr){ + memcpy(tr,&lc->sip_conf.transports,sizeof(*tr)); + return 0; +} + +/** + * Sets the UDP port to be used by SIP. + * + * Deprecated: use linphone_core_set_sip_transports() instead. + * @ingroup network_parameters +**/ +void linphone_core_set_sip_port(LinphoneCore *lc,int port) +{ + LCSipTransports tr; + memset(&tr,0,sizeof(tr)); + tr.udp_port=port; + linphone_core_set_sip_transports (lc,&tr); } /** @@ -1547,7 +1596,7 @@ void linphone_core_enable_ipv6(LinphoneCore *lc, bool_t val){ lc->sip_conf.ipv6_enabled=val; if (lc->sal){ /* we need to restart eXosip */ - linphone_core_set_sip_port(lc, lc->sip_conf.sip_port); + apply_transports(lc); } } } @@ -3478,7 +3527,7 @@ void sip_config_uninit(LinphoneCore *lc) MSList *elem; int i; sip_config_t *config=&lc->sip_conf; - lp_config_set_int(lc->config,"sip","sip_port",config->sip_port); + lp_config_set_int(lc->config,"sip","sip_port",config->transports.udp_port); lp_config_set_int(lc->config,"sip","guess_hostname",config->guess_hostname); lp_config_set_string(lc->config,"sip","contact",config->contact); lp_config_set_int(lc->config,"sip","inc_timeout",config->inc_timeout); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index d1b2571d0..34a3483ea 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -44,6 +44,15 @@ struct SalOp; struct _LpConfig; +struct _LCSipTransports{ + int udp_port; + int tcp_port; + int dtls_port; + int tls_port; +}; + +typedef struct _LCSipTransports LCSipTransports; + /** * Object that represents a SIP address. * @@ -609,9 +618,13 @@ void linphone_core_set_use_rfc2833_for_dtmf(LinphoneCore *lc,bool_t use_rfc2833) bool_t linphone_core_get_use_rfc2833_for_dtmf(LinphoneCore *lc); +void linphone_core_set_sip_port(LinphoneCore *lc, int port); + int linphone_core_get_sip_port(LinphoneCore *lc); -void linphone_core_set_sip_port(LinphoneCore *lc,int port); +int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports *transports); + +int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *transports); ortp_socket_t linphone_core_get_sip_socket(LinphoneCore *lc); diff --git a/coreapi/private.h b/coreapi/private.h index e14e1644f..cd3abd3c9 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -247,10 +247,11 @@ typedef struct sip_config { char *contact; char *guessed_contact; - int sip_port; MSList *proxies; MSList *deleted_proxies; int inc_timeout; /*timeout after an un-answered incoming call is rejected*/ + unsigned int keepalive_period; /* interval in ms between keep alive messages sent to the proxy server*/ + LCSipTransports transports; bool_t use_info; bool_t use_rfc2833; /*force RFC2833 to be sent*/ bool_t guess_hostname; @@ -261,9 +262,6 @@ typedef struct sip_config bool_t register_only_when_network_is_up; bool_t ping_with_options; bool_t auto_net_state_mon; - unsigned int keepalive_period; /* interval in ms between keep alive messages sent to the proxy server*/ - SalTransport transport; - } sip_config_t; typedef struct rtp_config @@ -273,7 +271,7 @@ typedef struct rtp_config int audio_jitt_comp; /*jitter compensation*/ int video_jitt_comp; /*jitter compensation*/ int nortp_timeout; - bool_t rtp_no_xmit_on_audio_mute; + bool_t rtp_no_xmit_on_audio_mute; /* stop rtp xmit when audio muted */ }rtp_config_t; diff --git a/coreapi/proxy.c b/coreapi/proxy.c index bf4e0613a..80eb5d522 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -230,14 +230,39 @@ void linphone_proxy_config_apply(LinphoneProxyConfig *obj,LinphoneCore *lc) linphone_proxy_config_done(obj); } +static char *guess_contact_for_register(LinphoneProxyConfig *obj){ + LinphoneAddress *proxy=linphone_address_new(obj->reg_proxy); + char *ret=NULL; + const char *host; + if (proxy==NULL) return NULL; + host=linphone_address_get_domain (proxy); + if (host!=NULL){ + LinphoneAddress *contact; + char localip[LINPHONE_IPADDR_SIZE]; + + linphone_core_get_local_ip(obj->lc,host,localip); + contact=linphone_address_new(obj->reg_identity); + linphone_address_set_domain (contact,localip); + linphone_address_set_port_int(contact,linphone_core_get_sip_port(obj->lc)); + ret=linphone_address_as_string_uri_only (contact); + linphone_address_destroy(contact); + } + linphone_address_destroy (proxy); + return ret; +} + static void linphone_proxy_config_register(LinphoneProxyConfig *obj){ const char *id_str; if (obj->reg_identity!=NULL) id_str=obj->reg_identity; else id_str=linphone_core_get_primary_contact(obj->lc); if (obj->reg_sendregister){ + char *contact; if (obj->op) sal_op_release(obj->op); obj->op=sal_op_new(obj->lc->sal); + contact=guess_contact_for_register(obj); + sal_op_set_contact(obj->op,contact); + ms_free(contact); sal_op_set_user_pointer(obj->op,obj); if (!sal_register(obj->op,obj->reg_proxy,obj->reg_identity,obj->expires)) { gstate_new_state(obj->lc,GSTATE_REG_PENDING,NULL); diff --git a/coreapi/sal.h b/coreapi/sal.h index 6cb1fd426..9790b8c71 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -225,6 +225,7 @@ typedef struct SalAuthInfo{ void sal_set_callbacks(Sal *ctx, const SalCallbacks *cbs); int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int is_secure); +int sal_unlisten_ports(Sal *ctx); ortp_socket_t sal_get_socket(Sal *ctx); void sal_set_user_agent(Sal *ctx, const char *user_agent); /*keepalive period in ms*/ diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index bc097f94a..fa6fb5f11 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -251,6 +251,7 @@ Sal * sal_init(){ } eXosip_init(); sal=ms_new0(Sal,1); + sal->keepalive_period=30; return sal; } @@ -309,6 +310,14 @@ void sal_set_callbacks(Sal *ctx, const SalCallbacks *cbs){ ctx->callbacks.ping_reply=(SalOnPingReply)unimplemented_stub; } +int sal_unlisten_ports(Sal *ctx){ + if (ctx->running){ + eXosip_quit(); + eXosip_init(); + } + return 0; +} + int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int is_secure){ int err; bool_t ipv6; @@ -325,10 +334,6 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i ms_warning("unexpected proto, using datagram"); } - if (ctx->running){ - eXosip_quit(); - eXosip_init(); - } err=0; eXosip_set_option(13,&err); /*13=EXOSIP_OPT_SRV_WITH_NAPTR, as it is an enum value, we can't use it unless we are sure of the version of eXosip, which is not the case*/ @@ -344,6 +349,7 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i #ifdef HAVE_EXOSIP_GET_SOCKET ms_message("Exosip has socket number %i",eXosip_get_socket(proto)); #endif + eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &ctx->keepalive_period); ctx->running=TRUE; return err; } @@ -1749,6 +1755,7 @@ void sal_address_destroy(SalAddress *u){ } void sal_set_keepalive_period(Sal *ctx,unsigned int value) { + ctx->keepalive_period=value; eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &value); } diff --git a/coreapi/sal_eXosip2.h b/coreapi/sal_eXosip2.h index 0df6023a6..5f2c681d1 100644 --- a/coreapi/sal_eXosip2.h +++ b/coreapi/sal_eXosip2.h @@ -38,6 +38,7 @@ struct Sal{ MSList *other_transactions; /*MSList of SalOp */ int running; int session_expires; + int keepalive_period; void *up; }; diff --git a/mediastreamer2 b/mediastreamer2 index 2c6506309..a6484a846 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 2c65063096918cce1dfcc6f01c0cbf43c3232dc0 +Subproject commit a6484a8463b62a60d03ef8358b2e305408f3b011 From 5689b5d8603a4c153876ba97e36cb3dcffd262c0 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 7 Jun 2010 12:09:47 +0200 Subject: [PATCH 06/14] fix linphone_core_get_sip_transports naming --- coreapi/linphonecore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 778494aa3..11674665d 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1553,7 +1553,7 @@ int linphone_core_set_sip_transports(LinphoneCore *lc, const LCSipTransports * t * is not used. * @ingroup network_parameters **/ -int linphone_core_get_sip_transport(LinphoneCore *lc, LCSipTransports *tr){ +int linphone_core_get_sip_transports(LinphoneCore *lc, LCSipTransports *tr){ memcpy(tr,&lc->sip_conf.transports,sizeof(*tr)); return 0; } From 10294f3ceb229040379335dc49f10ac362e1dc45 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 9 Jun 2010 14:49:48 +0200 Subject: [PATCH 07/14] fix bad guess of ip addresses with getifaddrs() (ipv6) --- coreapi/misc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/misc.c b/coreapi/misc.c index 55aa83d4d..58f325d94 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -683,6 +683,7 @@ static int get_local_ip_with_getifaddrs(int type, char *address, int size) if (strchr(address, '%') == NULL) { /*avoid ipv6 link-local addresses */ /*ms_message("getifaddrs() found %s",address);*/ ret++; + break; } } } From d3d68693f67af344d014372bb791c2bb30af7087 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 10 Jun 2010 09:35:32 +0200 Subject: [PATCH 08/14] re-enable LinphoneFactory log handler --- java/common/org/linphone/core/LinphoneCoreFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/common/org/linphone/core/LinphoneCoreFactory.java b/java/common/org/linphone/core/LinphoneCoreFactory.java index cd34cfe36..b3e2952fb 100644 --- a/java/common/org/linphone/core/LinphoneCoreFactory.java +++ b/java/common/org/linphone/core/LinphoneCoreFactory.java @@ -61,5 +61,5 @@ abstract public class LinphoneCoreFactory { */ abstract public void setDebugMode(boolean enable); - //abstract public void setLogHandler(LinphoneLogHandler handler); + abstract public void setLogHandler(LinphoneLogHandler handler); } From 481032c0fb78522592e822f73aee09aa33ac5c2d Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Mon, 14 Jun 2010 16:12:38 +0200 Subject: [PATCH 09/14] fix transport parameter in contact header (for tcp) --- coreapi/proxy.c | 8 +++++++- coreapi/sal.h | 2 +- coreapi/sal_eXosip2.c | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 80eb5d522..babd13e34 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -244,7 +244,13 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){ contact=linphone_address_new(obj->reg_identity); linphone_address_set_domain (contact,localip); linphone_address_set_port_int(contact,linphone_core_get_sip_port(obj->lc)); - ret=linphone_address_as_string_uri_only (contact); + linphone_address_set_display_name(contact,NULL); + LCSipTransports tr; + linphone_core_get_sip_transports(obj->lc,&tr); + if (tr.udp_port <= 0 && tr.tcp_port>0) { + sal_address_add_param(contact,"transport","tcp"); + } + ret=linphone_address_as_string(contact); linphone_address_destroy(contact); } linphone_address_destroy (proxy); diff --git a/coreapi/sal.h b/coreapi/sal.h index 9790b8c71..e6c1292a2 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -57,7 +57,7 @@ void sal_address_clean(SalAddress *addr); char *sal_address_as_string(const SalAddress *u); char *sal_address_as_string_uri_only(const SalAddress *u); void sal_address_destroy(SalAddress *u); - +void sal_address_add_param(SalAddress *u,const char* name,const char* value); diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index fa6fb5f11..df770ce12 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -1749,6 +1749,9 @@ char *sal_address_as_string_uri_only(const SalAddress *u){ osip_free(tmp); return ret; } +void sal_address_add_param(SalAddress *u,const char* name,const char* value) { + osip_uri_uparam_add (((osip_from_t*)u)->url,ms_strdup(name),ms_strdup(value)); +} void sal_address_destroy(SalAddress *u){ osip_from_free((osip_from_t*)u); From 8e6c12d12ac86b9802dff98cc25ab63ebdd4f5b7 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Tue, 15 Jun 2010 13:59:00 +0200 Subject: [PATCH 10/14] add random sip port selection add linphone_core_get_port --- coreapi/address.c | 6 ++++++ coreapi/linphonecore.c | 13 ++++++++++--- coreapi/linphonecore.h | 9 +++++++++ coreapi/sal.h | 3 +++ coreapi/sal_eXosip2.c | 12 ++++++++++++ 5 files changed, 40 insertions(+), 3 deletions(-) diff --git a/coreapi/address.c b/coreapi/address.c index 1d893aede..4d4b1d2d6 100644 --- a/coreapi/address.c +++ b/coreapi/address.c @@ -136,5 +136,11 @@ void linphone_address_destroy(LinphoneAddress *u){ sal_address_destroy(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); +} /** @} */ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 11674665d..b369bb82c 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -646,9 +646,16 @@ static void sip_config_read(LinphoneCore *lc) } linphone_core_enable_ipv6(lc,ipv6); memset(&tr,0,sizeof(tr)); - tr.udp_port=lp_config_get_int(lc->config,"sip","sip_port",5060); - tr.tcp_port=lp_config_get_int(lc->config,"sip","sip_tcp_port",0); - + if (lp_config_get_int(lc->config,"sip","sip_random_port",0)) { + tr.udp_port=(0xDFF&+random())+1024; + } else { + tr.udp_port=lp_config_get_int(lc->config,"sip","sip_port",5060); + } + if (lp_config_get_int(lc->config,"sip","sip_tcp_random_port",0)) { + tr.tcp_port=(0xDFF&+random())+1024; + } else { + tr.tcp_port=lp_config_get_int(lc->config,"sip","sip_tcp_port",0); + } /*start listening on ports*/ linphone_core_set_sip_transports(lc,&tr); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 34a3483ea..b780956ff 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -75,6 +75,15 @@ const char *linphone_address_get_scheme(const LinphoneAddress *u); const char *linphone_address_get_display_name(const LinphoneAddress* u); const char *linphone_address_get_username(const LinphoneAddress *u); const char *linphone_address_get_domain(const LinphoneAddress *u); +/** + * Get port number as an integer value. + * + */ +int linphone_address_get_port_int(const LinphoneAddress *u); +/** + * Get port number, null if not present. + */ +const char* linphone_address_get_port(const LinphoneAddress *u); void linphone_address_set_display_name(LinphoneAddress *u, const char *display_name); void linphone_address_set_username(LinphoneAddress *uri, const char *username); void linphone_address_set_domain(LinphoneAddress *uri, const char *host); diff --git a/coreapi/sal.h b/coreapi/sal.h index 9790b8c71..58d250e90 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -48,6 +48,9 @@ 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_username(const SalAddress *addr); const char *sal_address_get_domain(const SalAddress *addr); +const char * sal_address_get_port(const SalAddress *addr); +int sal_address_get_port_int(const SalAddress *uri); + void sal_address_set_display_name(SalAddress *addr, const char *display_name); void sal_address_set_username(SalAddress *addr, const char *username); void sal_address_set_domain(SalAddress *addr, const char *host); diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index fa6fb5f11..8a427a2df 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -1758,4 +1758,16 @@ void sal_set_keepalive_period(Sal *ctx,unsigned int value) { ctx->keepalive_period=value; eXosip_set_option (EXOSIP_OPT_UDP_KEEP_ALIVE, &value); } +const char * sal_address_get_port(const SalAddress *addr) { + const osip_from_t *u=(const osip_from_t*)addr; + return null_if_empty(u->url->port); +} +int sal_address_get_port_int(const SalAddress *uri) { + const char* port = sal_address_get_port(uri); + if (port != NULL) { + return atoi(port); + } else { + return 5060; + } +} From d21df41a760b67f13fdba03b612e94e6720abf61 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Wed, 16 Jun 2010 16:05:05 +0200 Subject: [PATCH 11/14] destroy cleared proxy config after 5 seconds --- coreapi/linphonecore.c | 10 ++++++++++ coreapi/proxy.c | 3 +++ 2 files changed, 13 insertions(+) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index b369bb82c..75bfee8ab 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -1646,6 +1646,16 @@ static void monitor_network_state(LinphoneCore *lc, time_t curtime){ static void proxy_update(LinphoneCore *lc){ ms_list_for_each(lc->sip_conf.proxies,(void (*)(void*))&linphone_proxy_config_update); + MSList* list=ms_list_copy(lc->sip_conf.deleted_proxies); + for(;list!=NULL;list=list->next){ + LinphoneProxyConfig* cfg = (LinphoneProxyConfig*) list->data; + if (ms_time(NULL) - cfg->deletion_date > 5) { + lc->sip_conf.deleted_proxies =ms_list_remove(lc->sip_conf.deleted_proxies,(void *)cfg); + ms_message("clearing proxy config for [%s]",linphone_proxy_config_get_addr(cfg)); + linphone_proxy_config_destroy(cfg); + } + } + ms_list_free(list); } static void assign_buddy_info(LinphoneCore *lc, BuddyInfo *info){ diff --git a/coreapi/proxy.c b/coreapi/proxy.c index babd13e34..59d767303 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -22,6 +22,7 @@ Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org) #include "sipsetup.h" #include "lpconfig.h" #include "private.h" +#include "mediastreamer2/mediastream.h" #include @@ -505,6 +506,7 @@ void linphone_core_remove_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cf lc->sip_conf.proxies=ms_list_remove(lc->sip_conf.proxies,(void *)cfg); /* add to the list of destroyed proxies, so that the possible unREGISTER request can succeed authentication */ lc->sip_conf.deleted_proxies=ms_list_append(lc->sip_conf.deleted_proxies,(void *)cfg); + cfg->deletion_date=ms_time(NULL); /* this will unREGISTER */ linphone_proxy_config_edit(cfg); if (lc->default_proxy==cfg){ @@ -793,3 +795,4 @@ void * linphone_proxy_config_get_user_data(LinphoneProxyConfig *cr) { + From fc4ab03344359fa2e52a98673ddd47c3e6804264 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Wed, 16 Jun 2010 16:22:44 +0200 Subject: [PATCH 12/14] add test code for renderer callback --- coreapi/linphonecore.c | 13 ++++++++++++- mediastreamer2 | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 778494aa3..ce57abed8 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2142,6 +2142,13 @@ bool_t linphone_core_inc_invite_pending(LinphoneCore*lc){ return FALSE; } +#ifdef TEST_EXT_RENDERER +static void rendercb(void *data, const MSPicture *local, const MSPicture *remote){ + ms_message("rendercb, local buffer=%p, remote buffer=%p", + local ? local->planes[0] : NULL, remote? remote->planes[0] : NULL); +} +#endif + void linphone_core_init_media_streams(LinphoneCore *lc, LinphoneCall *call){ SalMediaDescription *md=call->localdesc; lc->audiostream=audio_stream_new(md->streams[0].port,linphone_core_ipv6_enabled(lc)); @@ -2169,8 +2176,12 @@ void linphone_core_init_media_streams(LinphoneCore *lc, LinphoneCall *call){ rtp_session_set_transports(lc->audiostream->session,lc->a_rtp,lc->a_rtcp); #ifdef VIDEO_ENABLED - if ((lc->video_conf.display || lc->video_conf.capture) && md->streams[1].port>0) + if ((lc->video_conf.display || lc->video_conf.capture) && md->streams[1].port>0){ lc->videostream=video_stream_new(md->streams[1].port,linphone_core_ipv6_enabled(lc)); +#ifdef TEST_EXT_RENDERER + video_stream_set_render_callback(lc->videostream,rendercb,NULL); +#endif + } #else lc->videostream=NULL; #endif diff --git a/mediastreamer2 b/mediastreamer2 index a6484a846..f05af00e9 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit a6484a8463b62a60d03ef8358b2e305408f3b011 +Subproject commit f05af00e9c6d04920ad352633413f4065d00744f From 8821090e4551afe21adaa3d113e416fc1fe42f17 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 17 Jun 2010 09:51:39 +0200 Subject: [PATCH 13/14] add delation_date attribute to proxy cfg --- coreapi/private.h | 1 + 1 file changed, 1 insertion(+) diff --git a/coreapi/private.h b/coreapi/private.h index cd3abd3c9..43f4e0f08 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -207,6 +207,7 @@ struct _LinphoneProxyConfig bool_t publish; bool_t dial_escape_plus; void* user_data; + time_t deletion_date; }; struct _LinphoneAuthInfo From 62a94c9c262a3c36df6623333cd819622428b129 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 17 Jun 2010 12:17:42 +0200 Subject: [PATCH 14/14] fix get_soft_playback_level(): was returning the measured volume ! --- coreapi/linphonecore.c | 14 ++++++++++++-- mediastreamer2 | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index ce57abed8..8f86188ba 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -2655,7 +2655,11 @@ void linphone_core_set_ring_level(LinphoneCore *lc, int level){ if (sndcard) ms_snd_card_set_level(sndcard,MS_SND_CARD_PLAYBACK,level); } - +/** + * Sets call playback gain in db + * + * @ingroup media_parameters +**/ void linphone_core_set_soft_play_level(LinphoneCore *lc, float level){ float gain=level; lc->sound_conf.soft_play_lev=level; @@ -2666,11 +2670,17 @@ void linphone_core_set_soft_play_level(LinphoneCore *lc, float level){ ms_filter_call_method(st->volrecv,MS_VOLUME_SET_DB_GAIN,&gain); }else ms_warning("Could not apply gain: gain control wasn't activated."); } + +/** + * Returns call playback gain in db + * + * @ingroup media_parameters +**/ float linphone_core_get_soft_play_level(LinphoneCore *lc) { float gain=0; AudioStream *st=lc->audiostream; if (st->volrecv){ - ms_filter_call_method(st->volrecv,MS_VOLUME_GET,&gain); + ms_filter_call_method(st->volrecv,MS_VOLUME_GET_GAIN_DB,&gain); }else ms_warning("Could not get gain: gain control wasn't activated."); return gain; diff --git a/mediastreamer2 b/mediastreamer2 index f05af00e9..17e879de8 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit f05af00e9c6d04920ad352633413f4065d00744f +Subproject commit 17e879de84d894df6a1875665594567c1cf43617