/*prevent a gcc bug with %c*/
static size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm){
-#if !defined(_WIN32_WCE)
return strftime(s, max, fmt, tm);
-#else
- return 0;
- /*FIXME*/
-#endif /*_WIN32_WCE*/
}
static void set_call_log_date(LinphoneCallLog *cl, time_t start_time){
set_call_log_date(cl,cl->start_date_time);
cl->from=from;
cl->to=to;
- cl->status=LinphoneCallAborted; /*default status*/
+ cl->status=LinphoneCallAborted; /*default status*/
+ cl->quality=-1;
return cl;
}
float linphone_call_log_get_quality(LinphoneCallLog *cl){
return cl->quality;
}
-
+/**
+ * return true if video was enabled at the end of the call
+ */
+LinphoneCallStatus linphone_call_log_video_enabled(LinphoneCallLog *cl) {
+ return cl->video_enabled;
+}
/** @} */
void linphone_call_log_destroy(LinphoneCallLog *cl){
return linphone_call_get_remote_address(call);
}
+void linphone_core_set_log_handler(OrtpLogFunc logfunc) {
+ ortp_set_log_handler(logfunc);
+}
+
+void linphone_core_set_log_file(FILE *file) {
+ if (file == NULL) file = stdout;
+ ortp_set_log_file(file);
+}
+
+void linphone_core_set_log_level(OrtpLogLevel loglevel) {
+ ortp_set_log_level_mask(loglevel);
+}
+
/**
* Enable logs in supplied FILE*.
*
* @ingroup misc
+ * @deprecated Use #linphone_core_set_log_file and #linphone_core_set_log_level instead.
*
* @param file a C FILE* where to fprintf logs. If null stdout is used.
*
* Enable logs through the user's supplied log callback.
*
* @ingroup misc
+ * @deprecated Use #linphone_core_set_log_handler and #linphone_core_set_log_level instead.
*
* @param logfunc The address of a OrtpLogFunc callback whose protoype is
* typedef void (*OrtpLogFunc)(OrtpLogLevel lev, const char *fmt, va_list args);
* Entirely disable logging.
*
* @ingroup misc
+ * @deprecated Use #linphone_core_set_log_level instead.
**/
void linphone_core_disable_logs(){
ortp_set_log_level_mask(ORTP_ERROR|ORTP_FATAL);
linphone_core_set_firewall_policy(lc,tmp);
tmp=lp_config_get_int(lc->config,"net","nat_sdp_only",0);
lc->net_conf.nat_sdp_only=tmp;
- tmp=lp_config_get_int(lc->config,"net","mtu",0);
+ tmp=lp_config_get_int(lc->config,"net","mtu",1300);
linphone_core_set_mtu(lc,tmp);
tmp=lp_config_get_int(lc->config,"net","download_ptime",0);
linphone_core_set_download_ptime(lc,tmp);
int ipv6;
int random_port;
- tmp=lp_config_get_int(lc->config,"sip","use_info",0);
- linphone_core_set_use_info_for_dtmf(lc,tmp);
-
if (lp_config_get_int(lc->config,"sip","use_session_timers",0)==1){
sal_use_session_timers(lc->sal,200);
}
sal_reuse_authorization(lc->sal, lp_config_get_int(lc->config,"sip","reuse_authorization",0));
sal_expire_old_registration_contacts(lc->sal,lp_config_get_int(lc->config,"sip","expire_old_registration_contacts",0));
- tmp=lp_config_get_int(lc->config,"sip","use_rfc2833",1);
- linphone_core_set_use_rfc2833_for_dtmf(lc,tmp);
-
ipv6=lp_config_get_int(lc->config,"sip","use_ipv6",-1);
if (ipv6==-1){
ipv6=0;
tmp=lp_config_get_int(lc->config,"sip","in_call_timeout",0);
linphone_core_set_in_call_timeout(lc,tmp);
+
+ tmp=lp_config_get_int(lc->config,"sip","delayed_timeout",4);
+ linphone_core_set_delayed_timeout(lc,tmp);
/* get proxies config */
for(i=0;; i++){
linphone_core_enable_audio_adaptive_jittcomp(lc, adaptive_jitt_comp_enabled);
adaptive_jitt_comp_enabled = lp_config_get_int(lc->config, "rtp", "video_adaptive_jitt_comp_enabled", TRUE);
linphone_core_enable_video_adaptive_jittcomp(lc, adaptive_jitt_comp_enabled);
+ lc->rtp_conf.disable_upnp = lp_config_get_int(lc->config, "rtp", "disable_upnp", FALSE);
}
static PayloadType * find_payload(RtpProfile *prof, const char *mime_type, int clock_rate, int channels, const char *recv_fmtp){
}
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);
- lc->max_calls=lp_config_get_int(config,"misc","max_calls",NB_MAX_CALLS);
+ lc->max_call_logs=lp_config_get_int(config,"misc","history_max_size",15);
+ lc->max_calls=lp_config_get_int(config,"misc","max_calls",NB_MAX_CALLS);
}
-static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vtable, const char *config_path,
- const char *factory_config_path, void * userdata)
+static void linphone_core_init (LinphoneCore * lc, const LinphoneCoreVTable *vtable, LpConfig *config, void * userdata)
{
ms_message("Initializing LinphoneCore %s", linphone_core_get_version());
memset (lc, 0, sizeof (LinphoneCore));
+ lc->config=config;
lc->data=userdata;
lc->ringstream_autorelease=TRUE;
linphone_core_assign_payload_type(lc,&payload_type_silk_wb,-1,NULL);
linphone_core_assign_payload_type(lc,&payload_type_silk_swb,-1,NULL);
linphone_core_assign_payload_type(lc,&payload_type_g729,18,"annexb=no");
+ linphone_core_assign_payload_type(lc,&payload_type_aaceld_22k,-1,"config=F8EE2000; constantDuration=512; indexDeltaLength=3; indexLength=3; mode=AAC-hbr; profile-level-id=76; sizeLength=13; streamType=5");
+ linphone_core_assign_payload_type(lc,&payload_type_aaceld_44k,-1,"config=F8E82000; constantDuration=512; indexDeltaLength=3; indexLength=3; mode=AAC-hbr; profile-level-id=76; sizeLength=13; streamType=5");
linphone_core_handle_static_payloads(lc);
ms_init();
lc->msevq=ms_event_queue_new();
ms_set_global_event_queue(lc->msevq);
- lc->config=lp_config_new(config_path);
- if (factory_config_path)
- lp_config_read_file(lc->config,factory_config_path);
-
lc->sal=sal_init();
sal_set_user_pointer(lc->sal,lc);
sal_set_callbacks(lc->sal,&linphone_sal_callbacks);
* It is OPTIONAL, use NULL if unneeded.
* @param userdata an opaque user pointer that can be retrieved at any time (for example in
* callbacks) using linphone_core_get_user_data().
- *
+ * @see linphone_core_new_with_config
**/
LinphoneCore *linphone_core_new(const LinphoneCoreVTable *vtable,
const char *config_path, const char *factory_config_path, void * userdata)
{
- LinphoneCore *core=ms_new(LinphoneCore,1);
- linphone_core_init(core,vtable,config_path, factory_config_path, userdata);
+ LpConfig *config = lp_config_new_with_factory(config_path, factory_config_path);
+ return linphone_core_new_with_config(vtable, config, userdata);
+}
+
+LinphoneCore *linphone_core_new_with_config(const LinphoneCoreVTable *vtable, struct _LpConfig *config, void *userdata)
+{
+ LinphoneCore *core = ms_new(LinphoneCore, 1);
+ linphone_core_init(core, vtable, config, userdata);
return core;
}
**/
bool_t linphone_core_get_use_info_for_dtmf(LinphoneCore *lc)
{
- return lc->sip_conf.use_info;
+ return lp_config_get_int(lc->config, "sip", "use_info", 0);
}
/**
**/
void linphone_core_set_use_info_for_dtmf(LinphoneCore *lc,bool_t use_info)
{
- lc->sip_conf.use_info=use_info;
+ if (linphone_core_ready(lc)) {
+ lp_config_set_int(lc->config, "sip", "use_info", use_info);
+ }
}
/**
**/
bool_t linphone_core_get_use_rfc2833_for_dtmf(LinphoneCore *lc)
{
- return lc->sip_conf.use_rfc2833;
+ return lp_config_get_int(lc->config, "sip", "use_rfc2833", 1);
}
/**
**/
void linphone_core_set_use_rfc2833_for_dtmf(LinphoneCore *lc,bool_t use_rfc2833)
{
- lc->sip_conf.use_rfc2833=use_rfc2833;
+ if (linphone_core_ready(lc)) {
+ lp_config_set_int(lc->config, "sip", "use_rfc2833", use_rfc2833);
+ }
}
/**
lc->ecc->cb(lc,ecs,lc->ecc->delay,lc->ecc->cb_data);
if (ecs==LinphoneEcCalibratorDone){
int len=lp_config_get_int(lc->config,"sound","ec_tail_len",0);
- lp_config_set_int(lc->config, "sound", "ec_delay",MAX(lc->ecc->delay-(len/2),0));
+ int margin=len/2;
+
+ lp_config_set_int(lc->config, "sound", "ec_delay",MAX(lc->ecc->delay-margin,0));
} else if (ecs == LinphoneEcCalibratorFailed) {
- lp_config_set_int(lc->config, "sound", "ec_delay", LP_CONFIG_DEFAULT_INT(lc->config, "ec_delay", 250));
+ lp_config_set_int(lc->config, "sound", "ec_delay", -1);/*use default value from soundcard*/
} else if (ecs == LinphoneEcCalibratorDoneNoEcho) {
linphone_core_enable_echo_cancellation(lc, FALSE);
}
linphone_core_start_invite() */
calls=calls->next;
linphone_call_background_tasks(call,one_second_elapsed);
- if (call->state==LinphoneCallOutgoingInit && (elapsed>=4)){
+ if (call->state==LinphoneCallOutgoingInit && (elapsed>=lc->sip_conf.delayed_timeout)){
/*start the call even if the OPTIONS reply did not arrive*/
if (call->ice_session != NULL) {
ms_warning("ICE candidates gathering from [%s] has not finished yet, proceed with the call without ICE anyway."
if (call->state==LinphoneCallIncomingReceived){
ms_message("incoming call ringing for %i seconds",elapsed);
if (elapsed>lc->sip_conf.inc_timeout){
+ LinphoneReason decline_reason;
ms_message("incoming call timeout (%i)",lc->sip_conf.inc_timeout);
+ decline_reason=lc->current_call ? LinphoneReasonBusy : LinphoneReasonDeclined;
call->log->status=LinphoneCallMissed;
call->reason=LinphoneReasonNotAnswered;
- linphone_core_terminate_call(lc,call);
+ linphone_core_decline_call(lc,call,decline_reason);
}
}
if (lc->sip_conf.in_call_timeout > 0 && elapsed>lc->sip_conf.in_call_timeout) {
lc->initial_subscribes_sent=TRUE;
}
- if (one_second_elapsed && lp_config_needs_commit(lc->config)){
- lp_config_sync(lc->config);
+ if (one_second_elapsed) {
+ if (lp_config_needs_commit(lc->config)) {
+ lp_config_sync(lc->config);
+ }
}
}
}
if (call->dest_proxy==NULL && lc->sip_conf.ping_with_options==TRUE){
- /*defer the start of the call after the OPTIONS ping*/
- call->ping_replied=FALSE;
- call->ping_op=sal_op_new(lc->sal);
- sal_ping(call->ping_op,from,real_url);
- sal_op_set_user_pointer(call->ping_op,call);
- call->start_time=time(NULL);
- }else{
- if (defer==FALSE) linphone_core_start_invite(lc,call);
+#ifdef BUILD_UPNP
+ if (lc->upnp != NULL && linphone_core_get_firewall_policy(lc)==LinphonePolicyUseUpnp &&
+ linphone_upnp_context_get_state(lc->upnp) == LinphoneUpnpStateOk) {
+#else //BUILD_UPNP
+ {
+#endif //BUILD_UPNP
+ /*defer the start of the call after the OPTIONS ping*/
+ call->ping_replied=FALSE;
+ call->ping_op=sal_op_new(lc->sal);
+ sal_ping(call->ping_op,from,real_url);
+ sal_op_set_user_pointer(call->ping_op,call);
+ call->start_time=time(NULL);
+ defer = TRUE;
+ }
}
+
+ if (defer==FALSE) linphone_core_start_invite(lc,call);
if (real_url!=NULL) ms_free(real_url);
return call;
}else{
/* else play a tone within the context of the current call */
call->ringing_beep=TRUE;
- linphone_core_play_tone(lc);
+ linphone_core_play_named_tone(lc,LinphoneToneCallWaiting);
}
linphone_call_set_state(call,LinphoneCallIncomingReceived,"Incoming call");
}
#endif //BUILD_UPNP
}
-
- call->params = *params;
+
+ _linphone_call_params_copy(&call->params,params);
linphone_call_make_local_media_description(lc, call);
// Video adding
*
* @ingroup call_control
**/
-LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc)
-{
+LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc){
return lc->current_call;
}
*
* @ingroup call_control
**/
-int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call)
+int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call){
+ int err=_linphone_core_pause_call(lc,call);
+ if (err==0) call->paused_by_app=TRUE;
+ return err;
+}
+
+/* Internal version that does not play tone indication*/
+int _linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call)
{
const char *subject=NULL;
lc->vtable.display_status(lc,_("Pausing the current call..."));
if (call->audiostream || call->videostream)
linphone_call_stop_media_streams (call);
+ call->paused_by_app=FALSE;
return 0;
}
LinphoneCall *call=(LinphoneCall *)elem->data;
LinphoneCallState cs=linphone_call_get_state(call);
if (cs==LinphoneCallStreamsRunning || cs==LinphoneCallPausedByRemote){
- linphone_core_pause_call(lc,call);
+ _linphone_core_pause_call(lc,call);
}
}
return 0;
current_call=linphone_core_get_current_call(lc);
if(current_call != NULL){
ms_message("Pausing automatically the current call.");
- linphone_core_pause_call(lc,current_call);
+ _linphone_core_pause_call(lc,current_call);
+ }
+ if (lc->ringstream){
+ ring_stop(lc->ringstream);
+ lc->ringstream=NULL;
}
}
return lc->sip_conf.in_call_timeout;
}
+/**
+ * Returns the delayed timeout
+ *
+ * @ingroup call_control
+ * See linphone_core_set_delayed_timeout() for details.
+**/
+int linphone_core_get_delayed_timeout(LinphoneCore *lc){
+ return lc->sip_conf.delayed_timeout;
+}
+
+/**
+ * Set the in delayed timeout in seconds.
+ *
+ * @ingroup call_control
+ * After this timeout period, a delayed call (internal call initialisation or resolution) is resumed.
+**/
+void linphone_core_set_delayed_timeout(LinphoneCore *lc, int seconds){
+ lc->sip_conf.delayed_timeout=seconds;
+}
+
void linphone_core_set_presence_info(LinphoneCore *lc,int minutes_away,
const char *contact,
LinphoneOnlineStatus presence_mode)
ms_warning("UPNP is not available, reset firewall policy to no firewall");
pol = LinphonePolicyNoFirewall;
}
-#else //BUILD_UPNP
+#endif //BUILD_UPNP
+ lc->net_conf.firewall_policy=pol;
+#ifdef BUILD_UPNP
if(pol == LinphonePolicyUseUpnp) {
if(lc->upnp == NULL) {
lc->upnp = linphone_upnp_context_new(lc);
linphone_upnp_context_destroy(lc->upnp);
lc->upnp = NULL;
}
- }
+ }
+ linphone_core_enable_keep_alive(lc, (lc->sip_conf.keepalive_period > 0));
#endif //BUILD_UPNP
- lc->net_conf.firewall_policy=pol;
if (lc->sip_conf.contact) update_primary_contact(lc);
if (linphone_core_ready(lc))
lp_config_set_int(lc->config,"net","firewall_policy",pol);
*
**/
void linphone_core_set_device_rotation(LinphoneCore *lc, int rotation) {
-ms_message("%s : rotation=%d\n", __FUNCTION__, rotation);
+ ms_message("%s : rotation=%d\n", __FUNCTION__, rotation);
lc->device_rotation = rotation;
#ifdef VIDEO_ENABLED
LinphoneCall *call=linphone_core_get_current_call(lc);
else ms_filter_call_method(f, MS_DTMF_GEN_START, &dtmf);
}
-/**
- * @ingroup media_parameters
- * Plays a repeated tone to the local user until next further call to #linphone_core_stop_dtmf()
- * @param lc #LinphoneCore
-**/
-void linphone_core_play_tone(LinphoneCore *lc){
- MSFilter *f=get_dtmf_gen(lc);
- MSDtmfGenCustomTone def;
- if (f==NULL){
- ms_error("No dtmf generator at this time !");
- return;
+void linphone_core_play_named_tone(LinphoneCore *lc, LinphoneToneID toneid){
+ if (linphone_core_tone_indications_enabled(lc)){
+ MSFilter *f=get_dtmf_gen(lc);
+ MSDtmfGenCustomTone def;
+ if (f==NULL){
+ ms_error("No dtmf generator at this time !");
+ return;
+ }
+ memset(&def,0,sizeof(def));
+ def.amplitude=1;
+ /*these are french tones, excepted the failed one, which is USA congestion tone (does not exist in France)*/
+ switch(toneid){
+ case LinphoneToneCallOnHold:
+ case LinphoneToneCallWaiting:
+ def.duration=300;
+ def.frequencies[0]=440;
+ def.interval=2000;
+ break;
+ case LinphoneToneBusy:
+ def.duration=500;
+ def.frequencies[0]=440;
+ def.interval=500;
+ def.repeat_count=3;
+ break;
+ case LinphoneToneCallFailed:
+ def.duration=250;
+ def.frequencies[0]=480;
+ def.frequencies[0]=620;
+ def.interval=250;
+ def.repeat_count=3;
+
+ break;
+ default:
+ ms_warning("Unhandled tone id.");
+ }
+ if (def.duration>0)
+ ms_filter_call_method(f, MS_DTMF_GEN_PLAY_CUSTOM,&def);
}
- def.duration=300;
- def.frequency=500;
- def.amplitude=1;
- def.interval=2000;
- ms_filter_call_method(f, MS_DTMF_GEN_PLAY_CUSTOM,&def);
}
/**
lp_config_set_string(lc->config,"sip","contact",config->contact);
lp_config_set_int(lc->config,"sip","inc_timeout",config->inc_timeout);
lp_config_set_int(lc->config,"sip","in_call_timeout",config->in_call_timeout);
- lp_config_set_int(lc->config,"sip","use_info",config->use_info);
- lp_config_set_int(lc->config,"sip","use_rfc2833",config->use_rfc2833);
+ lp_config_set_int(lc->config,"sip","delayed_timeout",config->delayed_timeout);
lp_config_set_int(lc->config,"sip","use_ipv6",config->ipv6_enabled);
lp_config_set_int(lc->config,"sip","register_only_when_network_is_up",config->register_only_when_network_is_up);
lp_config_set_int(lc->config,"sip","register_only_when_upnp_is_ok",config->register_only_when_upnp_is_ok);
usleep(50000);
#endif
}
-
#ifdef BUILD_UPNP
if(lc->upnp != NULL) {
linphone_upnp_context_destroy(lc->upnp);
ms_list_for_each(lc->last_recv_msg_ids,ms_free);
lc->last_recv_msg_ids=ms_list_free(lc->last_recv_msg_ids);
+
+ // Free struct variable
+ if(lc->zrtp_secrets_cache != NULL) {
+ ms_free(lc->zrtp_secrets_cache);
+ }
+ if(lc->play_file!=NULL){
+ ms_free(lc->play_file);
+ }
+ if(lc->rec_file!=NULL){
+ ms_free(lc->rec_file);
+ }
linphone_core_free_payload_types(lc);
+
+ linphone_core_message_storage_close(lc);
ortp_exit();
linphone_core_set_state(lc,LinphoneGlobalOff,"Off");
#ifdef TUNNEL_ENABLED
}
lc->netup_time=curtime;
lc->network_reachable=isReachable;
+
if(!isReachable) {
sal_reset_transports(lc->sal);
}
+#ifdef BUILD_UPNP
+ if(lc->upnp == NULL) {
+ if(isReachable && lc->net_conf.firewall_policy == LinphonePolicyUseUpnp) {
+ lc->upnp = linphone_upnp_context_new(lc);
+ }
+ } else {
+ if(!isReachable && lc->net_conf.firewall_policy == LinphonePolicyUseUpnp) {
+ linphone_upnp_context_destroy(lc->upnp);
+ lc->upnp = NULL;
+ }
+ }
+#endif
}
void linphone_core_refresh_registers(LinphoneCore* lc) {
* Enables signaling keep alive
*/
void linphone_core_enable_keep_alive(LinphoneCore* lc,bool_t enable) {
+#ifdef BUILD_UPNP
+ if (linphone_core_get_firewall_policy(lc)==LinphonePolicyUseUpnp) {
+ enable = FALSE;
+ }
+#endif //BUILD_UPNP
if (enable > 0) {
sal_use_tcp_tls_keepalive(lc->sal,lc->sip_conf.tcp_tls_keepalive);
sal_set_keepalive_period(lc->sal,lc->sip_conf.keepalive_period);
int linphone_core_get_video_dscp(const LinphoneCore *lc){
return lp_config_get_int(lc->config,"rtp","video_dscp",0x2e);
}
+
+
+/**
+ * Sets the database filename where chat messages will be stored.
+ * If the file does not exist, it will be created.
+ * @ingroup initializing
+ * @param lc the linphone core
+ * @param path filesystem path
+**/
+void linphone_core_set_chat_database_path(LinphoneCore *lc, const char *path){
+ if (lc->chat_db_file){
+ ms_free(lc->chat_db_file);
+ lc->chat_db_file=NULL;
+ }
+ if (path) {
+ lc->chat_db_file=ms_strdup(path);
+ linphone_core_message_storage_init(lc);
+ }
+}
+
+