Commit 501ae333 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Improve ICE gathering in progress accessors.

parent 373c9257
...@@ -206,6 +206,7 @@ typedef struct _IceCheckList { ...@@ -206,6 +206,7 @@ typedef struct _IceCheckList {
uint32_t foundation_generator; /**< Autoincremented integer to generate unique foundation values */ uint32_t foundation_generator; /**< Autoincremented integer to generate unique foundation values */
bool_t mismatch; /**< Boolean value telling whether there was a mismatch during the answer/offer process */ bool_t mismatch; /**< Boolean value telling whether there was a mismatch during the answer/offer process */
bool_t gathering_candidates; /**< Boolean value telling whether a candidate gathering process is running or not */ bool_t gathering_candidates; /**< Boolean value telling whether a candidate gathering process is running or not */
bool_t gathering_finished; /**< Boolean value telling whether the candidate gathering process has finished or not */
MSTimeSpec gathering_start_time; /**< Time when the gathering process was started */ MSTimeSpec gathering_start_time; /**< Time when the gathering process was started */
} IceCheckList; } IceCheckList;
...@@ -249,6 +250,14 @@ MS2_PUBLIC IceCheckList * ice_check_list_new(void); ...@@ -249,6 +250,14 @@ MS2_PUBLIC IceCheckList * ice_check_list_new(void);
*/ */
MS2_PUBLIC void ice_check_list_destroy(IceCheckList *cl); MS2_PUBLIC void ice_check_list_destroy(IceCheckList *cl);
/**
* Tell whether ICE local candidates have been gathered for an ICE check list or not.
*
* @param session A pointer to a check list
* @return TRUE if local candidates have been gathered for the check list, FALSE otherwise.
*/
MS2_PUBLIC bool_t ice_check_list_candidates_gathered(const IceCheckList *cl);
/** /**
* Get the nth check list of an ICE session. * Get the nth check list of an ICE session.
* *
......
...@@ -789,15 +789,20 @@ void ice_session_check_mismatch(IceSession *session) ...@@ -789,15 +789,20 @@ void ice_session_check_mismatch(IceSession *session)
* CANDIDATES GATHERING * * CANDIDATES GATHERING *
*****************************************************************************/ *****************************************************************************/
static void ice_check_list_candidates_gathered(const IceCheckList *cl, bool_t *result) static void ice_check_list_candidates_gathered_result_ptr(const IceCheckList *cl, bool_t *result)
{ {
if (ms_list_size(cl->local_candidates) == 0) *result = FALSE; if (cl->gathering_finished == FALSE) *result = FALSE;
}
bool_t ice_check_list_candidates_gathered(const IceCheckList *cl)
{
return cl->gathering_finished;
} }
bool_t ice_session_candidates_gathered(const IceSession *session) bool_t ice_session_candidates_gathered(const IceSession *session)
{ {
bool_t result = TRUE; bool_t result = TRUE;
ms_list_for_each2(session->streams, (void (*)(void*,void*))ice_check_list_candidates_gathered, &result); ms_list_for_each2(session->streams, (void (*)(void*,void*))ice_check_list_candidates_gathered_result_ptr, &result);
return result; return result;
} }
...@@ -807,7 +812,7 @@ static void ice_check_list_gather_candidates(IceCheckList *cl, Session_Index *si ...@@ -807,7 +812,7 @@ static void ice_check_list_gather_candidates(IceCheckList *cl, Session_Index *si
ortp_socket_t sock = -1; ortp_socket_t sock = -1;
MSTimeSpec curtime = ice_current_time(); MSTimeSpec curtime = ice_current_time();
if ((cl->rtp_session != NULL) && (cl->gathering_candidates == FALSE) && (cl->state != ICL_Completed)) { if ((cl->rtp_session != NULL) && (cl->gathering_candidates == FALSE) && (cl->state != ICL_Completed) && (ice_check_list_candidates_gathered(cl) == FALSE)) {
cl->gathering_candidates = TRUE; cl->gathering_candidates = TRUE;
cl->gathering_start_time = curtime; cl->gathering_start_time = curtime;
sock = rtp_session_get_rtp_socket(cl->rtp_session); sock = rtp_session_get_rtp_socket(cl->rtp_session);
...@@ -1688,6 +1693,7 @@ static void ice_handle_received_binding_response(IceCheckList *cl, RtpSession *r ...@@ -1688,6 +1693,7 @@ static void ice_handle_received_binding_response(IceCheckList *cl, RtpSession *r
} }
if (ms_list_size(cl->stun_server_checks) == 0) { if (ms_list_size(cl->stun_server_checks) == 0) {
cl->gathering_candidates = FALSE; cl->gathering_candidates = FALSE;
cl->gathering_finished = TRUE;
ms_message("ice: Finished candidates gathering for check list %p", cl); ms_message("ice: Finished candidates gathering for check list %p", cl);
ice_dump_candidates(cl); ice_dump_candidates(cl);
if (ms_list_find_custom(cl->session->streams, (MSCompareFunc)ice_find_check_list_gathering_candidates, NULL) == NULL) { if (ms_list_find_custom(cl->session->streams, (MSCompareFunc)ice_find_check_list_gathering_candidates, NULL) == NULL) {
...@@ -2643,6 +2649,7 @@ static void ice_check_list_restart(IceCheckList *cl) ...@@ -2643,6 +2649,7 @@ static void ice_check_list_restart(IceCheckList *cl)
cl->state = ICL_Running; cl->state = ICL_Running;
cl->mismatch = FALSE; cl->mismatch = FALSE;
cl->gathering_candidates = FALSE; cl->gathering_candidates = FALSE;
cl->gathering_finished = FALSE;
} }
void ice_session_restart(IceSession *session) void ice_session_restart(IceSession *session)
...@@ -2679,6 +2686,7 @@ static void ice_check_gathering_timeout_of_check_list(const IceCheckList *cl, Ti ...@@ -2679,6 +2686,7 @@ static void ice_check_gathering_timeout_of_check_list(const IceCheckList *cl, Ti
static void ice_check_list_stop_gathering(IceCheckList *cl) static void ice_check_list_stop_gathering(IceCheckList *cl)
{ {
cl->gathering_candidates = FALSE; cl->gathering_candidates = FALSE;
cl->gathering_finished = TRUE;
} }
static bool_t ice_check_gathering_timeout(IceCheckList *cl, RtpSession *rtp_session, MSTimeSpec curtime) static bool_t ice_check_gathering_timeout(IceCheckList *cl, RtpSession *rtp_session, MSTimeSpec curtime)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment