Commit 3078bac7 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Calculate duration of the ICE gathering process.

parent 92847f56
...@@ -112,6 +112,8 @@ typedef struct _IceSession { ...@@ -112,6 +112,8 @@ typedef struct _IceSession {
bool_t send_event; /**< Boolean value telling whether an event must be sent or not */ bool_t send_event; /**< Boolean value telling whether an event must be sent or not */
struct sockaddr_storage ss; /**< STUN server address to use for the candidates gathering process */ struct sockaddr_storage ss; /**< STUN server address to use for the candidates gathering process */
socklen_t ss_len; /**< Length of the STUN server address to use for the candidates gathering process */ socklen_t ss_len; /**< Length of the STUN server address to use for the candidates gathering process */
MSTimeSpec gathering_start_ts;
MSTimeSpec gathering_end_ts;
} IceSession; } IceSession;
typedef struct _IceStunServerCheck { typedef struct _IceStunServerCheck {
...@@ -413,6 +415,14 @@ MS2_PUBLIC bool_t ice_session_candidates_gathered(const IceSession *session); ...@@ -413,6 +415,14 @@ MS2_PUBLIC bool_t ice_session_candidates_gathered(const IceSession *session);
*/ */
MS2_PUBLIC void ice_session_gather_candidates(IceSession *session, struct sockaddr_storage ss, socklen_t ss_len); MS2_PUBLIC void ice_session_gather_candidates(IceSession *session, struct sockaddr_storage ss, socklen_t ss_len);
/**
* Tell the duration of the gathering process for an ICE session in ms.
*
* @param session A pointer to a session
* @return -1 if gathering has not been run, the duration of the gathering process in ms otherwise.
*/
MS2_PUBLIC int ice_session_gathering_duration(IceSession *session);
/** /**
* Select ICE candidates that will be used and notified in the SDP. * Select ICE candidates that will be used and notified in the SDP.
* *
......
...@@ -211,6 +211,8 @@ static void ice_session_init(IceSession *session) ...@@ -211,6 +211,8 @@ static void ice_session_init(IceSession *session)
session->remote_pwd = NULL; session->remote_pwd = NULL;
session->event_time = 0; session->event_time = 0;
session->send_event = FALSE; session->send_event = FALSE;
session->gathering_start_ts.tv_sec = session->gathering_start_ts.tv_nsec = -1;
session->gathering_end_ts.tv_sec = session->gathering_end_ts.tv_nsec = -1;
} }
IceSession * ice_session_new(void) IceSession * ice_session_new(void)
...@@ -840,9 +842,17 @@ void ice_session_gather_candidates(IceSession *session, struct sockaddr_storage ...@@ -840,9 +842,17 @@ void ice_session_gather_candidates(IceSession *session, struct sockaddr_storage
session->ss_len = ss_len; session->ss_len = ss_len;
si.session = session; si.session = session;
si.index = 0; si.index = 0;
ms_get_cur_time(&session->gathering_start_ts);
ms_list_for_each2(session->streams, (void (*)(void*,void*))ice_check_list_gather_candidates, &si); ms_list_for_each2(session->streams, (void (*)(void*,void*))ice_check_list_gather_candidates, &si);
} }
int ice_session_gathering_duration(IceSession *session)
{
if ((session->gathering_start_ts.tv_sec == -1) || (session->gathering_end_ts.tv_sec == -1)) return -1;
return ((session->gathering_end_ts.tv_sec - session->gathering_start_ts.tv_sec) * 1000.0)
+ ((session->gathering_end_ts.tv_nsec - session->gathering_start_ts.tv_nsec) / 1000000.0);
}
/****************************************************************************** /******************************************************************************
* CANDIDATES SELECTION * * CANDIDATES SELECTION *
...@@ -1679,6 +1689,7 @@ static void ice_handle_received_binding_response(IceCheckList *cl, RtpSession *r ...@@ -1679,6 +1689,7 @@ static void ice_handle_received_binding_response(IceCheckList *cl, RtpSession *r
/* Notify the application when there is no longer any check list gathering candidates. */ /* Notify the application when there is no longer any check list gathering candidates. */
ev = ortp_event_new(ORTP_EVENT_ICE_GATHERING_FINISHED); ev = ortp_event_new(ORTP_EVENT_ICE_GATHERING_FINISHED);
ortp_event_get_data(ev)->info.ice_processing_successful = TRUE; ortp_event_get_data(ev)->info.ice_processing_successful = TRUE;
cl->session->gathering_end_ts = evt_data->ts;
rtp_session_dispatch_event(rtp_session, ev); rtp_session_dispatch_event(rtp_session, ev);
} }
} }
......
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