Commit add885a0 authored by Ghislain MARY's avatar Ghislain MARY

Some refactoring to use ICE session instead of lower level ICE check lists.

parent 41b69cc3
......@@ -318,10 +318,10 @@ MS2_PUBLIC const char * ice_check_list_remote_pwd(IceCheckList *cl);
/**
* Add a local candidate to an ICE check list.
*
* This function is not to be used directly. The ice_gather_candidates() function SHOULD be used instead.
* This function is not to be used directly. The ice_session_gather_candidates() function SHOULD be used instead.
* However, it is used by mediastream for testing purpose since it does not use gathering.
*/
MS2_PUBLIC IceCandidate * ice_add_local_candidate(IceCheckList *cl, const char *type, const char *ip, int port, uint16_t componentID, IceCandidate *base);
IceCandidate * ice_add_local_candidate(IceCheckList *cl, const char *type, const char *ip, int port, uint16_t componentID, IceCandidate *base);
/**
* Add a remote candidate to an ICE check list.
......@@ -338,23 +338,54 @@ MS2_PUBLIC IceCandidate * ice_add_local_candidate(IceCheckList *cl, const char *
*/
MS2_PUBLIC IceCandidate * ice_add_remote_candidate(IceCheckList *cl, const char *type, const char *ip, int port, uint16_t componentID, uint32_t priority, const char * const foundation);
void ice_handle_stun_packet(IceCheckList *cl, RtpSession *session, mblk_t *m);
/**
* Gather the local candidates for an ICE session.
*
* TODO: Define more precisely, probably provide a callback function to call when the gathering is finished.
*/
MS2_PUBLIC void ice_session_gather_candidates(IceSession *session);
void ice_gather_candidates(IceCheckList *cl);
/**
* Set the base for the local server reflexive candidates of an ICE session.
*
* This function SHOULD not be used. However, it is used by mediastream for testing purpose to
* work around the fact that it does not use candidates gathering.
* It is to be called automatically when the gathering process finishes.
*/
void ice_session_set_base_for_srflx_candidates(IceSession *session);
void ice_compute_candidates_foundations(IceCheckList *cl);
/**
* Compute the foundations of the local candidates of an ICE session.
*
* This function SHOULD not be used. However, it is used by mediastream for testing purpose to
* work around the fact that it does not use candidates gathering.
* It is to be called automatically when the gathering process finishes.
*/
void ice_session_compute_candidates_foundations(IceSession *session);
void ice_choose_default_candidates(IceCheckList *cl);
/**
* Choose the default candidates of an ICE session.
*
* @param session A pointer to a session
*
* This function is to be called once the remote candidate list has been received from the peer via SDP
* and each candidate as been added to the check lists using ice_add_remote_candidate(), but before calling
* ice_session_pair_candidates().
*
* TODO: Maybe incorporate this one directly in ice_session_pair_candidates().
*/
MS2_PUBLIC void ice_session_choose_default_candidates(IceSession *session);
void ice_pair_candidates(IceCheckList *cl, bool_t first_media_stream);
/**
* Pair the local and the remote candidates for an ICE session.
*
* @param session A pointer to a session
*/
MS2_PUBLIC void ice_session_pair_candidates(IceSession *session);
void ice_check_list_process(IceCheckList *cl, RtpSession *rtp_session);
/**
* This function SHOULD not be used. However, it is used by mediastream for testing purpose to
* work around the fact that it does not use candidates gathering.
*/
void ice_set_base_for_srflx_candidates(IceCheckList *cl);
void ice_handle_stun_packet(IceCheckList *cl, RtpSession *session, mblk_t *m);
/**
* Dump an ICE session in the traces (debug function).
......
......@@ -425,7 +425,7 @@ IceCandidate * ice_add_remote_candidate(IceCheckList *cl, const char *type, cons
* GATHER CANDIDATES *
*****************************************************************************/
void ice_gather_candidates(IceCheckList *cl)
void ice_session_gather_candidates(IceSession *session)
{
//TODO
}
......@@ -462,11 +462,16 @@ static void ice_compute_candidate_foundation(IceCandidate *candidate, IceCheckLi
cl->foundation_generator++;
}
void ice_compute_candidates_foundations(IceCheckList *cl)
static void ice_check_list_compute_candidates_foundations(IceCheckList *cl)
{
ms_list_for_each2(cl->local_candidates, (void (*)(void*,void*))ice_compute_candidate_foundation, cl);
}
void ice_session_compute_candidates_foundations(IceSession *session)
{
ms_list_for_each(session->streams, (void (*)(void*))ice_check_list_compute_candidates_foundations);
}
/******************************************************************************
* CHOOSE DEFAULT CANDIDATES *
......@@ -503,12 +508,17 @@ static void ice_choose_local_or_remote_default_candidates(IceCheckList *cl, MSLi
}
}
void ice_choose_default_candidates(IceCheckList *cl)
static void ice_check_list_choose_default_candidates(IceCheckList *cl)
{
ice_choose_local_or_remote_default_candidates(cl, cl->local_candidates);
ice_choose_local_or_remote_default_candidates(cl, cl->remote_candidates);
}
void ice_session_choose_default_candidates(IceSession *session)
{
ms_list_for_each(session->streams, (void (*)(void*))ice_check_list_choose_default_candidates);
}
/******************************************************************************
* FORM CANDIDATES PAIRS *
......@@ -697,8 +707,12 @@ static void ice_compute_pairs_states(IceCheckList *cl)
}
}
void ice_pair_candidates(IceCheckList *cl, bool_t first_media_stream)
static void ice_check_list_pair_candidates(IceCheckList *cl, IceSession *session)
{
bool_t first_media_stream = FALSE;
if (ms_list_nth_data(session->streams, 0) == cl) first_media_stream = TRUE;
ice_form_candidate_pairs(cl);
ice_prune_candidate_pairs(cl);
......@@ -710,6 +724,11 @@ void ice_pair_candidates(IceCheckList *cl, bool_t first_media_stream)
}
}
void ice_session_pair_candidates(IceSession *session)
{
ms_list_for_each2(session->streams, (void (*)(void*,void*))ice_check_list_pair_candidates, session);
}
/******************************************************************************
* GLOBAL PROCESS *
......@@ -775,7 +794,7 @@ static void ice_set_base_for_srflx_candidate(IceCandidate *candidate, IceCandida
candidate->base = base;
}
void ice_set_base_for_srflx_candidates(IceCheckList *cl)
static void ice_check_list_set_base_for_srflx_candidates(IceCheckList *cl)
{
MSList *base_elem;
IceCandidate *base;
......@@ -789,6 +808,11 @@ void ice_set_base_for_srflx_candidates(IceCheckList *cl)
}
}
void ice_session_set_base_for_srflx_candidates(IceSession *session)
{
ms_list_for_each(session->streams, (void (*)(void*))ice_check_list_set_base_for_srflx_candidates);
}
/******************************************************************************
* DEBUG FUNCTIONS *
......
......@@ -612,8 +612,6 @@ void setup_media_streams(MediastreamDatas* args) {
ice_add_local_candidate(args->audio->ice_check_list,candidate->type,candidate->ip,candidate->port,1,NULL);
ice_add_local_candidate(args->audio->ice_check_list,candidate->type,candidate->ip,candidate->port+1,2,NULL);
}
ice_set_base_for_srflx_candidates(args->audio->ice_check_list);
ice_compute_candidates_foundations(args->audio->ice_check_list);
}
if (args->ice_remote_candidates_nb) {
char foundation[4];
......@@ -628,10 +626,6 @@ void setup_media_streams(MediastreamDatas* args) {
}
}
ice_session_add_check_list(args->ice_session, args->audio->ice_check_list);
ice_choose_default_candidates(args->audio->ice_check_list);
ice_pair_candidates(args->audio->ice_check_list, TRUE);
ice_dump_candidates(args->audio->ice_check_list);
ice_dump_candidate_pairs(args->audio->ice_check_list);
if (args->audio) {
if (args->el) {
......@@ -726,6 +720,11 @@ void setup_media_streams(MediastreamDatas* args) {
printf("Error: video support not compiled.\n");
#endif
}
ice_session_set_base_for_srflx_candidates(args->ice_session);
ice_session_compute_candidates_foundations(args->ice_session);
ice_session_choose_default_candidates(args->ice_session);
ice_session_pair_candidates(args->ice_session);
OrtpNetworkSimulatorParams params={0};
if (args->netsim_bw>0){
params.enabled=TRUE;
......
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