From 0e517a8906aa25c22d1fa5f12f7f505f1c8fc791 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 17 May 2011 14:30:18 +0200 Subject: [PATCH] properly build REGISTER refreshes --- coreapi/linphonecore.c | 5 ++--- coreapi/linphonecore.h | 1 + coreapi/proxy.c | 10 ++++++++++ coreapi/sal.h | 1 + coreapi/sal_eXosip2.c | 19 +++++++++++++++++++ mediastreamer2 | 2 +- 6 files changed, 34 insertions(+), 4 deletions(-) diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 8c950bd5c..43f662bb7 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -3946,12 +3946,11 @@ void linphone_core_refresh_registers(LinphoneCore* lc) { for(;elem!=NULL;elem=elem->next){ LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data; if (linphone_proxy_config_register_enabled(cfg) ) { - cfg->registered=0; - cfg->commit=TRUE; + linphone_proxy_config_refresh_register(cfg); } } - } + void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t isReachable) { //first disable automatic mode if (lc->auto_net_state_mon) { diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 24f7efac6..5106533c6 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -364,6 +364,7 @@ bool_t linphone_proxy_config_publish_enabled(const LinphoneProxyConfig *obj); const char *linphone_proxy_config_get_addr(const LinphoneProxyConfig *obj); int linphone_proxy_config_get_expires(const LinphoneProxyConfig *obj); bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj); +void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj); struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj); bool_t linphone_proxy_config_get_dial_escape_plus(const LinphoneProxyConfig *cfg); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 674422be9..00bbb1202 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -290,6 +290,16 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *obj){ } } +/** + * Refresh a proxy registration. + * This is useful if for example you resuming from suspend, thus IP address may have changed. +**/ +void linphone_proxy_config_refresh_register(LinphoneProxyConfig *obj){ + if (obj->reg_sendregister && obj->op){ + sal_register_refresh(obj->op,obj->expires); + } +} + /** * Sets a dialing prefix to be automatically prepended when inviting a number with diff --git a/coreapi/sal.h b/coreapi/sal.h index c0b5f19b3..ecb140b71 100644 --- a/coreapi/sal.h +++ b/coreapi/sal.h @@ -315,6 +315,7 @@ void sal_call_send_vfu_request(SalOp *h); /*Registration*/ int sal_register(SalOp *op, const char *proxy, const char *from, int expires); +int sal_register_refresh(SalOp *op, int expires); int sal_unregister(SalOp *h); /*Messaging */ diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c index 97f8b497f..34cfd44f5 100644 --- a/coreapi/sal_eXosip2.c +++ b/coreapi/sal_eXosip2.c @@ -1908,6 +1908,25 @@ int sal_register(SalOp *h, const char *proxy, const char *from, int expires){ return 0; } +int sal_register_refresh(SalOp *op, int expires){ + osip_message_t *msg=NULL; + const char *contact=sal_op_get_contact(op); + + if (op->rid==-1){ + ms_error("Unexistant registration context, not possible to refresh."); + return -1; + } + eXosip_lock(); + eXosip_register_build_register(op->rid,expires,&msg); + if (msg!=NULL){ + if (contact) register_set_contact(msg,contact); + eXosip_register_send_register(op->rid,msg); + }else ms_error("Could not build REGISTER refresh message."); + eXosip_unlock(); + return 0; +} + + int sal_unregister(SalOp *h){ osip_message_t *msg=NULL; eXosip_lock(); diff --git a/mediastreamer2 b/mediastreamer2 index 88d2500c0..e7e43f83d 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 88d2500c0a1a01c136f0e7ebb8d9872262b57a41 +Subproject commit e7e43f83d827eebc1b6989f0ec22a89c00f15627