X-Git-Url: http://sjero.net/git/?a=blobdiff_plain;f=coreapi%2Flinphonecore.c;h=f4782908aa15e0962c07627b82b35593814bba39;hb=9f58698136035018a6dbc34a6c449de762f89232;hp=d9d199c3f95102cf8e43d4693e4dd71fb95a24dd;hpb=b8eff5b034d157bbbc9d7d641e8c37bd6470111a;p=linphone diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index d9d199c3..f4782908 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -92,12 +92,7 @@ int lc_callback_obj_invoke(LCCallbackObj *obj, LinphoneCore *lc){ /*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){ @@ -120,7 +115,8 @@ LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *fro 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; } @@ -371,7 +367,12 @@ int linphone_call_log_get_duration(LinphoneCallLog *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){ @@ -463,7 +464,7 @@ static void net_config_read (LinphoneCore *lc) 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); @@ -751,6 +752,7 @@ static void rtp_config_read(LinphoneCore *lc) 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){ @@ -2116,10 +2118,12 @@ void linphone_core_iterate(LinphoneCore *lc){ 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) { @@ -2753,7 +2757,7 @@ void linphone_core_notify_incoming_call(LinphoneCore *lc, LinphoneCall *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"); @@ -2834,8 +2838,8 @@ int linphone_core_update_call(LinphoneCore *lc, LinphoneCall *call, const Linpho } #endif //BUILD_UPNP } - - call->params = *params; + + _linphone_call_params_copy(&call->params,params); linphone_call_make_local_media_description(lc, call); // Video adding @@ -3304,8 +3308,7 @@ bool_t linphone_core_in_call(const LinphoneCore *lc){ * * @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; } @@ -3315,7 +3318,14 @@ LinphoneCall *linphone_core_get_current_call(const LinphoneCore *lc) * * @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; @@ -3353,6 +3363,7 @@ int linphone_core_pause_call(LinphoneCore *lc, LinphoneCall *call) 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; } @@ -3366,7 +3377,7 @@ int linphone_core_pause_all_calls(LinphoneCore *lc){ 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; @@ -3381,7 +3392,11 @@ void linphone_core_preempt_sound_resources(LinphoneCore *lc){ 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; } } @@ -4692,7 +4707,7 @@ int linphone_core_get_device_rotation(LinphoneCore *lc ) { * **/ 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); @@ -4904,13 +4919,54 @@ void linphone_core_play_tone(LinphoneCore *lc){ ms_error("No dtmf generator at this time !"); return; } + memset(&def,0,sizeof(def)); def.duration=300; - def.frequency=500; + def.frequencies[0]=500; def.amplitude=1; def.interval=2000; ms_filter_call_method(f, MS_DTMF_GEN_PLAY_CUSTOM,&def); } +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); + } +} + /** * @ingroup media_parameters * @@ -5262,6 +5318,8 @@ static void linphone_core_uninit(LinphoneCore *lc) } linphone_core_free_payload_types(lc); + + linphone_core_message_storage_close(lc); ortp_exit(); linphone_core_set_state(lc,LinphoneGlobalOff,"Off"); #ifdef TUNNEL_ENABLED @@ -5285,9 +5343,22 @@ static void set_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t cu } 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) { @@ -5779,3 +5850,24 @@ void linphone_core_set_video_dscp(LinphoneCore *lc, int dscp){ 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); + } +} + +