Commit d676eb51 authored by Simon Morlat's avatar Simon Morlat

implement dscp settings from config file and gtk interface

parent 417d5d93
......@@ -974,7 +974,7 @@ void linphone_call_set_next_video_frame_decoded_callback(LinphoneCall *call, Lin
void linphone_call_init_audio_stream(LinphoneCall *call){
LinphoneCore *lc=call->core;
AudioStream *audiostream;
int dscp=lp_config_get_int(lc->config,"rtp","audio_dscp",-1);
int dscp=linphone_core_get_audio_dscp(lc);
call->audiostream=audiostream=audio_stream_new(call->audio_port,call->audio_port+1,linphone_core_ipv6_enabled(lc));
if (dscp!=-1)
......@@ -1028,7 +1028,7 @@ void linphone_call_init_video_stream(LinphoneCall *call){
if ((lc->video_conf.display || lc->video_conf.capture) && call->params.has_video){
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);
int dscp=linphone_core_get_video_dscp(lc);
call->videostream=video_stream_new(call->video_port,call->video_port+1,linphone_core_ipv6_enabled(lc));
if (dscp!=-1)
......
......@@ -615,6 +615,7 @@ static void sip_config_read(LinphoneCore *lc)
sal_set_keepalive_period(lc->sal,lc->sip_conf.keepalive_period);
sal_use_one_matching_codec_policy(lc->sal,lp_config_get_int(lc->config,"sip","only_one_codec",0));
sal_use_double_registrations(lc->sal,lp_config_get_int(lc->config,"sip","use_double_registrations",1));
sal_set_dscp(lc->sal,linphone_core_get_sip_dscp(lc));
}
static void rtp_config_read(LinphoneCore *lc)
......@@ -5112,3 +5113,74 @@ void linphone_core_set_device_identifier(LinphoneCore *lc,const char* device_id)
const char* linphone_core_get_device_identifier(const LinphoneCore *lc) {
return lc->device_id;
}
/**
* Set the DSCP field for SIP signaling channel.
*
* @ingroup network_parameters
* * The DSCP defines the quality of service in IP packets.
*
**/
void linphone_core_set_sip_dscp(LinphoneCore *lc, int dscp){
sal_set_dscp(lc->sal,dscp);
if (linphone_core_ready(lc))
lp_config_set_int_hex(lc->config,"sip","dscp",dscp);
}
/**
* Get the DSCP field for SIP signaling channel.
*
* @ingroup network_parameters
* * The DSCP defines the quality of service in IP packets.
*
**/
int linphone_core_get_sip_dscp(const LinphoneCore *lc){
return lp_config_get_int(lc->config,"sip","dscp",0x1a);
}
/**
* Set the DSCP field for outgoing audio streams.
*
* @ingroup network_parameters
* The DSCP defines the quality of service in IP packets.
*
**/
void linphone_core_set_audio_dscp(LinphoneCore *lc, int dscp){
if (linphone_core_ready(lc))
lp_config_set_int_hex(lc->config,"rtp","audio_dscp",dscp);
}
/**
* Get the DSCP field for outgoing audio streams.
*
* @ingroup network_parameters
* The DSCP defines the quality of service in IP packets.
*
**/
int linphone_core_get_audio_dscp(const LinphoneCore *lc){
return lp_config_get_int(lc->config,"rtp","audio_dscp",0x2e);
}
/**
* Set the DSCP field for outgoing video streams.
*
* @ingroup network_parameters
* The DSCP defines the quality of service in IP packets.
*
**/
void linphone_core_set_video_dscp(LinphoneCore *lc, int dscp){
if (linphone_core_ready(lc))
lp_config_set_int_hex(lc->config,"rtp","video_dscp",dscp);
}
/**
* Get the DSCP field for outgoing video streams.
*
* @ingroup network_parameters
* The DSCP defines the quality of service in IP packets.
*
**/
int linphone_core_get_video_dscp(const LinphoneCore *lc){
return lp_config_get_int(lc->config,"rtp","video_dscp",0x2e);
}
......@@ -1389,6 +1389,15 @@ LinphoneTunnel *linphone_core_get_tunnel(LinphoneCore *lc);
void linphone_call_zoom_video(LinphoneCall* call, float zoom_factor, float* cx, float* cy);
void linphone_core_set_sip_dscp(LinphoneCore *lc, int dscp);
int linphone_core_get_sip_dscp(const LinphoneCore *lc);
void linphone_core_set_audio_dscp(LinphoneCore *lc, int dscp);
int linphone_core_get_audio_dscp(const LinphoneCore *lc);
void linphone_core_set_video_dscp(LinphoneCore *lc, int dscp);
int linphone_core_get_video_dscp(const LinphoneCore *lc);
#ifdef __cplusplus
}
#endif
......
......@@ -273,7 +273,13 @@ const char *lp_config_get_string(LpConfig *lpconfig, const char *section, const
int lp_config_get_int(LpConfig *lpconfig,const char *section, const char *key, int default_value){
const char *str=lp_config_get_string(lpconfig,section,key,NULL);
if (str!=NULL) return atoi(str);
if (str!=NULL) {
int ret=0;
if (strstr(str,"0x")==str){
sscanf(str,"%x",&ret);
}else ret=atoi(str);
return ret;
}
else return default_value;
}
......@@ -324,6 +330,12 @@ void lp_config_set_int(LpConfig *lpconfig,const char *section, const char *key,
lp_config_set_string(lpconfig,section,key,tmp);
}
void lp_config_set_int_hex(LpConfig *lpconfig,const char *section, const char *key, int value){
char tmp[30];
snprintf(tmp,sizeof(tmp),"0x%x",value);
lp_config_set_string(lpconfig,section,key,tmp);
}
void lp_config_set_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t value){
char tmp[30];
snprintf(tmp,sizeof(tmp),"%lli",(long long)value);
......
......@@ -96,6 +96,14 @@ void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *ke
* @ingroup misc
**/
void lp_config_set_int(LpConfig *lpconfig,const char *section, const char *key, int value);
/**
* Sets an integer config item, but store it as hexadecimal
*
* @ingroup misc
**/
void lp_config_set_int_hex(LpConfig *lpconfig,const char *section, const char *key, int value);
/**
* Sets a 64 bits integer config item
*
......
......@@ -325,6 +325,7 @@ void sal_auth_info_delete(const SalAuthInfo* auth_info);
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);
void sal_set_dscp(Sal *ctx, int dscp);
int sal_reset_transports(Sal *ctx);
ortp_socket_t sal_get_socket(Sal *ctx);
void sal_set_user_agent(Sal *ctx, const char *user_agent);
......
......@@ -283,6 +283,7 @@ Sal * sal_init(){
sal->rootCa = 0;
sal->verify_server_certs=TRUE;
sal->expire_old_contact=FALSE;
sal->dscp=-1;
return sal;
}
......@@ -380,6 +381,12 @@ static void set_tls_options(Sal *ctx){
#endif
}
void sal_set_dscp(Sal *ctx, int dscp){
ctx->dscp=dscp;
if (dscp!=-1)
eXosip_set_option(EXOSIP_OPT_SET_DSCP,&ctx->dscp);
}
int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int is_secure){
int err;
bool_t ipv6;
......@@ -406,6 +413,7 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i
eXosip_set_option(EXOSIP_OPT_USE_RPORT,&use_rports);
int dont_use_101 = !ctx->use_101; // Copy char to int to avoid bad alignment
eXosip_set_option(EXOSIP_OPT_DONT_SEND_101,&dont_use_101);
sal_set_dscp(ctx,ctx->dscp);
ipv6=strchr(addr,':')!=NULL;
eXosip_enable_ipv6(ipv6);
......
......@@ -41,6 +41,7 @@ struct Sal{
int keepalive_period;
void *up; /*user pointer*/
char* rootCa; /* File _or_ folder containing root CA */
int dscp;
bool_t one_matching_codec;
bool_t double_reg;
bool_t use_rports;
......
......@@ -9,7 +9,8 @@ UI_FILES= about.ui \
log.ui \
buddylookup.ui \
tunnel_config.ui \
waiting.ui
waiting.ui \
dscp_settings.ui
PIXMAPS= \
stock_people.png
......
<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.24"/>
<!-- interface-naming-policy project-wide -->
<object class="GtkDialog" id="dscp_settings">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Dscp settings</property>
<property name="modal">True</property>
<property name="type_hint">dialog</property>
<signal name="response" handler="linphone_gtk_dscp_edit_response" swapped="no"/>
<child internal-child="vbox">
<object class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
<object class="GtkButton" id="button2">
<property name="label">gtk-close</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button1">
<property name="label">gtk-ok</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_action_appearance">False</property>
<property name="use_stock">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkTable" id="table1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="homogeneous">True</property>
<child>
<object class="GtkEntry" id="sip_dscp">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
<property name="invisible_char_set">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="audio_dscp">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
<property name="invisible_char_set">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="video_dscp">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char"></property>
<property name="invisible_char_set">True</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
<property name="secondary_icon_sensitive">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">SIP</property>
</object>
</child>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Audio RTP stream</property>
</object>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Video RTP stream</property>
</object>
<packing>
<property name="top_attach">2</property>
<property name="bottom_attach">3</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;Set DSCP values (in hexadecimal)&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<action-widgets>
<action-widget response="-6">button2</action-widget>
<action-widget response="-5">button1</action-widget>
</action-widgets>
</object>
</interface>
This diff is collapsed.
......@@ -1131,3 +1131,55 @@ void linphone_gtk_tunnel_ok(GtkButton *button){
void linphone_gtk_tunnel_cancel(GtkButton *button){
}
static void show_dscp(GtkWidget *entry, int val){
char tmp[20];
snprintf(tmp,sizeof(tmp),"0x%x",val);
gtk_entry_set_text(GTK_ENTRY(entry),tmp);
}
static int read_dscp(GtkWidget *entry){
const char *val=gtk_entry_get_text(GTK_ENTRY(entry));
const char *begin;
int ret=0;
if (val==NULL || val[0]=='\0') return 0;
/*skip potential 0x*/
begin=strstr(val,"0x");
if (begin) begin+=2;
else begin=val;
if (sscanf(begin,"%x",&ret)==1)
return ret;
return -1;
}
void linphone_gtk_dscp_edit(){
LinphoneCore *lc=linphone_gtk_get_core();
GtkWidget *widget=linphone_gtk_create_window("dscp_settings");
show_dscp(linphone_gtk_get_widget(widget,"sip_dscp"),
linphone_core_get_sip_dscp(lc));
show_dscp(linphone_gtk_get_widget(widget,"audio_dscp"),
linphone_core_get_audio_dscp(lc));
show_dscp(linphone_gtk_get_widget(widget,"video_dscp"),
linphone_core_get_video_dscp(lc));
gtk_widget_show(widget);
}
void linphone_gtk_dscp_edit_response(GtkWidget *dialog, guint response_id){
LinphoneCore *lc=linphone_gtk_get_core();
switch(response_id){
case GTK_RESPONSE_OK:
linphone_core_set_sip_dscp(lc,
read_dscp(linphone_gtk_get_widget(dialog,"sip_dscp")));
linphone_core_set_audio_dscp(lc,
read_dscp(linphone_gtk_get_widget(dialog,"audio_dscp")));
linphone_core_set_video_dscp(lc,
read_dscp(linphone_gtk_get_widget(dialog,"video_dscp")));
break;
default:
break;
}
gtk_widget_destroy(dialog);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment