Commit e5933c61 authored by jehan's avatar jehan

improve calls in send-only/receive-only mode

parent 28ae2ec0
......@@ -366,8 +366,8 @@ belle_sdp_session_description_t * media_description_to_sdp ( const SalMediaDescr
belle_sdp_session_description_set_session_name ( session_desc,
belle_sdp_session_name_create ( desc->name[0]!='\0' ? desc->name : "Talk" ) );
if ( (!sal_media_description_has_dir ( desc,SalStreamSendOnly ) && !sal_media_description_has_dir ( desc,SalStreamInactive ))
|| desc->ice_ufrag[0] != '\0' ) {
if ( !sal_media_description_has_dir ( desc,SalStreamInactive ) || desc->ice_ufrag[0] != '\0' ) {
/*in case of sendonly, setting of the IP on cnx we give a chance to receive stun packets*/
belle_sdp_session_description_set_connection ( session_desc
,belle_sdp_connection_create ( "IN",inet6 ? "IP6" :"IP4",desc->addr ) );
......
oRTP @ 3585f885
Subproject commit 883191ebfb98be5a23d9b863063b79d2ac39d722
Subproject commit 3585f88590bcbf08c195934b490f55715eb97325
......@@ -2931,37 +2931,17 @@ static void accept_call_in_send_only_base(LinphoneCoreManager* pauline, Linphone
CU_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStreamsRunning,1,DEFAULT_WAIT_FOR));
CU_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallPausedByRemote,1,DEFAULT_WAIT_FOR));
{
const LinphoneCallParams *params = linphone_call_get_current_params(call);
CU_ASSERT_EQUAL(LinphoneMediaDirectionSendOnly,linphone_call_params_get_audio_direction(params));
CU_ASSERT_EQUAL(LinphoneMediaDirectionSendOnly,linphone_call_params_get_video_direction(params));
CU_ASSERT_TRUE(wait_for_list(lcs, &marie->stat.number_of_LinphoneCallStatsUpdated,2,DEFAULT_WAIT_FOR));
CU_ASSERT_TRUE(linphone_call_get_audio_stats(call)->download_bandwidth<5);
CU_ASSERT_TRUE(linphone_call_get_video_stats(call)->download_bandwidth<5);
}
check_media_direction(marie,call,lcs,LinphoneMediaDirectionSendOnly,LinphoneMediaDirectionSendOnly);
}
call=linphone_core_get_current_call(pauline->lc);
if (call) {
const LinphoneCallParams *params = linphone_call_get_current_params(call);
CU_ASSERT_EQUAL(LinphoneMediaDirectionRecvOnly,linphone_call_params_get_audio_direction(params));
CU_ASSERT_EQUAL(LinphoneMediaDirectionRecvOnly,linphone_call_params_get_video_direction(params));
CU_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_IframeDecoded,1,DEFAULT_WAIT_FOR));
CU_ASSERT_TRUE(wait_for_list(lcs, &pauline->stat.number_of_LinphoneCallStatsUpdated,4,DEFAULT_WAIT_FOR));
CU_ASSERT_TRUE(linphone_call_get_audio_stats(call)->download_bandwidth>0);
CU_ASSERT_TRUE(linphone_call_get_video_stats(call)->download_bandwidth>0);
CU_ASSERT_TRUE(linphone_call_get_audio_stats(call)->upload_bandwidth<5);
CU_ASSERT_TRUE(linphone_call_get_video_stats(call)->upload_bandwidth<5);
check_media_direction(pauline,call,lcs,LinphoneMediaDirectionRecvOnly,LinphoneMediaDirectionRecvOnly);
}
}
static void accept_call_in_send_only(void) {
static void accept_call_in_send_base(bool_t caller_has_ice) {
int begin;
int leaked_objects;
LinphoneCoreManager *pauline, *marie;
......@@ -2971,6 +2951,10 @@ static void accept_call_in_send_only(void) {
begin=belle_sip_object_get_object_count();
pauline = linphone_core_manager_new("pauline_rc");
if (caller_has_ice) {
linphone_core_set_stun_server(pauline->lc,"stun.linphone.org");
linphone_core_set_firewall_policy(pauline->lc,LinphonePolicyUseIce);
}
marie = linphone_core_manager_new("marie_rc");
lcs=ms_list_append(lcs,pauline->lc);
......@@ -2978,19 +2962,31 @@ static void accept_call_in_send_only(void) {
accept_call_in_send_only_base(pauline,marie,lcs);
end_call(marie,pauline);
ms_free(lcs);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
leaked_objects=belle_sip_object_get_object_count()-begin;
CU_ASSERT_TRUE(leaked_objects==0);
if (leaked_objects>0){
belle_sip_object_dump_active_objects();
}
end_call(marie,pauline);
ms_free(lcs);
linphone_core_manager_destroy(marie);
linphone_core_manager_destroy(pauline);
}
static void accept_call_in_send_only(void) {
accept_call_in_send_base(FALSE);
}
void two_accept_call_in_send_only() {
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() {
int begin;
int leaked_objects;
LinphoneCoreManager *pauline, *marie, *laure;
......@@ -3839,7 +3835,8 @@ test_t call_tests[] = {
{ "DTLS SRTP ice video call with relay",dtls_srtp_ice_video_call_with_relay},
{ "Video call with limited bandwidth", video_call_limited_bandwidth},
{ "Video call accepted in send only", accept_call_in_send_only},
{ "2 Video call accepted in send only", two_accept_call_in_send_only},
{ "Video call accepted in send only with ice", accept_call_in_send_only_with_ice},
{ "2 Video call accepted in send only", two_accepted_call_in_send_only},
{ "Video call with re-invite(inactive) followed by re-invite", video_call_with_re_invite_inactive_followed_by_re_invite},
{ "Video call with re-invite(inactive) followed by re-invite(no sdp)", video_call_with_re_invite_inactive_followed_by_re_invite_no_sdp},
#endif
......
......@@ -197,10 +197,14 @@ static void profile_call_base(bool_t avpf1, LinphoneMediaEncryption srtp1,bool_t
CU_ASSERT_TRUE(call(marie, pauline));
CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallStreamsRunning, 1));
CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &pauline->stat.number_of_LinphoneCallStreamsRunning, 1));
params = linphone_call_get_current_params(linphone_core_get_current_call(marie->lc));
CU_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), expected_profile);
params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc));
CU_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), expected_profile);
if (linphone_core_get_current_call(marie->lc)) {
params = linphone_call_get_current_params(linphone_core_get_current_call(marie->lc));
CU_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), expected_profile);
}
if (linphone_core_get_current_call(pauline->lc)) {
params = linphone_call_get_current_params(linphone_core_get_current_call(pauline->lc));
CU_ASSERT_STRING_EQUAL(linphone_call_params_get_rtp_profile(params), expected_profile);
}
linphone_core_terminate_all_calls(marie->lc);
CU_ASSERT_TRUE(wait_for(marie->lc, pauline->lc, &marie->stat.number_of_LinphoneCallEnd, 1));
......
......@@ -30,7 +30,7 @@ video_rtp_port=9410-9910
display=0
capture=0
show_local=0
size=vga
size=qcif
enabled=0
self_view=0
automatically_initiate=0
......
......@@ -39,7 +39,7 @@ video_rtp_port=28070-38000
display=0
capture=0
show_local=0
size=vga
size=qcif
enabled=0
self_view=0
automatically_initiate=0
......
......@@ -36,7 +36,7 @@ video_rtp_port=39072-49000
display=0
capture=0
show_local=0
size=vga
size=qcif
enabled=0
self_view=0
automatically_initiate=0
......
......@@ -19,7 +19,7 @@ EXTRA_DIST=xml2lpc_jni.cc lpc2xml_jni.cc
if BUILD_TOOLS
bin_PROGRAMS=xml2lpc_test lpc2xml_test lp-gen-wrappers
bin_PROGRAMS=xml2lpc_test lpc2xml_test lp-gen-wrappers auto_answer
xml2lpc_test_SOURCES=\
xml2lpc_test.c
......@@ -42,6 +42,11 @@ lp_gen_wrappers_SOURCES=genwrappers.cc \
lp_gen_wrappers_LDADD= \
$(LIBXML2_LIBS)
auto_answer_SOURCES=auto_answer.c
auto_answer_CFLAGS=$(COMMON_CFLAGS)
auto_answer_LDADD=\
$(top_builddir)/coreapi/liblinphone.la
endif
/*
linphone
Copyright (C) 2010 Belledonne Communications SARL
(simon.morlat@linphone.org)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef IN_LINPHONE
#include "linphonecore.h"
#else
#include "linphone/linphonecore.h"
#endif
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <signal.h>
static bool_t running=TRUE;
static void stop(int signum){
running=FALSE;
}
#ifndef PACKAGE_DATA_DIR
#define PACKAGE_DATA_DIR '.'
#endif
/*
* Call state notification callback
*/
static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg){
switch(cstate){
case LinphoneCallIncomingReceived:
printf("Incoming call arrive !\n");
/* accept the incoming call*/
LinphoneCallParams * call_params = linphone_core_create_default_call_parameters(lc);
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);
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:
printf("Unhandled notification %i\n",cstate);
}
}
extern MSWebCamDesc mire_desc;
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 ;
}
int main(int argc, char *argv[]){
LinphoneCoreVTable vtable={0};
LinphoneCore *lc;
LinphoneVideoPolicy policy;
int i;
policy.automatically_accept=TRUE;
LinphoneAddress *addr=NULL;
LCSipTransports tp;
char * tmp = NULL;
signal(SIGINT,stop);
for(i = 1; i < argc; ++i) {
if (strcmp(argv[i], "--verbose") == 0) {
linphone_core_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL);
} else if (strcmp(argv[i], "--listening-uri") == 0){
addr = linphone_address_new(argv[++i]);
if (!addr) {
printf("Error, bad sip uri");
helper();
}
switch(linphone_address_get_transport(addr)) {
case LinphoneTransportUdp:
case LinphoneTransportTcp:
break;
default:
printf("Error, bad sip uri [%s] transport, should be udp | tcp",argv[i]);
helper();
break;
}
} else {
helper();
}
}
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;
/*
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);
/*instead of using sound capture card, a file is played to the calling party*/
linphone_core_set_play_file(lc,PACKAGE_DATA_DIR "/sounds/linphone/hello16000.wav");
linphone_core_set_use_files(lc,TRUE);
ms_web_cam_manager_add_cam(ms_web_cam_manager_get(),ms_web_cam_new(&mire_desc));
linphone_core_set_video_device(lc,"Mire: Mire (synthetic moving picture)");
if (!addr) {
addr = linphone_address_new("sip:bot@localhost:5060");
}
memset(&tp,0,sizeof(LCSipTransports));
switch(linphone_address_get_transport(addr)) {
case LinphoneTransportUdp:
tp.udp_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_primary_contact(lc,tmp=linphone_address_as_string(addr));
ms_free(tmp);
/* main loop for receiving notifications and doing background linphonecore work: */
while(running){
linphone_core_iterate(lc);
ms_usleep(50000);
}
printf("Shutting down...\n");
linphone_core_destroy(lc);
printf("Exited\n");
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