]> sjero.net Git - linphone/commitdiff
implements playing of dtmfs outside of any call
authorSimon Morlat <simon.morlat@linphone.org>
Thu, 26 Aug 2010 10:10:12 +0000 (12:10 +0200)
committerSimon Morlat <simon.morlat@linphone.org>
Thu, 26 Aug 2010 10:10:12 +0000 (12:10 +0200)
console/commands.c
coreapi/callbacks.c
coreapi/linphonecore.c
coreapi/linphonecore.h
coreapi/private.h
gtk-glade/main.c
mediastreamer2

index 9efc054e7f5bb1a0ffdcfc4d1772043e2e7fb7aa..2fd9b5401c341545c56d66da55f7c7d3ea50fc96 100644 (file)
@@ -296,6 +296,7 @@ linphonec_parse_command_line(LinphoneCore *lc, char *cl)
                while ( isdigit(*cl) || *cl == '#' || *cl == '*' )
                {
                        linphone_core_send_dtmf(lc, *cl);
+                       linphone_core_play_dtmf (lc,*cl,100);
                        ms_sleep(1); // be nice
                        ++cl;
                }
index 6d0cd8b8fe1960f5f017ee7c8e96dc9731a9fc0a..aad80a60d10c18c0532dd1b8518c17d236282885 100644 (file)
@@ -97,6 +97,11 @@ static void call_received(SalOp *h){
 
        /* play the ring if this is the only call*/
        if (lc->sound_conf.ring_sndcard!=NULL && ms_list_size(lc->calls)==1){
+               if (lc->ringstream && lc->dmfs_playing_start_time!=0){
+                       ring_stop(lc->ringstream);
+                       lc->ringstream=NULL;
+                       lc->dmfs_playing_start_time=0;
+               }
                if(lc->ringstream==NULL){
                        MSSndCard *ringcard=lc->sound_conf.lsd_card ?lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard;
                        ms_message("Starting local ring...");
@@ -129,6 +134,11 @@ static void call_ringing(SalOp *h){
        
        md=sal_call_get_final_media_description(h);
        if (md==NULL){
+               if (lc->ringstream && lc->dmfs_playing_start_time!=0){
+                       ring_stop(lc->ringstream);
+                       lc->ringstream=NULL;
+                       lc->dmfs_playing_start_time=0;
+               }
                if (lc->ringstream!=NULL) return;       /*already ringing !*/
                if (lc->sound_conf.play_sndcard!=NULL){
                        MSSndCard *ringcard=lc->sound_conf.lsd_card ? lc->sound_conf.lsd_card : lc->sound_conf.play_sndcard;
index cede342dc680beaf687f5b9bdcb46e331229d049..5f388860b1e7ebf4ee8ca58bf8169ae6da89bae0 100644 (file)
@@ -27,6 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 #include "mediastreamer2/mseventqueue.h"
 #include "mediastreamer2/msvolume.h"
 #include "mediastreamer2/msequalizer.h"
+#include "mediastreamer2/dtmfgen.h"
 
 #ifdef INET6
 #ifndef WIN32
@@ -1641,6 +1642,13 @@ void linphone_core_iterate(LinphoneCore *lc){
                lc_callback_obj_invoke(&lc->preview_finished_cb,lc);
        }
 
+       if (lc->ringstream && lc->dmfs_playing_start_time!=0 
+           && (curtime-lc->dmfs_playing_start_time)>5){
+               ring_stop(lc->ringstream);
+               lc->ringstream=NULL;
+               lc->dmfs_playing_start_time=0;
+       }
+
        sal_iterate(lc->sal);
        ms_event_queue_pump(lc->msevq);
        if (lc->auto_net_state_mon) monitor_network_state(lc,curtime);
@@ -1671,7 +1679,7 @@ void linphone_core_iterate(LinphoneCore *lc){
        call = linphone_core_get_current_call(lc);
        if(call)
        {
-               if (one_second_elapsed)
+               if (call->state==LinphoneCallStreamsRunning && one_second_elapsed)
                {
                        RtpSession *as=NULL,*vs=NULL;
                        lc->prevtime=curtime;
@@ -3284,6 +3292,48 @@ void linphone_core_set_record_file(LinphoneCore *lc, const char *file){
        }
 }
 
+static MSFilter *get_dtmf_gen(LinphoneCore *lc){
+       LinphoneCall *call=linphone_core_get_current_call (lc);
+       if (call){
+               AudioStream *stream=call->audiostream;
+               if (stream){
+                       return stream->dtmfgen;
+               }
+       }
+       if (lc->ringstream==NULL){
+               MSSndCard *ringcard=lc->sound_conf.lsd_card ?lc->sound_conf.lsd_card : lc->sound_conf.ring_sndcard;
+               lc->ringstream=ring_start(NULL,0,ringcard);
+               lc->dmfs_playing_start_time=time(NULL);
+       }else{
+               if (lc->dmfs_playing_start_time!=0)
+                       lc->dmfs_playing_start_time=time(NULL);
+       }
+       return lc->ringstream->gendtmf;
+}
+
+/**
+ * Plays a dtmf to the local user.
+**/
+void linphone_core_play_dtmf(LinphoneCore *lc, char dtmf, int duration_ms){
+       MSFilter *f=get_dtmf_gen(lc);
+       if (f==NULL){
+               ms_error("No dtmf generator at this time !");
+               return;
+       }
+       if (duration_ms>0)
+               ms_filter_call_method(f, MS_DTMF_GEN_PLAY, &dtmf);
+       else ms_filter_call_method(f, MS_DTMF_GEN_START, &dtmf);
+}
+
+/**
+ * Stops playing a dtmf started by linphone_core_play_dtmf().
+**/
+void linphone_core_stop_dtmf(LinphoneCore *lc){
+       MSFilter *f=get_dtmf_gen(lc);
+       ms_filter_call_method_noarg (f, MS_DTMF_GEN_STOP);
+}
+
+
 /**
  * Retrieves the user pointer that was given to linphone_core_new()
  *
index d0c680d928562ecd8cfb0d5f7d60a2f93b1c0b16..e67da52099102b8945def26da34927bcccbdfb59 100644 (file)
@@ -769,6 +769,9 @@ void linphone_core_use_files(LinphoneCore *lc, bool_t yesno);
 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_stop_dtmf(LinphoneCore *lc);
+
 int linphone_core_get_current_call_duration(const LinphoneCore *lc);
 const LinphoneAddress *linphone_core_get_remote_address(LinphoneCore *lc);
 
index cb3ff78e278a1000ecaa21c2f2301de663b25754..bbb48d0cb3d09a557421a97a72a9d22b2de76390 100644 (file)
@@ -367,6 +367,7 @@ struct _LinphoneCore
        MSList *friends;
        MSList *auth_info;
        struct _RingStream *ringstream;
+       time_t dmfs_playing_start_time;
        LCCallbackObj preview_finished_cb;
        LinphoneCall *current_call;   /* the current call */
        MSList *calls;                          /* all the processed calls */
index d5a1b0997dbbdb18dd68965135b1995fe168f001..ddae9ff9016a218f5d8e413283cbcab750cd9872 100644 (file)
@@ -997,12 +997,12 @@ void linphone_gtk_load_identities(void){
 
 static void linphone_gtk_dtmf_clicked(GtkButton *button){
        const char *label=gtk_button_get_label(button);
+       GtkWidget *uri_bar=linphone_gtk_get_widget(gtk_widget_get_toplevel(GTK_WIDGET(button)),"uribar");
+       int pos=-1;
+       gtk_editable_insert_text(GTK_EDITABLE(uri_bar),label,1,&pos);
+       linphone_core_play_dtmf (linphone_gtk_get_core(),label[0],100);
        if (linphone_core_in_call(linphone_gtk_get_core())){
                linphone_core_send_dtmf(linphone_gtk_get_core(),label[0]);
-       }else{
-               GtkWidget *uri_bar=linphone_gtk_get_widget(gtk_widget_get_toplevel(GTK_WIDGET(button)),"uribar");
-               int pos=-1;
-               gtk_editable_insert_text(GTK_EDITABLE(uri_bar),label,1,&pos);
        }
 }
 
index 030250c162f546af5b1c2b97e51a71d81a73679b..332d79209b333bd8ded5b16a7b9dcfe2c0aedc63 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 030250c162f546af5b1c2b97e51a71d81a73679b
+Subproject commit 332d79209b333bd8ded5b16a7b9dcfe2c0aedc63