diff --git a/configure.ac b/configure.ac index 379f234..82a20ae 100644 --- a/configure.ac +++ b/configure.ac @@ -145,6 +145,28 @@ else echo "GTK interface compilation is disabled." fi +dnl conditionnal build of the notify library +if test "$mingw_found" != "yes" -a "$gtk_ui" = "true" ; then + AC_ARG_ENABLE(notify, + [ --enable-notify=[yes/no] Enable libnotify support [default=yes]], + [case "${enableval}" in + yes) notify=true ;; + no) notify=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-notify) ;; + esac],[notify=true]) + + if test "$notify" = "true"; then + PKG_CHECK_MODULES([NOTIFY], [libnotify], [found_notify=yes], foo=bar) + case "$found_notify" in + yes) + AC_SUBST(NOTIFY_CFLAGS) + AC_SUBST(NOTIFY_LIBS) + AC_DEFINE([HAVE_NOTIFY],[1],[NOTIFY support]) + esac + else + echo "Libnotify support is disabled." + fi +fi dnl os-specific problems not handled by existing macros. case "$host_os" in @@ -239,7 +261,6 @@ else package_prefix=${prefix} fi - if test "$relativeprefix" = "yes" ; then dnl allow binaries to install everywhere package_prefix="." diff --git a/coreapi/callbacks.c b/coreapi/callbacks.c index a101dbc..634022c 100644 --- a/coreapi/callbacks.c +++ b/coreapi/callbacks.c @@ -194,7 +194,8 @@ static void call_received(SalOp *h){ ms_message("the local ring is already started"); } }else{ - /*TODO : play a tone within the context of the current call */ + /* play a tone within the context of the current call */ + linphone_core_play_dtmf_tone(lc); } diff --git a/coreapi/ec-calibrator.c b/coreapi/ec-calibrator.c index 38b83f0..b0ec20c 100644 --- a/coreapi/ec-calibrator.c +++ b/coreapi/ec-calibrator.c @@ -110,7 +110,8 @@ static void ecc_play_tones(EcCalibrator *ecc){ ms_filter_call_method (ecc->det,MS_TONE_DETECTOR_ADD_SCAN,&expected_tone); - tone.frequency=1000; + tone.lowfreq=1000; + tone.highfreq=0; tone.duration=1000; tone.amplitude=1.0; @@ -119,7 +120,8 @@ static void ecc_play_tones(EcCalibrator *ecc){ ms_sleep(2); ms_filter_set_notify_callback(ecc->gen,on_tone_sent,ecc); - tone.frequency=2000; + tone.lowfreq=2000; + tone.highfreq=0; tone.duration=100; ms_filter_call_method(ecc->gen,MS_DTMF_GEN_PLAY_CUSTOM,&tone); diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c index e6fc1ef..b607ca1 100644 --- a/coreapi/linphonecore.c +++ b/coreapi/linphonecore.c @@ -641,7 +641,7 @@ static const char *codec_pref_order[]={ "gsm", "pcmu", "pcma", - "VP8-DRAFT-0-3-2" + "VP8-DRAFT-0-3-2", "H264", "MP4V-ES", "H263-1998", @@ -2306,7 +2306,6 @@ int linphone_core_accept_call(LinphoneCore *lc, LinphoneCall *call) ms_message("ring stopped"); lc->ringstream=NULL; } - linphone_core_get_default_proxy(lc,&cfg); dest_proxy=cfg; dest_proxy=linphone_core_lookup_known_proxy(lc,call->log->to); @@ -2362,6 +2361,11 @@ static void terminate_call(LinphoneCore *lc, LinphoneCall *call){ ring_stop(lc->ringstream); lc->ringstream=NULL; } + + /*stop any dtmf tone still playing */ + ms_message("test"); + linphone_core_stop_dtmf(lc); + linphone_call_stop_media_streams(call); if (lc->vtable.display_status!=NULL) lc->vtable.display_status(lc,_("Call ended") ); @@ -3676,6 +3680,26 @@ void linphone_core_play_dtmf(LinphoneCore *lc, char dtmf, int duration_ms){ /** * @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_dtmf_tone(LinphoneCore *lc){ + MSFilter *f=get_dtmf_gen(lc); + MSDtmfGenCustomTone def; + if (f==NULL){ + ms_error("No dtmf generator at this time !"); + return; + } + def.duration=100; + def.lowfreq=852; + def.highfreq=1633; + def.amplitude=0.5; + def.interval=600; + ms_filter_call_method(f, MS_DTMF_GEN_PLAY_CUSTOM,&def); +} + +/** + * @ingroup media_parameters * * Stops playing a dtmf started by linphone_core_play_dtmf(). **/ diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h index 010b158..d85f014 100644 --- a/coreapi/linphonecore.h +++ b/coreapi/linphonecore.h @@ -941,6 +941,7 @@ void linphone_core_set_play_file(LinphoneCore *lc, const char *file); void linphone_core_set_record_file(LinphoneCore *lc, const char *file); void linphone_core_play_dtmf(LinphoneCore *lc, char dtmf, int duration_ms); +void linphone_core_play_dtmf_tone(LinphoneCore *lc); void linphone_core_stop_dtmf(LinphoneCore *lc); int linphone_core_get_current_call_duration(const LinphoneCore *lc); diff --git a/gtk/Makefile.am b/gtk/Makefile.am index c51234e..56ac4a3 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -49,7 +49,7 @@ linphone_SOURCES= \ linphone_LDADD=$(ORTP_LIBS) \ $(MEDIASTREAMER_LIBS) \ $(top_builddir)/coreapi/liblinphone.la \ - $(LIBGTK_LIBS) $(LIBGTKMAC_LIBS) $(INTLLIBS) + $(LIBGTK_LIBS) $(NOTIFY_LIBS) $(LIBGTKMAC_LIBS) $(INTLLIBS) if BUILD_WIN32 diff --git a/gtk/main.c b/gtk/main.c index 6fea842..a8fed66 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -36,6 +36,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define chdir _chdir #endif +#ifdef HAVE_NOTIFY +#include +#endif + #define LINPHONE_ICON "linphone.png" const char *this_program_ident_string="linphone_ident_string=" LINPHONE_VERSION; @@ -218,6 +222,11 @@ static void linphone_gtk_init_liblinphone(const char *config_file, linphone_core_set_user_agent("Linphone", LINPHONE_VERSION); the_core=linphone_core_new(&vtable,config_file,factory_config_file,NULL); linphone_core_set_waiting_callback(the_core,linphone_gtk_wait,NULL); + +#ifdef HAVE_NOTIFY + if (!notify_init ("Linphone")) + ms_error("Libnotify failed to init."); +#endif } @@ -622,6 +631,22 @@ static void completion_add_text(GtkEntry *entry, const char *text){ save_uri_history(); } + +static void linphone_gtk_show_main_window(){ + GtkWidget *w=linphone_gtk_get_main_window(); + LinphoneCore *lc=linphone_gtk_get_core(); + if (linphone_core_video_enabled(lc)){ + linphone_core_enable_video_preview(lc,linphone_gtk_get_ui_config_int("videoselfview", + VIDEOSELFVIEW_DEFAULT)); + } + gtk_widget_show(w); + gtk_window_present(GTK_WINDOW(w)); +} + +static void linphone_gtk_show(LinphoneCore *lc){ + linphone_gtk_show_main_window(); +} + void linphone_gtk_call_terminated(LinphoneCall *call, const char *error){ GtkWidget *mw=linphone_gtk_get_main_window(); if (linphone_core_get_calls(linphone_gtk_get_core())==NULL){ @@ -753,6 +778,7 @@ void linphone_gtk_answer_clicked(GtkWidget *button){ if (call){ linphone_core_pause_all_calls(linphone_gtk_get_core()); linphone_core_accept_call(linphone_gtk_get_core(),call); + linphone_gtk_show_main_window(); } } @@ -763,7 +789,7 @@ void linphone_gtk_enable_video(GtkWidget *w){ gtk_widget_set_sensitive(selfview_item,val); if (val){ linphone_core_enable_video_preview(linphone_gtk_get_core(), - linphone_gtk_get_ui_config_int("videoselfview",VIDEOSELFVIEW_DEFAULT)); + linphone_gtk_get_ui_config_int("videoselfview",VIDEOSELFVIEW_DEFAULT)); }else{ linphone_core_enable_video_preview(linphone_gtk_get_core(),FALSE); } @@ -787,21 +813,6 @@ void linphone_gtk_used_identity_changed(GtkWidget *w){ if (sel) g_free(sel); } -static void linphone_gtk_show_main_window(){ - GtkWidget *w=linphone_gtk_get_main_window(); - LinphoneCore *lc=linphone_gtk_get_core(); - if (linphone_core_video_enabled(lc)){ - linphone_core_enable_video_preview(lc,linphone_gtk_get_ui_config_int("videoselfview", - VIDEOSELFVIEW_DEFAULT)); - } - gtk_widget_show(w); - gtk_window_present(GTK_WINDOW(w)); -} - -static void linphone_gtk_show(LinphoneCore *lc){ - linphone_gtk_show_main_window(); -} - static void linphone_gtk_notify_recv(LinphoneCore *lc, LinphoneFriend * fid){ linphone_gtk_show_friends(); } @@ -943,6 +954,9 @@ static void linphone_gtk_call_log_updated(LinphoneCore *lc, LinphoneCallLog *cl) } static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cs, const char *msg){ +#ifdef HAVE_NOTIFY + NotifyNotification *n=NULL; +#endif switch(cs){ case LinphoneCallOutgoingInit: linphone_gtk_create_in_call_view (call); @@ -958,13 +972,29 @@ static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call break; case LinphoneCallError: linphone_gtk_in_call_view_terminate (call,msg); +#ifdef HAVE_NOTIFY + n = notify_notification_new(_("Call Error"),g_markup_printf_escaped("%s\n%s",msg,linphone_call_get_remote_address_as_string(call)),NULL); +#endif break; case LinphoneCallEnd: linphone_gtk_in_call_view_terminate(call,NULL); +#ifdef HAVE_NOTIFY + n = notify_notification_new(_("Call Ended"),g_markup_printf_escaped("%s",linphone_call_get_remote_address_as_string(call)),NULL); +#endif break; case LinphoneCallIncomingReceived: linphone_gtk_create_in_call_view (call); linphone_gtk_in_call_view_set_incoming(call,!all_other_calls_paused (call,linphone_core_get_calls(lc))); +#ifdef HAVE_NOTIFY + n = notify_notification_new(_("Incoming call"),g_markup_printf_escaped("from %s",linphone_call_get_remote_address_as_string(call)),NULL); + notify_notification_add_action (n,"answer", + (all_other_calls_paused (call,linphone_core_get_calls(lc))) ? + _("Answer") : _("Pause all calls\nand answer"), + NOTIFY_ACTION_CALLBACK(linphone_gtk_answer_clicked), + NULL, + NULL); + notify_notification_add_action (n,"decline",_("Decline"),NOTIFY_ACTION_CALLBACK(linphone_gtk_decline_clicked),NULL,NULL); +#endif if (auto_answer) { linphone_call_ref(call); g_timeout_add(2000,(GSourceFunc)linphone_gtk_auto_answer ,call); @@ -973,11 +1003,17 @@ static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call case LinphoneCallResuming: linphone_gtk_enable_hold_button(call,TRUE,TRUE); linphone_gtk_in_call_view_set_in_call (call); +#ifdef HAVE_NOTIFY + n = notify_notification_new(_("Call resumed."),"",NULL); +#endif break; case LinphoneCallPausing: linphone_gtk_enable_hold_button(call,TRUE,FALSE); case LinphoneCallPausedByRemote: linphone_gtk_in_call_view_set_paused(call); +#ifdef HAVE_NOTIFY + n = notify_notification_new(_("Call Paused"),g_markup_printf_escaped("by %s",linphone_call_get_remote_address_as_string(call)),NULL); +#endif break; case LinphoneCallConnected: linphone_gtk_enable_hold_button (call,TRUE,TRUE); @@ -985,6 +1021,10 @@ static void linphone_gtk_call_state_changed(LinphoneCore *lc, LinphoneCall *call default: break; } +#ifdef HAVE_NOTIFY + if (n && !notify_notification_show(n,NULL)) + ms_error("Failed to send notification."); +#endif linphone_gtk_update_call_buttons (call); } @@ -1274,6 +1314,9 @@ gboolean linphone_gtk_close(GtkWidget *mw){ #else gtk_widget_hide(mw); #endif +#ifdef HAVE_NOTIFY + notify_uninit(); +#endif return TRUE; } @@ -1352,9 +1395,17 @@ void linphone_gtk_log_handler(OrtpLogLevel lev, const char *fmt, va_list args){ static void linphone_gtk_refer_received(LinphoneCore *lc, const char *refer_to){ - GtkEntry * uri_bar =GTK_ENTRY(linphone_gtk_get_widget( + GtkEntry * uri_bar =GTK_ENTRY(linphone_gtk_get_widget( linphone_gtk_get_main_window(), "uribar")); +#ifdef HAVE_NOTIFY + if (!notify_notification_show( + notify_notification_new(_("Call transferred"),g_markup_printf_escaped("to %s",refer_to),NULL), + NULL)) { + ms_error("Failed to send notification."); + } +#else linphone_gtk_show_main_window(); +#endif gtk_entry_set_text(uri_bar, refer_to); linphone_gtk_start_call(linphone_gtk_get_main_window()); } @@ -1363,8 +1414,8 @@ static void linphone_gtk_check_soundcards(){ const char **devices=linphone_core_get_sound_devices(linphone_gtk_get_core()); if (devices==NULL || devices[0]==NULL){ linphone_gtk_display_something(GTK_MESSAGE_WARNING, - _("No sound cards have been detected on this computer.\n" - "You won't be able to send or receive audio calls.")); + _("No sound cards have been detected on this computer.\n" + "You won't be able to send or receive audio calls.")); } } diff --git a/mediastreamer2 b/mediastreamer2 index 4506731..340acff 160000 --- a/mediastreamer2 +++ b/mediastreamer2 @@ -1 +1 @@ -Subproject commit 45067312fd5296d01ea66c851a0f87f9a993b52b +Subproject commit 340acff0001e92d1f126b484d100e1c1d0746b34-dirty diff --git a/oRTP b/oRTP index e161023..6eabe8e 160000 --- a/oRTP +++ b/oRTP @@ -1 +1 @@ -Subproject commit e16102322baf5bc6079216c44722f79d1a6202d4 +Subproject commit 6eabe8e0490f3c88becfaf403444bb1285edde9d-dirty