Commit 68b4de89 authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Fixed linphone_transports_new method + created LinphoneVideoActivationPolicy...

Fixed linphone_transports_new method + created LinphoneVideoActivationPolicy to replace LinphoneVideoPolicy
parent a160392f
......@@ -304,4 +304,12 @@ LinphoneErrorInfo *linphone_factory_create_error_info(LinphoneFactory *factory){
LinphoneRange *linphone_factory_create_range(LinphoneFactory *factory) {
return linphone_range_new();
}
LinphoneTransports *linphone_factory_create_transports(LinphoneFactory *factory) {
return linphone_transports_new();
}
LinphoneVideoActivationPolicy *linphone_factory_create_video_activation_policy(LinphoneFactory *factory) {
return linphone_video_activation_policy_new();
}
\ No newline at end of file
......@@ -2769,7 +2769,7 @@ BELLE_SIP_INSTANCIATE_VPTR(LinphoneTransports, belle_sip_object_t,
FALSE
);
LinphoneTransports *linphone_transports_new(LinphoneCore *lc) {
LinphoneTransports *linphone_transports_new() {
LinphoneTransports *transports = belle_sip_object_new(LinphoneTransports);
transports->udp_port = 0;
transports->tcp_port = 0;
......@@ -2888,7 +2888,7 @@ LinphoneStatus linphone_core_get_sip_transports(LinphoneCore *lc, LinphoneSipTra
}
LinphoneTransports *linphone_core_get_transports(LinphoneCore *lc){
LinphoneTransports *transports = linphone_transports_new(lc);
LinphoneTransports *transports = linphone_transports_new();
transports->udp_port = lc->sip_conf.transports.udp_port;
transports->tcp_port = lc->sip_conf.transports.tcp_port;
transports->tls_port = lc->sip_conf.transports.tls_port;
......@@ -2903,7 +2903,7 @@ void linphone_core_get_sip_transports_used(LinphoneCore *lc, LinphoneSipTranspor
}
LinphoneTransports *linphone_core_get_transports_used(LinphoneCore *lc){
LinphoneTransports *transports = linphone_transports_new(lc);
LinphoneTransports *transports = linphone_transports_new();
transports->udp_port = sal_get_listening_port(lc->sal, SalTransportUDP);
transports->tcp_port = sal_get_listening_port(lc->sal, SalTransportTCP);
transports->tls_port = sal_get_listening_port(lc->sal, SalTransportTLS);
......@@ -4920,6 +4920,54 @@ const LinphoneVideoPolicy *linphone_core_get_video_policy(const LinphoneCore *lc
return &lc->video_policy;
}
BELLE_SIP_DECLARE_NO_IMPLEMENTED_INTERFACES(LinphoneVideoActivationPolicy);
BELLE_SIP_INSTANCIATE_VPTR(LinphoneVideoActivationPolicy, belle_sip_object_t,
NULL, // destroy
NULL, // clone
NULL, // marshal
FALSE
);
LinphoneVideoActivationPolicy *linphone_video_activation_policy_new() {
LinphoneVideoActivationPolicy *policy = belle_sip_object_new(LinphoneVideoActivationPolicy);
policy->automatically_accept = FALSE;
policy->automatically_initiate = FALSE;
return policy;
}
LinphoneVideoActivationPolicy* linphone_video_activation_policy_ref(LinphoneVideoActivationPolicy* policy) {
return (LinphoneVideoActivationPolicy*) belle_sip_object_ref(policy);
}
void linphone_video_activation_policy_unref(LinphoneVideoActivationPolicy* policy) {
belle_sip_object_unref(policy);
}
void *linphone_video_activation_policy_get_user_data(const LinphoneVideoActivationPolicy *policy) {
return policy->user_data;
}
void linphone_video_activation_policy_set_user_data(LinphoneVideoActivationPolicy *policy, void *data) {
policy->user_data = data;
}
void linphone_core_set_video_activation_policy(LinphoneCore *lc, const LinphoneVideoActivationPolicy *policy) {
lc->video_policy.automatically_accept = policy->automatically_accept;
lc->video_policy.automatically_initiate = policy->automatically_initiate;
if (linphone_core_ready(lc)) {
lp_config_set_int(lc->config, "video", "automatically_initiate", policy->automatically_initiate);
lp_config_set_int(lc->config, "video", "automatically_accept", policy->automatically_accept);
}
}
LinphoneVideoActivationPolicy *linphone_core_get_video_activation_policy(const LinphoneCore *lc){
LinphoneVideoActivationPolicy *policy = linphone_video_activation_policy_new();
policy->automatically_accept = lc->video_policy.automatically_accept;
policy->automatically_initiate = lc->video_policy.automatically_initiate;
return policy;
}
void linphone_core_enable_video_preview(LinphoneCore *lc, bool_t val){
lc->video_conf.show_local=val;
if (linphone_core_ready(lc))
......
......@@ -1748,7 +1748,18 @@ struct _LinphoneTransports {
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneTransports);
LINPHONE_PUBLIC LinphoneTransports *linphone_transports_new(LinphoneCore *lc);
LinphoneTransports *linphone_transports_new(void);
struct _LinphoneVideoActivationPolicy {
belle_sip_object_t base;
void *user_data;
bool_t automatically_initiate; /**<Whether video shall be automatically proposed for outgoing calls.*/
bool_t automatically_accept; /**<Whether video shall be automatically accepted for incoming calls*/
};
BELLE_SIP_DECLARE_VPTR_NO_EXPORT(LinphoneVideoActivationPolicy);
LinphoneVideoActivationPolicy *linphone_video_activation_policy_new(void);
/** Belle Sip-based objects need unique ids
*/
......@@ -1802,7 +1813,8 @@ BELLE_SIP_TYPE_ID(LinphoneInfoMessage),
BELLE_SIP_TYPE_ID(LinphonePayloadType),
BELLE_SIP_TYPE_ID(LinphoneRange),
BELLE_SIP_TYPE_ID(LinphoneVideoDefinition),
BELLE_SIP_TYPE_ID(LinphoneTransports)
BELLE_SIP_TYPE_ID(LinphoneTransports),
BELLE_SIP_TYPE_ID(LinphoneVideoActivationPolicy)
BELLE_SIP_DECLARE_TYPES_END
......
......@@ -3212,6 +3212,7 @@ LINPHONE_PUBLIC bool_t linphone_core_video_display_enabled(LinphoneCore *lc);
* @param[in] lc LinphoneCore object
* @param[in] policy The video policy to use
* @ingroup media_parameters
* @deprecated
**/
LINPHONE_PUBLIC void linphone_core_set_video_policy(LinphoneCore *lc, const LinphoneVideoPolicy *policy);
......@@ -3221,9 +3222,60 @@ LINPHONE_PUBLIC void linphone_core_set_video_policy(LinphoneCore *lc, const Linp
* @param[in] lc LinphoneCore object
* @return The video policy being used
* @ingroup media_parameters
* @deprecated
**/
LINPHONE_PUBLIC const LinphoneVideoPolicy *linphone_core_get_video_policy(const LinphoneCore *lc);
/**
* Increment refcount.
* @param[in] policy LinphoneVideoActivationPolicy object
* @ingroup media_parameters
**/
LINPHONE_PUBLIC LinphoneVideoActivationPolicy *linphone_video_activation_policy_ref(LinphoneVideoActivationPolicy *policy);
/**
* Decrement refcount and possibly free the object.
* @param[in] policy LinphoneVideoActivationPolicy object
* @ingroup media_parameters
**/
LINPHONE_PUBLIC void linphone_video_activation_policy_unref(LinphoneVideoActivationPolicy *policy);
/**
* Gets the user data in the LinphoneVideoActivationPolicy object
* @param[in] policy the LinphoneVideoActivationPolicy
* @return the user data
* @ingroup media_parameters
*/
LINPHONE_PUBLIC void *linphone_video_activation_policy_get_user_data(const LinphoneVideoActivationPolicy *policy);
/**
* Sets the user data in the LinphoneVideoActivationPolicy object
* @param[in] policy the LinphoneVideoActivationPolicy object
* @param[in] data the user data
* @ingroup media_parameters
*/
LINPHONE_PUBLIC void linphone_video_activation_policy_set_user_data(LinphoneVideoActivationPolicy *policy, void *data);
/**
* Sets the default policy for video.
* This policy defines whether:
* - video shall be initiated by default for outgoing calls
* - video shall be accepted by default for incoming calls
* @param[in] lc LinphoneCore object
* @param[in] policy The video policy to use
* @ingroup media_parameters
**/
LINPHONE_PUBLIC void linphone_core_set_video_activation_policy(LinphoneCore *lc, const LinphoneVideoActivationPolicy *policy);
/**
* Get the default policy for video.
* See linphone_core_set_video_activation_policy() for more details.
* @param[in] lc LinphoneCore object
* @return The video policy being used
* @ingroup media_parameters
**/
LINPHONE_PUBLIC LinphoneVideoActivationPolicy *linphone_core_get_video_activation_policy(const LinphoneCore *lc);
/**
* Returns the zero terminated table of supported video resolutions.
* @ingroup media_parameters
......
......@@ -247,6 +247,20 @@ LINPHONE_PUBLIC LinphoneErrorInfo *linphone_factory_create_error_info(LinphoneF
* @return LinphoneRange object.
*/
LINPHONE_PUBLIC LinphoneRange *linphone_factory_create_range(LinphoneFactory *factory);
/**
* Creates an object LinphoneTransports.
* @param[in] factory LinphoneFactory object
* @return LinphoneTransports object.
*/
LINPHONE_PUBLIC LinphoneTransports *linphone_factory_create_transports(LinphoneFactory *factory);
/**
* Creates an object LinphoneVideoActivationPolicy.
* @param[in] factory LinphoneFactory object
* @return LinphoneVideoActivationPolicy object.
*/
LINPHONE_PUBLIC LinphoneVideoActivationPolicy *linphone_factory_create_video_activation_policy(LinphoneFactory *factory);
/**
* @}
*/
......
......@@ -1123,6 +1123,8 @@ typedef struct _LinphoneVideoDefinition LinphoneVideoDefinition;
/**
* Structure describing policy regarding video streams establishments.
* @ingroup media_parameters
* @deprecated
* @donotwrap
**/
typedef struct _LinphoneVideoPolicy {
bool_t automatically_initiate; /**<Whether video shall be automatically proposed for outgoing calls.*/
......@@ -1130,6 +1132,12 @@ typedef struct _LinphoneVideoPolicy {
bool_t unused[2];
} LinphoneVideoPolicy;
/**
* Structure describing policy regarding video streams establishments.
* @ingroup media_parameters
**/
typedef struct _LinphoneVideoActivationPolicy LinphoneVideoActivationPolicy;
typedef struct LinphoneVideoSizeDef {
MSVideoSize vsize;
const char *name;
......
......@@ -223,7 +223,7 @@ static LinphoneCall* _request_video(LinphoneCoreManager* caller,LinphoneCoreMana
bool_t request_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bool_t accept_with_params) {
stats initial_caller_stat=caller->stat;
stats initial_callee_stat=callee->stat;
const LinphoneVideoPolicy *video_policy;
LinphoneVideoActivationPolicy *video_policy;
LinphoneCall *call_obj;
bool_t video_added = FALSE;
......@@ -233,7 +233,7 @@ bool_t request_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bo
BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&callee->stat.number_of_LinphoneCallStreamsRunning,initial_callee_stat.number_of_LinphoneCallStreamsRunning+1));
BC_ASSERT_TRUE(wait_for(caller->lc,callee->lc,&caller->stat.number_of_LinphoneCallStreamsRunning,initial_caller_stat.number_of_LinphoneCallStreamsRunning+1));
video_policy = linphone_core_get_video_policy(caller->lc);
video_policy = linphone_core_get_video_activation_policy(caller->lc);
if (video_policy->automatically_accept || accept_with_params) {
video_added = BC_ASSERT_TRUE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc))));
video_added =
......@@ -243,6 +243,7 @@ bool_t request_video(LinphoneCoreManager* caller,LinphoneCoreManager* callee, bo
BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(callee->lc))));
BC_ASSERT_FALSE(linphone_call_params_video_enabled(linphone_call_get_current_params(linphone_core_get_current_call(caller->lc))));
}
linphone_video_activation_policy_unref(video_policy);
if (linphone_core_get_media_encryption(caller->lc) != LinphoneMediaEncryptionNone
&& linphone_core_get_media_encryption(callee->lc) != LinphoneMediaEncryptionNone) {
const LinphoneCallParams* call_param;
......
......@@ -145,7 +145,7 @@ static void register_with_refresh_base_2(LinphoneCore* lc
register_with_refresh_base_3(lc, refresh, domain, route, late_auth_info, transport,LinphoneRegistrationOk );
}
static void register_with_refresh_base(LinphoneCore* lc, bool_t refresh,const char* domain,const char* route) {
LinphoneTransports *transport = linphone_transports_new(lc);
LinphoneTransports *transport = linphone_transports_new();
linphone_transports_set_udp_port(transport, 5070);
linphone_transports_set_tcp_port(transport, 5070);
linphone_transports_set_tls_port(transport, 5071);
......@@ -289,7 +289,7 @@ static void simple_tcp_register_compatibility_mode(void){
LinphoneTransports *transport = NULL;
sprintf(route,"sip:%s",test_route);
lcm = create_lcm();
transport = linphone_transports_new(lcm->lc);
transport = linphone_transports_new();
linphone_transports_set_tcp_port(transport, 5070);
register_with_refresh_base_2(lcm->lc,FALSE,test_domain,route,FALSE,transport);
linphone_transports_unref(transport);
......@@ -369,7 +369,7 @@ static void authenticated_register_with_late_credentials(void){
sprintf(route,"sip:%s",test_route);
lcm = linphone_core_manager_new(NULL);
transport = linphone_transports_new(lcm->lc);
transport = linphone_transports_new();
linphone_transports_set_udp_port(transport, 5070);
linphone_transports_set_tcp_port(transport, 5070);
linphone_transports_set_dtls_port(transport, 5071);
......@@ -435,7 +435,7 @@ static void authenticated_register_with_wrong_late_credentials(void){
sprintf(route,"sip:%s",test_route);
lcm = linphone_core_manager_new(NULL);
transport = linphone_transports_new(lcm->lc);
transport = linphone_transports_new();
linphone_transports_set_udp_port(transport, 5070);
linphone_transports_set_tcp_port(transport, 5070);
linphone_transports_set_tls_port(transport, 5071);
......@@ -454,7 +454,7 @@ static void authenticated_register_with_wrong_late_credentials(void){
static void authenticated_register_with_wrong_credentials_with_params_base(const char* user_agent,LinphoneCoreManager *lcm) {
stats* counters;
LinphoneTransports *transport = linphone_transports_new(lcm->lc);
LinphoneTransports *transport = linphone_transports_new();
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,"wrong passwd",NULL,auth_domain,NULL); /*create authentication structure from identity*/
char route[256];
......@@ -584,7 +584,7 @@ static void transport_change(void){
lcm=configure_lcm();
if (lcm) {
lc=lcm->lc;
sip_tr = linphone_transports_new(lc);
sip_tr = linphone_transports_new();
counters = get_stats(lc);
register_ok=counters->number_of_LinphoneRegistrationOk;
......@@ -609,7 +609,7 @@ static void transport_change(void){
static void transport_dont_bind(void){
LinphoneCoreManager *pauline = linphone_core_manager_new("pauline_tcp_rc");
stats* counters = &pauline->stat;
LinphoneTransports *tr = linphone_transports_new(pauline->lc);
LinphoneTransports *tr = linphone_transports_new();
linphone_transports_set_tcp_port(tr, LC_SIP_TRANSPORT_DONTBIND);
linphone_transports_set_tls_port(tr, LC_SIP_TRANSPORT_DONTBIND);
......@@ -690,7 +690,7 @@ static void proxy_transport_change_with_wrong_port(void) {
LinphoneProxyConfig* proxy_config;
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
char route[256];
LinphoneTransports *transport= linphone_transports_new(lcm->lc);
LinphoneTransports *transport= linphone_transports_new();
sprintf(route,"sip:%s",test_route);
linphone_transports_set_udp_port(transport, LC_SIP_TRANSPORT_RANDOM);
linphone_transports_set_tcp_port(transport, LC_SIP_TRANSPORT_RANDOM);
......@@ -726,7 +726,7 @@ static void proxy_transport_change_with_wrong_port_givin_up(void) {
LinphoneProxyConfig* proxy_config;
LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,test_password,NULL,auth_domain,NULL); /*create authentication structure from identity*/
char route[256];
LinphoneTransports *transport = linphone_transports_new(lcm->lc);
LinphoneTransports *transport = linphone_transports_new();
sprintf(route,"sip:%s",test_route);
linphone_transports_set_udp_port(transport, LC_SIP_TRANSPORT_RANDOM);
linphone_transports_set_tcp_port(transport, LC_SIP_TRANSPORT_RANDOM);
......@@ -1018,7 +1018,7 @@ static void redirect(void){
sprintf(route,"sip:%s:5064",test_route);
lcm = create_lcm();
if (lcm) {
transport = linphone_transports_new(lcm->lc);
transport = linphone_transports_new();
linphone_transports_set_udp_port(transport, -1);
linphone_core_set_user_agent(lcm->lc,"redirect",NULL);
register_with_refresh_base_2(lcm->lc,FALSE,test_domain,route,FALSE,transport);
......
......@@ -414,24 +414,25 @@ static void forked_outgoing_early_media_video_call_with_inactive_audio_test(void
LinphoneCallParams *pauline_params;
LinphoneCallParams *marie1_params;
LinphoneCallParams *marie2_params;
LinphoneVideoPolicy pol;
LinphoneVideoActivationPolicy *pol = linphone_video_activation_policy_new();
LinphoneCall *marie1_call;
LinphoneCall *marie2_call;
LinphoneCall *pauline_call;
LinphoneInfoMessage *info;
int dummy = 0;
pol.automatically_accept = 1;
pol.automatically_initiate = 1;
pol->automatically_accept = TRUE;
pol->automatically_initiate = TRUE;
LinphoneRange *port_range = NULL;
linphone_core_enable_video_capture(pauline->lc, TRUE);
linphone_core_enable_video_display(pauline->lc, TRUE);
linphone_core_enable_video_capture(marie1->lc, TRUE);
linphone_core_enable_video_display(marie1->lc, TRUE);
linphone_core_set_video_policy(marie1->lc, &pol);
linphone_core_set_video_activation_policy(marie1->lc, pol);
linphone_core_enable_video_capture(marie2->lc, TRUE);
linphone_core_enable_video_display(marie2->lc, TRUE);
linphone_core_set_video_policy(marie2->lc, &pol);
linphone_core_set_video_activation_policy(marie2->lc, pol);
linphone_video_activation_policy_unref(pol);
linphone_core_set_audio_port_range(marie2->lc, 40200, 40300);
port_range = linphone_core_get_audio_ports_range(marie2->lc);
BC_ASSERT_EQUAL(port_range->min, 40200, int, "%i");
......
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