Commit 625ede5b authored by jehan's avatar jehan
Browse files

change auto_answer tool to bind both sip and rtp to a specified address

parent 48ed46c7
...@@ -45,7 +45,7 @@ static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCal ...@@ -45,7 +45,7 @@ static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCal
LinphoneCallParams * call_params; LinphoneCallParams * call_params;
switch(cstate){ switch(cstate){
case LinphoneCallIncomingReceived: case LinphoneCallIncomingReceived:
printf("Incoming call arrive !\n"); ms_message("Incoming call arrive !\n");
/* accept the incoming call*/ /* accept the incoming call*/
call_params = linphone_core_create_default_call_parameters(lc); call_params = linphone_core_create_default_call_parameters(lc);
linphone_call_params_enable_video(call_params,TRUE); linphone_call_params_enable_video(call_params,TRUE);
...@@ -55,23 +55,8 @@ static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCal ...@@ -55,23 +55,8 @@ static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCal
linphone_call_params_destroy(call_params); linphone_call_params_destroy(call_params);
break; break;
case LinphoneCallOutgoingEarlyMedia:
printf("Receiving some early media\n");
break;
case LinphoneCallConnected:
printf("We are connected !\n");
break;
case LinphoneCallStreamsRunning:
printf("Media streams established !\n");
break;
case LinphoneCallEnd:
printf("Call is terminated.\n");
break;
case LinphoneCallError:
printf("Call failure !");
break;
default: default:
printf("Unhandled notification %i\n",cstate); break;
} }
} }
extern MSWebCamDesc mire_desc; extern MSWebCamDesc mire_desc;
...@@ -90,7 +75,7 @@ int main(int argc, char *argv[]){ ...@@ -90,7 +75,7 @@ int main(int argc, char *argv[]){
LinphoneAddress *addr=NULL; LinphoneAddress *addr=NULL;
LCSipTransports tp; LCSipTransports tp;
char * tmp = NULL; char * tmp = NULL;
LpConfig * lp_config = lp_config_new(NULL);
policy.automatically_accept=TRUE; policy.automatically_accept=TRUE;
signal(SIGINT,stop); signal(SIGINT,stop);
for(i = 1; i < argc; ++i) { for(i = 1; i < argc; ++i) {
...@@ -102,33 +87,30 @@ int main(int argc, char *argv[]){ ...@@ -102,33 +87,30 @@ int main(int argc, char *argv[]){
printf("Error, bad sip uri"); printf("Error, bad sip uri");
helper(); helper();
} }
switch(linphone_address_get_transport(addr)) { /* switch(linphone_address_get_transport(addr)) {
case LinphoneTransportUdp: case LinphoneTransportUdp:
case LinphoneTransportTcp: case LinphoneTransportTcp:
break; break;
default: default:
printf("Error, bad sip uri [%s] transport, should be udp | tcp",argv[i]); ms_error("Error, bad sip uri [%s] transport, should be udp | tcp",argv[i]);
helper(); helper();
break; break;
} }*/
} else { } else {
helper(); helper();
} }
} }
if (!addr) {
addr = linphone_address_new("sip:bot@0.0.0.0:5060");
}
lp_config_set_string(lp_config,"sip","bind_address",linphone_address_get_domain(addr));
lp_config_set_string(lp_config,"rtp","bind_address",linphone_address_get_domain(addr));
linphone_core_enable_logs(NULL); /*enable liblinphone logs.*/
/*
Fill the LinphoneCoreVTable with application callbacks.
All are optional. Here we only use the call_state_changed callbacks
in order to get notifications about the progress of the call.
*/
vtable.call_state_changed=call_state_changed; vtable.call_state_changed=call_state_changed;
/* lc=linphone_core_new_with_config(&vtable,lp_config,NULL);
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_capture(lc,TRUE);
linphone_core_enable_video_display(lc,FALSE); linphone_core_enable_video_display(lc,FALSE);
linphone_core_set_video_policy(lc,&policy); linphone_core_set_video_policy(lc,&policy);
...@@ -146,21 +128,13 @@ int main(int argc, char *argv[]){ ...@@ -146,21 +128,13 @@ int main(int argc, char *argv[]){
} }
} }
if (!addr) {
addr = linphone_address_new("sip:bot@localhost:5060");
}
memset(&tp,0,sizeof(LCSipTransports)); memset(&tp,0,sizeof(LCSipTransports));
switch(linphone_address_get_transport(addr)) {
case LinphoneTransportUdp: tp.udp_port = linphone_address_get_port(addr);
tp.udp_port = linphone_address_get_port(addr); tp.tcp_port = linphone_address_get_port(addr);
break;
case LinphoneTransportTcp:
tp.tcp_port = linphone_address_get_port(addr);
break;
default:
break;
}
linphone_core_set_sip_transports(lc,&tp); linphone_core_set_sip_transports(lc,&tp);
linphone_core_set_audio_port_range(lc,1024,65000); linphone_core_set_audio_port_range(lc,1024,65000);
linphone_core_set_preferred_framerate(lc,5); linphone_core_set_preferred_framerate(lc,5);
...@@ -173,9 +147,9 @@ int main(int argc, char *argv[]){ ...@@ -173,9 +147,9 @@ int main(int argc, char *argv[]){
ms_usleep(50000); ms_usleep(50000);
} }
printf("Shutting down...\n"); ms_message("Shutting down...\n");
linphone_core_destroy(lc); linphone_core_destroy(lc);
printf("Exited\n"); ms_message("Exited\n");
return 0; return 0;
} }
......
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