mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-02-02 11:19:30 +00:00
cleanups, add network simulation api to liblinphone
This commit is contained in:
parent
21f9d22b0a
commit
49a91becb7
12 changed files with 86 additions and 38 deletions
|
|
@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
|
||||
/**
|
||||
* @addtogroup linphone_dict
|
||||
* @addtogroup misc
|
||||
* @{
|
||||
**/
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define LINPHONEEVENT_H
|
||||
|
||||
/**
|
||||
* @addtogroup subscriptions
|
||||
* @addtogroup event_api
|
||||
* @{
|
||||
**/
|
||||
|
||||
|
|
|
|||
|
|
@ -221,6 +221,12 @@ void text_received(LinphoneCore *lc, LinphoneChatRoom *room, const LinphoneAddre
|
|||
*
|
||||
**/
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup event_api Managing generic subscriptions and publishes
|
||||
* The LinphoneEvent api allows application to control subscriptions, receive notifications and make publish to peers, in a generic manner.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup misc Miscenalleous: logs, version strings, config storage
|
||||
**/
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@
|
|||
#include "private.h"
|
||||
#include "lpconfig.h"
|
||||
|
||||
static const char *_tunnel_mode_str[3] = { "disable", "enable", "auto" };
|
||||
|
||||
LinphoneTunnel* linphone_core_get_tunnel(const LinphoneCore *lc){
|
||||
return lc->tunnel;
|
||||
}
|
||||
|
|
@ -234,7 +232,7 @@ void linphone_tunnel_clean_servers(LinphoneTunnel *tunnel){
|
|||
}
|
||||
|
||||
void linphone_tunnel_set_mode(LinphoneTunnel *tunnel, LinphoneTunnelMode mode){
|
||||
lp_config_set_string(config(tunnel),"tunnel","mode", tunnel_mode_to_string(mode));
|
||||
lp_config_set_string(config(tunnel),"tunnel","mode", linphone_tunnel_mode_to_string(mode));
|
||||
bcTunnel(tunnel)->setMode(mode);
|
||||
}
|
||||
|
||||
|
|
@ -336,31 +334,13 @@ static void my_ortp_logv(OrtpLogLevel level, const char *fmt, va_list args){
|
|||
ortp_logv(level,fmt,args);
|
||||
}
|
||||
|
||||
LinphoneTunnelMode string_to_tunnel_mode(const char *string) {
|
||||
if(string != NULL) {
|
||||
int i;
|
||||
for(i=0; i<3 && strcmp(string, _tunnel_mode_str[i]) != 0; i++);
|
||||
if(i<3) {
|
||||
return (LinphoneTunnelMode)i;
|
||||
} else {
|
||||
ms_error("Invalid tunnel mode '%s'", string);
|
||||
return LinphoneTunnelModeDisable;
|
||||
}
|
||||
} else {
|
||||
return LinphoneTunnelModeDisable;
|
||||
}
|
||||
}
|
||||
|
||||
const char *tunnel_mode_to_string(LinphoneTunnelMode mode) {
|
||||
return _tunnel_mode_str[mode];
|
||||
}
|
||||
|
||||
/**
|
||||
* Startup tunnel using configuration.
|
||||
* Called internally from linphonecore at startup.
|
||||
*/
|
||||
void linphone_tunnel_configure(LinphoneTunnel *tunnel){
|
||||
LinphoneTunnelMode mode = string_to_tunnel_mode(lp_config_get_string(config(tunnel), "tunnel", "mode", NULL));
|
||||
LinphoneTunnelMode mode = linphone_tunnel_mode_from_string(lp_config_get_string(config(tunnel), "tunnel", "mode", NULL));
|
||||
bool_t tunnelizeSIPPackets = (bool_t)lp_config_get_int(config(tunnel), "tunnel", "sip", TRUE);
|
||||
linphone_tunnel_enable_logs_with_handler(tunnel,TRUE,my_ortp_logv);
|
||||
linphone_tunnel_load_config(tunnel);
|
||||
|
|
|
|||
|
|
@ -65,14 +65,14 @@ typedef enum _LinphoneTunnelMode {
|
|||
* @return An LinphoneTunnelMode enum. If the passed string is NULL or
|
||||
* does not match with any mode, the LinphoneTunnelModeDisable is returned.
|
||||
*/
|
||||
LINPHONE_PUBLIC LinphoneTunnelMode string_to_tunnel_mode(const char *string);
|
||||
LINPHONE_PUBLIC LinphoneTunnelMode linphone_tunnel_mode_from_string(const char *string);
|
||||
|
||||
/**
|
||||
* Convert a tunnel mode enum into string
|
||||
* @param mode Enum to convert
|
||||
* @return "disable", "enable" or "auto"
|
||||
*/
|
||||
LINPHONE_PUBLIC const char *tunnel_mode_to_string(LinphoneTunnelMode mode);
|
||||
LINPHONE_PUBLIC const char *linphone_tunnel_mode_to_string(LinphoneTunnelMode mode);
|
||||
|
||||
/**
|
||||
* Create a new tunnel configuration
|
||||
|
|
|
|||
|
|
@ -1863,7 +1863,7 @@ void linphone_call_init_audio_stream(LinphoneCall *call){
|
|||
call->media_ports[0].mcast_rtp_port ? call->media_ports[0].mcast_rtp_port : call->media_ports[0].rtp_port,
|
||||
call->media_ports[0].mcast_rtcp_port ? call->media_ports[0].mcast_rtcp_port : call->media_ports[0].rtcp_port);
|
||||
linphone_call_join_multicast_group(call, 0, &audiostream->ms);
|
||||
|
||||
rtp_session_enable_network_simulation(call->audiostream->ms.sessions.rtp_session, &lc->net_conf.netsim_params);
|
||||
cname = linphone_address_as_string_uri_only(call->me);
|
||||
audio_stream_set_rtcp_information(call->audiostream, cname, rtcp_tool);
|
||||
ms_free(cname);
|
||||
|
|
@ -1972,6 +1972,7 @@ void linphone_call_init_video_stream(LinphoneCall *call){
|
|||
call->media_ports[1].mcast_rtp_port>0 ? call->media_ports[1].mcast_rtp_port : call->media_ports[1].rtp_port,
|
||||
call->media_ports[1].mcast_rtcp_port>0 ? call->media_ports[1].mcast_rtcp_port : call->media_ports[1].rtcp_port);
|
||||
linphone_call_join_multicast_group(call, 1, &call->videostream->ms);
|
||||
rtp_session_enable_network_simulation(call->videostream->ms.sessions.rtp_session, &lc->net_conf.netsim_params);
|
||||
cname = linphone_address_as_string_uri_only(call->me);
|
||||
video_stream_set_rtcp_information(call->videostream, cname, rtcp_tool);
|
||||
ms_free(cname);
|
||||
|
|
|
|||
|
|
@ -3481,6 +3481,27 @@ LINPHONE_PUBLIC void linphone_core_enable_video_multicast(LinphoneCore *core, bo
|
|||
**/
|
||||
LINPHONE_PUBLIC bool_t linphone_core_video_multicast_enabled(const LinphoneCore *core);
|
||||
|
||||
/**
|
||||
* Set the network simulator parameters.
|
||||
* Liblinphone has the capabability of simulating the effects of a network (latency, lost packets, jitter, max bandwidth).
|
||||
* Please refer to the oRTP documentation for the meaning of the parameters of the OrtpNetworkSimulatorParams structure.
|
||||
* This function has effect for future calls, but not for currently running calls, though this behavior may be changed in future versions.
|
||||
* @warning Due to design of network simulation in oRTP, simulation is applied independently for audio and video stream. This means for example that a bandwidth
|
||||
* limit of 250kbit/s will have no effect on an audio stream running at 40kbit/s while a videostream targetting 400kbit/s will be highly affected.
|
||||
* @param lc the LinphoneCore
|
||||
* @param params the parameters used for the network simulation.
|
||||
* @return 0 if successful, -1 otherwise.
|
||||
**/
|
||||
LINPHONE_PUBLIC int linphone_core_set_network_simulator_params(LinphoneCore *lc, const OrtpNetworkSimulatorParams *params);
|
||||
|
||||
|
||||
/**
|
||||
* Get the previously set network simulation parameters.
|
||||
* @see linphone_core_set_network_simulator_params
|
||||
* @return a OrtpNetworkSimulatorParams structure.
|
||||
**/
|
||||
LINPHONE_PUBLIC const OrtpNetworkSimulatorParams *linphone_core_get_network_simulator_params(const LinphoneCore *lc);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1600,3 +1600,43 @@ bool_t linphone_core_symmetric_rtp_enabled(LinphoneCore*lc){
|
|||
return lp_config_get_int(lc->config,"rtp","symmetric",1);
|
||||
}
|
||||
|
||||
int linphone_core_set_network_simulator_params(LinphoneCore *lc, const OrtpNetworkSimulatorParams *params){
|
||||
if (params!=&lc->net_conf.netsim_params)
|
||||
lc->net_conf.netsim_params=*params;
|
||||
/*TODO: should we make some sanity checks on the parameters here*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
const OrtpNetworkSimulatorParams *linphone_core_get_network_simulator_params(const LinphoneCore *lc){
|
||||
return &lc->net_conf.netsim_params;
|
||||
}
|
||||
|
||||
static const char *_tunnel_mode_str[3] = { "disable", "enable", "auto" };
|
||||
|
||||
LinphoneTunnelMode linphone_tunnel_mode_from_string(const char *string) {
|
||||
if(string != NULL) {
|
||||
int i;
|
||||
for(i=0; i<3 && strcmp(string, _tunnel_mode_str[i]) != 0; i++);
|
||||
if(i<3) {
|
||||
return (LinphoneTunnelMode)i;
|
||||
} else {
|
||||
ms_error("Invalid tunnel mode '%s'", string);
|
||||
return LinphoneTunnelModeDisable;
|
||||
}
|
||||
} else {
|
||||
return LinphoneTunnelModeDisable;
|
||||
}
|
||||
}
|
||||
|
||||
const char *linphone_tunnel_mode_to_string(LinphoneTunnelMode mode) {
|
||||
switch(mode){
|
||||
case LinphoneTunnelModeAuto:
|
||||
return "auto";
|
||||
case LinphoneTunnelModeDisable:
|
||||
return "disable";
|
||||
case LinphoneTunnelModeEnable:
|
||||
return "enable";
|
||||
}
|
||||
return "invalid";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -622,6 +622,7 @@ typedef struct net_config
|
|||
int download_bw;
|
||||
int upload_bw;
|
||||
int mtu;
|
||||
OrtpNetworkSimulatorParams netsim_params;
|
||||
bool_t nat_sdp_only;
|
||||
}net_config_t;
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 680421e382ac666d58866f00e1ac5693d939fc07
|
||||
Subproject commit 0765d7dc442b85e3ecb27c7e1678dde2adecb3f1
|
||||
2
oRTP
2
oRTP
|
|
@ -1 +1 @@
|
|||
Subproject commit 60f6d0f909eddcefc83960f791ff30097c1e5c33
|
||||
Subproject commit d515df047678da3777b5e4691dc069c6837f77bf
|
||||
|
|
@ -2354,18 +2354,18 @@ void call_base(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_r
|
|||
|
||||
}
|
||||
|
||||
if (policy == LinphonePolicyUseIce)
|
||||
if (policy == LinphonePolicyUseIce){
|
||||
int i=0;
|
||||
CU_ASSERT_TRUE(check_ice(pauline,marie,enable_tunnel?LinphoneIceStateReflexiveConnection:LinphoneIceStateHostConnection));
|
||||
for (i=0;i<100;i++) { /*fixme to workaround a crash*/
|
||||
ms_usleep(20000);
|
||||
linphone_core_iterate(marie->lc);
|
||||
linphone_core_iterate(pauline->lc);
|
||||
}
|
||||
}
|
||||
#ifdef VIDEO_ENABLED
|
||||
if (enable_video) {
|
||||
int i=0;
|
||||
if (linphone_core_video_supported(marie->lc)) {
|
||||
for (i=0;i<100;i++) { /*fixme to workaround a crash*/
|
||||
ms_usleep(20000);
|
||||
linphone_core_iterate(marie->lc);
|
||||
linphone_core_iterate(pauline->lc);
|
||||
}
|
||||
|
||||
add_video(pauline,marie);
|
||||
if (policy == LinphonePolicyUseIce)
|
||||
CU_ASSERT_TRUE(check_ice(pauline,marie,enable_tunnel?LinphoneIceStateReflexiveConnection:LinphoneIceStateHostConnection));
|
||||
|
|
@ -2376,7 +2376,6 @@ void call_base(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_r
|
|||
} else {
|
||||
ms_warning ("not tested because video not available");
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue