From 68b4de89f107abcc5850b1ea6dc2b595beb840fe Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Tue, 18 Apr 2017 19:00:18 +0200 Subject: [PATCH] Fixed linphone_transports_new method + created LinphoneVideoActivationPolicy to replace LinphoneVideoPolicy --- coreapi/factory.c | 8 ++++++ coreapi/linphonecore.c | 54 +++++++++++++++++++++++++++++++++++--- coreapi/private.h | 16 +++++++++-- include/linphone/core.h | 52 ++++++++++++++++++++++++++++++++++++ include/linphone/factory.h | 14 ++++++++++ include/linphone/types.h | 8 ++++++ tester/call_video_tester.c | 5 ++-- tester/register_tester.c | 20 +++++++------- tester/video_tester.c | 11 ++++---- 9 files changed, 166 insertions(+), 22 deletions(-) diff --git a/coreapi/factory.c b/coreapi/factory.c index fa1fcd770..3ec5a770c 100644 --- a/coreapi/factory.c +++ b/coreapi/factory.c @@ -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 diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 27de7fe7e..c549730e5 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -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)) diff --git a/coreapi/private.h b/coreapi/private.h index 537337cf5..023acc490 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -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; /**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; diff --git a/tester/register_tester.c b/tester/register_tester.c index b5159d48c..6989c8b1c 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -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); diff --git a/tester/video_tester.c b/tester/video_tester.c index bab0f9947..2921d6bf7 100644 --- a/tester/video_tester.c +++ b/tester/video_tester.c @@ -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");