...
 
Commits (2)
......@@ -41,7 +41,7 @@ static void linphone_nat_policy_destroy(LinphoneNatPolicy *policy) {
if (policy->ref) belle_sip_free(policy->ref);
if (policy->stun_server) belle_sip_free(policy->stun_server);
if (policy->stun_server_username) belle_sip_free(policy->stun_server_username);
if (policy->stun_addrinfo) bctbx_freeaddrinfo(policy->stun_addrinfo);
if (policy->resolver_results) belle_sip_object_unref(policy->resolver_results);
if (policy->stun_resolver_context) {
belle_sip_resolver_context_cancel(policy->stun_resolver_context);
belle_sip_object_unref(policy->stun_resolver_context);
......@@ -185,9 +185,9 @@ void linphone_nat_policy_set_stun_server(LinphoneNatPolicy *policy, const char *
if (new_stun_server != NULL) {
policy->stun_server = new_stun_server;
}
if (policy->stun_addrinfo) {
bctbx_freeaddrinfo(policy->stun_addrinfo);
policy->stun_addrinfo = NULL;
if (policy->resolver_results) {
belle_sip_object_unref(policy->resolver_results);
policy->resolver_results = NULL;
}
if (policy->stun_resolver_context){
belle_sip_resolver_context_cancel(policy->stun_resolver_context);
......@@ -213,18 +213,21 @@ void linphone_nat_policy_set_stun_server_username(LinphoneNatPolicy *policy, con
if (new_username != NULL) policy->stun_server_username = new_username;
}
static void stun_server_resolved(void *data, const char *name, struct addrinfo *addrinfo, uint32_t ttl) {
static void stun_server_resolved(void *data, belle_sip_resolver_results_t *results) {
LinphoneNatPolicy *policy = (LinphoneNatPolicy *)data;
if (policy->stun_addrinfo) {
bctbx_freeaddrinfo(policy->stun_addrinfo);
policy->stun_addrinfo = NULL;
if (policy->resolver_results) {
belle_sip_object_unref(policy->resolver_results);
policy->resolver_results = NULL;
}
if (addrinfo) {
if (belle_sip_resolver_results_get_addrinfos(results)) {
ms_message("Stun server resolution successful.");
belle_sip_object_ref(results);
policy->resolver_results = results;
} else {
ms_warning("Stun server resolution failed.");
}
policy->stun_addrinfo = addrinfo;
if (policy->stun_resolver_context){
belle_sip_object_unref(policy->stun_resolver_context);
policy->stun_resolver_context = NULL;
......@@ -266,17 +269,17 @@ const struct addrinfo * linphone_nat_policy_get_stun_server_addrinfo(LinphoneNat
* - if no cached value exists, block for a short time; this case must be unprobable because the resolution will be asked each
* time the stun server value is changed.
*/
if (linphone_nat_policy_stun_server_activated(policy) && (policy->stun_addrinfo == NULL)) {
if (linphone_nat_policy_stun_server_activated(policy) && (policy->resolver_results == NULL)) {
int wait_ms = 0;
int wait_limit = 1000;
linphone_nat_policy_resolve_stun_server(policy);
while ((policy->stun_addrinfo == NULL) && (policy->stun_resolver_context != NULL) && (wait_ms < wait_limit)) {
while ((policy->resolver_results == NULL) && (policy->stun_resolver_context != NULL) && (wait_ms < wait_limit)) {
policy->lc->sal->iterate();
ms_usleep(50000);
wait_ms += 50;
}
}
return policy->stun_addrinfo;
return policy->resolver_results ? belle_sip_resolver_results_get_addrinfos(policy->resolver_results) : NULL;
}
LinphoneNatPolicy * linphone_core_create_nat_policy(LinphoneCore *lc) {
......
......@@ -470,7 +470,7 @@ struct _LinphoneNatPolicy {
void *user_data;
LinphoneCore *lc;
belle_sip_resolver_context_t *stun_resolver_context;
struct addrinfo *stun_addrinfo;
belle_sip_resolver_results_t *resolver_results;
char *stun_server;
char *stun_server_username;
char *ref;
......
......@@ -50,9 +50,11 @@ LINPHONE_PUBLIC void linphone_core_use_sound_daemon(LinphoneCore *lc, LinphoneSo
LINPHONE_PUBLIC void linphone_sound_daemon_destroy(LinphoneSoundDaemon *obj);
LINPHONE_DEPRECATED typedef void (*LinphoneEcCalibrationCallback)(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data);
LINPHONE_DEPRECATED typedef void (*LinphoneEcCalibrationAudioInit)(void *data);
LINPHONE_DEPRECATED typedef void (*LinphoneEcCalibrationAudioUninit)(void *data);
/*These typedefs are deprecated, but we don't mark them LINPHONE_DEPRECATED otherwise we get deprecation warnings with
* the deprecated linphone_core_start_echo_calibration() that make use of them*/
typedef void (*LinphoneEcCalibrationCallback)(LinphoneCore *lc, LinphoneEcCalibratorStatus status, int delay_ms, void *data);
typedef void (*LinphoneEcCalibrationAudioInit)(void *data);
typedef void (*LinphoneEcCalibrationAudioUninit)(void *data);
/**
* @brief Starts an echo calibration of the sound devices, in order to find adequate settings for the echo canceler automatically.
......
......@@ -267,34 +267,19 @@ void IceAgent::updateIceStateInCallStats () {
LinphoneCallStats *audioStats = mediaSession.getPrivate()->getStats(LinphoneStreamTypeAudio);
LinphoneCallStats *videoStats = mediaSession.getPrivate()->getStats(LinphoneStreamTypeVideo);
LinphoneCallStats *textStats = mediaSession.getPrivate()->getStats(LinphoneStreamTypeText);
IceSessionState sessionState = ice_session_state(iceSession);
if ((sessionState == IS_Completed) || ((sessionState == IS_Failed) && ice_session_has_completed_check_list(iceSession))) {
_linphone_call_stats_set_ice_state(audioStats, LinphoneIceStateNotActivated);
if (audioCheckList && mediaSession.getMediaParams()->audioEnabled())
updateIceStateInCallStatsForStream(audioStats, audioCheckList);
_linphone_call_stats_set_ice_state(videoStats, LinphoneIceStateNotActivated);
if (videoCheckList && mediaSession.getMediaParams()->videoEnabled())
updateIceStateInCallStatsForStream(videoStats, videoCheckList);
_linphone_call_stats_set_ice_state(textStats, LinphoneIceStateNotActivated);
if (textCheckList && mediaSession.getMediaParams()->realtimeTextEnabled())
updateIceStateInCallStatsForStream(textStats, textCheckList);
} else if (sessionState == IS_Running) {
if (audioCheckList && mediaSession.getMediaParams()->audioEnabled())
_linphone_call_stats_set_ice_state(audioStats, LinphoneIceStateInProgress);
if (videoCheckList && mediaSession.getMediaParams()->videoEnabled())
_linphone_call_stats_set_ice_state(videoStats, LinphoneIceStateInProgress);
if (textCheckList && mediaSession.getMediaParams()->realtimeTextEnabled())
_linphone_call_stats_set_ice_state(textStats, LinphoneIceStateInProgress);
} else {
if (audioCheckList && mediaSession.getMediaParams()->audioEnabled())
_linphone_call_stats_set_ice_state(audioStats, LinphoneIceStateFailed);
if (videoCheckList && mediaSession.getMediaParams()->videoEnabled())
_linphone_call_stats_set_ice_state(videoStats, LinphoneIceStateFailed);
if (textCheckList && mediaSession.getMediaParams()->realtimeTextEnabled())
_linphone_call_stats_set_ice_state(textStats, LinphoneIceStateFailed);
}
_linphone_call_stats_set_ice_state(audioStats, LinphoneIceStateNotActivated);
if (audioCheckList && mediaSession.getMediaParams()->audioEnabled())
updateIceStateInCallStatsForStream(audioStats, audioCheckList);
_linphone_call_stats_set_ice_state(videoStats, LinphoneIceStateNotActivated);
if (videoCheckList && mediaSession.getMediaParams()->videoEnabled())
updateIceStateInCallStatsForStream(videoStats, videoCheckList);
_linphone_call_stats_set_ice_state(textStats, LinphoneIceStateNotActivated);
if (textCheckList && mediaSession.getMediaParams()->realtimeTextEnabled())
updateIceStateInCallStatsForStream(textStats, textCheckList);
lInfo() << "CallSession [" << &mediaSession << "] New ICE state: audio: [" << linphone_ice_state_to_string(linphone_call_stats_get_ice_state(audioStats)) <<
"] video: [" << linphone_ice_state_to_string(linphone_call_stats_get_ice_state(videoStats)) <<
"] text: [" << linphone_ice_state_to_string(linphone_call_stats_get_ice_state(textStats)) << "]";
......@@ -716,11 +701,21 @@ bool IceAgent::iceParamsFoundInRemoteMediaDescription (const SalMediaDescription
}
void IceAgent::updateIceStateInCallStatsForStream (LinphoneCallStats *stats, IceCheckList *cl) {
if (ice_check_list_state(cl) != ICL_Completed) {
_linphone_call_stats_set_ice_state(stats, LinphoneIceStateFailed);
return;
IceCheckListState state = ice_check_list_state(cl);
switch (state){
case ICL_Failed:
_linphone_call_stats_set_ice_state(stats, LinphoneIceStateFailed);
break;
case ICL_Running:
_linphone_call_stats_set_ice_state(stats, LinphoneIceStateInProgress);
break;
case ICL_Completed:
goto set_ice_connection_type;
break;
}
return;
set_ice_connection_type:
switch (ice_check_list_selected_valid_candidate_type(cl)) {
case ICT_HostCandidate:
_linphone_call_stats_set_ice_state(stats, LinphoneIceStateHostConnection);
......
......@@ -59,7 +59,9 @@ public:
bool isControlling () const;
bool prepare (const SalMediaDescription *localDesc, bool incomingOffer, bool allowGathering = true);
void prepareIceForStream (MediaStream *ms, bool createChecklist);
//Clear all local candidates and restart the ICE session
void resetSession (IceRole role);
//Restart the session but keeping previous local candidates
void restartSession (IceRole role);
void startConnectivityChecks ();
void stopIceForInactiveStreams (SalMediaDescription *desc);
......