fix crash with ICE and compilation error

This commit is contained in:
Simon Morlat 2014-04-18 11:02:09 +02:00
parent 471314ee1a
commit d6fef910bb
2 changed files with 32 additions and 16 deletions

View file

@ -109,10 +109,10 @@ static bool_t linphone_call_are_all_streams_encrypted(LinphoneCall *call) {
number_of_encrypted_stream++;
}
}
return number_of_active_stream>0 & number_of_active_stream==number_of_encrypted_stream;
return number_of_active_stream>0 && number_of_active_stream==number_of_encrypted_stream;
}
void propagate_encryption_changed(LinphoneCall *call){
static void propagate_encryption_changed(LinphoneCall *call){
LinphoneCore *lc=call->core;
if (!linphone_call_are_all_streams_encrypted(call)) {
ms_message("Some streams are not encrypted");
@ -1462,8 +1462,8 @@ int linphone_call_prepare_ice(LinphoneCall *call, bool_t incoming_offer){
if (has_video) _linphone_call_prepare_ice_for_stream(call,1,TRUE);
/*start ICE gathering*/
if (incoming_offer)
linphone_core_update_ice_from_remote_media_description(call,remote);
if (!ice_session_candidates_gathered(call->ice_session)){
linphone_core_update_ice_from_remote_media_description(call,remote); /*this may delete the ice session*/
if (call->ice_session && !ice_session_candidates_gathered(call->ice_session)){
if (call->audiostream->ms.state==MSStreamInitialized)
audio_stream_prepare_sound(call->audiostream, NULL, NULL);
#ifdef VIDEO_ENABLED

View file

@ -553,14 +553,18 @@ static bool_t check_ice(LinphoneCoreManager* caller, LinphoneCoreManager* callee
return success;
}
static void _call_with_ice(bool_t random_ports) {
static void _call_with_ice(bool_t caller_with_ice, bool_t callee_with_ice, bool_t random_ports) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce);
linphone_core_set_stun_server(marie->lc,"stun.linphone.org");
linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce);
linphone_core_set_stun_server(pauline->lc,"stun.linphone.org");
if (callee_with_ice){
linphone_core_set_firewall_policy(marie->lc,LinphonePolicyUseIce);
linphone_core_set_stun_server(marie->lc,"stun.linphone.org");
}
if (caller_with_ice){
linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce);
linphone_core_set_stun_server(pauline->lc,"stun.linphone.org");
}
if (random_ports){
linphone_core_set_audio_port(marie->lc,-1);
@ -571,12 +575,14 @@ static void _call_with_ice(bool_t random_ports) {
CU_ASSERT_TRUE(call(pauline,marie));
CU_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
/*wait for the ICE reINVITE to complete*/
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
if (callee_with_ice && caller_with_ice) {
check_ice(pauline,marie,LinphoneIceStateHostConnection);
/*wait for the ICE reINVITE to complete*/
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
CU_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
CU_ASSERT_TRUE(check_ice(pauline,marie,LinphoneIceStateHostConnection));
}
liblinphone_tester_check_rtcp(marie,pauline);
/*then close the call*/
@ -589,11 +595,19 @@ static void _call_with_ice(bool_t random_ports) {
}
static void call_with_ice(void){
_call_with_ice(FALSE);
_call_with_ice(TRUE,TRUE,FALSE);
}
static void call_with_ice_random_ports(void){
_call_with_ice(TRUE);
_call_with_ice(TRUE,TRUE,TRUE);
}
static void ice_to_not_ice(void){
_call_with_ice(TRUE,FALSE,FALSE);
}
static void not_ice_to_ice(void){
_call_with_ice(FALSE,TRUE,FALSE);
}
static void call_with_custom_headers(void) {
@ -2000,6 +2014,8 @@ test_t call_tests[] = {
{ "Call transfer existing call outgoing call", call_transfer_existing_call_outgoing_call },
{ "Call with ICE", call_with_ice },
{ "Call with ICE (random ports)", call_with_ice_random_ports },
{ "Call from ICE to not ICE",ice_to_not_ice},
{ "Call from not ICE to ICE",not_ice_to_ice},
{ "Call with custom headers",call_with_custom_headers},
{ "Call established with rejected INFO",call_established_with_rejected_info},
{ "Call established with rejected RE-INVITE",call_established_with_rejected_reinvite},