Merge branch 'master' of git.sv.gnu.org:/srv/git/linphone

Conflicts:
	mediastreamer2
This commit is contained in:
Simon Morlat 2011-05-24 15:56:24 +02:00
commit 165a0584fe
10 changed files with 88 additions and 52 deletions

View file

@ -211,13 +211,14 @@
<target name="all" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>all</buildTarget>
<buildTarget>install</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>false</useDefaultCommand>
<runAllBuilders>true</runAllBuilders>
</target>
<target name="install" path="" targetID="org.eclipse.cdt.build.MakeTargetBuilder">
<buildCommand>make</buildCommand>
<buildArguments/>
<buildTarget>install</buildTarget>
<stopOnError>true</stopOnError>
<useDefaultCommand>true</useDefaultCommand>

View file

@ -23,15 +23,18 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "mediastreamer2/mstonedetector.h"
#include "mediastreamer2/dtmfgen.h"
#include "lpconfig.h"
static void ecc_init_filters(EcCalibrator *ecc){
unsigned int rate;
ecc->ticker=ms_ticker_new();
ecc->sndread=ms_snd_card_create_reader(ecc->play_card);
ms_filter_call_method(ecc->sndread,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ecc->det=ms_filter_new(MS_TONE_DETECTOR_ID);
ms_filter_call_method(ecc->det,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ecc->rec=ms_filter_new(MS_FILE_REC_ID);
ms_filter_link(ecc->sndread,0,ecc->det,0);
@ -39,14 +42,17 @@ static void ecc_init_filters(EcCalibrator *ecc){
ecc->play=ms_filter_new(MS_FILE_PLAYER_ID);
ecc->gen=ms_filter_new(MS_DTMF_GEN_ID);
ms_filter_call_method(ecc->gen,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ecc->resampler=ms_filter_new(MS_RESAMPLE_ID);
ecc->sndwrite=ms_snd_card_create_writer(ecc->capt_card);
ms_filter_link(ecc->play,0,ecc->gen,0);
ms_filter_link(ecc->gen,0,ecc->resampler,0);
ms_filter_link(ecc->resampler,0,ecc->sndwrite,0);
unsigned int rate;
ms_filter_call_method(ecc->sndwrite,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->sndwrite,MS_FILTER_GET_SAMPLE_RATE,&rate);
ms_filter_call_method(ecc->resampler,MS_FILTER_SET_SAMPLE_RATE,&ecc->rate);
ms_filter_call_method(ecc->resampler,MS_FILTER_SET_OUTPUT_SAMPLE_RATE,&rate);
ms_ticker_attach(ecc->ticker,ecc->play);
@ -149,9 +155,10 @@ static void * ecc_thread(void *p){
return NULL;
}
EcCalibrator * ec_calibrator_new(MSSndCard *play_card, MSSndCard *capt_card, LinphoneEcCalibrationCallback cb, void *cb_data ){
EcCalibrator * ec_calibrator_new(MSSndCard *play_card, MSSndCard *capt_card, unsigned int rate, LinphoneEcCalibrationCallback cb, void *cb_data ){
EcCalibrator *ecc=ms_new0(EcCalibrator,1);
ecc->rate=rate;
ecc->cb=cb;
ecc->cb_data=cb_data;
ecc->capt_card=capt_card;
@ -174,6 +181,7 @@ int linphone_core_start_echo_calibration(LinphoneCore *lc, LinphoneEcCalibration
ms_error("Echo calibration is still on going !");
return -1;
}
lc->ecc=ec_calibrator_new(lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard,cb,cb_data);
unsigned int rate = lp_config_get_int(lc->config,"sound","echo_cancellation_rate",8000);
lc->ecc=ec_calibrator_new(lc->sound_conf.play_sndcard,lc->sound_conf.capt_sndcard,rate,cb,cb_data);
return 0;
}

View file

@ -228,19 +228,12 @@ LinphoneCall * linphone_call_new_incoming(LinphoneCore *lc, LinphoneAddress *fro
*/
static void linphone_call_set_terminated(LinphoneCall *call){
LinphoneCallStatus status=LinphoneCallAborted;
LinphoneCore *lc=call->core;
linphone_core_update_allocated_audio_bandwidth(lc);
if (call->state==LinphoneCallEnd){
if (call->reason==LinphoneReasonDeclined){
status=LinphoneCallDeclined;
}
else status=LinphoneCallSuccess;
}
call->owns_call_log=FALSE;
linphone_call_log_completed(call->log,call, status);
linphone_call_log_completed(call);
if (call == lc->current_call){
@ -320,8 +313,14 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
call->state=cstate;
}
if (cstate==LinphoneCallEnd || cstate==LinphoneCallError){
linphone_call_set_terminated (call);
if (call->reason==LinphoneReasonDeclined){
call->log->status=LinphoneCallDeclined;
}
linphone_call_set_terminated (call);
}
if (cstate == LinphoneCallConnected) {
call->log->status=LinphoneCallSuccess;
}
if (lc->vtable.call_state_changed)
lc->vtable.call_state_changed(lc,call,cstate,message);
@ -1179,3 +1178,35 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
linphone_core_disconnected(call->core,call);
}
void linphone_call_log_completed(LinphoneCall *call){
LinphoneCore *lc=call->core;
call->log->duration=time(NULL)-call->start_time;
if (call->log->status==LinphoneCallMissed){
char *info;
lc->missed_calls++;
info=ortp_strdup_printf(ngettext("You have missed %i call.",
"You have missed %i calls.", lc->missed_calls),
lc->missed_calls);
if (lc->vtable.display_status!=NULL)
lc->vtable.display_status(lc,info);
ms_free(info);
}
lc->call_logs=ms_list_prepend(lc->call_logs,(void *)call->log);
if (ms_list_size(lc->call_logs)>lc->max_call_logs){
MSList *elem,*prevelem=NULL;
/*find the last element*/
for(elem=lc->call_logs;elem!=NULL;elem=elem->next){
prevelem=elem;
}
elem=prevelem;
linphone_call_log_destroy((LinphoneCallLog*)elem->data);
lc->call_logs=ms_list_remove_link(lc->call_logs,elem);
}
if (lc->vtable.call_log_updated!=NULL){
lc->vtable.call_log_updated(lc,call->log);
}
call_logs_write_to_config_file(lc);
}

View file

@ -97,10 +97,11 @@ LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *fro
set_call_log_date(cl,&loctime);
cl->from=from;
cl->to=to;
cl->status=LinphoneCallAborted; /*default status*/
return cl;
}
static void call_logs_write_to_config_file(LinphoneCore *lc){
void call_logs_write_to_config_file(LinphoneCore *lc){
MSList *elem;
char logsection[32];
int i;
@ -156,37 +157,6 @@ static void call_logs_read_from_config_file(LinphoneCore *lc){
}
void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call, LinphoneCallStatus status){
LinphoneCore *lc=call->core;
calllog->duration=time(NULL)-call->start_time;
if (status==LinphoneCallMissed){
char *info;
lc->missed_calls++;
info=ortp_strdup_printf(ngettext("You have missed %i call.",
"You have missed %i calls.", lc->missed_calls),
lc->missed_calls);
if (lc->vtable.display_status!=NULL)
lc->vtable.display_status(lc,info);
ms_free(info);
}else calllog->status=status;
lc->call_logs=ms_list_prepend(lc->call_logs,(void *)calllog);
if (ms_list_size(lc->call_logs)>lc->max_call_logs){
MSList *elem,*prevelem=NULL;
/*find the last element*/
for(elem=lc->call_logs;elem!=NULL;elem=elem->next){
prevelem=elem;
}
elem=prevelem;
linphone_call_log_destroy((LinphoneCallLog*)elem->data);
lc->call_logs=ms_list_remove_link(lc->call_logs,elem);
}
if (lc->vtable.call_log_updated!=NULL){
lc->vtable.call_log_updated(lc,calllog);
}
call_logs_write_to_config_file(lc);
}
/**
* @addtogroup call_logs
@ -494,6 +464,7 @@ static void sip_config_read(LinphoneCore *lc)
}
sal_use_rport(lc->sal,lp_config_get_int(lc->config,"sip","use_rport",1));
sal_use_101(lc->sal,lp_config_get_int(lc->config,"sip","use_101",1));
tmp=lp_config_get_int(lc->config,"sip","use_rfc2833",0);
linphone_core_set_use_rfc2833_for_dtmf(lc,tmp);
@ -914,6 +885,10 @@ void linphone_core_set_state(LinphoneCore *lc, LinphoneGlobalState gstate, const
lc->vtable.global_state_changed(lc,gstate,message);
}
}
static void misc_config_read (LinphoneCore *lc) {
LpConfig *config=lc->config;
lc->max_call_logs=lp_config_get_int(config,"misc","history_max_size",15);
}
static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vtable, const char *config_path,
const char *factory_config_path, void * userdata)
@ -993,7 +968,7 @@ static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vta
video_config_read(lc);
//autoreplier_config_init(&lc->autoreplier_conf);
lc->presence_mode=LinphoneStatusOnline;
lc->max_call_logs=15;
misc_config_read(lc);
ui_config_read(lc);
if (lc->vtable.display_status)
lc->vtable.display_status(lc,_("Ready"));

View file

@ -108,7 +108,7 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const
/* private: */
LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *local, LinphoneAddress * remote);
void linphone_call_log_completed(LinphoneCallLog *calllog, LinphoneCall *call, LinphoneCallStatus status);
void linphone_call_log_completed(LinphoneCall *call);
void linphone_call_log_destroy(LinphoneCallLog *cl);
void linphone_auth_info_write_config(struct _LpConfig *config, LinphoneAuthInfo *obj, int pos);
@ -472,6 +472,7 @@ struct _EcCalibrator{
int sent_count;
int64_t acc;
int delay;
unsigned int rate;
LinphoneEcCalibratorStatus status;
};
@ -489,5 +490,5 @@ void linphone_call_background_tasks(LinphoneCall *call, bool_t one_second_elapse
#ifndef NB_MAX_CALLS
#define NB_MAX_CALLS (10)
#endif
void call_logs_write_to_config_file(LinphoneCore *lc);
#endif /* _PRIVATE_H */

View file

@ -263,6 +263,7 @@ void sal_use_session_timers(Sal *ctx, int expires);
void sal_use_double_registrations(Sal *ctx, bool_t enabled);
void sal_use_one_matching_codec_policy(Sal *ctx, bool_t one_matching_codec);
void sal_use_rport(Sal *ctx, bool_t use_rports);
void sal_use_101(Sal *ctx, bool_t use_101);
int sal_iterate(Sal *sal);
MSList * sal_get_pending_auths(Sal *sal);

View file

@ -274,6 +274,7 @@ Sal * sal_init(){
sal->keepalive_period=30;
sal->double_reg=TRUE;
sal->use_rports=TRUE;
sal->use_101=TRUE;
return sal;
}
@ -369,6 +370,9 @@ int sal_listen_port(Sal *ctx, const char *addr, int port, SalTransport tr, int i
/*see if it looks like an IPv6 address*/
int use_rports = ctx->use_rports; // Copy char to int to avoid bad alignment
eXosip_set_option(EXOSIP_OPT_USE_RPORT,&use_rports);
int dont_use_101 = !ctx->use_101; // Copy char to int to avoid bad alignment
eXosip_set_option(EXOSIP_OPT_DONT_SEND_101,&dont_use_101);
ipv6=strchr(addr,':')!=NULL;
eXosip_enable_ipv6(ipv6);
@ -417,7 +421,9 @@ void sal_use_double_registrations(Sal *ctx, bool_t enabled){
void sal_use_rport(Sal *ctx, bool_t use_rports){
ctx->use_rports=use_rports;
}
void sal_use_101(Sal *ctx, bool_t use_101){
ctx->use_101=use_101;
}
static int extract_received_rport(osip_message_t *msg, const char **received, int *rportval){
osip_via_t *via=NULL;
osip_generic_param_t *param=NULL;

View file

@ -43,6 +43,7 @@ struct Sal{
bool_t one_matching_codec;
bool_t double_reg;
bool_t use_rports;
bool_t use_101;
};
struct SalOp{

View file

@ -27,10 +27,21 @@ static void calibration_finished(LinphoneCore *lc, LinphoneEcCalibratorStatus st
if (status==LinphoneEcCalibratorDone) ms_message("Measured delay is %i",delay);
}
static char config_file[1024];
void parse_args(int argc, char *argv[]){
if (argc != 3 || strncmp("-c",argv[1], 2) || access(argv[2],F_OK)!=0) {
printf("Usage: test_ecc [-c config_file] where config_file will be written with the detected value\n");
exit(-1);
}
strncpy(config_file,argv[2],1024);
}
int main(int argc, char *argv[]){
if (argc>1) parse_args(argc,argv);
int count=0;
LinphoneCoreVTable vtable={0};
LinphoneCore *lc=linphone_core_new(&vtable,NULL,NULL,NULL);
LinphoneCore *lc=linphone_core_new(&vtable,config_file,NULL,NULL);
linphone_core_enable_logs(NULL);

View file

@ -34,6 +34,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# define _(String) gettext (String)
#else
# define _(String) (String)
# define ngettext(singular,plural,number) ((number>1) ? (plural) : (singular) )
#endif
#undef N_