Merge branch 'master' into zrtphash

Conflicts:
	mediastreamer2
This commit is contained in:
Johan Pascal 2016-04-15 16:48:25 +02:00
commit 1bf41396e4
23 changed files with 321 additions and 101 deletions

View file

@ -148,7 +148,8 @@ TunnelManager::TunnelManager(LinphoneCore* lc) :
mTunnelClient(NULL),
mHttpProxyPort(0),
mVTable(NULL),
mLongRunningTaskId(0)
mLongRunningTaskId(0),
mSimulateUdpLoss(false)
{
linphone_core_add_iterate_hook(mCore,(LinphoneCoreIterateHook)sOnIterate,this);
mTransportFactories.audio_rtcp_func=sCreateRtpTransport;
@ -342,18 +343,12 @@ LinphoneTunnelMode TunnelManager::getMode() const {
void TunnelManager::processUdpMirrorEvent(const Event &ev){
if(mState != autodetecting) return;
if (ev.mData.mHaveUdp) {
ms_message("TunnelManager: UDP mirror test succeed on %s:%d", mCurrentUdpMirrorClient->getServerAddress().mAddr.c_str(), mCurrentUdpMirrorClient->getServerAddress().mPort);
if(mTunnelClient) {
if(mTunnelizeSipPackets) doUnregistration();
sal_set_tunnel(mCore->sal,NULL);
delete mTunnelClient;
mTunnelClient = NULL;
if(mTunnelizeSipPackets) doRegistration();
if (mSimulateUdpLoss || !ev.mData.mHaveUdp) {
if (mSimulateUdpLoss) {
ms_message("TunnelManager: simulate UDP lost on %s:%d", mCurrentUdpMirrorClient->getServerAddress().mAddr.c_str(), mCurrentUdpMirrorClient->getServerAddress().mPort);
} else {
ms_message("TunnelManager: UDP mirror test failed on %s:%d", mCurrentUdpMirrorClient->getServerAddress().mAddr.c_str(), mCurrentUdpMirrorClient->getServerAddress().mPort);
}
mState = disabled;
} else {
ms_message("TunnelManager: UDP mirror test failed on %s:%d", mCurrentUdpMirrorClient->getServerAddress().mAddr.c_str(), mCurrentUdpMirrorClient->getServerAddress().mPort);
mCurrentUdpMirrorClient++;
if (mCurrentUdpMirrorClient !=mUdpMirrorClients.end()) {
ms_message("TunnelManager: trying another UDP mirror on %s:%d", mCurrentUdpMirrorClient->getServerAddress().mAddr.c_str(), mCurrentUdpMirrorClient->getServerAddress().mPort);
@ -370,6 +365,16 @@ void TunnelManager::processUdpMirrorEvent(const Event &ev){
mState = ready;
}
}
} else {
ms_message("TunnelManager: UDP mirror test succeed on %s:%d", mCurrentUdpMirrorClient->getServerAddress().mAddr.c_str(), mCurrentUdpMirrorClient->getServerAddress().mPort);
if(mTunnelClient) {
if(mTunnelizeSipPackets) doUnregistration();
sal_set_tunnel(mCore->sal,NULL);
delete mTunnelClient;
mTunnelClient = NULL;
if(mTunnelizeSipPackets) doRegistration();
}
mState = disabled;
}
}
@ -390,8 +395,15 @@ void TunnelManager::sUdpMirrorClientCallback(bool isUdpAvailable, void* data) {
void TunnelManager::networkReachableCb(LinphoneCore *lc, bool_t reachable) {
TunnelManager *tunnel = bcTunnel(linphone_core_get_tunnel(lc));
if(reachable && tunnel->getMode() == LinphoneTunnelModeAuto && tunnel->mState != connecting && tunnel->mState != autodetecting) {
LOGI("TunnelManager: Network is now reachable, starting auto detection");
tunnel->startAutoDetection();
tunnel->mState = autodetecting;
} else if (!reachable && tunnel->mState == autodetecting) {
// if network is no more reachable, cancel autodetection
for(UdpMirrorClientList::iterator udpMirror = tunnel->mUdpMirrorClients.begin(); udpMirror != tunnel->mUdpMirrorClients.end(); udpMirror++) {
udpMirror->stop();
}
tunnel->mState = disabled;
}
linphone_core_get_local_ip_for(AF_INET, NULL,tunnel->mLocalAddr);
}
@ -455,3 +467,7 @@ void TunnelManager::setHttpProxy(const char *host,int port, const char *username
LinphoneCore *TunnelManager::getLinphoneCore() const{
return mCore;
}
void TunnelManager::simulateUdpLoss(bool enabled) {
mSimulateUdpLoss = enabled;
}

View file

@ -155,6 +155,9 @@ namespace belledonnecomm {
bool isConnected() const;
bool isActivated() const;
void simulateUdpLoss(bool enabled);
private:
enum State {
disabled,
@ -215,6 +218,7 @@ namespace belledonnecomm {
std::queue<Event> mEvq;
char mLocalAddr[64];
unsigned long mLongRunningTaskId;
bool mSimulateUdpLoss;
};
/**

View file

@ -430,10 +430,11 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
belle_generic_uri_t *uri = NULL;
belle_http_request_t *req = NULL;
belle_sip_memory_body_handler_t *bh = NULL;
LinphoneCardDavContext *cdc = query->context;
char* ua = NULL;
uri = belle_generic_uri_parse(query->url);
if (!uri) {
LinphoneCardDavContext *cdc = query->context;
if (cdc && cdc->sync_done_cb) {
cdc->sync_done_cb(cdc, FALSE, "Could not send request, URL is invalid");
}
@ -443,7 +444,6 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
req = belle_http_request_create(query->method, uri, belle_sip_header_content_type_create("application", "xml; charset=utf-8"), NULL);
if (!req) {
LinphoneCardDavContext *cdc = query->context;
if (cdc && cdc->sync_done_cb) {
cdc->sync_done_cb(cdc, FALSE, "Could not create belle_http_request_t");
}
@ -452,6 +452,9 @@ static void linphone_carddav_send_query(LinphoneCardDavQuery *query) {
return;
}
ua = ms_strdup_printf("%s/%s", linphone_core_get_user_agent(cdc->friend_list->lc), linphone_core_get_version());
belle_sip_message_add_header((belle_sip_message_t *)req, belle_sip_header_create("User-Agent", ua));
ms_free(ua);
if (query->depth) {
belle_sip_message_add_header((belle_sip_message_t *)req, belle_sip_header_create("Depth", query->depth));
} else if (query->ifmatch) {

View file

@ -377,3 +377,7 @@ void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel) {
bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel) {
return linphone_tunnel_get_mode(tunnel) == LinphoneTunnelModeAuto;
}
void linphone_tunnel_simulate_udp_loss(LinphoneTunnel *tunnel, bool_t enabled) {
bcTunnel(tunnel)->simulateUdpLoss(enabled);
}

View file

@ -357,6 +357,8 @@ LINPHONE_PUBLIC void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel);
*/
LINPHONE_PUBLIC bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel);
LINPHONE_PUBLIC void linphone_tunnel_simulate_udp_loss(LinphoneTunnel *tunnel, bool_t enabled);
/**
* @}
**/

View file

@ -93,3 +93,4 @@ void linphone_tunnel_enable(LinphoneTunnel *tunnel, bool_t enabled) {}
bool_t linphone_tunnel_enabled(const LinphoneTunnel *tunnel) { return FALSE; }
void linphone_tunnel_auto_detect(LinphoneTunnel *tunnel) {}
bool_t linphone_tunnel_auto_detect_enabled(LinphoneTunnel *tunnel) { return FALSE; }
void linphone_tunnel_simulate_udp_loss(LinphoneTunnel *tunnel, bool_t enabled) {}

View file

@ -38,6 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/msvolume.h"
#include "mediastreamer2/msequalizer.h"
#include "mediastreamer2/dtmfgen.h"
#include "mediastreamer2/msjpegwriter.h"
#ifdef INET6
#ifndef _WIN32
@ -1724,9 +1725,9 @@ static void linphone_core_init(LinphoneCore * lc, const LinphoneCoreVTable *vtab
lc->config=lp_config_ref(config);
lc->data=userdata;
lc->ringstream_autorelease=TRUE;
linphone_core_add_friend_list(lc, NULL);
linphone_task_list_init(&lc->hooks);
internal_vtable->notify_received = linphone_core_internal_notify_received;
@ -3225,7 +3226,7 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
linphone_core_notify_display_warning(lc,_("Sorry, we have reached the maximum number of simultaneous calls"));
return NULL;
}
cp = linphone_call_params_copy(params);
real_url=linphone_address_as_string(addr);
@ -5356,6 +5357,43 @@ void linphone_core_migrate_logs_from_rc_to_db(LinphoneCore *lc) {
* Video related functions *
******************************************************************************/
#ifdef VIDEO_ENABLED
static void snapshot_taken(void *userdata, struct _MSFilter *f, unsigned int id, void *arg) {
if (id == MS_JPEG_WRITER_SNAPSHOT_TAKEN) {
LinphoneCore *lc = (LinphoneCore *)userdata;
linphone_core_enable_video_preview(lc, FALSE);
}
}
#endif
int linphone_core_take_preview_snapshot(LinphoneCore *lc, const char *file) {
LinphoneCall *call = linphone_core_get_current_call(lc);
if (!file) return -1;
if (call) {
return linphone_call_take_preview_snapshot(call, file);
} else {
#ifdef VIDEO_ENABLED
if (lc->previewstream == NULL) {
MSVideoSize vsize=lc->video_conf.preview_vsize.width != 0 ? lc->video_conf.preview_vsize : lc->video_conf.vsize;
lc->previewstream = video_preview_new(lc->factory);
video_preview_set_size(lc->previewstream, vsize);
video_preview_set_display_filter_name(lc->previewstream, NULL);
video_preview_set_fps(lc->previewstream,linphone_core_get_preferred_framerate(lc));
video_preview_start(lc->previewstream, lc->video_conf.device);
lc->previewstream->ms.factory = lc->factory;
linphone_core_enable_video_preview(lc, TRUE);
ms_filter_add_notify_callback(lc->previewstream->local_jpegwriter, snapshot_taken, lc, TRUE);
ms_filter_call_method(lc->previewstream->local_jpegwriter, MS_JPEG_WRITER_TAKE_SNAPSHOT, (void*)file);
} else {
ms_filter_call_method(lc->previewstream->local_jpegwriter, MS_JPEG_WRITER_TAKE_SNAPSHOT, (void*)file);
}
return 0;
#endif
}
return -1;
}
static void toggle_video_preview(LinphoneCore *lc, bool_t val){
#ifdef VIDEO_ENABLED
@ -6530,7 +6568,7 @@ static void linphone_core_uninit(LinphoneCore *lc)
linphone_core_iterate(lc);
ms_usleep(50000);
}
lc->chatrooms = ms_list_free_with_data(lc->chatrooms, (MSIterateFunc)linphone_chat_room_release);
linphone_core_set_state(lc,LinphoneGlobalShutdown,"Shutting down");
@ -6595,13 +6633,13 @@ static void linphone_core_uninit(LinphoneCore *lc)
if (lc->ringtoneplayer) {
linphone_ringtoneplayer_destroy(lc->ringtoneplayer);
}
linphone_core_free_payload_types(lc);
if (lc->supported_formats) ms_free(lc->supported_formats);
linphone_core_message_storage_close(lc);
linphone_core_call_log_storage_close(lc);
linphone_core_friends_storage_close(lc);
linphone_core_set_state(lc,LinphoneGlobalOff,"Off");
linphone_core_deactivate_log_serialization_if_needed();
ms_list_free_with_data(lc->vtable_refs,(void (*)(void *))v_table_reference_destroy);
@ -7104,7 +7142,7 @@ LinphoneCall* linphone_core_find_call_from_uri(const LinphoneCore *lc, const cha
/**
* Check if a call will need the sound resources in near future (typically an outgoing call that is awaiting
* Check if a call will need the sound resources in near future (typically an outgoing call that is awaiting
* response).
* In liblinphone, it is not possible to have two independant calls using sound device or camera at the same time.
* In order to prevent this situation, an application can use linphone_core_sound_resources_locked() to know whether

View file

@ -3609,6 +3609,15 @@ LINPHONE_PUBLIC void linphone_core_set_preferred_framerate(LinphoneCore *lc, flo
**/
LINPHONE_PUBLIC float linphone_core_get_preferred_framerate(LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_enable_video_preview(LinphoneCore *lc, bool_t val);
/**
* Take a photo of currently from capture device and write it into a jpeg file.
* Note that the snapshot is asynchronous, an application shall not assume that the file is created when the function returns.
* @ingroup misc
* @param lc the linphone core
* @param file a path where to write the jpeg content.
* @return 0 if successfull, -1 otherwise (typically if jpeg format is not supported).
**/
LINPHONE_PUBLIC int linphone_core_take_preview_snapshot(LinphoneCore *lc, const char *file);
LINPHONE_PUBLIC bool_t linphone_core_video_preview_enabled(const LinphoneCore *lc);
LINPHONE_PUBLIC void linphone_core_enable_self_view(LinphoneCore *lc, bool_t val);

View file

@ -632,6 +632,7 @@ struct _LinphoneProxyConfig
unsigned long long previous_publish_config_hash[2];
char *refkey;
char *sip_etag; /*publish context*/
};
BELLE_SIP_DECLARE_VPTR(LinphoneProxyConfig);

View file

@ -1061,6 +1061,12 @@ int linphone_proxy_config_done(LinphoneProxyConfig *cfg)
if (!cfg->publish) {
/*publish is terminated*/
linphone_event_terminate(cfg->long_term_event);
} else {
const char * sip_etag = linphone_event_get_custom_header(cfg->long_term_event, "SIP-ETag");
if (sip_etag) {
if (cfg->sip_etag) ms_free(cfg->sip_etag);
cfg->sip_etag = ms_strdup(sip_etag);
}
}
linphone_event_unref(cfg->long_term_event);
cfg->long_term_event = NULL;
@ -1115,6 +1121,11 @@ int linphone_proxy_config_send_publish(LinphoneProxyConfig *proxy, LinphonePrese
linphone_content_set_buffer(content,presence_body,strlen(presence_body));
linphone_content_set_type(content, "application");
linphone_content_set_subtype(content,"pidf+xml");
if (proxy->sip_etag) {
linphone_event_add_custom_header(proxy->long_term_event, "SIP-If-Match", proxy->sip_etag);
ms_free(proxy->sip_etag);
proxy->sip_etag=NULL;
}
err = linphone_event_send_publish(proxy->long_term_event, content);
linphone_content_unref(content);
ms_free(presence_body);
@ -1128,6 +1139,10 @@ void _linphone_proxy_config_unpublish(LinphoneProxyConfig *obj) {
(linphone_event_get_publish_state(obj->long_term_event) == LinphonePublishProgress && obj->publish_expires != 0))) {
linphone_event_unpublish(obj->long_term_event);
}
if (obj->sip_etag) {
ms_free(obj->sip_etag);
obj->sip_etag=NULL;
}
}
const char *linphone_proxy_config_get_route(const LinphoneProxyConfig *cfg){

View file

@ -180,6 +180,11 @@ void linphone_gtk_push_text(GtkWidget *w, const LinphoneAddress *from,
g_object_set_data(G_OBJECT(w),"from_message",g_strdup(from_str));
}
ms_free(from_str);
if (!message) {
const char *external_body_url = linphone_chat_message_get_external_body_url(msg);
if (external_body_url) message = external_body_url;
}
// Inserts message body and tags URIs as hypertext links
if(message) {

@ -1 +1 @@
Subproject commit 2abbb7ae3c3585533c0f731f2fc56611597e9158
Subproject commit 9dd1aeeac987da96a91ce13ffd8f21b8bfbe17e5

View file

@ -1383,7 +1383,7 @@ static void call_with_custom_sdp_attributes(void) {
linphone_core_manager_destroy(pauline);
}
void call_paused_resumed_base(bool_t multicast) {
void call_paused_resumed_base(bool_t multicast, bool_t with_losses) {
LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
LinphoneCall* call_pauline;
@ -1400,8 +1400,18 @@ void call_paused_resumed_base(bool_t multicast) {
wait_for_until(pauline->lc, marie->lc, NULL, 5, 3000);
if (with_losses) {
sal_set_send_error(marie->lc->sal,1500); /*to trash 200ok without generating error*/
}
linphone_core_pause_call(pauline->lc,call_pauline);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1));
if (with_losses) {
BC_ASSERT_FALSE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1,1000));
sal_set_send_error(marie->lc->sal,0); /*to trash 200ok without generating error*/
}
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1));
@ -1416,16 +1426,44 @@ void call_paused_resumed_base(bool_t multicast) {
wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000);
/*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/
stats = rtp_session_get_stats(call_pauline->sessions->rtp_session);
BC_ASSERT_EQUAL((int)stats->cum_packet_loss, 0, int, "%d");
if (BC_ASSERT_PTR_NOT_NULL(call_pauline->sessions->rtp_session)) {
stats = rtp_session_get_stats(call_pauline->sessions->rtp_session);
BC_ASSERT_EQUAL((int)stats->cum_packet_loss, 0, int, "%d");
}
if (with_losses) {
/* now we want to loose the ack*/
linphone_core_pause_call(pauline->lc,call_pauline);
sal_set_send_error(pauline->lc->sal,1500); /*to trash ACK without generating error*/
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,2));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,2));
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,2,1000));
/*now try to resume*/
sal_set_send_error(pauline->lc->sal,0);
linphone_core_resume_call(pauline->lc,call_pauline);
BC_ASSERT_FALSE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3,2000));
BC_ASSERT_FALSE(wait_for_until(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3,2000));
/*resume failed because ACK not received to re-invite is rejected*/
/*next try is ok*/
linphone_core_resume_call(pauline->lc,call_pauline);
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,3));
BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,3));
}
end_call(pauline, marie);
end:
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void call_paused_resumed(void) {
call_paused_resumed_base(FALSE);
call_paused_resumed_base(FALSE,FALSE);
}
static void call_paused_resumed_with_sip_packets_losses(void) {
call_paused_resumed_base(FALSE,TRUE);
}
static void call_paused_by_both(void) {
@ -6246,6 +6284,7 @@ test_t call_tests[] = {
TEST_NO_TAG("Call without SDP", call_with_no_sdp),
TEST_NO_TAG("Call without SDP and ACK without SDP", call_with_no_sdp_ack_without_sdp),
TEST_NO_TAG("Call paused resumed", call_paused_resumed),
TEST_NO_TAG("Call paused resumed with sip packets looses", call_paused_resumed_with_sip_packets_losses),
#ifdef VIDEO_ENABLED
TEST_NO_TAG("Call paused resumed with video", call_paused_resumed_with_video),
TEST_NO_TAG("Call paused resumed with video no sdp ack", call_paused_resumed_with_no_sdp_ack),

View file

@ -336,7 +336,7 @@ void account_manager_destroy(void);
LinphoneCore* configure_lc_from(LinphoneCoreVTable* v_table, const char* path, const char* file, void* user_data);
void liblinphone_tester_enable_ipv6(bool_t enabled);
void linphone_call_iframe_decoded_cb(LinphoneCall *call,void * user_data);
void call_paused_resumed_base(bool_t multicast);
void call_paused_resumed_base(bool_t multicast,bool_t with_losses);
void simple_call_base(bool_t enable_multicast_recv_side);
void call_base_with_configfile(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy,bool_t enable_tunnel, const char *marie_rc, const char *pauline_rc);
void call_base(LinphoneMediaEncryption mode, bool_t enable_video,bool_t enable_relay,LinphoneFirewallPolicy policy,bool_t enable_tunnel);

View file

@ -668,7 +668,9 @@ static void eject_from_3_participants_conference(LinphoneCoreManager *marie, Lin
BC_ASSERT_TRUE(wait_for_list(lcs,&laure->stat.number_of_LinphoneCallEnd,initial_laure_stat.number_of_LinphoneCallEnd+1,5000));
}
BC_ASSERT_PTR_NOT_NULL(linphone_core_get_conference(marie->lc));
if (!BC_ASSERT_PTR_NOT_NULL(linphone_core_get_conference(marie->lc))) {
goto end;
}
linphone_core_add_to_conference(marie->lc,marie_call_pauline);

View file

@ -69,7 +69,7 @@ static void call_multicast(void) {
call_multicast_base(FALSE);
}
static void multicast_audio_with_pause_resume(void) {
call_paused_resumed_base(TRUE);
call_paused_resumed_base(TRUE,FALSE);
}
#ifdef VIDEO_ENABLED
static void call_multicast_video(void) {

View file

@ -158,13 +158,16 @@ static void simple_publish_with_expire(int expires) {
linphone_proxy_config_edit(proxy);
linphone_proxy_config_done(proxy);
/*make sure no publish is sent*/
BC_ASSERT_FALSE(wait_for_until(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,3,expires*1000/2));
BC_ASSERT_FALSE(wait_for_until(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,3,2000));
linphone_proxy_config_edit(proxy);
linphone_proxy_config_enable_publish(proxy,FALSE);
linphone_proxy_config_done(proxy);
/*fixme PUBLISH state machine is too simple, clear state should only be propagated at API level when 200ok is received*/
/*BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,3));*/
wait_for_until(marie->lc,marie->lc,NULL,0,2000);
BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishCleared,1));
linphone_proxy_config_edit(proxy);
@ -180,7 +183,7 @@ static void simple_publish_with_expire(int expires) {
BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishOk,4));
linphone_core_manager_destroy(marie);
BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishCleared,2,int,"%i");
/*fixme we should wait untill 200okBC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishCleared,2,int,"%i");*/
BC_ASSERT_EQUAL(marie->stat.number_of_LinphonePublishOk,4,int,"%i");
}
@ -480,6 +483,7 @@ static void subscriber_no_longer_reachable(void){
LinphoneFriend *lf;
MSList *lcs = NULL;
LinphonePresenceModel * presence;
int previous_number_of_LinphonePresenceActivityOnline=0;
lcs = ms_list_append(lcs, marie->lc);
lcs = ms_list_append(lcs, pauline1->lc);
@ -510,6 +514,8 @@ static void subscriber_no_longer_reachable(void){
presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityBusy,NULL);
linphone_core_set_presence_model(pauline1->lc,presence);
previous_number_of_LinphonePresenceActivityOnline=marie->stat.number_of_LinphonePresenceActivityOnline;
/*don't schedule marie to simulate Notify timeout server side*/
wait_for_until(pauline1->lc, NULL, 0, 0, 35000);
@ -523,7 +529,7 @@ static void subscriber_no_longer_reachable(void){
linphone_core_set_presence_model(pauline1->lc,presence);
/*because subscription not is automatically restarted*/
BC_ASSERT_FALSE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,2, 4000));
BC_ASSERT_FALSE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,previous_number_of_LinphonePresenceActivityOnline+1, 4000));
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline1);
@ -533,7 +539,7 @@ static void subscriber_no_longer_reachable(void){
}
static void subscribe_with_late_publish(void) {
#if 0
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
LinphoneProxyConfig* proxy;
@ -548,16 +554,18 @@ static void subscribe_with_late_publish(void) {
lf_identity=linphone_address_as_string_uri_only(marie->identity);
lf = linphone_core_create_friend_with_address(pauline->lc,lf_identity);
lp_config_set_int(pauline_lp,"sip","subscribe_expires",5);
lp_config_set_int(pauline_lp,"sip","subscribe_expires",10);
linphone_core_add_friend(pauline->lc,lf);
/*wait for subscribe acknowledgment*/
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyPresenceReceived,1,2000));
BC_ASSERT_EQUAL(LinphoneStatusOffline,linphone_friend_get_status(lf), int, "%d");
/*BC_ASSERT_EQUAL(LinphoneStatusOffline,linphone_friend_get_status(lf), int, "%d");*/
/*enable publish*/
presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityPresentation,NULL);
linphone_core_set_presence_model(marie->lc,presence);
proxy = linphone_core_get_default_proxy_config(marie->lc);
linphone_proxy_config_edit(proxy);
@ -566,19 +574,16 @@ static void subscribe_with_late_publish(void) {
linphone_proxy_config_done(proxy);
/*wait for marie status*/
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyPresenceReceived,2,2000));
BC_ASSERT_EQUAL(LinphoneStatusOnline,linphone_friend_get_status(lf), int, "%d");
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphonePresenceActivityPresentation,1,2000));
presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityBusy,NULL);
linphone_core_set_presence_model(marie->lc,presence);
/*wait for new status*/
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyPresenceReceived,3,2000));
BC_ASSERT_EQUAL(LinphoneStatusBusy,linphone_friend_get_status(lf), int, "%d");
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphonePresenceActivityBusy,1,2000));
/*wait for refresh*/
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyPresenceReceived,4,5000));
BC_ASSERT_EQUAL(LinphoneStatusBusy,linphone_friend_get_status(lf), int, "%d");
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphonePresenceActivityBusy,2,4000));
/*linphone_core_remove_friend(pauline->lc,lf);*/
/*wait for final notify*/
@ -587,10 +592,11 @@ static void subscribe_with_late_publish(void) {
*/
/*Expect a notify at publication expiration because marie is no longuer scheduled*/
BC_ASSERT_TRUE(wait_for_until(pauline->lc,pauline->lc,&pauline->stat.number_of_NotifyPresenceReceived,6,5000));
BC_ASSERT_EQUAL(LinphoneStatusOffline,linphone_friend_get_status(lf), int, "%d");
BC_ASSERT_FALSE(wait_for_until(pauline->lc,pauline->lc,&pauline->stat.number_of_LinphonePresenceActivityBusy,3,6000));
/*thanks to long term presence we are still online*/
BC_ASSERT_EQUAL(LinphoneStatusOnline,linphone_friend_get_status(lf), int, "%d");
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphonePresenceActivityBusy,4,5000));/*re- schedule marie to clean up things*/
BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphonePresenceActivityBusy,3,5000));/*re- schedule marie to clean up things*/
/*simulate a rapid presence change to make sure only first and last are transmited*/
linphone_core_set_presence_model(marie->lc,linphone_presence_model_new_with_activity(LinphonePresenceActivityAway,NULL));
@ -606,6 +612,7 @@ static void subscribe_with_late_publish(void) {
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
#endif
}
static void test_forked_subscribe_notify_publish(void) {
@ -743,7 +750,7 @@ static void test_presence_list_base(bool_t enable_compression) {
lcs = ms_list_append(lcs, marie->lc);
lcs = ms_list_append(lcs, pauline->lc);
wait_for_list(lcs, &laure->stat.number_of_NotifyPresenceReceived, 2, 2000);
wait_for_list(lcs, &laure->stat.number_of_NotifyPresenceReceived, 2, 4000);
BC_ASSERT_EQUAL(laure->stat.number_of_NotifyPresenceReceived, 2, int, "%d");
BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity);
@ -769,7 +776,7 @@ static void test_presence_list_base(bool_t enable_compression) {
linphone_friend_list_unref(lfl);
linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(marie->lc), NULL, FALSE);
wait_for_list(lcs, &marie->stat.number_of_NotifyPresenceReceived, 1, 2000);
wait_for_list(lcs, &marie->stat.number_of_NotifyPresenceReceived, 1, 4000);
BC_ASSERT_EQUAL(marie->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(marie->lc)->expected_notification_version, 1, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(marie->lc), laure_identity);
@ -787,7 +794,7 @@ static void test_presence_list_base(bool_t enable_compression) {
linphone_friend_list_unref(lfl);
linphone_friend_list_update_subscriptions(linphone_core_get_default_friend_list(pauline->lc), NULL, FALSE);
wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 1, 2000);
wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 1, 4000);
BC_ASSERT_EQUAL(pauline->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(pauline->lc)->expected_notification_version, 1, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity);
@ -797,7 +804,7 @@ static void test_presence_list_base(bool_t enable_compression) {
linphone_core_set_presence_model(marie->lc, linphone_core_create_presence_model_with_activity(marie->lc, LinphonePresenceActivityOnThePhone, NULL));
wait_for_list(lcs, &laure->stat.number_of_NotifyPresenceReceived, 4, 2000);
wait_for_list(lcs, &laure->stat.number_of_NotifyPresenceReceived, 4, 4000);
/* The number of PresenceReceived events can be 3 or 4 here. TODO: ideally it should always be 3. */
BC_ASSERT_GREATER(laure->stat.number_of_NotifyPresenceReceived, 3, int, "%d");
BC_ASSERT_LOWER(laure->stat.number_of_NotifyPresenceReceived, 4, int, "%d");
@ -805,7 +812,7 @@ static void test_presence_list_base(bool_t enable_compression) {
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnThePhone, int, "%d");
wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 2, 2000);
wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 2, 4000);
BC_ASSERT_EQUAL(pauline->stat.number_of_NotifyPresenceReceived, 2, int, "%d");
BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(pauline->lc)->expected_notification_version, 2, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity);
@ -821,20 +828,34 @@ static void test_presence_list_base(bool_t enable_compression) {
reset_counters(&laure->stat);
reset_counters(&marie->stat);
if (!BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphonePresenceActivityOffline, 1, 2000))) goto end;
/*keep in ming long terme presence*/
if (!BC_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphonePresenceActivityOnline, 1, 4000)))
goto end;
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), marie_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
/*BC_ASSERT_EQUAL(linphone_presence_activity_get_type(linphone_presence_model_get_activity(linphone_friend_get_presence_model(lf)))
, LinphonePresenceActivityOnline, int, "%d"); fixme, should be LinphonePresenceActivityUnknown*/
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnline, int, "%d");
if (!BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphonePresenceActivityOffline, 2, 2000))) goto end;
if (!BC_ASSERT_TRUE(wait_for_list(lcs, &laure->stat.number_of_LinphonePresenceActivityOnline, 2, 4000))) goto end;
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnline, int, "%d");
/*BC_ASSERT_EQUAL(linphone_presence_activity_get_type(linphone_presence_model_get_activity(linphone_friend_get_presence_model(lf)))
, LinphonePresenceActivityOnline, int, "%d"); fixme, should be LinphonePresenceActivityUnknown*/
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), marie_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnline, int, "%d");
/*BC_ASSERT_EQUAL(linphone_presence_activity_get_type(linphone_presence_model_get_activity(linphone_friend_get_presence_model(lf)))
, LinphonePresenceActivityOnline, int, "%d"); fixme, should be LinphonePresenceActivityUnknown*/
if (!BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphonePresenceActivityOffline, 1, 2000))) goto end;
if (!BC_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphonePresenceActivityOnline, 1, 4000))) goto end;
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(marie->lc), laure_identity);
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d");
BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOnline, int, "%d");
/*BC_ASSERT_EQUAL(linphone_presence_activity_get_type(linphone_presence_model_get_activity(linphone_friend_get_presence_model(lf)))
, LinphonePresenceActivityOnline, int, "%d"); fixme, should be LinphonePresenceActivityUnknown*/
end:
linphone_core_manager_destroy(laure);
@ -883,7 +904,7 @@ static void test_presence_list_subscribe_before_publish(void) {
wait_for_list(lcs, &dummy, 1, 2000); /* Wait a little bit for the subscribe to happen */
enable_publish(pauline, TRUE);
wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 1, 2000);
wait_for_list(lcs, &pauline->stat.number_of_NotifyPresenceReceived, 1, 4000);
BC_ASSERT_GREATER(laure->stat.number_of_NotifyPresenceReceived, 1, int, "%d");
BC_ASSERT_GREATER(linphone_core_get_default_friend_list(laure->lc)->expected_notification_version, 1, int, "%d");
lf = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(laure->lc), pauline_identity);
@ -1068,8 +1089,8 @@ static void long_term_presence_inexistent_friend(void) {
static void long_term_presence_list(void) {
LinphoneFriend *f1, *f2;
LinphoneFriendList* friends;
LinphoneCoreManager* pauline = presence_linphone_core_manager_new("pauline");
linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL);
LinphoneCoreManager *pauline = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc");
enable_publish(pauline, TRUE);
enable_deflate_content_encoding(pauline, FALSE);
friends = linphone_core_create_friend_list(pauline->lc);
@ -1084,8 +1105,8 @@ static void long_term_presence_list(void) {
linphone_core_add_friend_list(pauline->lc, friends);
linphone_friend_list_unref(friends);
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_NotifyPresenceReceived,2));
BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(pauline->lc)->expected_notification_version, 1, int, "%d");
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_NotifyPresenceReceived,1));
BC_ASSERT_EQUAL(linphone_core_get_default_friend_list(pauline->lc)->expected_notification_version, 2, int, "%d");
f1 = linphone_friend_list_find_friend_by_uri(linphone_core_get_default_friend_list(pauline->lc), "sip:liblinphone_tester@sip.example.org");
BC_ASSERT_EQUAL(linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(f1)), LinphonePresenceBasicStatusOpen, int, "%d");

