Commit 1bf41396 authored by johan's avatar johan
Browse files

Merge branch 'master' into zrtphash

Conflicts:
	mediastreamer2
parents 0a0f714c 2a090655
......@@ -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;
}
......@@ -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;
};
/**
......
......@@ -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) {
......
......@@ -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);
}
......@@ -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);
/**
* @}
**/
......
......@@ -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) {}
......@@ -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
......
......@@ -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);
......
......@@ -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);
......
......@@ -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){
......
......@@ -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) {
......
mediastreamer2 @ 9dd1aeea
Subproject commit 2abbb7ae3c3585533c0f731f2fc56611597e9158
Subproject commit 9dd1aeeac987da96a91ce13ffd8f21b8bfbe17e5
......@@ -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),
......
......@@ -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);
......
......@@ -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);
......
......@@ -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) {
......
......@@ -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*/
/*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. */