diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index 9c99e2722..033b1660b 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -627,7 +627,7 @@ static void call_failure(SalOp *op, SalError error, SalReason sr, const char *de || call->state==LinphoneCallOutgoingProgress || call->state==LinphoneCallOutgoingRinging /*push case*/ || call->state==LinphoneCallOutgoingEarlyMedia){ - LinphoneAddress* redirection_to = linphone_call_get_remote_contact_address(call); + LinphoneAddress* redirection_to = (LinphoneAddress*)sal_op_get_remote_contact_address(call->op); if( redirection_to ){ char* url = linphone_address_as_string(redirection_to); ms_error("Redirecting call [%p] to %s",call, url); diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index 901fcf5be..820ee3427 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -1058,18 +1058,12 @@ const char *linphone_call_get_remote_user_agent(LinphoneCall *call){ * Returns the far end's sip contact as a string, if available. **/ const char *linphone_call_get_remote_contact(LinphoneCall *call){ - if (call->op){ - return sal_op_get_remote_contact(call->op); - } - return NULL; -} - -/** - * Returns the far end's sip contact as a string, if available. -**/ -LinphoneAddress *linphone_call_get_remote_contact_address(LinphoneCall *call){ - if (call->op){ - return (LinphoneAddress*)sal_op_get_remote_contact_address(call->op); + const LinphoneCallParams* lcp = linphone_call_get_remote_params(call); + if( lcp ){ + // we're not using sal_op_get_remote_contact() here because the returned value is stripped from + // params that we need, like the instanceid. Getting it from the headers will make sure we + // get everything + return linphone_call_params_get_custom_header(lcp, "Contact"); } return NULL; } diff --git a/tester/call_tester.c b/tester/call_tester.c index 2b40e6bf0..6c8710dba 100644 --- a/tester/call_tester.c +++ b/tester/call_tester.c @@ -550,9 +550,9 @@ static void call_with_custom_headers(void) { LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc"); LinphoneCall *call_marie,*call_pauline; LinphoneCallParams *params; - const LinphoneCallParams *remote_params; + const LinphoneCallParams *marie_remote_params; const char *hvalue; - const char *pauline_remote_contact_header, + char *pauline_remote_contact_header, *pauline_remote_contact, *marie_remote_contact, *marie_remote_contact_header; @@ -578,19 +578,22 @@ static void call_with_custom_headers(void) { CU_ASSERT_PTR_NOT_NULL(call_marie); CU_ASSERT_PTR_NOT_NULL(call_pauline); - remote_params=linphone_call_get_remote_params(call_marie); - hvalue=linphone_call_params_get_custom_header(remote_params,"Weather"); + marie_remote_params=linphone_call_get_remote_params(call_marie); + hvalue=linphone_call_params_get_custom_header(marie_remote_params,"Weather"); CU_ASSERT_PTR_NOT_NULL(hvalue); CU_ASSERT_STRING_EQUAL(hvalue,"bad"); - hvalue=linphone_call_params_get_custom_header(remote_params,"uriHeader"); + hvalue=linphone_call_params_get_custom_header(marie_remote_params,"uriHeader"); CU_ASSERT_PTR_NOT_NULL(hvalue); CU_ASSERT_STRING_EQUAL(hvalue,"myUriHeader"); - pauline_remote_contact_header = linphone_call_params_get_custom_header(linphone_call_get_remote_params(call_pauline), "Contact"); - pauline_remote_contact = linphone_call_get_remote_contact(call_pauline); - marie_remote_contact = linphone_call_get_remote_contact(call_marie); - marie_remote_contact_header = linphone_call_params_get_custom_header(remote_params, "Contact"); + // FIXME: we have to strdup because successive calls to get_remote_params erase the returned const char*!! + pauline_remote_contact = ms_strdup(linphone_call_get_remote_contact(call_pauline)); + pauline_remote_contact_header = ms_strdup(linphone_call_params_get_custom_header(linphone_call_get_remote_params(call_pauline), "Contact")); + + marie_remote_contact = ms_strdup(linphone_call_get_remote_contact(call_marie)); + marie_remote_contact_header = ms_strdup(linphone_call_params_get_custom_header(marie_remote_params, "Contact")); + CU_ASSERT_PTR_NOT_NULL(pauline_remote_contact); CU_ASSERT_PTR_NOT_NULL(pauline_remote_contact_header); CU_ASSERT_PTR_NOT_NULL(marie_remote_contact); @@ -598,6 +601,12 @@ static void call_with_custom_headers(void) { CU_ASSERT_STRING_EQUAL(pauline_remote_contact,pauline_remote_contact_header); CU_ASSERT_STRING_EQUAL(marie_remote_contact,marie_remote_contact_header); + ms_free(pauline_remote_contact); + ms_free(pauline_remote_contact_header); + ms_free(marie_remote_contact); + ms_free(marie_remote_contact_header); + + /*just to sleep*/ linphone_core_terminate_all_calls(pauline->lc); CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallEnd,1));