From 32eb45dfc6296fb61fe6c1d9df73167432cd68f2 Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Thu, 24 Sep 2015 11:14:31 +0200 Subject: [PATCH] fix bad handling of remote params, resulting in wrong information given in them in case of received INVITE without SDP --- coreapi/call_params.c | 10 ++++++++++ coreapi/callbacks.c | 26 +++++++++++++++----------- coreapi/linphonecall.c | 13 +++++++------ coreapi/private.h | 1 + tester/call_tester.c | 33 ++++++++------------------------- 5 files changed, 41 insertions(+), 42 deletions(-) diff --git a/coreapi/call_params.c b/coreapi/call_params.c index 1f22ad4fd..8ff2f2e56 100644 --- a/coreapi/call_params.c +++ b/coreapi/call_params.c @@ -72,6 +72,16 @@ SalStreamDir get_video_dir_from_call_params(const LinphoneCallParams *params) { return sal_dir_from_call_params_dir(linphone_call_params_get_video_direction(params)); } +void linphone_call_params_set_custom_headers(LinphoneCallParams *params, const SalCustomHeader *ch){ + if (params->custom_headers){ + sal_custom_header_free(params->custom_headers); + params->custom_headers = NULL; + } + if (ch){ + params->custom_headers = sal_custom_header_clone(ch); + } +} + /******************************************************************************* * Public functions * diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index c3abebc53..d0255bb0a 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -627,6 +627,19 @@ static void call_paused_by_remote(LinphoneCore *lc, LinphoneCall *call){ linphone_call_params_unref(params); } +static void call_updated_by_remote(LinphoneCore *lc, LinphoneCall *call){ + linphone_core_notify_display_status(lc,_("Call is updated by remote.")); + linphone_call_set_state(call, LinphoneCallUpdatedByRemote,"Call updated by remote"); + if (call->defer_update == FALSE){ + linphone_core_accept_call_update(lc,call,NULL); + }else{ + if (call->state == LinphoneCallUpdatedByRemote){ + ms_message("LinphoneCall [%p]: UpdatedByRemoted was signaled but defered. LinphoneCore expects the application to call " + "linphone_core_accept_call_update() later.", call); + } + } +} + /* this callback is called when an incoming re-INVITE/ SIP UPDATE modifies the session*/ static void call_updated(LinphoneCore *lc, LinphoneCall *call, SalOp *op, bool_t is_update){ SalMediaDescription *rmd=sal_call_get_remote_media_description(op); @@ -638,12 +651,7 @@ static void call_updated(LinphoneCore *lc, LinphoneCall *call, SalOp *op, bool_t if (sal_media_description_has_dir(rmd,SalStreamSendRecv) || sal_media_description_has_dir(rmd,SalStreamRecvOnly)){ call_resumed(lc,call); }else{ - /*we are staying in PausedByRemote*/ - linphone_core_notify_display_status(lc,_("Call is updated by remote.")); - linphone_call_set_state(call, LinphoneCallUpdatedByRemote,"Call updated by remote"); - if (call->defer_update == FALSE){ - linphone_core_accept_call_update(lc,call,NULL); - } + call_updated_by_remote(lc, call); } break; /*SIP UPDATE CASE*/ @@ -660,11 +668,7 @@ static void call_updated(LinphoneCore *lc, LinphoneCall *call, SalOp *op, bool_t if (sal_media_description_has_dir(rmd,SalStreamSendOnly) || sal_media_description_has_dir(rmd,SalStreamInactive)){ call_paused_by_remote(lc,call); }else{ - linphone_core_notify_display_status(lc,_("Call is updated by remote.")); - linphone_call_set_state(call, LinphoneCallUpdatedByRemote,"Call updated by remote"); - if (call->defer_update == FALSE){ - linphone_core_accept_call_update(lc,call,NULL); - } + call_updated_by_remote(lc, call); } break; case LinphoneCallPaused: diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index d34fdef0a..22ff4e183 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1394,7 +1394,7 @@ void linphone_call_fix_call_parameters(LinphoneCall *call){ ms_message("Call [%p]: disabling video in our call params because the remote doesn't want it.", call); call->params->has_video = FALSE; } - if (rcp->has_video && call->core->video_policy.automatically_accept && !call->params->has_video){ + if (rcp->has_video && call->core->video_policy.automatically_accept && linphone_core_video_enabled(call->core) && !call->params->has_video){ ms_message("Call [%p]: re-enabling video in our call params because the remote wants it and the policy allows to automatically accept.", call); call->params->has_video = TRUE; } @@ -1727,8 +1727,7 @@ const LinphoneCallParams * linphone_call_get_remote_params(LinphoneCall *call){ if (call->op){ LinphoneCallParams *cp; SalMediaDescription *md; - if (call->remote_params != NULL) linphone_call_params_unref(call->remote_params); - cp = call->remote_params = linphone_call_params_new(); + md=sal_call_get_remote_media_description(call->op); if (md) { SalStreamDescription *sd; @@ -1736,7 +1735,9 @@ const LinphoneCallParams * linphone_call_get_remote_params(LinphoneCall *call){ unsigned int nb_audio_streams = sal_media_description_nb_active_streams_of_type(md, SalAudio); unsigned int nb_video_streams = sal_media_description_nb_active_streams_of_type(md, SalVideo); unsigned int nb_text_streams = sal_media_description_nb_active_streams_of_type(md, SalText); - + if (call->remote_params != NULL) linphone_call_params_unref(call->remote_params); + cp = call->remote_params = linphone_call_params_new(); + for (i = 0; i < nb_video_streams; i++) { sd = sal_media_description_get_active_stream_of_type(md, SalVideo, i); if (sal_stream_description_active(sd) == TRUE) cp->has_video = TRUE; @@ -1757,8 +1758,8 @@ const LinphoneCallParams * linphone_call_get_remote_params(LinphoneCall *call){ } if (md->name[0]!='\0') linphone_call_params_set_session_name(cp,md->name); } - cp->custom_headers=sal_custom_header_clone((SalCustomHeader*)sal_op_get_recv_custom_header(call->op)); - return cp; + linphone_call_params_set_custom_headers(call->remote_params, sal_op_get_recv_custom_header(call->op)); + return call->remote_params; } return NULL; } diff --git a/coreapi/private.h b/coreapi/private.h index dcedc3e2e..c4e87bc86 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -343,6 +343,7 @@ LinphoneCallParams * linphone_call_params_new(void); SalMediaProto get_proto_from_call_params(const LinphoneCallParams *params); SalStreamDir get_audio_dir_from_call_params(const LinphoneCallParams *params); SalStreamDir get_video_dir_from_call_params(const LinphoneCallParams *params); +void linphone_call_params_set_custom_headers(LinphoneCallParams *params, const SalCustomHeader *ch); void linphone_auth_info_write_config(struct _LpConfig *config, LinphoneAuthInfo *obj, int pos); void linphone_core_write_auth_info(LinphoneCore *lc, LinphoneAuthInfo *ai); diff --git a/tester/call_tester.c b/tester/call_tester.c index 2422b6c69..5e5e0fd08 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -1839,11 +1839,6 @@ void video_call_base_2(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, LinphoneCall* pauline_call; LinphoneVideoPolicy marie_policy, pauline_policy; - linphone_core_enable_video_capture(marie->lc, TRUE); - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - linphone_core_enable_video_display(pauline->lc, FALSE); - if (using_policy) { marie_policy.automatically_initiate=FALSE; marie_policy.automatically_accept=TRUE; @@ -1853,20 +1848,12 @@ void video_call_base_2(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, linphone_core_set_video_policy(marie->lc,&marie_policy); linphone_core_set_video_policy(pauline->lc,&pauline_policy); } - if (callee_video_enabled) { - linphone_core_enable_video_display(marie->lc, TRUE); - linphone_core_enable_video_capture(marie->lc, TRUE); - } else { - linphone_core_enable_video_display(marie->lc, FALSE); - linphone_core_enable_video_capture(marie->lc, FALSE); - } - if (caller_video_enabled) { - linphone_core_enable_video_display(pauline->lc, TRUE); - linphone_core_enable_video_capture(pauline->lc, TRUE); - } else { - linphone_core_enable_video_display(pauline->lc, FALSE); - linphone_core_enable_video_capture(pauline->lc, FALSE); - } + + linphone_core_enable_video_display(marie->lc, callee_video_enabled); + linphone_core_enable_video_capture(marie->lc, callee_video_enabled); + + linphone_core_enable_video_display(pauline->lc, caller_video_enabled); + linphone_core_enable_video_capture(pauline->lc, caller_video_enabled); if (mode==LinphoneMediaEncryptionDTLS) { /* for DTLS we must access certificates or at least have a directory to store them */ marie->lc->user_certificates_path = bc_tester_file("certificates-marie"); @@ -1907,17 +1894,13 @@ void video_call_base_2(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(marie_call))); BC_ASSERT_FALSE(linphone_call_log_video_enabled(linphone_call_get_call_log(pauline_call))); } - liblinphone_tester_check_rtcp(marie,pauline); - } - } + static void video_call_base(LinphoneCoreManager* pauline,LinphoneCoreManager* marie, bool_t using_policy,LinphoneMediaEncryption mode, bool_t callee_video_enabled, bool_t caller_video_enabled) { video_call_base_2(pauline,marie,using_policy,mode,callee_video_enabled,caller_video_enabled); - linphone_core_terminate_all_calls(pauline->lc); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1)); - BC_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1)); + end_call(pauline, marie); } static void video_call(void) { LinphoneCoreManager* marie = linphone_core_manager_new("marie_rc");