implement compatibility mode for sdp cnx adde set to 0.0.0.0 in case of send only

param: [sip,cnx_ip_to_0000_if_sendonly_enabled]  with default value 0
This commit is contained in:
Jehan Monnier 2015-03-27 14:17:39 +01:00
parent c049220be8
commit 83f4d95545
9 changed files with 80 additions and 7 deletions

View file

@ -107,6 +107,7 @@ struct SalOp{
bool_t has_auth_pending;
SalOpSDPHandling sdp_handling;
int auth_requests; /*number of auth requested for this op*/
bool_t cnx_ip_to_0000_if_sendonly_enabled; /*for */
};

View file

@ -36,7 +36,14 @@ static void call_set_error(SalOp* op,belle_sip_response_t* response){
sal_op_set_error_info_from_response(op,response);
op->base.root->callbacks.call_failure(op);
}
static void set_addr_to_0000(char value[]) {
if (ms_is_ipv6(value)) {
strcpy(value,"::0");
} else {
strcpy(value,"0.0.0.0");
}
return;
}
static void sdp_process(SalOp *h){
ms_message("Doing SDP offer/answer process of type %s",h->sdp_offering ? "outgoing" : "incoming");
if (h->result){
@ -56,6 +63,15 @@ static void sdp_process(SalOp *h){
belle_sip_object_unref(h->sdp_answer);
}
offer_answer_initiate_incoming(h->base.local_media,h->base.remote_media,h->result,h->base.root->one_matching_codec);
/*for backward compatibility purpose*/
if(h->cnx_ip_to_0000_if_sendonly_enabled && sal_media_description_has_dir(h->result,SalStreamSendOnly)) {
set_addr_to_0000(h->result->addr);
for(i=0;i<h->result->nb_streams;++i){
if (h->result->streams[i].dir == SalStreamSendOnly)
set_addr_to_0000(h->result->streams[i].rtp_addr);
set_addr_to_0000(h->result->streams[i].rtcp_addr);
}
}
h->sdp_answer=(belle_sdp_session_description_t *)belle_sip_object_ref(media_description_to_sdp(h->result));
/*once we have generated the SDP answer, we modify the result description for processing by the upper layer.
It should contains media parameters constraint from the remote offer, not our response*/

View file

@ -803,3 +803,9 @@ void sal_call_set_sdp_handling(SalOp *h, SalOpSDPHandling handling) {
if (handling != SalOpSDPNormal) ms_message("Enabling special SDP handling for SalOp[%p]!", h);
h->sdp_handling = handling;
}
void sal_op_cnx_ip_to_0000_if_sendonly_enable(SalOp *op,bool_t yesno) {
op->cnx_ip_to_0000_if_sendonly_enabled = yesno;
}
bool_t sal_op_cnx_ip_to_0000_if_sendonly_enabled(SalOp *op) {
return op->cnx_ip_to_0000_if_sendonly_enabled;
}

View file

@ -1016,6 +1016,8 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
call->core=lc;
linphone_call_incoming_select_ip_version(call);
sal_op_cnx_ip_to_0000_if_sendonly_enable(op,lp_config_get_default_int(lc->config,"sip","cnx_ip_to_0000_if_sendonly_enabled",0));
if (lc->sip_conf.ping_with_options){
#ifdef BUILD_UPNP
if (lc->upnp != NULL && linphone_core_get_firewall_policy(lc)==LinphonePolicyUseUpnp &&

View file

@ -3118,6 +3118,7 @@ void linphone_configure_op(LinphoneCore *lc, SalOp *op, const LinphoneAddress *d
sal_address_destroy(new_contact);
}
}
sal_op_cnx_ip_to_0000_if_sendonly_enable(op,lp_config_get_default_int(lc->config,"sip","cnx_ip_to_0000_if_sendonly_enabled",0)); /*also set in linphone_call_new_incoming*/
}
/**

View file

@ -450,7 +450,7 @@ LinphoneAddress *guess_contact_for_register(LinphoneProxyConfig *obj){
* unregister without moving the register_enable flag
*/
void _linphone_proxy_config_unregister(LinphoneProxyConfig *obj) {
if (obj->state == LinphoneRegistrationOk) {
if (obj->op && obj->state == LinphoneRegistrationOk) {
sal_unregister(obj->op);
}
}

View file

@ -827,6 +827,10 @@ char* sal_op_get_public_uri(SalOp *sal);
unsigned long sal_begin_background_task(const char *name, void (*max_time_reached)(void *), void *data);
void sal_end_background_task(unsigned long id);
/*Some old equipment may not only rely on attribute sendonly/recvonly/sendrecv/inative*/
void sal_op_cnx_ip_to_0000_if_sendonly_enable(SalOp *sal,bool_t yesno);
bool_t sal_op_cnx_ip_to_0000_if_sendonly_enabled(SalOp *sal);
#endif

View file

@ -1301,7 +1301,51 @@ bool_t pause_call_1(LinphoneCoreManager* mgr_1,LinphoneCall* call_1,LinphoneCore
CU_ASSERT_EQUAL(linphone_call_get_state(call_2),LinphoneCallPausedByRemote);
return linphone_call_get_state(call_1) == LinphoneCallPaused && linphone_call_get_state(call_2)==LinphoneCallPausedByRemote;
}
#if 0
void concurrent_paused_resumed_base() {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
LinphoneCall* call_pauline,call_marie;
const rtp_stats_t * stats;
CU_ASSERT_TRUE(call(pauline,marie));
call_pauline = linphone_core_get_current_call(pauline->lc);
call_marie = linphone_core_get_current_call(marie->lc);
linphone_core_pause_call(pauline->lc,call_pauline);
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPausing,1));
linphone_core_pause_call(marie->lc,call_marie);
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallPausedByRemote,1));
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallPaused,1));
/*stay in pause a little while in order to generate traffic*/
wait_for_until(pauline->lc, marie->lc, NULL, 5, 2000);
linphone_core_resume_call(pauline->lc,call_pauline);
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&pauline->stat.number_of_LinphoneCallStreamsRunning,2));
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallStreamsRunning,2));
/*same here: wait a while for a bit of a traffic, we need to receive a RTCP packet*/
wait_for_until(pauline->lc, marie->lc, NULL, 5, 5000);
/*since RTCP streams are reset when call is paused/resumed, there should be no loss at all*/
stats = rtp_session_get_stats(call_pauline->sessions->rtp_session);
CU_ASSERT_EQUAL(stats->cum_packet_loss, 0);
/*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));
CU_ASSERT_TRUE(wait_for(pauline->lc,marie->lc,&marie->stat.number_of_LinphoneCallEnd,1));
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
#endif
static void call_paused_resumed_from_callee(void) {
LinphoneCoreManager* marie = linphone_core_manager_new( "marie_rc");
LinphoneCoreManager* pauline = linphone_core_manager_new( "pauline_rc");
@ -3003,9 +3047,7 @@ static void accept_call_in_send_only(void) {
}
static void accept_call_in_send_only_with_ice(void) {
#if 0
accept_call_in_send_base(TRUE);
#endif
}
void two_accepted_call_in_send_only() {

View file

@ -48,6 +48,7 @@ static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCal
printf("Incoming call arrive !\n");
/* accept the incoming call*/
call_params = linphone_core_create_default_call_parameters(lc);
linphone_call_params_enable_video(call_params,TRUE);
linphone_call_params_set_audio_direction(call_params,LinphoneMediaDirectionSendOnly);
linphone_call_params_set_video_direction(call_params,LinphoneMediaDirectionSendOnly);
linphone_core_accept_call_with_params(lc,call,call_params);
@ -78,7 +79,7 @@ static void helper() {
printf("auto_answer --help\n"
"\t\t\t--listening-uri <uri> uri to listen on, default [sip:localhost:5060]\n"
"\t\t\t--verbose\n");
return ;
exit(0);
}
int main(int argc, char *argv[]){
@ -128,7 +129,6 @@ int main(int argc, char *argv[]){
Instanciate a LinphoneCore object given the LinphoneCoreVTable
*/
lc=linphone_core_new(&vtable,NULL,NULL,NULL);
linphone_core_enable_video_capture(lc,TRUE);
linphone_core_enable_video_display(lc,FALSE);
linphone_core_set_video_policy(lc,&policy);
@ -162,7 +162,8 @@ int main(int argc, char *argv[]){
break;
}
linphone_core_set_sip_transports(lc,&tp);
linphone_core_set_audio_port_range(lc,1024,65000);
linphone_core_set_preferred_framerate(lc,5);
linphone_core_set_primary_contact(lc,tmp=linphone_address_as_string(addr));
ms_free(tmp);