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/console/commands.c b/console/commands.c index 73e1b2b54..e6cdca200 100644 --- a/console/commands.c +++ b/console/commands.c @@ -80,6 +80,9 @@ static int lpc_cmd_codec(LinphoneCore *lc, char *args); static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args); static int lpc_cmd_pause(LinphoneCore *lc, char *args); static int lpc_cmd_resume(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); @@ -221,19 +224,27 @@ LPC_COMMAND commands[] = { "'speak ' : speak a text using the specified espeak voice.\n" "Example for english voice: 'speak default Hello my friend !'" }, - { "codec", lpc_cmd_codec, "Codec configuration", - "'codec list' : list codecs\n" - "'codec enable ' : enable available codec\n" - "'codec disable ' : disable codecs" }, - { "ec", lpc_cmd_echocancellation, "Echo cancellation", - "'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" }, - { "pause", lpc_cmd_pause, "pause a call", - "'pause' : pause the current call\n"}, - { "resume", lpc_cmd_resume, "resume a call", - "'resume' : resume the unique call\n" - "'resume ' : hold off the call with cid \n"}, + { "codec", lpc_cmd_codec, "Codec configuration", + "'codec list' : list codecs\n" + "'codec enable ' : enable available codec\n" + "'codec disable ' : disable codecs" }, + { "ec", lpc_cmd_echocancellation, "Echo cancellation", + "'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" }, + { "pause", lpc_cmd_pause, "pause a call", + "'pause' : pause the current call\n"}, + { "resume", lpc_cmd_resume, "resume a call", + "'resume' : resume the unique call\n" + "'resume ' : hold off the call with cid \n"}, + { "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 } }; @@ -1770,9 +1781,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)); @@ -1984,6 +1997,38 @@ static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){ return 1; } +static int lpc_cmd_mute_mic(LinphoneCore *lc, char *args) +{ + linphone_core_mute_mic(lc, 1); + return 1; +} + +static int lpc_cmd_unmute_mic(LinphoneCore *lc, char *args){ + 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/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 51171d9f5..3423dd87c 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -478,19 +478,20 @@ static void sip_config_read(LinphoneCore *lc) { char *contact; const char *tmpstr; - int port; + LCSipTransports tr; int i,tmp; int ipv6; + tmp=lp_config_get_int(lc->config,"sip","use_info",0); + linphone_core_set_use_info_for_dtmf(lc,tmp); + if (lp_config_get_int(lc->config,"sip","use_session_timers",0)==1){ sal_use_session_timers(lc->sal,200); } - - port=lp_config_get_int(lc->config,"sip","use_info",0); - linphone_core_set_use_info_for_dtmf(lc,port); - 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){ @@ -501,8 +502,19 @@ 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); + memset(&tr,0,sizeof(tr)); + 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); tmpstr=lp_config_get_string(lc->config,"sip","contact",NULL); if (tmpstr==NULL || linphone_core_set_primary_contact(lc,tmpstr)==-1) { @@ -553,6 +565,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); @@ -570,6 +587,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); @@ -582,6 +601,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){ @@ -1076,7 +1097,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); @@ -1205,6 +1226,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. * @@ -1215,6 +1240,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. * @@ -1287,11 +1316,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"; @@ -1323,37 +1354,91 @@ 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 -**/ -int linphone_core_set_sip_port(LinphoneCore *lc,int port) -{ - const char *anyaddr; - int err=0; - if (port==lc->sip_conf.sip_port) return 0; - 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 -1; - if (lc->sip_conf.ipv6_enabled) anyaddr="::0"; else anyaddr="0.0.0.0"; - err=sal_listen_port (lc->sal,anyaddr,port, SalTransportDatagram,FALSE); - if (err<0){ - char *msg=ortp_strdup_printf("UDP port %i seems already in use ! Cannot initialize.",port); - ms_warning(msg); - if (lc->vtable.display_warning) - lc->vtable.display_warning(lc,msg); - ms_free(msg); - return -1; + + 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_transports(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); +} + /** * Returns TRUE if IPv6 is enabled. * @@ -1378,7 +1463,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); } } } @@ -1435,6 +1520,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){ @@ -1971,6 +2066,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){ #ifdef PRINTF_DEBUG printf("%s(%d)\n",__FUNCTION__,__LINE__); @@ -2001,8 +2103,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 @@ -2047,6 +2153,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); @@ -2667,7 +2774,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; @@ -2678,11 +2789,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; @@ -2993,6 +3110,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; } } @@ -3005,6 +3126,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; } @@ -3529,7 +3668,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 c77d1e26a..f9dc69e63 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. * @@ -66,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); @@ -655,9 +673,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); -int 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); @@ -734,6 +756,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/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; } } } diff --git a/coreapi/private.h b/coreapi/private.h index e67ccc130..2a55b428f 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -203,6 +203,7 @@ struct _LinphoneProxyConfig bool_t publish; bool_t dial_escape_plus; void* user_data; + time_t deletion_date; }; struct _LinphoneAuthInfo @@ -238,14 +239,16 @@ struct _LinphoneFriend{ bool_t inc_subscribe_pending; }; + 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; @@ -256,7 +259,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*/ } sip_config_t; typedef struct rtp_config @@ -266,6 +268,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; @@ -397,6 +401,7 @@ struct _LinphoneCore bool_t preview_finished; bool_t auto_net_state_mon; bool_t network_reachable; + bool_t audio_muted; }; bool_t linphone_core_can_we_add_call(LinphoneCore *lc); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index bf4e0613a..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 @@ -230,14 +231,45 @@ 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)); + 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); + 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); @@ -474,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){ @@ -762,3 +795,4 @@ void * linphone_proxy_config_get_user_data(LinphoneProxyConfig *cr) { + diff --git a/coreapi/sal.h b/coreapi/sal.h index 18403045e..c8ed11a49 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); @@ -57,7 +60,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); @@ -227,6 +230,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 69f746642..2a2c85516 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,15 +310,30 @@ 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; int proto=IPPROTO_UDP; - if (ctx->running){ - eXosip_quit(); - eXosip_init(); + switch (tr) { + case SalTransportDatagram: + proto=IPPROTO_UDP; + break; + case SalTransportStream: + proto= IPPROTO_TCP; + break; + default: + ms_warning("unexpected proto, using datagram"); } + 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*/ @@ -325,14 +341,15 @@ 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); #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; } @@ -367,6 +384,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); @@ -1750,14 +1773,30 @@ 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); } 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; + } +} /** * Send a re-Invite used to hold the current call 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/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 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); } 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" 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