From 4e847d24ca5c3a5012cb62beee4248667428b24c Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 30 Aug 2012 16:27:16 +0200 Subject: [PATCH 1/4] add function LinphoneProxyConfig * linphone_core_create_proxy_config(LinphoneCore *lc) to create proxy config with default values from section [default_values] --- coreapi/linphonecore.h | 8 ++++++++ coreapi/proxy.c | 29 +++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 4895ccb93..2972bc090 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -956,6 +956,14 @@ const char *linphone_core_get_payload_type_description(LinphoneCore *lc, Payload bool_t linphone_core_check_payload_type_usability(LinphoneCore *lc, PayloadType *pt); +/** + * @ingroup proxy + *Create a proxy config with default value from Linphone core. + *@param lc #LinphoneCore object + *@return #LinphoneProxyConfig with defualt value set + */ +LinphoneProxyConfig * linphone_core_create_proxy_config(LinphoneCore *lc); + int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *config); void linphone_core_clear_proxy_config(LinphoneCore *lc); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 8e066ea33..11a55f59b 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -42,10 +42,17 @@ void linphone_proxy_config_write_all_to_config_file(LinphoneCore *lc){ lp_config_set_int(lc->config,"sip","default_proxy",linphone_core_get_default_proxy(lc,NULL)); } -void linphone_proxy_config_init(LinphoneProxyConfig *obj){ +#define DEFAULT_INT(config,name,default) \ + config?lp_config_get_int(config,"default_values",#name,default):default +#define DEFAULT_STRING(config,name,default) \ + config?lp_config_get_string(config,"default_values",#name,default):default + +static void linphone_proxy_config_init(LinphoneCore* lc,LinphoneProxyConfig *obj){ memset(obj,0,sizeof(LinphoneProxyConfig)); obj->magic=linphone_proxy_config_magic; - obj->expires=3600; + obj->expires=DEFAULT_INT((lc?lc->config:NULL),reg_expires,3600); + obj->dial_prefix=ms_strdup(DEFAULT_STRING((lc?lc->config:NULL),dial_prefix,'\0')); + obj->dial_escape_plus=DEFAULT_INT((lc?lc->config:NULL),dial_escape_plus,0); } /** @@ -54,15 +61,21 @@ void linphone_proxy_config_init(LinphoneProxyConfig *obj){ **/ /** - * Creates an empty proxy config. + * @deprecated, use #linphone_core_create_proxy_config instead + *Creates an empty proxy config. **/ -LinphoneProxyConfig *linphone_proxy_config_new(){ +LinphoneProxyConfig *linphone_proxy_config_new() { + return linphone_core_create_proxy_config(NULL); +} +LinphoneProxyConfig * linphone_core_create_proxy_config(LinphoneCore *lc) { LinphoneProxyConfig *obj=NULL; obj=ms_new(LinphoneProxyConfig,1); - linphone_proxy_config_init(obj); + linphone_proxy_config_init(lc,obj); return obj; } + + /** * Destroys a proxy config. * @@ -701,13 +714,13 @@ LinphoneProxyConfig *linphone_proxy_config_new_from_config_file(LpConfig *config tmp=lp_config_get_string(config,key,"reg_route",NULL); if (tmp!=NULL) linphone_proxy_config_set_route(cfg,tmp); - linphone_proxy_config_expires(cfg,lp_config_get_int(config,key,"reg_expires",600)); + linphone_proxy_config_expires(cfg,lp_config_get_int(config,key,"reg_expires",DEFAULT_INT(config,reg_expires,600))); linphone_proxy_config_enableregister(cfg,lp_config_get_int(config,key,"reg_sendregister",0)); linphone_proxy_config_enable_publish(cfg,lp_config_get_int(config,key,"publish",0)); - linphone_proxy_config_set_dial_escape_plus(cfg,lp_config_get_int(config,key,"dial_escape_plus",0)); - linphone_proxy_config_set_dial_prefix(cfg,lp_config_get_string(config,key,"dial_prefix",NULL)); + linphone_proxy_config_set_dial_escape_plus(cfg,lp_config_get_int(config,key,"dial_escape_plus",DEFAULT_INT(config,dial_escape_plus,0))); + linphone_proxy_config_set_dial_prefix(cfg,lp_config_get_string(config,key,"dial_prefix",DEFAULT_STRING(config,dial_prefix,NULL))); tmp=lp_config_get_string(config,key,"type",NULL); if (tmp!=NULL && strlen(tmp)>0) From 335129ed8ad1abb545d9e1cae809eaed1b5608dc Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 31 Aug 2012 10:04:57 +0200 Subject: [PATCH 2/4] add dscp settings --- coreapi/linphonecall.c | 7 +++++++ mediastreamer2 | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 68e5936ed..929814b52 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -938,8 +938,11 @@ void linphone_call_init_audio_stream(LinphoneCall *call){ LinphoneCore *lc=call->core; SalMediaDescription *md=call->localdesc; AudioStream *audiostream; + int dscp=lp_config_get_int(lc->config,"rtp","audio_dscp",-1); call->audiostream=audiostream=audio_stream_new(md->streams[0].rtp_port,md->streams[0].rtcp_port,linphone_core_ipv6_enabled(lc)); + if (dscp!=-1) + audio_stream_set_dscp(audiostream,dscp); if (linphone_core_echo_limiter_enabled(lc)){ const char *type=lp_config_get_string(lc->config,"sound","el_type","mic"); if (strcasecmp(type,"mic")==0) @@ -990,7 +993,11 @@ void linphone_call_init_video_stream(LinphoneCall *call){ if ((lc->video_conf.display || lc->video_conf.capture) && md->streams[1].rtp_port>0){ int video_recv_buf_size=lp_config_get_int(lc->config,"video","recv_buf_size",0); + int dscp=lp_config_get_int(lc->config,"rtp","video_dscp",-1); + call->videostream=video_stream_new(md->streams[1].rtp_port,md->streams[1].rtcp_port,linphone_core_ipv6_enabled(lc)); + if (dscp!=-1) + video_stream_set_dscp(call->videostream,dscp); video_stream_enable_display_filter_auto_rotate(call->videostream, lp_config_get_int(lc->config,"video","display_filter_auto_rotate",0)); if (video_recv_buf_size>0) rtp_session_set_recv_buf_size(call->videostream->session,video_recv_buf_size); diff --git a/mediastreamer2 b/mediastreamer2 index 1a267bd2f..06b53e9d7 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 1a267bd2fb946b51b877a8cbc78f3445c11ab361 +Subproject commit 06b53e9d743ce42d9cf1d343514889a6a44a1ef5 From 5129e306ab832326e887431c38fc22ebaf6b7433 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 30 Aug 2012 15:26:28 +0200 Subject: [PATCH 3/4] Handle IPv6 addresses in parse_hostname_to_addr(). This is needed to correctly handle and IPv6 address set as gateway when using the nat firewall policy. --- coreapi/misc.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/coreapi/misc.c b/coreapi/misc.c index bf5c53dcc..a22bbc1d9 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -408,19 +408,29 @@ static int sendStunRequest(int sock, const struct sockaddr *server, socklen_t ad int parse_hostname_to_addr(const char *server, struct sockaddr_storage *ss, socklen_t *socklen){ struct addrinfo hints,*res=NULL; + int family = PF_INET; + int port_int = 3478; int ret; - const char *port; + char port[6]; char host[NI_MAXHOST]; - char *p; - host[NI_MAXHOST-1]='\0'; - strncpy(host,server,sizeof(host)-1); - p=strchr(host,':'); - if (p) { - *p='\0'; - port=p+1; - }else port="3478"; + char *p1, *p2; + if ((sscanf(server, "[%64[^]]]:%d", host, &port_int) == 2) || (sscanf(server, "[%64[^]]]", host) == 1)) { + family = PF_INET6; + } else { + p1 = strchr(server, ':'); + p2 = strrchr(server, ':'); + if (p1 && p2 && (p1 != p2)) { + family = PF_INET6; + host[NI_MAXHOST-1]='\0'; + strncpy(host, server, sizeof(host) - 1); + } else if (sscanf(server, "%[^:]:%d", host, &port_int) != 2) { + host[NI_MAXHOST-1]='\0'; + strncpy(host, server, sizeof(host) - 1); + } + } + snprintf(port, sizeof(port), "%d", port_int); memset(&hints,0,sizeof(hints)); - hints.ai_family=PF_INET; + hints.ai_family=family; hints.ai_socktype=SOCK_DGRAM; hints.ai_protocol=IPPROTO_UDP; ret=getaddrinfo(host,port,&hints,&res); From 86d32db4d17cc50bb5005d2700ddd358810ce3ea Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Fri, 31 Aug 2012 11:32:50 +0200 Subject: [PATCH 4/4] Update ms2 submodule. --- mediastreamer2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mediastreamer2 b/mediastreamer2 index 06b53e9d7..beb4318d1 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 06b53e9d743ce42d9cf1d343514889a6a44a1ef5 +Subproject commit beb4318d1e5eb282adc82967a9c80e89cd406045