Commit 4e511fe4 authored by Ghislain MARY's avatar Ghislain MARY
Browse files

Merge branch 'dev_ice'

parents 42e4255c 98cfcb39
......@@ -850,6 +850,16 @@ lpc_cmd_firewall(LinphoneCore *lc, char *args)
{
linphone_core_set_firewall_policy(lc,LinphonePolicyNoFirewall);
}
else if (strcmp(args,"ice")==0)
{
setting = linphone_core_get_stun_server(lc);
if ( ! setting )
{
linphonec_out("No stun server address is defined, use 'stun <address>' first\n");
return 1;
}
linphone_core_set_firewall_policy(lc,LinphonePolicyUseIce);
}
else if (strcmp(args,"stun")==0)
{
setting = linphone_core_get_stun_server(lc);
......@@ -883,6 +893,9 @@ lpc_cmd_firewall(LinphoneCore *lc, char *args)
case LinphonePolicyUseNatAddress:
linphonec_out("Using supplied nat address %s.\n", setting ? setting : linphone_core_get_nat_address(lc));
break;
case LinphonePolicyUseIce:
linphonec_out("Using ice with stun server %s to discover firewall address\n", setting ? setting : linphone_core_get_stun_server(lc));
break;
}
return 1;
}
......
......@@ -97,7 +97,7 @@ void call_accept(Call *call)
osip_message_set_content_type(msg,"application/sdp");
osip_message_set_body(msg,call->sdpc->answerstr,strlen(call->sdpc->answerstr));
eXosip_call_send_answer(call->tid,200,msg);
call->audio_stream=audio_stream_new(call->audio.localport,call->root->ipv6);
call->audio_stream=audio_stream_new(call->audio.localport,call->audio.localport+1,call->root->ipv6);
audio_stream_start_with_files(call->audio_stream, call->profile,
call->audio.remaddr,call->audio.remoteport,call->audio.remoteport+1,
call->audio.pt,20,hellofile,record_file);
......
......@@ -140,16 +140,10 @@ static bool_t already_a_call_pending(LinphoneCore *lc){
static void call_received(SalOp *h){
LinphoneCore *lc=(LinphoneCore *)sal_get_user_pointer(sal_op_get_sal(h));
char *barmesg;
LinphoneCall *call;
const char *from,*to;
char *tmp;
LinphoneAddress *from_parsed;
LinphoneAddress *from_addr, *to_addr;
SalMediaDescription *md;
bool_t propose_early_media=lp_config_get_int(lc->config,"sip","incoming_calls_early_media",FALSE);
bool_t prevent_colliding_calls=lp_config_get_int(lc->config,"sip","prevent_colliding_calls",TRUE);
const char *ringback_tone=linphone_core_get_remote_ringback_tone (lc);
/* first check if we can answer successfully to this invite */
if (lc->presence_mode==LinphoneStatusBusy ||
......@@ -188,72 +182,18 @@ static void call_received(SalOp *h){
call=linphone_call_new_incoming(lc,from_addr,to_addr,h);
sal_call_set_local_media_description(h,call->localdesc);
md=sal_call_get_final_media_description(h);
if (md && sal_media_description_empty(md)){
sal_call_decline(h,SalReasonMedia,NULL);
linphone_call_unref(call);
return;
}
/* the call is acceptable so we can now add it to our list */
linphone_core_add_call(lc,call);
from_parsed=linphone_address_new(sal_op_get_from(h));
linphone_address_clean(from_parsed);
tmp=linphone_address_as_string(from_parsed);
linphone_address_destroy(from_parsed);
barmesg=ortp_strdup_printf("%s %s%s",tmp,_("is contacting you"),
(sal_call_autoanswer_asked(h)) ?_(" and asked autoanswer."):_("."));
if (lc->vtable.show) lc->vtable.show(lc);
if (lc->vtable.display_status)
lc->vtable.display_status(lc,barmesg);
/* play the ring if this is the only call*/
if (ms_list_size(lc->calls)==1){
lc->current_call=call;
if (lc->ringstream && lc->dmfs_playing_start_time!=0){
ring_stop(lc->ringstream);
lc->ringstream=NULL;
lc->dmfs_playing_start_time=0;
}
if (lc->sound_conf.ring_sndcard!=NULL){
if(lc->ringstream==NULL && lc->sound_conf.local_ring){
MSSndCard *ringcard=lc->sound_conf.lsd_card ?lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard;
ms_message("Starting local ring...");
lc->ringstream=ring_start(lc->sound_conf.local_ring,2000,ringcard);
}
else
{
ms_message("the local ring is already started");
}
}
}else{
/* else play a tone within the context of the current call */
call->ringing_beep=TRUE;
linphone_core_play_tone(lc);
}
linphone_call_ref(call); /*prevent the call from being destroyed while we are notifying, if the user declines within the state callback */
linphone_call_set_state(call,LinphoneCallIncomingReceived,"Incoming call");
if (call->state==LinphoneCallIncomingReceived){
sal_call_notify_ringing(h,propose_early_media || ringback_tone!=NULL);
if (propose_early_media || ringback_tone!=NULL){
linphone_call_set_state(call,LinphoneCallIncomingEarlyMedia,"Incoming call early media");
md=sal_call_get_final_media_description(h);
linphone_core_update_streams(lc,call,md);
}
if (sal_call_get_replaces(call->op)!=NULL && lp_config_get_int(lc->config,"sip","auto_answer_replacing_calls",1)){
linphone_core_accept_call(lc,call);
}
if ((linphone_core_get_firewall_policy(lc) == LinphonePolicyUseIce) && (call->ice_session != NULL)) {
/* Defer ringing until the end of the ICE candidates gathering process. */
ms_message("Defer ringing to gather ICE candidates");
return;
}
linphone_call_unref(call);
ms_free(barmesg);
ms_free(tmp);
linphone_core_notify_incoming_call(lc,call);
}
static void call_ringing(SalOp *h){
......@@ -320,7 +260,12 @@ static void call_accepted(SalOp *op){
ms_warning("No call to accept.");
return ;
}
/* Handle remote ICE attributes if any. */
if (call->ice_session != NULL) {
linphone_core_update_ice_from_remote_media_description(call, sal_call_get_remote_media_description(op));
}
md=sal_call_get_final_media_description(op);
if (call->state==LinphoneCallOutgoingProgress ||
......@@ -414,6 +359,11 @@ static void call_ack(SalOp *op){
static void call_accept_update(LinphoneCore *lc, LinphoneCall *call){
SalMediaDescription *md;
SalMediaDescription *rmd=sal_call_get_remote_media_description(call->op);
if ((rmd!=NULL) && (call->ice_session!=NULL)) {
linphone_core_update_ice_from_remote_media_description(call,rmd);
linphone_core_update_local_media_description_from_ice(call->localdesc,call->ice_session);
}
sal_call_accept(call->op);
md=sal_call_get_final_media_description(call->op);
if (md && !sal_media_description_empty(md))
......@@ -810,7 +760,8 @@ static void ping_reply(SalOp *op){
ms_message("ping reply !");
if (call){
if (call->state==LinphoneCallOutgoingInit){
linphone_core_start_invite(call->core,call,NULL);
call->ping_replied=TRUE;
linphone_core_proceed_with_invite_if_ready(call->core,call,NULL);
}
}
else
......
......@@ -104,7 +104,7 @@ static RtpProfile *make_dummy_profile(int samplerate){
static void add_local_endpoint(LinphoneConference *conf,LinphoneCore *lc){
/*create a dummy audiostream in order to extract the local part of it */
/* network address and ports have no meaning and are not used here. */
AudioStream *st=audio_stream_new(65000,FALSE);
AudioStream *st=audio_stream_new(65000,65001,FALSE);
MSSndCard *playcard=lc->sound_conf.lsd_card ?
lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
MSSndCard *captcard=lc->sound_conf.capt_sndcard;
......@@ -114,6 +114,7 @@ static void add_local_endpoint(LinphoneConference *conf,LinphoneCore *lc){
audio_stream_start_full(st, conf->local_dummy_profile,
"127.0.0.1",
65000,
"127.0.0.1",
65001,
0,
40,
......
This diff is collapsed.
......@@ -1855,6 +1855,11 @@ void linphone_core_iterate(LinphoneCore *lc){
linphone_call_background_tasks(call,one_second_elapsed);
if (call->state==LinphoneCallOutgoingInit && (curtime-call->start_time>=2)){
/*start the call even if the OPTIONS reply did not arrive*/
if (call->ice_session != NULL) {
/* ICE candidates gathering has not finished yet, proceed with the call without ICE anyway. */
linphone_call_delete_ice_session(call);
linphone_call_stop_media_streams(call);
}
linphone_core_start_invite(lc,call,NULL);
}
if (call->state==LinphoneCallIncomingReceived){
......@@ -2103,6 +2108,27 @@ static char *get_fixed_contact(LinphoneCore *lc, LinphoneCall *call , LinphonePr
return NULL;
}
int linphone_core_proceed_with_invite_if_ready(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy){
bool_t ice_ready = FALSE;
bool_t ping_ready = FALSE;
if (call->ice_session != NULL) {
if (ice_session_candidates_gathered(call->ice_session)) ice_ready = TRUE;
} else {
ice_ready = TRUE;
}
if (call->ping_op != NULL) {
if (call->ping_replied == TRUE) ping_ready = TRUE;
} else {
ping_ready = TRUE;
}
if ((ice_ready == TRUE) && (ping_ready == TRUE)) {
return linphone_core_start_invite(lc, call, dest_proxy);
}
return 0;
}
int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphoneProxyConfig *dest_proxy){
int err;
char *contact;
......@@ -2121,6 +2147,8 @@ int linphone_core_start_invite(LinphoneCore *lc, LinphoneCall *call, LinphonePro
audio_stream_prepare_sound(call->audiostream,lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard);
if (!lc->sip_conf.sdp_200_ack){
call->media_pending=TRUE;
if (call->ice_session != NULL)
linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
sal_call_set_local_media_description(call->op,call->localdesc);
}
real_url=linphone_address_as_string(call->log->to);
......@@ -2243,6 +2271,7 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
char *real_url=NULL;
LinphoneProxyConfig *dest_proxy=NULL;
LinphoneCall *call;
bool_t use_ice = FALSE;
linphone_core_preempt_sound_resources(lc);
......@@ -2284,14 +2313,29 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
/* this call becomes now the current one*/
lc->current_call=call;
linphone_call_set_state (call,LinphoneCallOutgoingInit,"Starting outgoing call");
if (dest_proxy!=NULL || lc->sip_conf.ping_with_options==FALSE){
linphone_core_start_invite(lc,call,dest_proxy);
}else{
if (linphone_core_get_firewall_policy(call->core) == LinphonePolicyUseIce) {
/* Defer the start of the call after the ICE gathering process. */
linphone_call_init_media_streams(call);
linphone_call_start_media_streams_for_ice_gathering(call);
call->start_time=time(NULL);
if (linphone_core_gather_ice_candidates(lc,call)<0) {
/* Ice candidates gathering failed, proceed with the call anyway. */
linphone_call_delete_ice_session(call);
linphone_call_stop_media_streams(call);
} else {
use_ice = TRUE;
}
}
if (dest_proxy==NULL && lc->sip_conf.ping_with_options==TRUE){
/*defer the start of the call after the OPTIONS ping*/
call->ping_replied=FALSE;
call->ping_op=sal_op_new(lc->sal);
sal_ping(call->ping_op,from,real_url);
sal_op_set_user_pointer(call->ping_op,call);
call->start_time=time(NULL);
}else{
if (use_ice==FALSE) linphone_core_start_invite(lc,call,dest_proxy);
}
if (real_url!=NULL) ms_free(real_url);
......@@ -2355,6 +2399,96 @@ bool_t linphone_core_inc_invite_pending(LinphoneCore*lc){
return FALSE;
}
void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *call){
char *barmesg;
char *tmp;
LinphoneAddress *from_parsed;
SalMediaDescription *md;
bool_t propose_early_media=lp_config_get_int(lc->config,"sip","incoming_calls_early_media",FALSE);
const char *ringback_tone=linphone_core_get_remote_ringback_tone (lc);
if (call->ice_session != NULL)
linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
md=sal_call_get_final_media_description(call->op);
if (md && sal_media_description_empty(md)){
sal_call_decline(call->op,SalReasonMedia,NULL);
linphone_call_unref(call);
return;
}
from_parsed=linphone_address_new(sal_op_get_from(call->op));
linphone_address_clean(from_parsed);
tmp=linphone_address_as_string(from_parsed);
linphone_address_destroy(from_parsed);
barmesg=ortp_strdup_printf("%s %s%s",tmp,_("is contacting you"),
(sal_call_autoanswer_asked(call->op)) ?_(" and asked autoanswer."):_("."));
if (lc->vtable.show) lc->vtable.show(lc);
if (lc->vtable.display_status)
lc->vtable.display_status(lc,barmesg);
/* play the ring if this is the only call*/
if (ms_list_size(lc->calls)==1){
lc->current_call=call;
if (lc->ringstream && lc->dmfs_playing_start_time!=0){
ring_stop(lc->ringstream);
lc->ringstream=NULL;
lc->dmfs_playing_start_time=0;
}
if (lc->sound_conf.ring_sndcard!=NULL){
if(lc->ringstream==NULL && lc->sound_conf.local_ring){
MSSndCard *ringcard=lc->sound_conf.lsd_card ?lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard;
ms_message("Starting local ring...");
lc->ringstream=ring_start(lc->sound_conf.local_ring,2000,ringcard);
}
else
{
ms_message("the local ring is already started");
}
}
}else{
/* else play a tone within the context of the current call */
call->ringing_beep=TRUE;
linphone_core_play_tone(lc);
}
linphone_call_set_state(call,LinphoneCallIncomingReceived,"Incoming call");
if (call->state==LinphoneCallIncomingReceived){
sal_call_notify_ringing(call->op,propose_early_media || ringback_tone!=NULL);
if (propose_early_media || ringback_tone!=NULL){
linphone_call_set_state(call,LinphoneCallIncomingEarlyMedia,"Incoming call early media");
md=sal_call_get_final_media_description(call->op);
linphone_core_update_streams(lc,call,md);
}
if (sal_call_get_replaces(call->op)!=NULL && lp_config_get_int(lc->config,"sip","auto_answer_replacing_calls",1)){
linphone_core_accept_call(lc,call);
}
}
linphone_call_unref(call);
ms_free(barmesg);
ms_free(tmp);
}
int linphone_core_start_update_call(LinphoneCore *lc, LinphoneCall *call){
const char *subject;
call->camera_active=call->params.has_video;
update_local_media_description(lc,call);
if (call->ice_session != NULL)
linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
if (call->params.in_conference){
subject="Conference";
}else{
subject="Media change";
}
if (lc->vtable.display_status)
lc->vtable.display_status(lc,_("Modifying call parameters..."));
sal_call_set_local_media_description (call->op,call->localdesc);
return sal_call_update(call->op,subject);
}
/**
* @ingroup call_control
* Updates a running call according to supplied call parameters or parameters changed in the LinphoneCore.
......@@ -2372,20 +2506,27 @@ bool_t linphone_core_inc_invite_pending(LinphoneCore*lc){
int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params){
int err=0;
if (params!=NULL){
const char *subject;
call->params=*params;
call->camera_active=call->params.has_video;
update_local_media_description(lc,call);
if (params->in_conference){
subject="Conference";
}else{
subject="Media change";
#ifdef VIDEO_ENABLED
if ((call->ice_session != NULL) && (call->videostream != NULL) && !params->has_video) {
ice_session_remove_check_list(call->ice_session, call->videostream->ice_check_list);
call->videostream->ice_check_list = NULL;
}
if ((call->ice_session != NULL) && ((ice_session_state(call->ice_session) != IS_Completed) || (call->params.has_video != params->has_video))) {
/* Defer call update until the ICE candidates gathering process has finished. */
ms_message("Defer call update to gather ICE candidates");
call->params = *params;
update_local_media_description(lc, call);
if (call->params.has_video) {
linphone_call_init_video_stream(call);
video_stream_prepare_video(call->videostream);
if (linphone_core_gather_ice_candidates(lc,call)<0) {
/* Ice candidates gathering failed, proceed with the call anyway. */
linphone_call_delete_ice_session(call);
} else return err;
}
}
if (lc->vtable.display_status)
lc->vtable.display_status(lc,_("Modifying call parameters..."));
sal_call_set_local_media_description (call->op,call->localdesc);
err=sal_call_update(call->op,subject);
#endif
err = linphone_core_start_update_call(lc, call);
}else{
#ifdef VIDEO_ENABLED
if (call->videostream!=NULL){
......@@ -2423,6 +2564,24 @@ int linphone_core_defer_call_update(LinphoneCore *lc, LinphoneCall *call){
return -1;
}
int linphone_core_start_accept_call_update(LinphoneCore *lc, LinphoneCall *call){
SalMediaDescription *md;
if (call->ice_session != NULL) {
if (ice_session_nb_losing_pairs(call->ice_session) > 0) {
/* Defer the sending of the answer until there are no losing pairs left. */
return 0;
}
linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
}
sal_call_set_local_media_description(call->op,call->localdesc);
sal_call_accept(call->op);
md=sal_call_get_final_media_description(call->op);
if (md && !sal_media_description_empty(md))
linphone_core_update_streams (lc,call,md);
linphone_call_set_state(call,LinphoneCallStreamsRunning,"Connected (streams running)");
return 0;
}
/**
* @ingroup call_control
* Accept call modifications initiated by other end.
......@@ -2443,14 +2602,14 @@ int linphone_core_defer_call_update(LinphoneCore *lc, LinphoneCall *call){
* @return 0 if sucessful, -1 otherwise (actually when this function call is performed outside ot #LinphoneCallUpdatedByRemote state).
**/
int linphone_core_accept_call_update(LinphoneCore *lc, LinphoneCall *call, const LinphoneCallParams *params){
SalMediaDescription *md;
bool_t old_has_video = call->params.has_video;
if (call->state!=LinphoneCallUpdatedByRemote){
ms_error("linphone_core_accept_update(): invalid state %s to call this function.",
linphone_call_state_to_string(call->state));
return -1;
}
if (params==NULL){
call->params.has_video=lc->video_policy.automatically_accept;
call->params.has_video=lc->video_policy.automatically_accept || call->current_params.has_video;
}else
call->params=*params;
......@@ -2460,12 +2619,22 @@ int linphone_core_accept_call_update(LinphoneCore *lc, LinphoneCall *call, const
}
call->camera_active=call->params.has_video;
update_local_media_description(lc,call);
sal_call_set_local_media_description(call->op,call->localdesc);
sal_call_accept(call->op);
md=sal_call_get_final_media_description(call->op);
if (md && !sal_media_description_empty(md))
linphone_core_update_streams (lc,call,md);
linphone_call_set_state(call,LinphoneCallStreamsRunning,"Connected (streams running)");
if (call->ice_session != NULL) {
linphone_core_update_ice_from_remote_media_description(call, sal_call_get_remote_media_description(call->op));
#ifdef VIDEO_ENABLED
if ((call->ice_session != NULL) &&!ice_session_candidates_gathered(call->ice_session)) {
if ((call->params.has_video) && (call->params.has_video != old_has_video)) {
linphone_call_init_video_stream(call);
video_stream_prepare_video(call->videostream);
if (linphone_core_gather_ice_candidates(lc,call)<0) {
/* Ice candidates gathering failed, proceed with the call anyway. */
linphone_call_delete_ice_session(call);
} else return 0;
}
}
#endif
}
linphone_core_start_accept_call_update(lc, call);
return 0;
}
......@@ -2728,6 +2897,8 @@ int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call)
return -1;
}
update_local_media_description(lc,call);
if (call->ice_session != NULL)
linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
if (sal_media_description_has_dir(call->resultdesc,SalStreamSendRecv)){
sal_media_description_set_dir(call->localdesc,SalStreamSendOnly);
subject="Call on hold";
......@@ -2805,6 +2976,8 @@ int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *the_call)
if (call->audiostream) audio_stream_play(call->audiostream, NULL);
update_local_media_description(lc,the_call);
if (call->ice_session != NULL)
linphone_core_update_local_media_description_from_ice(call->localdesc, call->ice_session);
sal_call_set_local_media_description(call->op,call->localdesc);
sal_media_description_set_dir(call->localdesc,SalStreamSendRecv);
if (call->params.in_conference && !call->current_params.in_conference) subject="Conference";
......
......@@ -742,7 +742,8 @@ typedef struct _LCCallbackObj
typedef enum _LinphoneFirewallPolicy{
LinphonePolicyNoFirewall,
LinphonePolicyUseNatAddress,
LinphonePolicyUseStun
LinphonePolicyUseStun,
LinphonePolicyUseIce
} LinphoneFirewallPolicy;
typedef enum _LinphoneWaitingState{
......
......@@ -563,6 +563,249 @@ void linphone_core_run_stun_tests(LinphoneCore *lc, LinphoneCall *call){
}
}
int linphone_core_gather_ice_candidates(LinphoneCore *lc, LinphoneCall *call)
{
char local_addr[64];
struct sockaddr_storage ss;
socklen_t ss_len;
IceCheckList *audio_check_list;
IceCheckList *video_check_list;
const char *server = linphone_core_get_stun_server(lc);
if ((server == NULL) || (call->ice_session == NULL)) return -1;
audio_check_list = ice_session_check_list(call->ice_session, 0);
video_check_list = ice_session_check_list(call->ice_session, 1);
if (audio_check_list == NULL) return -1;
if (lc->sip_conf.ipv6_enabled){
ms_warning("stun support is not implemented for ipv6");
return -1;
}
if (parse_hostname_to_addr(server, &ss, &ss_len) < 0) {
ms_error("Fail to parser stun server address: %s", server);
return -1;
}
if (lc->vtable.display_status != NULL)
lc->vtable.display_status(lc, _("ICE local candidates gathering in progress..."));
/* Gather local host candidates. */
if (linphone_core_get_local_ip_for(AF_INET, NULL, local_addr) < 0) {
ms_error("Fail to get local ip");
return -1;
}
ice_add_local_candidate(audio_check_list, "host", local_addr, call->audio_port, 1, NULL);
ice_add_local_candidate(audio_check_list, "host", local_addr, call->audio_port + 1, 2, NULL);
if (call->params.has_video && (video_check_list != NULL)) {
ice_add_local_candidate(video_check_list, "host", local_addr, call->video_port, 1, NULL);
ice_add_local_candidate(video_check_list, "host", local_addr, call->video_port + 1, 2, NULL);
}
/* Gather local srflx candidates. */
ice_session_gather_candidates(call->ice_session, ss, ss_len);
return 0;
}
void linphone_core_update_local_media_description_from_ice(SalMediaDescription *desc, IceSession *session)
{
const char *rtp_addr, *rtcp_addr;
IceSessionState session_state = ice_session_state(session);
int nb_candidates;
int i, j;
if (session_state == IS_Completed) {
desc->ice_completed = TRUE;
ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, 0), &rtp_addr, NULL, NULL, NULL);
strncpy(desc->addr, rtp_addr, sizeof(desc->addr));
}
else {
desc->ice_completed = FALSE;
}
strncpy(desc->ice_pwd, ice_session_local_pwd(session), sizeof(desc->ice_pwd));
strncpy(desc->ice_ufrag, ice_session_local_ufrag(session), sizeof(desc->ice_ufrag));
for (i = 0; i < desc->nstreams; i++) {
SalStreamDescription *stream = &desc->streams[i];
IceCheckList *cl = ice_session_check_list(session, i);
nb_candidates = 0;
if (cl == NULL) continue;
if (cl->state == ICL_Completed) {
stream->ice_completed = TRUE;
ice_check_list_selected_valid_local_candidate(ice_session_check_list(session, i), &rtp_addr, &stream->rtp_port, &rtcp_addr, &stream->rtcp_port);
strncpy(stream->rtp_addr, rtp_addr, sizeof(stream->rtp_addr));
strncpy(stream->rtcp_addr, rtcp_addr, sizeof(stream->rtcp_addr));
} else {
stream->ice_completed = FALSE;
}
if ((strlen(ice_check_list_local_pwd(cl)) != strlen(desc->ice_pwd)) || (strcmp(ice_check_list_local_pwd(cl), desc->ice_pwd)))
strncpy(stream->ice_pwd, ice_check_list_local_pwd(cl), sizeof(stream->ice_pwd));
else
memset(stream->ice_pwd, 0, sizeof(stream->ice_pwd));
if ((strlen(ice_check_list_local_ufrag(cl)) != strlen(desc->ice_ufrag)) || (strcmp(ice_check_list_local_ufrag(cl), desc->ice_ufrag)))
strncpy(stream->ice_ufrag, ice_check_list_local_ufrag(cl), sizeof(stream->ice_ufrag));
else
memset(stream->ice_pwd, 0, sizeof(stream->ice_pwd));
stream->ice_mismatch = ice_check_list_is_mismatch(cl);
if ((cl->state == ICL_Running) || (cl->state == ICL_Completed)) {
memset(stream->ice_candidates, 0, sizeof(stream->ice_candidates));