Commit 711db764 authored by Julien Wadel's avatar Julien Wadel
Browse files

Add a function to allow skipping the auto selection of proxy when calling and test functions

parent f6dbd5d5
......@@ -4230,8 +4230,10 @@ LinphoneCall * linphone_core_invite_address_with_params(LinphoneCore *lc, const
if (!L_GET_PRIVATE_FROM_C_OBJECT(lc)->canWeAddCall())
return NULL;
proxy = linphone_call_params_get_proxy_config(params);
if( proxy == NULL)
proxy=linphone_core_lookup_known_proxy(lc,addr);
cp = linphone_call_params_copy(params);
proxy=linphone_core_lookup_known_proxy(lc,addr);
if (proxy!=NULL) {
from=linphone_proxy_config_get_identity(proxy);
linphone_call_params_enable_avpf(cp, linphone_proxy_config_avpf_enabled(proxy));
......
......@@ -291,6 +291,23 @@ LINPHONE_PUBLIC void linphone_call_params_set_audio_direction(LinphoneCallParams
**/
LINPHONE_PUBLIC void linphone_call_params_set_video_direction(LinphoneCallParams *call_params, LinphoneMediaDirection direction);
/**
* Set the #LinphoneProxyConfig to use for the call
*
* @param params the #LinphoneCallParams @notnil
* @param proxy_config The #LinphoneProxyConfig to use, or NULL if none has been selected. The #LinphoneCallParams keep a reference on it and remove the older if it exists. @maybenil
**/
LINPHONE_PUBLIC void linphone_call_params_set_proxy_config(LinphoneCallParams *params, LinphoneProxyConfig *proxy_config);
/**
* Get the #LinphoneProxyConfig that is used for the call
*
* @param params the #LinphoneCallParams @notnil
* @return The selected #LinphoneProxyConfig for the call, or NULL if none has been selected. @maybenil
**/
LINPHONE_PUBLIC LinphoneProxyConfig *linphone_call_params_get_proxy_config(const LinphoneCallParams *params);
int linphone_call_params_get_audio_bandwidth_limit(const LinphoneCallParams *params);
bool_t linphone_call_params_real_early_media_enabled(const LinphoneCallParams *params);
......
......@@ -1191,6 +1191,7 @@ LINPHONE_PUBLIC LinphoneCall * linphone_core_invite_with_params(LinphoneCore *co
* created by linphone_core_interpret_url().
* The application doesn't own a reference to the returned #LinphoneCall object.
* Use linphone_call_ref() to safely keep the #LinphoneCall pointer valid within your application.
* If the proxy is not specified in parameters, the caller proxy will be automatically selected by finding what is the best to reach the destination of the call.
* @param core #LinphoneCore object @notnil
* @param addr The destination of the call (sip address). @notnil
* @param params Call parameters @notnil
......
......@@ -21,6 +21,7 @@
#define LINPHONE_PROXY_CONFIG_H
#include "linphone/types.h"
#include "linphone/sipsetup.h"
#ifdef __cplusplus
extern "C" {
......
......@@ -327,6 +327,14 @@ void linphone_call_params_set_video_direction (LinphoneCallParams *params, Linph
L_GET_CPP_PTR_FROM_C_OBJECT(params)->setVideoDirection(dir);
}
void linphone_call_params_set_proxy_config (LinphoneCallParams *params, LinphoneProxyConfig *proxy_config) {
L_GET_CPP_PTR_FROM_C_OBJECT(params)->setProxyConfig(proxy_config);
}
LinphoneProxyConfig *linphone_call_params_get_proxy_config (const LinphoneCallParams *params) {
return L_GET_CPP_PTR_FROM_C_OBJECT(params)->getProxyConfig();
}
void linphone_call_params_enable_audio_multicast (LinphoneCallParams *params, bool_t yesno) {
L_GET_CPP_PTR_FROM_C_OBJECT(params)->enableAudioMulticast(!!yesno);
}
......
......@@ -55,6 +55,7 @@ public:
std::string sessionName;
LinphonePrivacyMask privacy = LinphonePrivacyNone;
LinphoneProxyConfig * proxyConfig = NULL;
private:
bool inConference = false;
......
......@@ -20,6 +20,8 @@
#include "call-session-params-p.h"
#include "call-session-params.h"
#include "linphone/proxy_config.h"
using namespace std;
LINPHONE_BEGIN_NAMESPACE
......@@ -42,6 +44,9 @@ void CallSessionParamsPrivate::clone (const CallSessionParamsPrivate *src) {
customContactParameters = src->customContactParameters;
referer = src->referer;
customContents = src->customContents;
proxyConfig = src->proxyConfig;
if( proxyConfig)
linphone_proxy_config_ref(proxyConfig);
}
// -----------------------------------------------------------------------------
......@@ -63,7 +68,12 @@ void CallSessionParamsPrivate::setCustomHeaders (const SalCustomHeader *ch) {
CallSessionParams::CallSessionParams () : ClonableObject(*new CallSessionParamsPrivate) {}
CallSessionParams::CallSessionParams (CallSessionParamsPrivate &p) : ClonableObject(p) {}
CallSessionParams::CallSessionParams (CallSessionParamsPrivate &p) : ClonableObject(p) {
L_D();
d->proxyConfig = p.proxyConfig;
if( d->proxyConfig )
linphone_proxy_config_ref(d->proxyConfig);
}
CallSessionParams::CallSessionParams (const CallSessionParams &other)
: ClonableObject(*new CallSessionParamsPrivate) {
......@@ -75,6 +85,8 @@ CallSessionParams::~CallSessionParams () {
L_D();
if (d->customHeaders)
sal_custom_header_free(d->customHeaders);
if( d->proxyConfig )
linphone_proxy_config_unref(d->proxyConfig);
}
CallSessionParams &CallSessionParams::operator= (const CallSessionParams &other) {
......@@ -90,6 +102,7 @@ void CallSessionParams::initDefault (const std::shared_ptr<Core> &core, Linphone
L_D();
d->inConference = false;
d->privacy = LinphonePrivacyDefault;
setProxyConfig(NULL);
}
// -----------------------------------------------------------------------------
......@@ -174,4 +187,20 @@ const list<Content>& CallSessionParams::getCustomContents() const {
return d->customContents;
}
// -----------------------------------------------------------------------------
LinphoneProxyConfig *CallSessionParams::getProxyConfig() const {
L_D();
return d->proxyConfig;
}
void CallSessionParams::setProxyConfig(LinphoneProxyConfig *proxyConfig) {
L_D();
if( proxyConfig )
linphone_proxy_config_ref(proxyConfig);
if( d->proxyConfig )
linphone_proxy_config_unref(d->proxyConfig);
d->proxyConfig = proxyConfig;
}
LINPHONE_END_NAMESPACE
......@@ -71,6 +71,9 @@ public:
void addCustomContent (const Content& content);
const std::list<Content>& getCustomContents () const;
LinphoneProxyConfig *getProxyConfig() const;
void setProxyConfig(LinphoneProxyConfig *proxyConfig);
protected:
explicit CallSessionParams (CallSessionParamsPrivate &p);
......
......@@ -88,6 +88,7 @@ protected:
virtual LinphoneStatus startUpdate (const std::string &subject);
virtual void terminate ();
virtual void updateCurrentParams () const;
virtual void setDestProxy (LinphoneProxyConfig *proxy);// Set destProxy and update the proxy of currentParams
void setBroken ();
void setContactOp ();
......
......@@ -701,6 +701,11 @@ void CallSessionPrivate::terminate () {
void CallSessionPrivate::updateCurrentParams () const {}
void CallSessionPrivate::setDestProxy (LinphoneProxyConfig *proxy){
destProxy = proxy;
currentParams->setProxyConfig(proxy);
}
// -----------------------------------------------------------------------------
void CallSessionPrivate::setBroken () {
......@@ -997,13 +1002,12 @@ lInfo() << "Call session " << __func__ << " Call is in state " << Utils::toStrin
void CallSession::configure (LinphoneCallDir direction, LinphoneProxyConfig *cfg, SalCallOp *op, const Address &from, const Address &to) {
L_D();
d->direction = direction;
d->destProxy = cfg;
d->setDestProxy(cfg);
LinphoneAddress *fromAddr = linphone_address_new(from.asString().c_str());
LinphoneAddress *toAddr = linphone_address_new(to.asString().c_str());
if (!d->destProxy) {
/* Try to define the destination proxy if it has not already been done to have a correct contact field in the SIP messages */
d->destProxy = linphone_core_lookup_known_proxy(getCore()->getCCore(), toAddr);
d->setDestProxy( linphone_core_lookup_known_proxy(getCore()->getCCore(), toAddr) );
}
if (d->log) {
......
......@@ -537,6 +537,44 @@ static void call_outbound_with_multiple_proxy(void) {
linphone_core_manager_destroy(pauline);
}
static void call_outbound_using_different_proxies(void) {
LinphoneCoreManager* marie = linphone_core_manager_new2( "marie_dual_proxy_rc", FALSE);// Caller
LinphoneCoreManager* pauline = linphone_core_manager_new2( "pauline_tcp_rc", FALSE);// Callee
BC_ASSERT_TRUE(wait_for_until(pauline->lc, NULL, &pauline->stat.number_of_LinphoneRegistrationOk, 1, 10000));
BC_ASSERT_TRUE(wait_for_until(marie->lc, NULL, &marie->stat.number_of_LinphoneRegistrationOk, 2, 10000));
for(const bctbx_list_t * proxy=linphone_core_get_proxy_config_list(marie->lc) ; proxy!=NULL ; proxy=proxy->next) {
const LinphoneAddress * marieProxyAddress = linphone_proxy_config_get_identity_address((LinphoneProxyConfig*)proxy->data);
// Set the proxy to be used in call
linphone_core_set_default_proxy_config(marie->lc, (LinphoneProxyConfig*)proxy->data);
LinphoneCall * caller = linphone_core_invite(marie->lc, linphone_core_get_identity(pauline->lc));
if( BC_ASSERT_PTR_NOT_NULL(caller) ) {
wait_for_until(marie->lc, pauline->lc, NULL, 5, 500); // Wait for stabilize call
const LinphoneCallParams * callerParameters = linphone_call_get_current_params(caller);
if(BC_ASSERT_PTR_NOT_NULL(callerParameters)){
const LinphoneProxyConfig * callerProxyConfig = linphone_call_params_get_proxy_config(callerParameters);
if(BC_ASSERT_PTR_NOT_NULL(callerProxyConfig)){
const LinphoneAddress * callerAddress = linphone_proxy_config_get_identity_address(callerProxyConfig);
if(BC_ASSERT_PTR_NOT_NULL(callerAddress)){
BC_ASSERT_TRUE(linphone_address_weak_equal(callerAddress, marieProxyAddress ));// Main test : the caller address must use the selected proxy
LinphoneCall * callee = linphone_core_get_current_call(pauline->lc);
BC_ASSERT_PTR_NOT_NULL(callee);
if(callee){
const LinphoneAddress * remoteAddress = linphone_call_get_remote_address(callee);
BC_ASSERT_TRUE(linphone_address_weak_equal(remoteAddress, marieProxyAddress));// Main test : callee get a call from the selected proxy of caller
}
}
}
}
}
end_call(marie, pauline);
wait_for_until(marie->lc, pauline->lc, NULL, 5, 500);// Wait between each session to proper ending calls
}
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
#if 0 /* TODO: activate test when the implementation is ready */
static void multiple_answers_call(void) {
/* Scenario is this: pauline calls marie, which is registered 2 times.
......@@ -5198,6 +5236,7 @@ test_t call_tests[] = {
TEST_NO_TAG("Call IPv6 to IPv4 without relay", v6_to_v4_call_without_relay),
TEST_NO_TAG("IPv6 call over NAT64", v6_call_over_nat_64),
TEST_NO_TAG("Outbound call with multiple proxy possible", call_outbound_with_multiple_proxy),
TEST_NO_TAG("Outbound call using different proxies", call_outbound_using_different_proxies),
TEST_NO_TAG("Audio call recording", audio_call_recording_test),
#if 0 // not yet activated because not implemented
TEST_NO_TAG("Multiple answers to a call", multiple_answers_call),
......
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