mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Allow network state change to be notified immediately without linphone_core_iterate() being called.
This commit is contained in:
parent
da3007f50d
commit
184388008e
2 changed files with 20 additions and 12 deletions
|
|
@ -3184,6 +3184,16 @@ bool_t linphone_core_content_encoding_supported(const LinphoneCore *lc, const ch
|
|||
return (strcmp(handle_content_encoding, content_encoding) == 0) && lc->sal->isContentEncodingAvailable(content_encoding);
|
||||
}
|
||||
|
||||
static void notify_network_reachable_change (LinphoneCore *lc) {
|
||||
if (!lc->network_reachable_to_be_notified)
|
||||
return;
|
||||
|
||||
lc->network_reachable_to_be_notified = FALSE;
|
||||
linphone_core_notify_network_reachable(lc, lc->sip_network_reachable);
|
||||
if (lc->sip_network_reachable)
|
||||
linphone_core_resolve_stun_server(lc);
|
||||
}
|
||||
|
||||
static void monitor_network_state(LinphoneCore *lc, time_t curtime){
|
||||
bool_t new_status=lc->network_last_status;
|
||||
char newip[LINPHONE_IPADDR_SIZE];
|
||||
|
|
@ -3212,6 +3222,8 @@ static void monitor_network_state(LinphoneCore *lc, time_t curtime){
|
|||
}
|
||||
lc->network_last_check=curtime;
|
||||
}
|
||||
|
||||
notify_network_reachable_change(lc);
|
||||
}
|
||||
|
||||
static void proxy_update(LinphoneCore *lc){
|
||||
|
|
@ -3304,13 +3316,6 @@ void linphone_core_iterate(LinphoneCore *lc){
|
|||
int64_t diff_time;
|
||||
bool one_second_elapsed = false;
|
||||
|
||||
if (lc->network_reachable_to_be_notified) {
|
||||
lc->network_reachable_to_be_notified=FALSE;
|
||||
linphone_core_notify_network_reachable(lc,lc->sip_network_reachable);
|
||||
if (lc->sip_network_reachable) {
|
||||
linphone_core_resolve_stun_server(lc);
|
||||
}
|
||||
}
|
||||
if (lc->prevtime_ms == 0){
|
||||
lc->prevtime_ms = curtime_ms;
|
||||
}
|
||||
|
|
@ -6327,19 +6332,22 @@ static void disable_internal_network_reachability_detection(LinphoneCore *lc){
|
|||
}
|
||||
}
|
||||
|
||||
void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t isReachable) {
|
||||
void linphone_core_set_network_reachable(LinphoneCore *lc, bool_t isReachable) {
|
||||
disable_internal_network_reachability_detection(lc);
|
||||
set_network_reachable(lc, isReachable, ms_time(NULL));
|
||||
notify_network_reachable_change(lc);
|
||||
}
|
||||
|
||||
void linphone_core_set_media_network_reachable(LinphoneCore *lc, bool_t is_reachable){
|
||||
disable_internal_network_reachability_detection(lc);
|
||||
set_media_network_reachable(lc, is_reachable);
|
||||
notify_network_reachable_change(lc);
|
||||
}
|
||||
|
||||
void linphone_core_set_sip_network_reachable(LinphoneCore *lc, bool_t is_reachable){
|
||||
disable_internal_network_reachability_detection(lc);
|
||||
set_sip_network_reachable(lc, is_reachable, ms_time(NULL));
|
||||
notify_network_reachable_change(lc);
|
||||
}
|
||||
|
||||
bool_t linphone_core_is_network_reachable(LinphoneCore* lc) {
|
||||
|
|
|
|||
|
|
@ -5310,16 +5310,16 @@ static void recovered_call_on_network_switch_in_early_media_base (bool_t callerL
|
|||
if (callerLosesNetwork) {
|
||||
/* Disconnect Marie's network and then reconnect it */
|
||||
linphone_core_set_network_reachable(marie->lc, FALSE);
|
||||
wait_for(marie->lc, pauline->lc, &marie->stat.number_of_NetworkReachableFalse, 1);
|
||||
BC_ASSERT_EQUAL(marie->stat.number_of_NetworkReachableFalse, 1, int, "%d");
|
||||
linphone_core_set_network_reachable(marie->lc, TRUE);
|
||||
wait_for(marie->lc, pauline->lc, &marie->stat.number_of_NetworkReachableTrue, 2);
|
||||
BC_ASSERT_EQUAL(marie->stat.number_of_NetworkReachableTrue, 2, int, "%d");
|
||||
BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneRegistrationOk, 2));
|
||||
} else {
|
||||
/* Disconnect Pauline's network and then reconnect it */
|
||||
linphone_core_set_network_reachable(pauline->lc, FALSE);
|
||||
wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_NetworkReachableFalse, 1);
|
||||
BC_ASSERT_EQUAL(pauline->stat.number_of_NetworkReachableFalse, 1, int, "%d");
|
||||
linphone_core_set_network_reachable(pauline->lc, TRUE);
|
||||
wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_NetworkReachableTrue, 2);
|
||||
BC_ASSERT_EQUAL(pauline->stat.number_of_NetworkReachableTrue, 2, int, "%d");
|
||||
BC_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneRegistrationOk, 2));
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue