forked from mirrors/linphone-iphone
implement manual low banwdwidth mode.
It is also possible to check whether peer is under low bandwidth by looking into the linphone_call_get_remote_params()
This commit is contained in:
parent
4315fafad9
commit
c6bd038a6d
4 changed files with 49 additions and 18 deletions
|
|
@ -219,9 +219,7 @@ void linphone_call_make_local_media_description(LinphoneCore *lc, LinphoneCall *
|
|||
SalMediaDescription *md=sal_media_description_new();
|
||||
bool_t keep_srtp_keys=lp_config_get_int(lc->config,"sip","keep_srtp_keys",0);
|
||||
|
||||
if (call->ping_time>0) {
|
||||
linphone_core_adapt_to_network(lc,call->ping_time,&call->params);
|
||||
}
|
||||
linphone_core_adapt_to_network(lc,call->ping_time,&call->params);
|
||||
|
||||
md->session_id=(old_md ? old_md->session_id : (rand() & 0xfff));
|
||||
md->session_ver=(old_md ? (old_md->session_ver+1) : (rand() & 0xfff));
|
||||
|
|
@ -746,6 +744,11 @@ const LinphoneCallParams * linphone_call_get_remote_params(LinphoneCall *call){
|
|||
}else if (vsd){
|
||||
cp->has_video=is_video_active(vsd);
|
||||
}
|
||||
if (!cp->has_video){
|
||||
if (md->bandwidth>0 && md->bandwidth<=linphone_core_get_edge_bw(call->core)){
|
||||
cp->low_bandwidth=TRUE;
|
||||
}
|
||||
}
|
||||
return cp;
|
||||
}
|
||||
}
|
||||
|
|
@ -925,9 +928,31 @@ const PayloadType* linphone_call_params_get_used_video_codec(const LinphoneCallP
|
|||
return cp->video_codec;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup call_control
|
||||
* Use to know if this call has been configured in low bandwidth mode.
|
||||
* This mode can be automatically discovered thanks to a stun server when activate_edge_workarounds=1 in section [net] of configuration file.
|
||||
* An application that would have reliable way to know network capacity may not use activate_edge_workarounds=1 but instead manually configure
|
||||
* low bandwidth mode with linphone_call_params_enable_low_bandwidth().
|
||||
* <br> When enabled, this param may transform a call request with video in audio only mode.
|
||||
* @return TRUE if low bandwidth has been configured/detected
|
||||
*/
|
||||
bool_t linphone_call_params_low_bandwidth_enabled(const LinphoneCallParams *cp) {
|
||||
return cp->low_bandwidth;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ingroup call_control
|
||||
* Indicate low bandwith mode.
|
||||
* Configuring a call to low bandwidth mode will result in the core to activate several settings for the call in order to ensure that bitrate usage
|
||||
* is lowered to the minimum possible. Typically, ptime (packetization time) will be increased, audio codec's output bitrate will be targetted to 20kbit/s provided
|
||||
* that it is achievable by the codec selected after SDP handshake. Video is automatically disabled.
|
||||
*
|
||||
**/
|
||||
void linphone_call_params_enable_low_bandwidth(LinphoneCallParams *cp, bool_t enabled){
|
||||
cp->low_bandwidth=TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether video is enabled.
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -204,14 +204,9 @@ bool_t linphone_call_params_early_media_sending_enabled(const LinphoneCallParams
|
|||
bool_t linphone_call_params_local_conference_mode(const LinphoneCallParams *cp);
|
||||
void linphone_call_params_set_audio_bandwidth_limit(LinphoneCallParams *cp, int bw);
|
||||
void linphone_call_params_destroy(LinphoneCallParams *cp);
|
||||
/**
|
||||
* @ingroup call_control
|
||||
* Use to know if this call has been configured in low bandwidth mode.
|
||||
* This mode can be automatically discovered thanks to a stun server when activate_edge_workarounds=1 in section [net] of configuration file
|
||||
* <br> When enabled, this param may transform a call request with video in audio only mode.
|
||||
* @return TRUE if low bandwidth has been configured/detected
|
||||
*/
|
||||
bool_t linphone_call_params_low_bandwidth_enabled(const LinphoneCallParams *cp);
|
||||
void linphone_call_params_enable_low_bandwidth(LinphoneCallParams *cp, bool_t enabled);
|
||||
|
||||
/**
|
||||
* Enum describing failure reasons.
|
||||
* @ingroup initializing
|
||||
|
|
|
|||
|
|
@ -574,21 +574,31 @@ int linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call){
|
|||
return -1;
|
||||
}
|
||||
|
||||
int linphone_core_get_edge_bw(LinphoneCore *lc){
|
||||
int edge_bw=lp_config_get_int(lc->config,"net","edge_bw",20);
|
||||
return edge_bw;
|
||||
}
|
||||
|
||||
int linphone_core_get_edge_ptime(LinphoneCore *lc){
|
||||
int edge_ptime=lp_config_get_int(lc->config,"net","edge_ptime",100);
|
||||
return edge_ptime;
|
||||
}
|
||||
|
||||
void linphone_core_adapt_to_network(LinphoneCore *lc, int ping_time_ms, LinphoneCallParams *params){
|
||||
if (lp_config_get_int(lc->config,"net","activate_edge_workarounds",0)==1){
|
||||
if (ping_time_ms>0 && lp_config_get_int(lc->config,"net","activate_edge_workarounds",0)==1){
|
||||
ms_message("Stun server ping time is %i ms",ping_time_ms);
|
||||
int threshold=lp_config_get_int(lc->config,"net","edge_ping_time",500);
|
||||
|
||||
if (ping_time_ms>threshold){
|
||||
int edge_ptime=lp_config_get_int(lc->config,"net","edge_ptime",100);
|
||||
int edge_bw=lp_config_get_int(lc->config,"net","edge_bw",20);
|
||||
/* we are in a 2G network*/
|
||||
params->up_bw=params->down_bw=edge_bw;
|
||||
params->up_ptime=params->down_ptime=edge_ptime;
|
||||
params->has_video=FALSE;
|
||||
/* we might be in a 2G network*/
|
||||
params->low_bandwidth=TRUE;
|
||||
}/*else use default settings */
|
||||
}
|
||||
if (params->low_bandwidth){
|
||||
params->up_bw=params->down_bw=linphone_core_get_edge_bw(lc);
|
||||
params->up_ptime=params->down_ptime=linphone_core_get_edge_ptime(lc);
|
||||
params->has_video=FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -639,7 +639,8 @@ void _linphone_core_codec_config_write(LinphoneCore *lc);
|
|||
#endif
|
||||
void call_logs_write_to_config_file(LinphoneCore *lc);
|
||||
|
||||
|
||||
int linphone_core_get_edge_bw(LinphoneCore *lc);
|
||||
int linphone_core_get_edge_ptime(LinphoneCore *lc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue