From 5644d8332f5912280aa4b656e59f2d8c9480e178 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 4 Feb 2016 11:22:16 +0100 Subject: [PATCH 1/5] Fix build on Windows. --- coreapi/private.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coreapi/private.h b/coreapi/private.h index 9c3b07f8f..92e9999d3 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -1430,7 +1430,7 @@ typedef struct _VTableReference VTableReference; void v_table_reference_destroy(VTableReference *ref); -void _linphone_core_add_listener(LinphoneCore *lc, LinphoneCoreVTable *vtable, bool_t autorelease, bool_t internal); +LINPHONE_PUBLIC void _linphone_core_add_listener(LinphoneCore *lc, LinphoneCoreVTable *vtable, bool_t autorelease, bool_t internal); #ifdef VIDEO_ENABLED LINPHONE_PUBLIC MSWebCam *linphone_call_get_video_device(const LinphoneCall *call); From 8246df5cd4dc2df0b2fcba5c147b09328f3ffa8d Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Thu, 4 Feb 2016 12:14:28 +0100 Subject: [PATCH 2/5] Fix Python module build. --- .../apixml2python/handwritten_definitions.mustache | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/tools/python/apixml2python/handwritten_definitions.mustache b/tools/python/apixml2python/handwritten_definitions.mustache index 98bdb1d44..1ecc8fb17 100644 --- a/tools/python/apixml2python/handwritten_definitions.mustache +++ b/tools/python/apixml2python/handwritten_definitions.mustache @@ -393,13 +393,13 @@ static PyObject * pylinphone_Core_get_video_devices(PyObject *self, void *closur return _list; } -static void pylinphone_init_ms2_plugins(void) { - ms_init(); // Initialize mediastreamer2 before loading the plugins +static void pylinphone_init_ms2_plugins(LinphoneCore *lc) { + MSFactory *factory = linphone_core_get_ms_factory(lc); #ifdef ENABLE_OPENH264 - libmsopenh264_init(); + libmsopenh264_init(factory); #endif #ifdef ENABLE_WASAPI - libmswasapi_init(); + libmswasapi_init(factory); #endif } @@ -431,9 +431,9 @@ static PyObject * pylinphone_Core_class_method_new(PyObject *cls, PyObject *args {{/core_events}} pylinphone_trace(1, "[PYLINPHONE] >>> %s(%p, \"%s\", \"%s\")", __FUNCTION__, _vtable_dict, _config_path, _factory_config_path); - pylinphone_init_ms2_plugins(); cresult = linphone_core_new(&_vtable, _config_path, _factory_config_path, self); self->native_ptr = cresult; + pylinphone_init_ms2_plugins(cresult); pyret = Py_BuildValue("O", self); @@ -474,9 +474,9 @@ static PyObject * pylinphone_Core_class_method_new_with_config(PyObject *cls, Py {{/core_events}} pylinphone_trace(1, "[PYLINPHONE] >>> %s(%p [%p])", __FUNCTION__, _config, _config_native_ptr); - pylinphone_init_ms2_plugins(); cresult = linphone_core_new_with_config(&_vtable, _config_native_ptr, self); self->native_ptr = cresult; + pylinphone_init_ms2_plugins(cresult); pyret = Py_BuildValue("O", self); @@ -492,7 +492,6 @@ static void pylinphone_Core_dealloc(PyObject *self) { if (native_ptr != NULL) { linphone_core_destroy(native_ptr); - ms_exit(); // De-initialize mediastreamer } pylinphone_dispatch_messages(); From 72ff7c93549e630a6b5fca01c27b803719d080a1 Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Thu, 4 Feb 2016 12:22:31 +0100 Subject: [PATCH 3/5] tester: fix crash in presence --- tester/presence_tester.c | 145 ++++++++++++++++++++------------------- 1 file changed, 74 insertions(+), 71 deletions(-) diff --git a/tester/presence_tester.c b/tester/presence_tester.c index 32d3e7255..5c95563c1 100644 --- a/tester/presence_tester.c +++ b/tester/presence_tester.c @@ -133,7 +133,7 @@ static void simple_publish_with_expire(int expires) { LinphoneCoreVTable *vtable = linphone_core_v_table_new(); vtable->publish_state_changed = linphone_publish_state_changed; _linphone_core_add_listener(marie->lc, vtable, TRUE, TRUE ); - + proxy = linphone_core_get_default_proxy_config(marie->lc); linphone_proxy_config_edit(proxy); if (expires >0) { @@ -141,16 +141,16 @@ static void simple_publish_with_expire(int expires) { } linphone_proxy_config_enable_publish(proxy,TRUE); linphone_proxy_config_done(proxy); - + BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,1)); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishOk,1)); - + presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityOffline,NULL); linphone_core_set_presence_model(marie->lc,presence); - + BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,2)); BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishOk,2)); - + linphone_proxy_config_edit(proxy); linphone_proxy_config_done(proxy); /*make sure no publish is sent*/ @@ -159,10 +159,10 @@ static void simple_publish_with_expire(int expires) { linphone_proxy_config_edit(proxy); linphone_proxy_config_enable_publish(proxy,FALSE); linphone_proxy_config_done(proxy); - + /*BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishProgress,3));*/ BC_ASSERT_TRUE(wait_for(marie->lc,marie->lc,&marie->stat.number_of_LinphonePublishCleared,1)); - + linphone_proxy_config_edit(proxy); linphone_proxy_config_enable_publish(proxy,TRUE); linphone_proxy_config_done(proxy); @@ -225,7 +225,7 @@ static void subscribe_failure_handle_by_app(void) { LinphoneProxyConfig* config; LinphoneFriend* lf; char* lf_identity=linphone_address_as_string_uri_only(pauline->identity); - + config = linphone_core_get_default_proxy_config(marie->lc); BC_ASSERT_TRUE(subscribe_to_callee_presence(marie,pauline)); @@ -397,34 +397,34 @@ static void subscribe_presence_forked(void){ LinphoneCoreManager* pauline2 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneFriend *lf; MSList *lcs = NULL; - + lcs = ms_list_append(lcs, marie->lc); lcs = ms_list_append(lcs, pauline1->lc); lcs = ms_list_append(lcs, pauline2->lc); - + lf = linphone_core_create_friend(marie->lc); linphone_friend_set_address(lf, pauline1->identity); linphone_friend_enable_subscribes(lf, TRUE); - + linphone_core_add_friend(marie->lc, lf); linphone_friend_unref(lf); - + BC_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_NewSubscriptionRequest,1, 10000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline2->stat.number_of_NewSubscriptionRequest,1, 2000)); /*we should get two notifies*/ BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,2, 10000)); - - /*marie also shall receive two SUBSCRIBEs from the two paulines, but won't be notified to the app since + + /*marie also shall receive two SUBSCRIBEs from the two paulines, but won't be notified to the app since Marie set Pauline as a friend.*/ BC_ASSERT_EQUAL(marie->stat.number_of_NewSubscriptionRequest, 0, int, "%d"); /*and the two paulines shall be notified of marie's presence*/ BC_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_LinphonePresenceActivityOnline,1, 3000)); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline2->stat.number_of_LinphonePresenceActivityOnline,1, 2000)); - + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline1); linphone_core_manager_destroy(pauline2); - + ms_list_free(lcs); } @@ -433,36 +433,39 @@ static void subscribe_presence_expired(void){ LinphoneCoreManager* pauline1 = linphone_core_manager_new(transport_supported(LinphoneTransportTls) ? "pauline_rc" : "pauline_tcp_rc"); LinphoneFriend *lf; MSList *lcs = NULL; - + lcs = ms_list_append(lcs, marie->lc); lcs = ms_list_append(lcs, pauline1->lc); - + lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 10); lf = linphone_core_create_friend(marie->lc); linphone_friend_set_address(lf, pauline1->identity); linphone_friend_enable_subscribes(lf, TRUE); - + linphone_core_add_friend(marie->lc, lf); linphone_friend_unref(lf); BC_ASSERT_TRUE(wait_for_list(lcs,&pauline1->stat.number_of_NewSubscriptionRequest,1, 5000)); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,1, 2000)); - - lf = linphone_core_find_friend(pauline1->lc, marie->identity); - BC_ASSERT_PTR_NOT_NULL(lf->insubs); - - /*marie comes offline suddenly*/ - linphone_core_set_network_reachable(marie->lc, FALSE); - /*after a certain time, pauline shall see the incoming SUBSCRIBE expired*/ - wait_for_list(lcs,NULL, 0, 11000); - BC_ASSERT_PTR_NULL(lf->insubs); - /*just make network reachable so that marie can unregister properly*/ - linphone_core_set_network_reachable(marie->lc, TRUE); - BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneRegistrationOk,2, 10000)); + lf = linphone_core_find_friend(pauline1->lc, marie->identity); + BC_ASSERT_PTR_NOT_NULL(lf); + if (lf) { + BC_ASSERT_PTR_NOT_NULL(lf->insubs); + + /*marie comes offline suddenly*/ + linphone_core_set_network_reachable(marie->lc, FALSE); + /*after a certain time, pauline shall see the incoming SUBSCRIBE expired*/ + wait_for_list(lcs,NULL, 0, 11000); + BC_ASSERT_PTR_NULL(lf->insubs); + + /*just make network reachable so that marie can unregister properly*/ + linphone_core_set_network_reachable(marie->lc, TRUE); + BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphoneRegistrationOk,2, 10000)); + } linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline1); - + ms_list_free(lcs); } @@ -472,46 +475,46 @@ static void subscriber_no_longuer_reachable(void){ LinphoneFriend *lf; MSList *lcs = NULL; LinphonePresenceModel * presence; - + lcs = ms_list_append(lcs, marie->lc); lcs = ms_list_append(lcs, pauline1->lc); - + lp_config_set_int(marie->lc->config, "sip", "subscribe_expires", 40); linphone_core_set_user_agent(marie->lc, "full-presence-support", NULL); linphone_core_set_user_agent(pauline1->lc, "full-presence-support", NULL); - + enable_publish(pauline1, TRUE); - + lf = linphone_core_create_friend(marie->lc); linphone_friend_set_address(lf, pauline1->identity); linphone_friend_enable_subscribes(lf, TRUE); - + linphone_core_add_friend(marie->lc, lf); linphone_friend_unref(lf); BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,1, 2000)); - - + + presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityBusy,NULL); linphone_core_set_presence_model(pauline1->lc,presence); /*don't schedule marie to simulate Notify timeout server side*/ wait_for_until(pauline1->lc, NULL, 0, 0, 35000); - + //sal_set_send_error(marie->lc->sal,0); - + /*because of notify timeout detected by server, so subscription is reset*/ BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOffline,2, 4000)); - + // now subscribetion is supposed to be dead because notify was not answered in time. presence =linphone_presence_model_new_with_activity(LinphonePresenceActivityOnline,NULL); linphone_core_set_presence_model(pauline1->lc,presence); - + /*becasue subscription is automatically restarted*/ BC_ASSERT_TRUE(wait_for_list(lcs,&marie->stat.number_of_LinphonePresenceActivityOnline,2, 4000)); - + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline1); - + ms_list_free(lcs); } @@ -525,7 +528,7 @@ static void test_subscribe_notify_publish(void) { LpConfig *pauline_lp; char* lf_identity; LinphoneFriend *lf; - + linphone_core_set_user_agent(marie->lc, "full-presence-support", NULL); linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL); pauline_lp = linphone_core_get_config(pauline->lc); @@ -569,25 +572,25 @@ static void test_subscribe_notify_publish(void) { /*wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_NotifyPresenceReceived,4,5000); BC_ASSERT_EQUAL(LinphonePresenceActivityOffline,linphone_friend_get_status(lf), int, "%d"); */ - + /*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_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphonePresenceActivityBusy,4,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)); linphone_core_set_presence_model(marie->lc,linphone_presence_model_new_with_activity(LinphonePresenceActivityBreakfast,NULL)); linphone_core_set_presence_model(marie->lc,linphone_presence_model_new_with_activity(LinphonePresenceActivityAppointment,NULL)); - + BC_ASSERT_TRUE(wait_for_until(pauline->lc,marie->lc,&pauline->stat.number_of_LinphonePresenceActivityAppointment,1,5000)); - + BC_ASSERT_EQUAL(pauline->stat.number_of_LinphonePresenceActivityAway, 1, int,"%i"); BC_ASSERT_EQUAL(pauline->stat.number_of_LinphonePresenceActivityBreakfast, 0, int,"%i"); BC_ASSERT_EQUAL(pauline->stat.number_of_LinphonePresenceActivityAppointment, 1, int,"%i"); - - + + linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); } @@ -609,7 +612,7 @@ static void test_forked_subscribe_notify_publish(void) { linphone_core_set_user_agent(marie2->lc, "full-presence-support", NULL); linphone_core_set_user_agent(pauline->lc, "full-presence-support", NULL); - + pauline_lp = linphone_core_get_config(pauline->lc); lf_identity=linphone_address_as_string_uri_only(marie->identity); lf = linphone_core_create_friend_with_address(pauline->lc,lf_identity); @@ -783,17 +786,17 @@ static void test_presence_list(void) { enable_publish(pauline, FALSE); wait_for_list(lcs, &dummy, 1, 2000); /* Wait a little bit for the presence notifications. TODO: Wait for the correct number of PresenceReceived events. */ - + lf = linphone_friend_list_find_friend_by_uri(pauline->lc->friendlist, marie_identity); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); lf = linphone_friend_list_find_friend_by_uri(laure->lc->friendlist, pauline_identity); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); lf = linphone_friend_list_find_friend_by_uri(laure->lc->friendlist, marie_identity); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); - + lf = linphone_friend_list_find_friend_by_uri(marie->lc->friendlist, laure_identity); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); - + linphone_core_manager_destroy(laure); linphone_core_manager_destroy(marie); linphone_core_manager_destroy(pauline); @@ -855,19 +858,19 @@ static void test_presence_list_subscription_expire_for_unknown(void) { LinphoneFriendList *lfl; LinphoneFriend *lf; lp_config_set_int(laure->lc->config, "sip", "rls_presence_expires", 3); - + lfl = linphone_core_create_friend_list(laure->lc); linphone_friend_list_set_rls_uri(lfl, rls_uri); lf = linphone_core_create_friend_with_address(laure->lc, "sip:michelle@sip.inexistentdomain.com"); linphone_friend_list_add_friend(lfl, lf); linphone_core_set_friend_list(laure->lc, lfl); linphone_friend_list_update_subscriptions(lfl,NULL,FALSE); - + linphone_friend_list_unref(lfl); - + /* wait for refresh*/ BC_ASSERT_FALSE(wait_for_until(laure->lc, NULL, &laure->stat.number_of_NotifyPresenceReceived, 1, 4000)); - + linphone_core_manager_destroy(laure); } @@ -881,12 +884,12 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) { MSList* lcs = NULL; int dummy = 0; lp_config_set_int(laure->lc->config, "sip", "rls_presence_expires", 5); - + pauline_identity = get_identity(pauline); - + linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityVacation, NULL)); - + lfl = linphone_core_create_friend_list(laure->lc); linphone_friend_list_set_rls_uri(lfl, rls_uri); lf = linphone_core_create_friend_with_address(laure->lc, pauline_identity); @@ -897,12 +900,12 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) { linphone_friend_list_unref(lfl); linphone_core_set_presence_model(laure->lc, linphone_core_create_presence_model_with_activity(laure->lc, LinphonePresenceActivityOnline, NULL)); linphone_friend_list_update_subscriptions(laure->lc->friendlist, NULL, FALSE); - + lcs = ms_list_append(lcs, laure->lc); lcs = ms_list_append(lcs, pauline->lc); - + wait_for_list(lcs, &dummy, 1, 2000); /* Wait a little bit for the subscribe to happen */ - + enable_publish(pauline, TRUE); BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityVacation, 1, 6000)); BC_ASSERT_GREATER(laure->stat.number_of_NotifyPresenceReceived, 1, int, "%d"); @@ -915,7 +918,7 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) { BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusOffline, int, "%d"); BC_ASSERT_EQUAL(lf->presence_received, FALSE, int, "%d"); BC_ASSERT_EQUAL(lf->subscribe_active, TRUE, int, "%d"); - + BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityVacation, 2, 6000)); if (io_error) { ms_message("Simulating socket error"); @@ -930,15 +933,15 @@ static void test_presence_list_subscribe_with_error(bool_t io_error) { /*restart normal behavior*/ sal_set_send_error(laure->lc->sal,0); sal_set_recv_error(laure->lc->sal, 1); - + BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityVacation, 3, 6000)); /* give time for subscription to recover to avoid to receive 491 Request pending*/ - + linphone_core_set_presence_model(pauline->lc, linphone_core_create_presence_model_with_activity(pauline->lc, LinphonePresenceActivityAway, NULL)); BC_ASSERT_TRUE(wait_for_until(laure->lc, pauline->lc, &laure->stat.number_of_LinphonePresenceActivityAway, 1, 6000)); lf = linphone_friend_list_find_friend_by_uri(laure->lc->friendlist, pauline_identity); BC_ASSERT_EQUAL(linphone_friend_get_status(lf), LinphoneStatusAway, int, "%d"); - + linphone_core_manager_destroy(laure); linphone_core_manager_destroy(pauline); } From 2f3c2491e0b2c6a5cfa468f7d3a7aea83fc58bb2 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 4 Feb 2016 13:41:51 +0100 Subject: [PATCH 4/5] fix crash when notification timeout is received --- coreapi/bellesip_sal/sal_op_publish.c | 2 +- coreapi/presence.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coreapi/bellesip_sal/sal_op_publish.c b/coreapi/bellesip_sal/sal_op_publish.c index d5c16ff66..a525a9998 100644 --- a/coreapi/bellesip_sal/sal_op_publish.c +++ b/coreapi/bellesip_sal/sal_op_publish.c @@ -32,7 +32,7 @@ static void publish_refresher_listener (belle_sip_refresher_t* refresher }else if (status_code>=200){ belle_sip_header_t *sip_etag; const char *sip_etag_string = NULL; - if ((sip_etag = belle_sip_message_get_header(BELLE_SIP_MESSAGE(response), "SIP-ETag"))) { + if (response && (sip_etag = belle_sip_message_get_header(BELLE_SIP_MESSAGE(response), "SIP-ETag"))) { sip_etag_string = belle_sip_header_get_unparsed_value(sip_etag); } sal_op_set_entity_tag(op, sip_etag_string); diff --git a/coreapi/presence.c b/coreapi/presence.c index b4d46f934..bb0694522 100644 --- a/coreapi/presence.c +++ b/coreapi/presence.c @@ -1460,7 +1460,7 @@ static LinphonePresenceModel * process_pidf_xml_presence_notification(xmlparsing void linphone_core_add_subscriber(LinphoneCore *lc, const char *subscriber, SalOp *op){ - LinphoneFriend *fl=linphone_friend_new_with_address(subscriber); + LinphoneFriend *fl=linphone_core_create_friend_with_address(lc,subscriber); char *tmp; if (fl==NULL) return ; From 89e977998fccced8c60c5e9bfc2e46f550ed1591 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Thu, 4 Feb 2016 16:11:43 +0100 Subject: [PATCH 5/5] start long running task during tunnel udp link probing --- coreapi/TunnelManager.cc | 20 ++++++++++++++++++-- coreapi/TunnelManager.hh | 1 + 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/coreapi/TunnelManager.cc b/coreapi/TunnelManager.cc index d7ce537f5..99e84f293 100644 --- a/coreapi/TunnelManager.cc +++ b/coreapi/TunnelManager.cc @@ -47,7 +47,10 @@ void TunnelManager::addServer(const char *ip, int port) { void TunnelManager::cleanServers() { mServerAddrs.clear(); - + if (mLongRunningTaskId > 0) { + sal_end_background_task(mLongRunningTaskId); + mLongRunningTaskId = 0; + } UdpMirrorClientList::iterator it; for (it = mUdpMirrorClients.begin(); it != mUdpMirrorClients.end();) { UdpMirrorClient& s=*it++; @@ -135,7 +138,8 @@ TunnelManager::TunnelManager(LinphoneCore* lc) : mTunnelizeSipPackets(true), mTunnelClient(NULL), mHttpProxyPort(0), - mVTable(NULL) + mVTable(NULL), + mLongRunningTaskId(0) { linphone_core_add_iterate_hook(mCore,(LinphoneCoreIterateHook)sOnIterate,this); mTransportFactories.audio_rtcp_func=sCreateRtpTransport; @@ -153,6 +157,10 @@ TunnelManager::TunnelManager(LinphoneCore* lc) : } TunnelManager::~TunnelManager(){ + if (mLongRunningTaskId > 0) { + sal_end_background_task(mLongRunningTaskId); + mLongRunningTaskId = 0; + } for(UdpMirrorClientList::iterator udpMirror = mUdpMirrorClients.begin(); udpMirror != mUdpMirrorClients.end(); udpMirror++) { udpMirror->stop(); } @@ -248,6 +256,10 @@ void TunnelManager::setMode(LinphoneTunnelMode mode) { void TunnelManager::tunnelCallback(bool connected, TunnelManager *zis){ Event ev; + if (zis->mLongRunningTaskId > 0) { + sal_end_background_task(zis->mLongRunningTaskId); + zis->mLongRunningTaskId = 0; + } ev.mType=TunnelEvent; ev.mData.mConnected=connected; zis->postEvent(ev); @@ -334,6 +346,8 @@ void TunnelManager::processUdpMirrorEvent(const Event &ev){ mCurrentUdpMirrorClient++; if (mCurrentUdpMirrorClient !=mUdpMirrorClients.end()) { ms_message("TunnelManager: trying another UDP mirror"); + if (mLongRunningTaskId == 0) + mLongRunningTaskId = sal_begin_background_task("Tunnel auto detect", NULL, NULL); UdpMirrorClient &lUdpMirrorClient=*mCurrentUdpMirrorClient; lUdpMirrorClient.start(TunnelManager::sUdpMirrorClientCallback,(void*)this); } else { @@ -378,6 +392,8 @@ bool TunnelManager::startAutoDetection() { } ms_message("TunnelManager: Starting auto-detection"); mCurrentUdpMirrorClient = mUdpMirrorClients.begin(); + if (mLongRunningTaskId == 0) + mLongRunningTaskId = sal_begin_background_task("Tunnel auto detect", NULL, NULL); UdpMirrorClient &lUdpMirrorClient=*mCurrentUdpMirrorClient; lUdpMirrorClient.start(TunnelManager::sUdpMirrorClientCallback,(void*)this); return true; diff --git a/coreapi/TunnelManager.hh b/coreapi/TunnelManager.hh index f8002ee5d..764c8efda 100644 --- a/coreapi/TunnelManager.hh +++ b/coreapi/TunnelManager.hh @@ -201,6 +201,7 @@ namespace belledonnecomm { Mutex mMutex; std::queue mEvq; char mLocalAddr[64]; + unsigned long mLongRunningTaskId; }; /**