View file

@ -7,6 +7,6 @@ sip_random_port=1
[auth_info_0]
domain=dav.linphone.org
username=sylvain
ha1=4747ce2517a985f2fc20234a38f068b6
realm=SabreDAV
username=tester
ha1=102bdd8ccafef75cf7572c97969afd9a
realm=BaikalDAV

View file

@ -1,3 +1,3 @@
[misc]
config-uri=file://./rcfiles/marie_remote_localfile2_rc
config-uri=file://marie_remote_localfile2_rc

View file

@ -113,7 +113,17 @@ static void remote_provisioning_file(void) {
#elif defined(LINPHONE_WINDOWS_UNIVERSAL)
marie = linphone_core_manager_new2("marie_remote_localfile_win10_rc", FALSE);
#else
marie = linphone_core_manager_new2("marie_remote_localfile_rc", FALSE);
marie = ms_new0(LinphoneCoreManager, 1);
linphone_core_manager_init(marie, "marie_remote_localfile_rc");
// fix relative path to absolute path
{
char* path = bc_tester_res("rcfiles/marie_remote_localfile2_rc");
char* abspath = ms_strdup_printf("file://%s", path);
lp_config_set_string(marie->lc->config, "misc", "config-uri", abspath);
linphone_core_manager_start(marie, 1);
ms_free(path);
ms_free(abspath);
}
#endif
BC_ASSERT_TRUE(wait_for(marie->lc,NULL,&marie->stat.number_of_LinphoneConfiguringSuccessful,1));

View file

@ -385,7 +385,7 @@ LinphoneCoreManager* linphone_core_manager_new( const char* rc_file) {
return manager;
}
LinphoneCoreManager* linphone_core_manager_new2( const char* rc_file, int check_for_proxies) {
LinphoneCoreManager* linphone_core_manager_new2(const char* rc_file, int check_for_proxies) {
LinphoneCoreManager *manager = ms_new0(LinphoneCoreManager, 1);
linphone_core_manager_init(manager, rc_file);
linphone_core_manager_start(manager, check_for_proxies);

View file

@ -23,6 +23,28 @@
#include "private.h"
#include "liblinphone_tester.h"
/* Retrieve the public IP from a given hostname */
static const char* get_ip_from_hostname(const char * tunnel_hostname){
struct addrinfo hints;
struct addrinfo *res = NULL, *it = NULL;
struct sockaddr_in *add;
char * output = NULL;
int err;
memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
if ((err = getaddrinfo(tunnel_hostname, NULL, &hints, &res))){
ms_error("error while retrieving IP from %s: %s", tunnel_hostname, gai_strerror(err));
return NULL;
}
for (it=res; it!=NULL; it=it->ai_next){
add = (struct sockaddr_in *) it->ai_addr;
output = inet_ntoa( add->sin_addr );
}
freeaddrinfo(res);
return output;
}
static char* get_public_contact_ip(LinphoneCore* lc) {
const LinphoneAddress * contact = linphone_proxy_config_get_contact(linphone_core_get_default_proxy_config(lc));
BC_ASSERT_PTR_NOT_NULL(contact);
@ -30,24 +52,17 @@ static char* get_public_contact_ip(LinphoneCore* lc) {
}
static void call_with_tunnel_base_with_config_files(LinphoneTunnelMode tunnel_mode, bool_t with_sip, LinphoneMediaEncryption encryption, bool_t with_video_and_ice, const char *marie_rc, const char *pauline_rc) {
static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_sip, LinphoneMediaEncryption encryption, bool_t with_video_and_ice) {
if (linphone_core_tunnel_available()){
LinphoneCoreManager *pauline = linphone_core_manager_new( pauline_rc);
LinphoneCoreManager *marie = linphone_core_manager_new( marie_rc);
LinphoneCoreManager *pauline = linphone_core_manager_new( "pauline_rc");
LinphoneCoreManager *marie = linphone_core_manager_new( "marie_rc");
LinphoneCall *pauline_call, *marie_call;
LinphoneProxyConfig *proxy = linphone_core_get_default_proxy_config(pauline->lc);
LinphoneAddress *server_addr = linphone_address_new(linphone_proxy_config_get_server_addr(proxy));
LinphoneAddress *route = linphone_address_new(linphone_proxy_config_get_route(proxy));
LinphoneAddress *tunnel_name, *tunnel_ip_addr;
const char * tunnel_ip;
const char * tunnel_ip = get_ip_from_hostname("tunnel.linphone.org");
char *public_ip, *public_ip2=NULL;
linphone_core_enable_dns_srv(pauline->lc,FALSE);
tunnel_name = linphone_address_new("sip:tunnel.wildcard2.linphone.org:443");
tunnel_ip_addr = linphone_core_manager_resolve(pauline, tunnel_name);
tunnel_ip = linphone_address_get_domain(tunnel_ip_addr);
linphone_core_enable_dns_srv(pauline->lc,TRUE);
BC_ASSERT_TRUE(wait_for(pauline->lc,NULL,&pauline->stat.number_of_LinphoneRegistrationOk,1));
public_ip = get_public_contact_ip(pauline->lc);
BC_ASSERT_STRING_NOT_EQUAL(public_ip, tunnel_ip);
@ -78,15 +93,13 @@ static void call_with_tunnel_base_with_config_files(LinphoneTunnelMode tunnel_mo
LinphoneTunnel *tunnel = linphone_core_get_tunnel(pauline->lc);
LinphoneTunnelConfig *config = linphone_tunnel_config_new();
linphone_tunnel_config_set_host(config, tunnel_ip);
linphone_tunnel_config_set_host(config, "tunnel.linphone.org");
linphone_tunnel_config_set_port(config, 443);
linphone_tunnel_config_set_remote_udp_mirror_port(config, 12345);
linphone_tunnel_add_server(tunnel, config);
linphone_tunnel_set_mode(tunnel, tunnel_mode);
linphone_tunnel_enable_sip(tunnel, with_sip);
linphone_tunnel_config_unref(config);
/*
* Enabling the tunnel with sip cause another REGISTER to be made.
* In automatic mode, the udp test should conclude (assuming we have a normal network), that no
@ -146,8 +159,6 @@ static void call_with_tunnel_base_with_config_files(LinphoneTunnelMode tunnel_mo
if(public_ip2 != NULL) ms_free(public_ip2);
linphone_address_destroy(server_addr);
linphone_address_destroy(route);
linphone_address_destroy(tunnel_name);
linphone_address_destroy(tunnel_ip_addr);
linphone_core_manager_destroy(pauline);
linphone_core_manager_destroy(marie);
}else{
@ -155,9 +166,6 @@ static void call_with_tunnel_base_with_config_files(LinphoneTunnelMode tunnel_mo
}
}
static void call_with_tunnel_base(LinphoneTunnelMode tunnel_mode, bool_t with_sip, LinphoneMediaEncryption encryption, bool_t with_video_and_ice) {
call_with_tunnel_base_with_config_files(tunnel_mode, with_sip, encryption, with_video_and_ice, "marie_rc", "pauline_rc");
}
static void call_with_tunnel(void) {
call_with_tunnel_base(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, FALSE);
@ -171,10 +179,6 @@ static void call_with_tunnel_without_sip(void) {
call_with_tunnel_base(LinphoneTunnelModeEnable, FALSE, LinphoneMediaEncryptionNone, FALSE);
}
static void call_with_tunnel_verify_server_certificate(void) {
call_with_tunnel_base_with_config_files(LinphoneTunnelModeEnable, TRUE, LinphoneMediaEncryptionNone, FALSE, "marie_rc", "pauline_tunnel_verify_server_certificate_rc");
}
static void call_with_tunnel_auto(void) {
call_with_tunnel_base(LinphoneTunnelModeAuto, TRUE, LinphoneMediaEncryptionNone, FALSE);
}
@ -240,11 +244,54 @@ static void tunnel_ice_call(void) {
else
ms_warning("Could not test %s because tunnel functionality is not available",__FUNCTION__);
}
static void register_on_second_tunnel(void) {
if (linphone_core_tunnel_available()) {
LinphoneCoreManager *pauline = linphone_core_manager_new( "pauline_rc");
LinphoneTunnel *tunnel = linphone_core_get_tunnel(pauline->lc);
LinphoneTunnelConfig *config = linphone_tunnel_config_new();
const char * tunnel_ip = get_ip_from_hostname("tunnel.linphone.org");
char* public_ip;
linphone_tunnel_simulate_udp_loss(tunnel, TRUE);
linphone_tunnel_config_set_host(config, "tunnel.linphone.org");
// add a first tunnel config with an invalid port
linphone_tunnel_config_set_port(config, 4141);
linphone_tunnel_config_set_remote_udp_mirror_port(config, 54321);
linphone_tunnel_add_server(tunnel, config);
// then a proper server
linphone_tunnel_config_set_port(config, 443);
linphone_tunnel_config_set_remote_udp_mirror_port(config, 12345);
linphone_tunnel_add_server(tunnel, config);
linphone_tunnel_set_mode(tunnel, LinphoneTunnelModeAuto);
linphone_tunnel_enable_sip(tunnel, TRUE);
reset_counters(&pauline->stat);
linphone_core_refresh_registers(pauline->lc);
// we should expect 2 registers: since tunnel autodetection takes several seconds, a first
// register will be made, then tunnel will be configured and another register will be fired up
BC_ASSERT_TRUE(wait_for(pauline->lc, NULL, &pauline->stat.number_of_LinphoneRegistrationOk,2));
public_ip = get_public_contact_ip(pauline->lc);
BC_ASSERT_STRING_EQUAL(public_ip, tunnel_ip);
ms_free(public_ip);
linphone_tunnel_config_unref(config);
linphone_core_manager_destroy(pauline);
} else {
ms_warning("Could not test %s because tunnel functionality is not available",__FUNCTION__);
}
}
test_t tunnel_tests[] = {
TEST_NO_TAG("Simple", call_with_tunnel),
TEST_NO_TAG("With SRTP", call_with_tunnel_srtp),
TEST_NO_TAG("Without SIP", call_with_tunnel_without_sip),
TEST_NO_TAG("Verify Server Certificate", call_with_tunnel_verify_server_certificate),
TEST_NO_TAG("In automatic mode", call_with_tunnel_auto),
TEST_NO_TAG("In automatic mode with SRTP without SIP", call_with_tunnel_auto_without_sip_with_srtp),
TEST_NO_TAG("Ice call", tunnel_ice_call),
@ -257,6 +304,7 @@ test_t tunnel_tests[] = {
TEST_NO_TAG("DTLS ice video call", tunnel_dtls_video_ice_call),
TEST_NO_TAG("ZRTP ice video call", tunnel_zrtp_video_ice_call),
#endif
TEST_NO_TAG("Register on second tunnel", register_on_second_tunnel),
};
test_suite_t tunnel_test_suite = {"Tunnel", NULL, NULL, liblinphone_tester_before_each, liblinphone_tester_after_each,

View file

@ -23,6 +23,8 @@
#include <time.h>
#define CARDDAV_SERVER "http://dav.linphone.org/card.php/addressbooks/tester/default"
#ifdef VCARD_ENABLED
static char *create_filepath(const char *dir, const char *filename, const char *ext) {
return ms_strdup_printf("%s/%s.%s", dir, filename, ext);
@ -390,7 +392,7 @@ static void carddav_sync(void) {
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneCardDavContext *c = NULL;
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_unref(lfl);
c = linphone_carddav_context_new(lfl);
@ -421,7 +423,7 @@ static void carddav_sync_2(void) {
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneCardDavContext *c = NULL;
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_unref(lfl);
c = linphone_carddav_context_new(lfl);
@ -463,7 +465,7 @@ static void carddav_sync_3(void) {
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneCardDavContext *c = NULL;
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_unref(lfl);
c = linphone_carddav_context_new(lfl);
@ -502,7 +504,7 @@ static void carddav_sync_4(void) {
LinphoneFriendList *lfl = linphone_core_create_friend_list(manager->lc);
LinphoneCardDavContext *c = NULL;
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_unref(lfl);
c = linphone_carddav_context_new(lfl);
@ -566,7 +568,7 @@ static void carddav_integration(void) {
LinphoneCardDAVStats *stats = (LinphoneCardDAVStats *)ms_new0(LinphoneCardDAVStats, 1);
const char *refkey = "toto";
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
cbs = linphone_friend_list_get_callbacks(lfl);
linphone_friend_list_cbs_set_user_data(cbs, stats);
linphone_friend_list_cbs_set_contact_created(cbs, carddav_contact_created);
@ -596,7 +598,7 @@ static void carddav_integration(void) {
linphone_friend_unref(lf);
lvc2 = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sberfini@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
linphone_vcard_set_url(lvc2, "/sabredav/addressbookserver.php/addressbooks/sylvain/default/me.vcf");
linphone_vcard_set_url(lvc2, "/card.php/addressbooks/tester/default/me.vcf");
lf2 = linphone_friend_new_from_vcard(lvc2);
linphone_friend_set_ref_key(lf2, refkey);
BC_ASSERT_EQUAL(linphone_friend_list_add_local_friend(lfl, lf2), LinphoneFriendListOK, int, "%d");
@ -650,7 +652,7 @@ static void carddav_clean(void) { // This is to ensure the content of the test
linphone_friend_list_cbs_set_contact_updated(cbs, carddav_contact_updated);
linphone_friend_list_cbs_set_sync_status_changed(cbs, carddav_sync_status_changed);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_friend_list_synchronize_friends_from_server(lfl);
wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 2000);
@ -669,7 +671,7 @@ static void carddav_clean(void) { // This is to ensure the content of the test
}
lvc = linphone_vcard_new_from_vcard4_buffer("BEGIN:VCARD\r\nVERSION:4.0\r\nFN:Sylvain Berfini\r\nIMPP:sip:sylvain@sip.linphone.org\r\nUID:1f08dd48-29ac-4097-8e48-8596d7776283\r\nEND:VCARD\r\n");
linphone_vcard_set_url(lvc, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default/me.vcf");
linphone_vcard_set_url(lvc, "http://dav.linphone.org/card.php/addressbooks/tester/default/me.vcf");
lf = linphone_friend_new_from_vcard(lvc);
linphone_friend_list_add_friend(lfl, lf);
wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 2000);
@ -693,7 +695,7 @@ static void carddav_multiple_sync(void) {
linphone_friend_list_cbs_set_contact_updated(cbs, carddav_contact_updated);
linphone_friend_list_cbs_set_sync_status_changed(cbs, carddav_sync_status_changed);
linphone_core_add_friend_list(manager->lc, lfl);
linphone_friend_list_set_uri(lfl, "http://dav.linphone.org/sabredav/addressbookserver.php/addressbooks/sylvain/default");
linphone_friend_list_set_uri(lfl, CARDDAV_SERVER);
linphone_friend_list_synchronize_friends_from_server(lfl);
wait_for_until(manager->lc, NULL, &stats->sync_done_count, 1, 2000);