diff --git a/coreapi/dict.c b/coreapi/dict.c index 4535e1a27..417bb33f0 100644 --- a/coreapi/dict.c +++ b/coreapi/dict.c @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /** - * @addtogroup linphone_dict + * @addtogroup misc * @{ **/ diff --git a/coreapi/event.h b/coreapi/event.h index 894f3e32a..fe3f984de 100644 --- a/coreapi/event.h +++ b/coreapi/event.h @@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define LINPHONEEVENT_H /** - * @addtogroup subscriptions + * @addtogroup event_api * @{ **/ diff --git a/coreapi/help/doxygen.dox b/coreapi/help/doxygen.dox index 0f8e094f4..a8baa5138 100644 --- a/coreapi/help/doxygen.dox +++ b/coreapi/help/doxygen.dox @@ -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 **/ diff --git a/coreapi/linphone_tunnel.cc b/coreapi/linphone_tunnel.cc index 9dd4e8adf..7dd27d890 100644 --- a/coreapi/linphone_tunnel.cc +++ b/coreapi/linphone_tunnel.cc @@ -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); diff --git a/coreapi/linphone_tunnel.h b/coreapi/linphone_tunnel.h index f071f3c37..c1c378ed3 100644 --- a/coreapi/linphone_tunnel.h +++ b/coreapi/linphone_tunnel.h @@ -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 diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index b118b163f..94573cad1 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -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); diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 7e3994706..5f1e4f5c2 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -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 diff --git a/coreapi/misc.c b/coreapi/misc.c index 5912acc8f..666ac8919 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -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"; +} + diff --git a/coreapi/private.h b/coreapi/private.h index 4414f50ec..d08c569ff 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -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; diff --git a/mediastreamer2 b/mediastreamer2 index 680421e38..0765d7dc4 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 680421e382ac666d58866f00e1ac5693d939fc07 +Subproject commit 0765d7dc442b85e3ecb27c7e1678dde2adecb3f1 diff --git a/oRTP b/oRTP index 60f6d0f90..d515df047 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit 60f6d0f909eddcefc83960f791ff30097c1e5c33 +Subproject commit d515df047678da3777b5e4691dc069c6837f77bf diff --git a/tester/call_tester.c b/tester/call_tester.c index 5442364d7..326a2a29e 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -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