diff --git a/coreapi/linphone_tunnel.h b/coreapi/linphone_tunnel.h index ecaaf2227..5e6640e8d 100644 --- a/coreapi/linphone_tunnel.h +++ b/coreapi/linphone_tunnel.h @@ -176,9 +176,23 @@ LINPHONE_PUBLIC void linphone_tunnel_config_set_delay(LinphoneTunnelConfig *tunn */ LINPHONE_PUBLIC int linphone_tunnel_config_get_delay(const LinphoneTunnelConfig *tunnel); +/** + * Increment the refcount of LinphoneTunnelConfig object. + * @param cfg the LinphoneTunnelConfig object. + * @return the same cfg object. +**/ +LINPHONE_PUBLIC LinphoneTunnelConfig * linphone_tunnel_config_ref(LinphoneTunnelConfig *cfg); + + +/** + * Decrement the refcount of LinphoneTunnelConfig object. + * @param cfg the LinphoneTunnelConfig object. +**/ +LINPHONE_PUBLIC void linphone_tunnel_config_unref(LinphoneTunnelConfig *cfg); /** * Destroy a tunnel configuration * @param tunnel LinphoneTunnelConfig object + * @deprecated use linphone_tunnel_config_unref(). */ LINPHONE_PUBLIC void linphone_tunnel_config_destroy(LinphoneTunnelConfig *tunnel); diff --git a/coreapi/linphone_tunnel_config.c b/coreapi/linphone_tunnel_config.c index f38568016..bf836e797 100644 --- a/coreapi/linphone_tunnel_config.c +++ b/coreapi/linphone_tunnel_config.c @@ -21,16 +21,20 @@ */ #include "linphone_tunnel.h" +#include "private.h" + struct _LinphoneTunnelConfig { + belle_sip_object_t base; char *host; int port; int remote_udp_mirror_port; - int delay; + int delay; + void *user_data; }; LinphoneTunnelConfig *linphone_tunnel_config_new() { - LinphoneTunnelConfig *ltc = ms_new0(LinphoneTunnelConfig,1); + LinphoneTunnelConfig *ltc = belle_sip_object_new(LinphoneTunnelConfig); ltc->remote_udp_mirror_port = 12345; ltc->delay = 1000; return ltc; @@ -74,10 +78,40 @@ int linphone_tunnel_config_get_delay(const LinphoneTunnelConfig *tunnel) { return tunnel->delay; } -void linphone_tunnel_config_destroy(LinphoneTunnelConfig *tunnel) { +static void _linphone_tunnel_config_destroy(LinphoneTunnelConfig *tunnel) { if(tunnel->host != NULL) { ms_free(tunnel->host); } - ms_free(tunnel); } +LinphoneTunnelConfig * linphone_tunnel_config_ref(LinphoneTunnelConfig *cfg){ + return (LinphoneTunnelConfig*)belle_sip_object_ref(cfg); +} + +void linphone_tunnel_config_unref(LinphoneTunnelConfig *cfg){ + belle_sip_object_unref(cfg); +} + +void linphone_tunnel_config_destroy(LinphoneTunnelConfig *tunnel){ + linphone_tunnel_config_unref(tunnel); +} + +void linphone_tunnel_config_set_user_data(LinphoneTunnelConfig *cfg, void *ud){ + cfg->user_data = ud; +} + +void *linphone_tunnel_config_get_user_data(LinphoneTunnelConfig *cfg){ + return cfg->user_data; +} + +BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneTunnelConfig); + +BELLE_SIP_INSTANCIATE_VPTR(LinphoneTunnelConfig, belle_sip_object_t, + (belle_sip_object_destroy_t)_linphone_tunnel_config_destroy, + NULL, // clone + NULL, // marshal + FALSE +); + + + diff --git a/coreapi/private.h b/coreapi/private.h index 70de18d88..11f0147e5 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1262,7 +1262,8 @@ BELLE_SIP_TYPE_ID(LinphoneProxyConfig), BELLE_SIP_TYPE_ID(LinphoneFriend), BELLE_SIP_TYPE_ID(LinphoneXmlRpcRequest), BELLE_SIP_TYPE_ID(LinphoneXmlRpcRequestCbs), -BELLE_SIP_TYPE_ID(LinphoneXmlRpcSession) +BELLE_SIP_TYPE_ID(LinphoneXmlRpcSession), +BELLE_SIP_TYPE_ID(LinphoneTunnelConfig) BELLE_SIP_DECLARE_TYPES_END @@ -1365,6 +1366,8 @@ MSWebCam *get_nowebcam_device(); #endif bool_t linphone_core_lime_for_file_sharing_enabled(const LinphoneCore *lc); +BELLE_SIP_DECLARE_VPTR(LinphoneTunnelConfig); + #ifdef __cplusplus } #endif