diff --git a/.cproject b/.cproject index 3ab1fad71..63cf57632 100644 --- a/.cproject +++ b/.cproject @@ -22,7 +22,7 @@ - + @@ -35,221 +35,167 @@ + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - make - all - true - true - true - - - make - CFLAGS="-g" - install - true - true - true - - - make - CFLAGS="-g" - install - true - true - true - - - make - all - true - true - true - - - make - all - true - true - true - - - + + + + + + + make + all + true + true + true + + + make + CFLAGS="-g" + install + true + true + true + + + make + CFLAGS="-g" + install + true + true + true + + + make + all + true + true + true + + + make + all + true + true + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.project b/.project index 2fbbd2688..dcc5fd75c 100644 --- a/.project +++ b/.project @@ -23,7 +23,7 @@ org.eclipse.cdt.make.core.buildArguments - CFLAGS="-g -Werror -Wall" + CFLAGS="-g -Werror -Wall" CXXFLAGS="-g" org.eclipse.cdt.make.core.buildCommand diff --git a/Makefile.am b/Makefile.am index 62ef80a60..1126cbe26 100644 --- a/Makefile.am +++ b/Makefile.am @@ -230,4 +230,7 @@ clean-local: rm -rf $(BUNDLEDIR) discovery: touch specs.cpp - $(CC) $(CFLAGS) $(MEDIASTREAMER2_CFLAGS) $(ORTP_CFLAGS) -E -P -v -dD specs.cpp + $(CC) --include $(top_builddir)/config.h \ + --include $(top_builddir)/mediastreamer2/mediastreamer-config.h \ + --include $(top_builddir)/oRTP/ortp-config.h \ + $(TUNNEL_CFLAGS) $(CFLAGS) $(MEDIASTREAMER2_CFLAGS) $(ORTP_CFLAGS) -E -P -v -dD specs.cpp diff --git a/build/android/common.mk b/build/android/common.mk index 38b6c22cd..4fa833b59 100644 --- a/build/android/common.mk +++ b/build/android/common.mk @@ -43,19 +43,24 @@ LOCAL_SRC_FILES := \ callbacks.c \ linphonecall.c \ conference.c \ - ec-calibrator.c + ec-calibrator.c \ + linphone_tunnel.cc ifndef MY_LOG_DOMAIN MY_LOG_DOMAIN = \"Linphone\" endif +ifndef LINPHONE_VERSION +LINPHONE_VERSION = "Devel" +endif + LOCAL_CFLAGS += \ -D_BYTE_ORDER=_LITTLE_ENDIAN \ -DORTP_INET6 \ -DINET6 \ -DOSIP_MT \ -DENABLE_TRACE \ - -DLINPHONE_VERSION=\"3.4.0\" \ + -DLINPHONE_VERSION=\"$(LINPHONE_VERSION)\" \ -DLINPHONE_PLUGINS_DIR=\"\\tmp\" \ -DLOG_DOMAIN=$(MY_LOG_DOMAIN) @@ -91,7 +96,7 @@ LOCAL_STATIC_LIBRARIES := \ ifeq ($(BUILD_TUNNEL),1) LOCAL_CFLAGS +=-DTUNNEL_ENABLED LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../tunnel/include $(LOCAL_PATH)/../../tunnel/src -LOCAL_SRC_FILES += linphone_tunnel.cc TunnelManager.cc +LOCAL_SRC_FILES += TunnelManager.cc ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) LOCAL_SHARED_LIBRARIES += libtunnelclient else diff --git a/console/linphonec.c b/console/linphonec.c index 7d5c0cdd2..6220a0599 100644 --- a/console/linphonec.c +++ b/console/linphonec.c @@ -346,7 +346,7 @@ static void linphonec_call_state_changed(LinphoneCore *lc, LinphoneCall *call, L linphonec_out("Resuming call %i with %s.\n", id, from); break; case LinphoneCallStreamsRunning: - linphonec_out("Media streams established with %s for call %i.\n", from,id); + linphonec_out("Media streams established with %s for call %i (%s).\n", from,id,( linphone_call_params_video_enabled( linphone_call_get_current_params(call)) ? "video":"audio")); break; case LinphoneCallPausing: linphonec_out("Pausing call %i with %s.\n", id, from); diff --git a/coreapi/TunnelManager.cc b/coreapi/TunnelManager.cc index 44d12251c..e3c7e6595 100644 --- a/coreapi/TunnelManager.cc +++ b/coreapi/TunnelManager.cc @@ -31,15 +31,16 @@ Mutex TunnelManager::sMutex; int TunnelManager::eXosipSendto(int fd,const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen,void* userdata){ TunnelManager* lTunnelMgr=(TunnelManager*)userdata; - int err; + sMutex.lock(); if (lTunnelMgr->mSipSocket==NULL){ sMutex.unlock(); - return len;//let ignore the error + return len; } - err=lTunnelMgr->mSipSocket->sendto(buf,len,to,tolen); + lTunnelMgr->mSipSocket->sendto(buf,len,to,tolen); sMutex.unlock(); - return err; + //ignore the error in all cases, retransmissions might be successful. + return len; } int TunnelManager::eXosipRecvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen,void* userdata){ diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java index e7db170b8..58a75e56b 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialBuddyStatus.java @@ -98,6 +98,7 @@ public class TutorialBuddyStatus implements LinphoneCoreListener { public void callState(LinphoneCore lc, LinphoneCall call, State cstate, String msg) {} public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {} public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call,boolean encrypted, String authenticationToken) {} + public void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event){} public static void main(String[] args) { diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java index 5837876cb..c81823e8a 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialChatRoom.java @@ -76,6 +76,7 @@ public class TutorialChatRoom implements LinphoneCoreListener { public void callState(LinphoneCore lc, LinphoneCall call, State cstate, String msg){} public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {} public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call,boolean encrypted, String authenticationToken) {} + public void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event){} public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from, String message) { write("Message ["+message+"] received from ["+from.asString()+"]"); diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java index 30510fd84..6daa65711 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialHelloWorld.java @@ -70,7 +70,7 @@ public class TutorialHelloWorld implements LinphoneCoreListener { public void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from, String message) {} public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {} public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call,boolean encrypted, String authenticationToken) {} - + public void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event){} /* * Call state notification listener */ diff --git a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java index 8af45162c..674044471 100644 --- a/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java +++ b/coreapi/help/java/org/linphone/core/tutorials/TutorialRegistration.java @@ -81,6 +81,7 @@ public class TutorialRegistration implements LinphoneCoreListener { public void callState(LinphoneCore lc, LinphoneCall call, State cstate, String msg) {} public void ecCalibrationStatus(LinphoneCore lc, EcCalibratorStatus status,int delay_ms, Object data) {} public void callEncryptionChanged(LinphoneCore lc, LinphoneCall call,boolean encrypted, String authenticationToken) {} + public void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event){} public static void main(String[] args) { // Check tutorial was called with the right number of arguments diff --git a/coreapi/linphonecall.c b/coreapi/linphonecall.c index ac8460291..77fd9e20f 100644 --- a/coreapi/linphonecall.c +++ b/coreapi/linphonecall.c @@ -68,14 +68,6 @@ LinphoneCore *linphone_call_get_core(const LinphoneCall *call){ return call->core; } -const LinphoneCallStats *linphone_call_get_audio_stats(const LinphoneCall *call) { - return &call->stats[LINPHONE_CALL_STATS_AUDIO]; -} - -const LinphoneCallStats *linphone_call_get_video_stats(const LinphoneCall *call) { - return &call->stats[LINPHONE_CALL_STATS_VIDEO]; -} - const char* linphone_call_get_authentication_token(LinphoneCall *call){ return call->auth_token; } @@ -497,9 +489,10 @@ void linphone_call_set_state(LinphoneCall *call, LinphoneCallState cstate, const call->state=cstate; } if (cstate==LinphoneCallEnd || cstate==LinphoneCallError){ - switch(call->reason){ + switch(call->reason){ case LinphoneReasonDeclined: call->log->status=LinphoneCallDeclined; + break; case LinphoneReasonNotAnswered: call->log->status=LinphoneCallMissed; break; @@ -940,6 +933,8 @@ void linphone_call_init_media_streams(LinphoneCall *call){ audio_stream_enable_noise_gate(audiostream,enabled); } + audio_stream_set_features(audiostream,linphone_core_get_audio_features(lc)); + if (lc->rtptf){ RtpTransport *artp=lc->rtptf->audio_rtp_func(lc->rtptf->audio_rtp_func_data, call->audio_port); RtpTransport *artcp=lc->rtptf->audio_rtcp_func(lc->rtptf->audio_rtcp_func_data, call->audio_port+1); @@ -1518,7 +1513,7 @@ bool_t linphone_call_echo_limiter_enabled(const LinphoneCall *call){ **/ /** - * Returns the measured sound volume played locally (received from remote) + * Returns the measured sound volume played locally (received from remote). * It is expressed in dbm0. **/ float linphone_call_get_play_volume(LinphoneCall *call){ @@ -1533,7 +1528,7 @@ float linphone_call_get_play_volume(LinphoneCall *call){ } /** - * Returns the measured sound volume recorded locally (sent to remote) + * Returns the measured sound volume recorded locally (sent to remote). * It is expressed in dbm0. **/ float linphone_call_get_record_volume(LinphoneCall *call){ @@ -1583,6 +1578,21 @@ float linphone_call_get_average_quality(LinphoneCall *call){ return -1; } +/** + * Access last known statistics for audio stream, for a given call. +**/ +const LinphoneCallStats *linphone_call_get_audio_stats(const LinphoneCall *call) { + return &call->stats[LINPHONE_CALL_STATS_AUDIO]; +} + +/** + * Access last known statistics for video stream, for a given call. +**/ +const LinphoneCallStats *linphone_call_get_video_stats(const LinphoneCall *call) { + return &call->stats[LINPHONE_CALL_STATS_VIDEO]; +} + + /** * @} **/ diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index 41b9e2dda..62942726a 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -17,6 +17,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#define _GNU_SOURCE + #include "linphonecore.h" #include "sipsetup.h" #include "lpconfig.h" @@ -85,23 +87,24 @@ static size_t my_strftime(char *s, size_t max, const char *fmt, const struct t #endif /*_WIN32_WCE*/ } -static void set_call_log_date(LinphoneCallLog *cl, const struct tm *loctime){ - my_strftime(cl->start_date,sizeof(cl->start_date),"%c",loctime); +static void set_call_log_date(LinphoneCallLog *cl, time_t start_time){ + struct tm loctime; +#ifdef WIN32 +#if !defined(_WIN32_WCE) + loctime=*localtime(&start_time); + /*FIXME*/ +#endif /*_WIN32_WCE*/ +#else + localtime_r(&start_time,&loctime); +#endif + my_strftime(cl->start_date,sizeof(cl->start_date),"%c",&loctime); } LinphoneCallLog * linphone_call_log_new(LinphoneCall *call, LinphoneAddress *from, LinphoneAddress *to){ LinphoneCallLog *cl=ms_new0(LinphoneCallLog,1); - struct tm loctime; cl->dir=call->dir; -#ifdef WIN32 -#if !defined(_WIN32_WCE) - loctime=*localtime(&call->start_time); - /*FIXME*/ -#endif /*_WIN32_WCE*/ -#else - localtime_r(&call->start_time,&loctime); -#endif - set_call_log_date(cl,&loctime); + cl->start_date_time=call->start_time; + set_call_log_date(cl,cl->start_date_time); cl->from=from; cl->to=to; cl->status=LinphoneCallAborted; /*default status*/ @@ -120,6 +123,7 @@ void call_logs_write_to_config_file(LinphoneCore *lc){ for(i=0,elem=lc->call_logs;elem!=NULL;elem=elem->next,++i){ LinphoneCallLog *cl=(LinphoneCallLog*)elem->data; snprintf(logsection,sizeof(logsection),"call_log_%i",i); + lp_config_clean_section(cfg,logsection); lp_config_set_int(cfg,logsection,"dir",cl->dir); lp_config_set_int(cfg,logsection,"status",cl->status); tmp=linphone_address_as_string(cl->from); @@ -128,11 +132,13 @@ void call_logs_write_to_config_file(LinphoneCore *lc){ tmp=linphone_address_as_string(cl->to); lp_config_set_string(cfg,logsection,"to",tmp); ms_free(tmp); - lp_config_set_string(cfg,logsection,"start_date",cl->start_date); + if (cl->start_date_time) + lp_config_set_int64(cfg,logsection,"start_date_time",(int64_t)cl->start_date_time); + else lp_config_set_string(cfg,logsection,"start_date",cl->start_date); lp_config_set_int(cfg,logsection,"duration",cl->duration); if (cl->refkey) lp_config_set_string(cfg,logsection,"refkey",cl->refkey); lp_config_set_float(cfg,logsection,"quality",cl->quality); - lp_config_set_int(cfg,logsection,"video_enabled", cl->video_enabled); + lp_config_set_int(cfg,logsection,"video_enabled", cl->video_enabled); } for(;imax_call_logs;++i){ snprintf(logsection,sizeof(logsection),"call_log_%i",i); @@ -140,10 +146,21 @@ void call_logs_write_to_config_file(LinphoneCore *lc){ } } +static time_t string_to_time(const char *date){ +#ifndef WIN32 + struct tm tmtime={0}; + strptime(date,"%c",&tmtime); + return mktime(&tmtime); +#else + return 0; +#endif +} + static void call_logs_read_from_config_file(LinphoneCore *lc){ char logsection[32]; int i; const char *tmp; + uint64_t sec; LpConfig *cfg=lc->config; for(i=0;;++i){ snprintf(logsection,sizeof(logsection),"call_log_%i",i); @@ -155,13 +172,23 @@ static void call_logs_read_from_config_file(LinphoneCore *lc){ if (tmp) cl->from=linphone_address_new(tmp); tmp=lp_config_get_string(cfg,logsection,"to",NULL); if (tmp) cl->to=linphone_address_new(tmp); - tmp=lp_config_get_string(cfg,logsection,"start_date",NULL); - if (tmp) strncpy(cl->start_date,tmp,sizeof(cl->start_date)); + sec=lp_config_get_int64(cfg,logsection,"start_date_time",0); + if (sec) { + /*new call log format with date expressed in seconds */ + cl->start_date_time=(time_t)sec; + set_call_log_date(cl,cl->start_date_time); + }else{ + tmp=lp_config_get_string(cfg,logsection,"start_date",NULL); + if (tmp) { + strncpy(cl->start_date,tmp,sizeof(cl->start_date)); + cl->start_date_time=string_to_time(cl->start_date); + } + } cl->duration=lp_config_get_int(cfg,logsection,"duration",0); tmp=lp_config_get_string(cfg,logsection,"refkey",NULL); if (tmp) cl->refkey=ms_strdup(tmp); cl->quality=lp_config_get_float(cfg,logsection,"quality",-1); - cl->video_enabled=lp_config_get_int(cfg,logsection,"video_enabled",0); + cl->video_enabled=lp_config_get_int(cfg,logsection,"video_enabled",0); lc->call_logs=ms_list_append(lc->call_logs,cl); }else break; } @@ -458,6 +485,9 @@ static void sound_config_read(LinphoneCore *lc) linphone_core_set_playback_gain_db (lc,gain); linphone_core_set_remote_ringback_tone (lc,lp_config_get_string(lc->config,"sound","ringback_tone",NULL)); + + /*just parse requested stream feature once at start to print out eventual errors*/ + linphone_core_get_audio_features(lc); } static void sip_config_read(LinphoneCore *lc) @@ -505,10 +535,13 @@ static void sip_config_read(LinphoneCore *lc) if (tr.udp_port>0 && random_port){ tr.udp_port=random_port; + tr.tls_port=tr.tcp_port=0; /*make sure only one transport is active at a time*/ }else if (tr.tcp_port>0 && random_port){ tr.tcp_port=random_port; + tr.tls_port=tr.udp_port=0; /*make sure only one transport is active at a time*/ }else if (tr.tls_port>0 && random_port){ tr.tls_port=random_port; + tr.udp_port=tr.tcp_port=0; /*make sure only one transport is active at a time*/ } #ifdef __linux @@ -543,7 +576,7 @@ static void sip_config_read(LinphoneCore *lc) linphone_core_set_guess_hostname(lc,tmp); - tmp=lp_config_get_int(lc->config,"sip","inc_timeout",15); + tmp=lp_config_get_int(lc->config,"sip","inc_timeout",30); linphone_core_set_inc_timeout(lc,tmp); /* get proxies config */ @@ -1828,6 +1861,7 @@ void linphone_core_iterate(LinphoneCore *lc){ elapsed=curtime-call->start_time; ms_message("incoming call ringing for %i seconds",elapsed); if (elapsed>lc->sip_conf.inc_timeout){ + ms_message("incoming call timeout (%i)",lc->sip_conf.inc_timeout); call->log->status=LinphoneCallMissed; call->reason=LinphoneReasonNotAnswered; linphone_core_terminate_call(lc,call); @@ -3473,7 +3507,6 @@ LinphoneFirewallPolicy linphone_core_get_firewall_policy(const LinphoneCore *lc) * @ingroup call_logs **/ const MSList * linphone_core_get_call_logs(LinphoneCore *lc){ - lc->missed_calls=0; return lc->call_logs; } @@ -3489,17 +3522,31 @@ void linphone_core_clear_call_logs(LinphoneCore *lc){ call_logs_write_to_config_file(lc); } +/** + * Returns number of missed calls. + * Once checked, this counter can be reset with linphone_core_reset_missed_calls_count(). +**/ int linphone_core_get_missed_calls_count(LinphoneCore *lc) { return lc->missed_calls; } +/** + * Resets the counter of missed calls. +**/ void linphone_core_reset_missed_calls_count(LinphoneCore *lc) { lc->missed_calls=0; } -void linphone_core_remove_call_log(LinphoneCore *lc, void *data) { - lc->call_logs = ms_list_remove(lc->call_logs, data); +/** + * Remove a specific call log from call history list. + * This function destroys the call log object. It must not be accessed anymore by the application after calling this function. + * @param lc the linphone core object + * @param a LinphoneCallLog object. +**/ +void linphone_core_remove_call_log(LinphoneCore *lc, LinphoneCallLog *cl){ + lc->call_logs = ms_list_remove(lc->call_logs, cl); call_logs_write_to_config_file(lc); + linphone_call_log_destroy(cl); } static void toggle_video_preview(LinphoneCore *lc, bool_t val){ @@ -3572,6 +3619,7 @@ bool_t linphone_core_video_enabled(LinphoneCore *lc){ * This policy defines whether: * - video shall be initiated by default for outgoing calls * - video shall be accepter by default for incoming calls + * @ingroup media_parameters **/ void linphone_core_set_video_policy(LinphoneCore *lc, const LinphoneVideoPolicy *policy){ lc->video_policy=*policy; @@ -3584,6 +3632,7 @@ void linphone_core_set_video_policy(LinphoneCore *lc, const LinphoneVideoPolicy /** * Get the default policy for video. * See linphone_core_set_video_policy() for more details. + * @ingroup media_parameters **/ const LinphoneVideoPolicy *linphone_core_get_video_policy(LinphoneCore *lc){ return &lc->video_policy; diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index c9c6fc1a1..3d10a26af 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -155,14 +155,22 @@ typedef struct _LinphoneCallLog{ float quality; int video_enabled; struct _LinphoneCore *lc; + time_t start_date_time; /**Start date of the call in seconds as expressed in a time_t */ } LinphoneCallLog; + +/** + * Enum describing type of media encryption types. +**/ enum LinphoneMediaEncryption { LinphoneMediaEncryptionNone, LinphoneMediaEncryptionSRTP, LinphoneMediaEncryptionZRTP }; +/** + * Enum describing type of media encryption types. +**/ typedef enum LinphoneMediaEncryption LinphoneMediaEncryption; /*public: */ @@ -174,13 +182,13 @@ const rtp_stats_t *linphone_call_log_get_local_stats(const LinphoneCallLog *cl); const rtp_stats_t *linphone_call_log_get_remote_stats(const LinphoneCallLog *cl); char * linphone_call_log_to_str(LinphoneCallLog *cl); +struct _LinphoneCallParams; /** * The LinphoneCallParams is an object containing various call related parameters. * It can be used to retrieve parameters from a currently running call or modify the call's characteristics * dynamically. **/ -struct _LinphoneCallParams; typedef struct _LinphoneCallParams LinphoneCallParams; const PayloadType* linphone_call_params_get_used_audio_codec(const LinphoneCallParams *cp); @@ -209,12 +217,17 @@ enum _LinphoneReason{ LinphoneReasonNotAnswered }; +/** + * Enum describing failure reasons. + * @ingroup initializing +**/ typedef enum _LinphoneReason LinphoneReason; const char *linphone_reason_to_string(LinphoneReason err); /** * Structure describing policy regarding video streams establishments. + * @ingroup media_parameters **/ struct _LinphoneVideoPolicy{ bool_t automatically_initiate; /**CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,env->NewStringUTF(message)); + env->CallVoidMethod(lcData->listener,lcData->displayStatusId,lcData->core,message ? env->NewStringUTF(message) : NULL); } static void displayMessageCb(LinphoneCore *lc, const char *message) { @@ -492,6 +492,10 @@ extern "C" jlong Java_org_linphone_core_LinphoneCoreImpl_clearAuthInfos(JNIEnv* linphone_core_clear_all_auth_info((LinphoneCore*)lc); } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_refreshRegisters(JNIEnv* env, jobject thiz,jlong lc) { + linphone_core_refresh_registers((LinphoneCore*)lc); +} + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_addAuthInfo( JNIEnv* env ,jobject thiz ,jlong lc @@ -594,6 +598,12 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setNetworkStateReachable linphone_core_set_network_reachable((LinphoneCore*)lc,isReachable); } +extern "C" jboolean Java_org_linphone_core_LinphoneCoreImpl_isNetworkStateReachable( JNIEnv* env + ,jobject thiz + ,jlong lc) { + return linphone_core_is_network_reachabled((LinphoneCore*)lc); +} + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setPlaybackGain( JNIEnv* env ,jobject thiz ,jlong lc @@ -657,7 +667,7 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_resetMissedCallsCount(JN extern "C" void Java_org_linphone_core_LinphoneCoreImpl_removeCallLog(JNIEnv* env ,jobject thiz ,jlong lc, jlong log) { - linphone_core_remove_call_log((LinphoneCore*)lc, (void*) log); + linphone_core_remove_call_log((LinphoneCore*)lc, (LinphoneCallLog*) log); } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_clearCallLogs(JNIEnv* env @@ -1199,6 +1209,19 @@ extern "C" jlong Java_org_linphone_core_LinphoneCallImpl_getCallLog( JNIEnv* en return (jlong)linphone_call_get_call_log((LinphoneCall*)ptr); } +extern "C" void Java_org_linphone_core_LinphoneCallImpl_takeSnapshot( JNIEnv* env + ,jobject thiz + ,jlong ptr, jstring path) { + const char* filePath = path != NULL ? env->GetStringUTFChars(path, NULL) : NULL; + linphone_call_take_video_snapshot((LinphoneCall*)ptr, filePath); +} + +extern "C" void Java_org_linphone_core_LinphoneCallImpl_zoomVideo( JNIEnv* env + ,jobject thiz + ,jlong ptr, jfloat zoomFactor, jfloat cx, jfloat cy) { + linphone_call_zoom_video((LinphoneCall*)ptr, zoomFactor, &cx, &cy); +} + extern "C" jboolean Java_org_linphone_core_LinphoneCallImpl_isIncoming( JNIEnv* env ,jobject thiz ,jlong ptr) { @@ -1685,33 +1708,42 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setMaxCalls(JNIEnv *env, extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAddServerAndMirror(JNIEnv *env,jobject thiz,jlong pCore, jstring jHost, jint port, jint mirror, jint delay) { -#ifdef TUNNEL_ENABLED - LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; + LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; + if (!tunnel) return; const char* cHost=env->GetStringUTFChars(jHost, NULL); linphone_tunnel_add_server_and_mirror(tunnel, cHost, port, mirror, delay); env->ReleaseStringUTFChars(jHost, cHost); -#endif } +extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelSetHttpProxy(JNIEnv *env,jobject thiz,jlong pCore, + jstring jHost, jint port, jstring username, jstring password) { + + LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; + if (!tunnel) return; + const char* cHost=(jHost!=NULL) ? env->GetStringUTFChars(jHost, NULL) : NULL; + const char* cUsername= (username!=NULL) ? env->GetStringUTFChars(username, NULL) : NULL; + const char* cPassword= (password!=NULL) ? env->GetStringUTFChars(password, NULL) : NULL; + linphone_tunnel_set_http_proxy(tunnel,cHost, port,cUsername,cPassword); + if (cHost) env->ReleaseStringUTFChars(jHost, cHost); + if (cUsername) env->ReleaseStringUTFChars(username, cUsername); + if (cPassword) env->ReleaseStringUTFChars(password, cPassword); +} + + extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelAutoDetect(JNIEnv *env,jobject thiz,jlong pCore) { -#ifdef TUNNEL_ENABLED LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; linphone_tunnel_auto_detect(tunnel); -#endif + } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelCleanServers(JNIEnv *env,jobject thiz,jlong pCore) { -#ifdef TUNNEL_ENABLED LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; linphone_tunnel_clean_servers(tunnel); -#endif } extern "C" void Java_org_linphone_core_LinphoneCoreImpl_tunnelEnable(JNIEnv *env,jobject thiz,jlong pCore, jboolean enable) { -#ifdef TUNNEL_ENABLED LinphoneTunnel *tunnel=((LinphoneCore *) pCore)->tunnel; if (!tunnel) return; linphone_tunnel_enable(tunnel, enable); -#endif } @@ -1737,3 +1769,8 @@ extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setVideoPolicy(JNIEnv *e extern "C" void Java_org_linphone_core_LinphoneCoreImpl_setCpuCountNative(JNIEnv *env, jobject thiz, jint count) { ms_set_cpu_count(count); } + +extern "C" jstring Java_org_linphone_core_LinphoneCoreImpl_getVersion(JNIEnv* env,jobject thiz,jlong ptr) { + jstring jvalue =env->NewStringUTF(linphone_core_get_version()); + return jvalue; +} diff --git a/coreapi/lpconfig.c b/coreapi/lpconfig.c index d12166ec4..4cd7202cc 100644 --- a/coreapi/lpconfig.c +++ b/coreapi/lpconfig.c @@ -277,6 +277,18 @@ int lp_config_get_int(LpConfig *lpconfig,const char *section, const char *key, i else return default_value; } +int64_t lp_config_get_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t default_value){ + const char *str=lp_config_get_string(lpconfig,section,key,NULL); + if (str!=NULL) { +#ifdef WIN32 + return (int64_t)_atoi64(str); +#else + return atoll(str); +#endif + } + else return default_value; +} + float lp_config_get_float(LpConfig *lpconfig,const char *section, const char *key, float default_value){ const char *str=lp_config_get_string(lpconfig,section,key,NULL); float ret=default_value; @@ -312,6 +324,13 @@ void lp_config_set_int(LpConfig *lpconfig,const char *section, const char *key, lp_config_set_string(lpconfig,section,key,tmp); } +void lp_config_set_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t value){ + char tmp[30]; + snprintf(tmp,sizeof(tmp),"%lli",(long long)value); + lp_config_set_string(lpconfig,section,key,tmp); +} + + void lp_config_set_float(LpConfig *lpconfig,const char *section, const char *key, float value){ char tmp[30]; snprintf(tmp,sizeof(tmp),"%f",value); diff --git a/coreapi/lpconfig.h b/coreapi/lpconfig.h index ed7a66b1e..c1821d2aa 100644 --- a/coreapi/lpconfig.h +++ b/coreapi/lpconfig.h @@ -66,6 +66,16 @@ int lp_config_read_file(LpConfig *lpconfig, const char *filename); * The default integer value is returned if the config item isn't found. **/ int lp_config_get_int(LpConfig *lpconfig,const char *section, const char *key, int default_value); + +/** + * Retrieves a configuration item as a 64 bit integer, given its section, key, and default value. + * + * @ingroup misc + * The default integer value is returned if the config item isn't found. +**/ +int64_t lp_config_get_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t default_value); + + int lp_config_read_file(LpConfig *lpconfig, const char *filename); /** * Retrieves a configuration item as a float, given its section, key, and default value. @@ -86,6 +96,13 @@ void lp_config_set_string(LpConfig *lpconfig,const char *section, const char *ke * @ingroup misc **/ void lp_config_set_int(LpConfig *lpconfig,const char *section, const char *key, int value); +/** + * Sets a 64 bits integer config item + * + * @ingroup misc +**/ +void lp_config_set_int64(LpConfig *lpconfig,const char *section, const char *key, int64_t value); + /** * Sets a float config item * diff --git a/coreapi/misc.c b/coreapi/misc.c index a749bf279..786347d63 100644 --- a/coreapi/misc.c +++ b/coreapi/misc.c @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "private.h" +#include "lpconfig.h" #include "mediastreamer2/mediastream.h" #include #include @@ -574,6 +575,37 @@ LinphoneProxyConfig * is_a_linphone_proxy_config(void *user_pointer){ return cfg->magic==linphone_proxy_config_magic ? cfg : NULL; } +unsigned int linphone_core_get_audio_features(LinphoneCore *lc){ + unsigned int ret=0; + const char *features=lp_config_get_string(lc->config,"sound","features",NULL); + if (features){ + char tmp[256]={0}; + char name[256]; + char *p,*n; + strncpy(tmp,features,sizeof(tmp)-1); + for(p=tmp;*p!='\0';p++){ + if (*p==' ') continue; + n=strchr(p,'|'); + if (n) *n='\0'; + sscanf(p,"%s",name); + ms_message("Found audio feature %s",name); + if (strcasecmp(name,"PLC")==0) ret|=AUDIO_STREAM_FEATURE_PLC; + else if (strcasecmp(name,"EC")==0) ret|=AUDIO_STREAM_FEATURE_EC; + else if (strcasecmp(name,"EQUALIZER")==0) ret|=AUDIO_STREAM_FEATURE_EQUALIZER; + else if (strcasecmp(name,"VOL_SND")==0) ret|=AUDIO_STREAM_FEATURE_VOL_SND; + else if (strcasecmp(name,"VOL_RCV")==0) ret|=AUDIO_STREAM_FEATURE_VOL_RCV; + else if (strcasecmp(name,"DTMF")==0) ret|=AUDIO_STREAM_FEATURE_DTMF; + else if (strcasecmp(name,"DTMF_ECHO")==0) ret|=AUDIO_STREAM_FEATURE_DTMF_ECHO; + else if (strcasecmp(name,"ALL")==0) ret|=AUDIO_STREAM_FEATURE_ALL; + else if (strcasecmp(name,"NONE")==0) ret=0; + else ms_error("Unsupported audio feature %s requested in config file.",name); + if (!n) break; + p=n; + } + }else ret=AUDIO_STREAM_FEATURE_ALL; + return ret; +} + #ifdef HAVE_GETIFADDRS @@ -697,7 +729,6 @@ int linphone_core_get_local_ip_for(int type, const char *dest, char *result){ - void _linphone_core_configure_resolver(){ /*bionic declares _res but does not define nor export it !!*/ #ifdef ANDROID diff --git a/coreapi/private.h b/coreapi/private.h index 1ab7a6a7d..24ee7f899 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -270,6 +270,7 @@ struct _LinphoneProxyConfig char *reg_identity; char *reg_route; char *realm; + char *contact_params; int expires; int reg_time; SalOp *op; @@ -566,6 +567,7 @@ void linphone_call_remove_from_conf(LinphoneCall *call); void linphone_core_conference_check_uninit(LinphoneCore *lc); bool_t linphone_core_sound_resources_available(LinphoneCore *lc); void linphone_core_notify_refer_state(LinphoneCore *lc, LinphoneCall *referer, LinphoneCall *newcall); +unsigned int linphone_core_get_audio_features(LinphoneCore *lc); void __linphone_core_invalidate_registers(LinphoneCore* lc); void _linphone_core_codec_config_write(LinphoneCore *lc); diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 1676e0918..8e066ea33 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -256,9 +256,10 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){ if (proxy==NULL) return NULL; host=linphone_address_get_domain (proxy); if (host!=NULL){ - LinphoneAddress *contact; char localip[LINPHONE_IPADDR_SIZE]; + char *tmp; LCSipTransports tr; + LinphoneAddress *contact; linphone_core_get_local_ip(obj->lc,host,localip); contact=linphone_address_new(obj->reg_identity); @@ -274,8 +275,12 @@ static char *guess_contact_for_register(LinphoneProxyConfig *obj){ sal_address_set_param(contact,"transport","tls"); } } - ret=linphone_address_as_string(contact); + tmp=linphone_address_as_string_uri_only(contact); + if (obj->contact_params) + ret=ms_strdup_printf("<%s;%s>",tmp,obj->contact_params); + else ret=ms_strdup_printf("<%s>",tmp); linphone_address_destroy(contact); + ms_free(tmp); } linphone_address_destroy (proxy); return ret; @@ -511,6 +516,31 @@ bool_t linphone_proxy_config_register_enabled(const LinphoneProxyConfig *obj){ return obj->reg_sendregister; } +/** + * Set optional contact parameters that will be added to the contact information sent in the registration. + * @param obj the proxy config object + * @param contact_params a string contaning the additional parameters in text form, like "myparam=something;myparam2=something_else" + * + * The main use case for this function is provide the proxy additional information regarding the user agent, like for example unique identifier or apple push id. + * As an example, the contact address in the SIP register sent will look like . +**/ +void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *obj, const char *contact_params){ + if (obj->contact_params) { + ms_free(obj->contact_params); + obj->contact_params=NULL; + } + if (contact_params){ + obj->contact_params=ms_strdup(contact_params); + } +} + +/** + * Returns previously set contact parameters. +**/ +const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *obj){ + return obj->contact_params; +} + struct _LinphoneCore * linphone_proxy_config_get_core(const LinphoneProxyConfig *obj){ return obj->lc; } diff --git a/coreapi/sal_eXosip2_sdp.c b/coreapi/sal_eXosip2_sdp.c index f67fb9cfd..32f031864 100644 --- a/coreapi/sal_eXosip2_sdp.c +++ b/coreapi/sal_eXosip2_sdp.c @@ -116,7 +116,7 @@ static int _sdp_message_get_mline_dir(sdp_message_t *sdp, int mline){ }else if (keywordcmp("sendonly",attr->a_att_field)==0){ return SalStreamSendOnly; }else if (keywordcmp("recvonly",attr->a_att_field)==0){ - return SalStreamSendOnly; + return SalStreamRecvOnly; }else if (keywordcmp("inactive",attr->a_att_field)==0){ return SalStreamInactive; } diff --git a/gtk/calllogs.c b/gtk/calllogs.c index bd5969ec8..9494dbfa2 100644 --- a/gtk/calllogs.c +++ b/gtk/calllogs.c @@ -58,6 +58,15 @@ void linphone_gtk_call_log_update(GtkWidget *w){ gchar *logtxt, *minutes, *seconds; gchar quality[20]; const char *status=NULL; + gchar *start_date=NULL; + +#if GLIB_CHECK_VERSION(2,26,0) + if (cl->start_date_time){ + GDateTime *dt=g_date_time_new_from_unix_local(cl->start_date_time); + start_date=g_date_time_format(dt,"%c"); + g_date_time_unref(dt); + } +#endif display=linphone_address_get_display_name (la); if (display==NULL){ @@ -91,14 +100,15 @@ void linphone_gtk_call_log_update(GtkWidget *w){ _("%s\t%s\t" "Quality: %s\n%s\t%s %s\t"), display, addr, cl->quality!=-1 ? quality : _("n/a"), - cl->start_date, minutes, seconds); + start_date ? start_date : cl->start_date, minutes, seconds); else logtxt=g_markup_printf_escaped( _("%s\t%s\t" "\n%s\t%s"), display, addr, - cl->start_date, status); + start_date ? start_date : cl->start_date, status); g_free(minutes); g_free(seconds); + if (start_date) g_free(start_date); gtk_list_store_append (store,&iter); gtk_list_store_set (store,&iter, 0, cl->dir==LinphoneCallOutgoing ? GTK_STOCK_GO_UP : GTK_STOCK_GO_DOWN, diff --git a/gtk/main.c b/gtk/main.c index 2a6c307b6..fa04a24e0 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -77,6 +77,7 @@ static gboolean iconified=FALSE; static gchar *workingdir=NULL; static char *progpath=NULL; gchar *linphone_logfile=NULL; +static gboolean workaround_gtk_entry_chinese_bug=FALSE; static GOptionEntry linphone_options[]={ { @@ -347,6 +348,11 @@ GtkWidget *linphone_gtk_create_widget(const char *filename, const char *widget_n return w; } +static void entry_unmapped(GtkWidget *entry){ + g_message("Entry is unmapped, calling unrealize to workaround chinese bug."); + gtk_widget_unrealize(entry); +} + GtkWidget *linphone_gtk_get_widget(GtkWidget *window, const char *name){ GtkBuilder *builder=(GtkBuilder*)g_object_get_data(G_OBJECT(window),"builder"); GObject *w; @@ -358,6 +364,15 @@ GtkWidget *linphone_gtk_get_widget(GtkWidget *window, const char *name){ if (w==NULL){ g_error("No widget named %s found in xml interface.",name); } + if (workaround_gtk_entry_chinese_bug){ + if (strcmp(G_OBJECT_TYPE_NAME(w),"GtkEntry")==0){ + if (g_object_get_data(G_OBJECT(w),"entry_bug_workaround")==NULL){ + g_object_set_data(G_OBJECT(w),"entry_bug_workaround",GINT_TO_POINTER(1)); + g_message("%s is a GtkEntry",name); + g_signal_connect(G_OBJECT(w),"unmap",(GCallback)entry_unmapped,NULL); + } + } + } return GTK_WIDGET(w); } @@ -1765,6 +1780,9 @@ int main(int argc, char *argv[]){ char tmp[128]; snprintf(tmp,sizeof(tmp),"LANG=%s",lang); _putenv(tmp); + if (strncmp(lang,"zh",2)==0){ + workaround_gtk_entry_chinese_bug=TRUE; + } #else setenv("LANG",lang,1); #endif diff --git a/gtk/setupwizard.c b/gtk/setupwizard.c index ae1bcfa6a..39673da99 100644 --- a/gtk/setupwizard.c +++ b/gtk/setupwizard.c @@ -538,11 +538,6 @@ GtkWidget * linphone_gtk_create_assistant(void){ ok = create_pixbuf(linphone_gtk_get_ui_config("ok","ok.png")); notok = create_pixbuf(linphone_gtk_get_ui_config("notok","notok.png")); -#if !GLIB_CHECK_VERSION(2, 31, 0) - g_thread_init (NULL); -#endif - gdk_threads_init (); - GtkWidget *p1=create_intro(); GtkWidget *p2=create_setup_signin_choice(); GtkWidget *p31=create_account_informations_page(); @@ -605,3 +600,4 @@ GtkWidget * linphone_gtk_create_assistant(void){ return w; } + diff --git a/java/common/org/linphone/core/LinphoneCall.java b/java/common/org/linphone/core/LinphoneCall.java index 4d8e23d80..c42ebb740 100644 --- a/java/common/org/linphone/core/LinphoneCall.java +++ b/java/common/org/linphone/core/LinphoneCall.java @@ -244,4 +244,14 @@ public interface LinphoneCall { boolean isInConference(); float getPlayVolume(); + + /** + * Take a photo of currently received video and write it into a jpeg file. + */ + void takeSnapshot(String path); + + /** + * Scale the video by factor, and center it using cx,cy point + */ + void zoomVideo(float factor, float cx, float cy); } diff --git a/java/common/org/linphone/core/LinphoneCallLog.java b/java/common/org/linphone/core/LinphoneCallLog.java index 98bf40c50..40299e6d9 100644 --- a/java/common/org/linphone/core/LinphoneCallLog.java +++ b/java/common/org/linphone/core/LinphoneCallLog.java @@ -95,8 +95,6 @@ public interface LinphoneCallLog { */ public CallStatus getStatus(); - public long getNativePtr(); - /** * @return a human readble String with the start date/time of the call */ diff --git a/java/common/org/linphone/core/LinphoneCore.java b/java/common/org/linphone/core/LinphoneCore.java index 86559f43f..e06342178 100644 --- a/java/common/org/linphone/core/LinphoneCore.java +++ b/java/common/org/linphone/core/LinphoneCore.java @@ -180,6 +180,9 @@ public interface LinphoneCore { this.tcp = t.tcp; this.tls = t.tls; } + public String toString() { + return "udp["+udp+"] tcp["+tcp+"] tls["+tls+"]"; + } } /** * Media (RTP) encryption enum-like. @@ -743,6 +746,7 @@ public interface LinphoneCore { void tunnelEnable(boolean enable); void tunnelAutoDetect(); void tunnelCleanServers(); + void tunnelSetHttpProxy(String proxy_host, int port, String username, String password); /** * @param host tunnel server ip address * @param port tunnel server tls port, recommended value is 443 @@ -775,4 +779,13 @@ public interface LinphoneCore { * Set missed calls count to zero */ public void resetMissedCallsCount(); + /** + * re-initiates registration if network is up. + */ + public void refreshRegisters(); + + /** + * return the version code of linphone core + */ + public String getVersion(); } diff --git a/java/common/org/linphone/core/LinphoneCoreListener.java b/java/common/org/linphone/core/LinphoneCoreListener.java index cfe43895e..400e942c3 100644 --- a/java/common/org/linphone/core/LinphoneCoreListener.java +++ b/java/common/org/linphone/core/LinphoneCoreListener.java @@ -103,5 +103,14 @@ public interface LinphoneCoreListener { * @param data */ void ecCalibrationStatus(LinphoneCore lc,LinphoneCore.EcCalibratorStatus status, int delay_ms, Object data); + /** + * Report Notified message received for this identity. + * @param lc LinphoneCore + * @param call LinphoneCall in case the notify is part of a dialog, may be null + * @param from LinphoneAddress the message comes from + * @param event String the raw body of the notify event. + * + */ + void notifyReceived(LinphoneCore lc, LinphoneCall call, LinphoneAddress from, byte[] event); } diff --git a/mediastreamer2 b/mediastreamer2 index 415269b15..863022b56 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 415269b15fb64aec82328332602591abac2d782d +Subproject commit 863022b56fab41d2ca45dd1d149cb0caab08b54b