]> sjero.net Git - linphone/commitdiff
display audio levels in gtk interface
authorSimon Morlat <simon.morlat@linphone.org>
Tue, 27 Sep 2011 20:21:32 +0000 (22:21 +0200)
committerSimon Morlat <simon.morlat@linphone.org>
Tue, 27 Sep 2011 20:21:32 +0000 (22:21 +0200)
coreapi/linphonecall.c
gtk/friendlist.c
gtk/incall_view.c
gtk/main.c
gtk/main.ui
mediastreamer2
pixmaps/Makefile.am
pixmaps/mic_active.png
pixmaps/mic_muted.png
pixmaps/speaker.png [new file with mode: 0644]

index 215248f3b15ceaff64065db26785c1c19eb59594..8ab925cf49c9645b45b67df71123d24ddb54c996 100644 (file)
@@ -1268,9 +1268,9 @@ bool_t linphone_call_echo_limiter_enabled(const LinphoneCall *call){
 **/
 float linphone_call_get_play_volume(LinphoneCall *call){
        AudioStream *st=call->audiostream;
-       if (st && st->volsend){
+       if (st && st->volrecv){
                float vol=0;
-               ms_filter_call_method(st->volsend,MS_VOLUME_GET,&vol);
+               ms_filter_call_method(st->volrecv,MS_VOLUME_GET,&vol);
                return vol;
                
        }
@@ -1283,9 +1283,9 @@ float linphone_call_get_play_volume(LinphoneCall *call){
 **/
 float linphone_call_get_record_volume(LinphoneCall *call){
        AudioStream *st=call->audiostream;
-       if (st && st->volrecv){
+       if (st && st->volsend && !call->audio_muted && call->state==LinphoneCallStreamsRunning){
                float vol=0;
-               ms_filter_call_method(st->volrecv,MS_VOLUME_GET,&vol);
+               ms_filter_call_method(st->volsend,MS_VOLUME_GET,&vol);
                return vol;
                
        }
index 075bbd99ad9bb966279e619707006c0037ee6def..9dacac717882571f03567d4e85c1f051ca615469 100644 (file)
@@ -198,7 +198,9 @@ static void update_star(GtkEntry *entry, gboolean is_known){
        unstarred=g_object_get_data(G_OBJECT(entry),"unstarred_icon");
        if (is_known && (active==unstarred)){
                gtk_entry_set_icon_from_pixbuf(entry,GTK_ENTRY_ICON_SECONDARY,starred);
+               gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry),GTK_ENTRY_ICON_SECONDARY,NULL);
        }else if ((!is_known) && (active==starred)){
+               gtk_entry_set_icon_tooltip_text(GTK_ENTRY(entry),GTK_ENTRY_ICON_SECONDARY,_("Add to addressbook"));
                gtk_entry_set_icon_from_pixbuf(entry,GTK_ENTRY_ICON_SECONDARY,unstarred);
        }
 }
index 6a2dc0cda96370628ffe1fb442274c67cd049136..0fc8a5545d87bbf2ab026bd60ee0ca314e493990 100644 (file)
@@ -319,6 +319,67 @@ static gboolean linphone_gtk_in_call_view_refresh(LinphoneCall *call){
        return TRUE;
 }
 
+typedef float (*get_volume_t)(void *data);
+
+typedef struct _volume_ctx{
+       GtkWidget *widget;
+       get_volume_t get_volume;
+       void *data;
+       float last_value;
+}volume_ctx_t;
+
+#define UNSIGNIFICANT_VOLUME (-26)
+#define SMOOTH 0.15
+
+static gboolean update_audio_meter(volume_ctx_t *ctx){
+       float volume_db=ctx->get_volume(ctx->data);
+       float frac=(volume_db-UNSIGNIFICANT_VOLUME)/(float)(-UNSIGNIFICANT_VOLUME+3.0);
+       if (frac<0) frac=0;
+       if (frac>1.0) frac=1.0;
+       if (frac<ctx->last_value){
+               frac=(frac*SMOOTH)+(ctx->last_value*(1-SMOOTH));
+       }
+       ctx->last_value=frac;
+       //g_message("volume_db=%f, frac=%f",volume_db,frac);
+       gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ctx->widget),frac);
+       return TRUE;
+}
+
+static void on_audio_meter_destroy(guint task_id){
+       g_source_remove(task_id);
+}
+
+void linphone_gtk_init_audio_meter(GtkWidget *w, get_volume_t get_volume, void *data){
+       guint task_id=GPOINTER_TO_INT(g_object_get_data(G_OBJECT(w),"task_id"));
+       if (task_id==0){
+               volume_ctx_t *ctx=g_new(volume_ctx_t,1);
+               ctx->widget=w;
+               ctx->get_volume=get_volume;
+               ctx->data=data;
+               ctx->last_value=0;
+               g_object_set_data_full(G_OBJECT(w),"ctx",ctx,g_free);
+               task_id=g_timeout_add(50,(GSourceFunc)update_audio_meter,ctx);
+               g_object_set_data_full(G_OBJECT(w),"task_id",GINT_TO_POINTER(task_id),(GDestroyNotify)on_audio_meter_destroy);
+       }
+}
+
+void linphone_gtk_in_call_view_enable_audio_view(LinphoneCall *call){
+       GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
+       GtkWidget *audio_view=linphone_gtk_get_widget(callview,"incall_audioview");
+       //GtkWidget *mic=linphone_gtk_get_widget(callview,"incall_mic_icon");
+       GtkWidget *spk=linphone_gtk_get_widget(callview,"incall_spk_icon");
+       GtkWidget *mic_level=linphone_gtk_get_widget(callview,"mic_audiolevel");
+       GtkWidget *spk_level=linphone_gtk_get_widget(callview,"spk_audiolevel");
+       GdkPixbuf *pbuf;
+       //gtk_image_set_from_pixbuf(GTK_IMAGE(mic),(pbuf=create_pixbuf("mic_active.png")));
+       //g_object_unref(pbuf);
+       gtk_image_set_from_pixbuf(GTK_IMAGE(spk),(pbuf=create_pixbuf("speaker.png")));
+       g_object_unref(pbuf);
+       linphone_gtk_init_audio_meter(mic_level,(get_volume_t)linphone_call_get_record_volume,call);
+       linphone_gtk_init_audio_meter(spk_level,(get_volume_t)linphone_call_get_play_volume,call);
+       gtk_widget_show_all(audio_view);
+}
+
 void linphone_gtk_in_call_view_set_in_call(LinphoneCall *call){
        GtkWidget *callview=(GtkWidget*)linphone_call_get_user_pointer(call);
        GtkWidget *status=linphone_gtk_get_widget(callview,"in_call_status");
@@ -340,6 +401,7 @@ void linphone_gtk_in_call_view_set_in_call(LinphoneCall *call){
                taskid=g_timeout_add(250,(GSourceFunc)linphone_gtk_in_call_view_refresh,call);
                g_object_set_data(G_OBJECT(callview),"taskid",GINT_TO_POINTER(taskid));
        }
+       linphone_gtk_in_call_view_enable_audio_view(call);
 }
 
 void linphone_gtk_in_call_view_set_paused(LinphoneCall *call){
@@ -383,6 +445,7 @@ void linphone_gtk_in_call_view_terminate(LinphoneCall *call, const char *error_m
                   linphone_gtk_get_ui_config("stop_call_icon","stopcall-red.png"),FALSE);
        
        gtk_widget_hide(linphone_gtk_get_widget(callview,"answer_decline_panel"));
+       gtk_widget_hide(linphone_gtk_get_widget(callview,"incall_audioview"));
        linphone_gtk_enable_mute_button(
                GTK_BUTTON(linphone_gtk_get_widget(callview,"incall_mute")),FALSE);
        linphone_gtk_enable_hold_button(call,FALSE,TRUE);
@@ -394,14 +457,14 @@ void linphone_gtk_draw_mute_button(GtkButton *button, gboolean active){
        g_object_set_data(G_OBJECT(button),"active",GINT_TO_POINTER(active));
        if (active){
                GtkWidget *image=create_pixmap("mic_muted.png");
-               gtk_button_set_label(GTK_BUTTON(button),_("Unmute"));
+               /*gtk_button_set_label(GTK_BUTTON(button),_("Unmute"));*/
                if (image!=NULL) {
                        gtk_button_set_image(GTK_BUTTON(button),image);
                        gtk_widget_show(image);
                }
        }else{
                GtkWidget *image=create_pixmap("mic_active.png");
-               gtk_button_set_label(GTK_BUTTON(button),_("Mute"));
+               /*gtk_button_set_label(GTK_BUTTON(button),_("Mute"));*/
                if (image!=NULL) {
                        gtk_button_set_image(GTK_BUTTON(button),image);
                        gtk_widget_show(image);
@@ -417,7 +480,8 @@ void linphone_gtk_mute_clicked(GtkButton *button){
 
 void linphone_gtk_enable_mute_button(GtkButton *button, gboolean sensitive)
 {
-       gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);
+       /*gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);*/
+       gtk_widget_set_visible(GTK_WIDGET(button),sensitive);
        linphone_gtk_draw_mute_button(button,FALSE);
 }
 
@@ -459,5 +523,6 @@ void linphone_gtk_enable_hold_button(LinphoneCall *call, gboolean sensitive, gbo
        g_return_if_fail(callview!=NULL);
        button=linphone_gtk_get_widget(callview,"hold_call");
        gtk_widget_set_sensitive(GTK_WIDGET(button),sensitive);
+       gtk_widget_set_visible(GTK_WIDGET(button),sensitive);
        linphone_gtk_draw_hold_button(GTK_BUTTON(button),!holdon);
 }
index be32459e50fe5aa934359e875cd7b38b946674c4..e3a7b2742a8a992a6faecffe4707dea53a3ea85c 100644 (file)
@@ -321,6 +321,7 @@ GtkWidget *linphone_gtk_create_widget(const char *filename, const char *widget_n
                return NULL;
        }
        g_object_set_data(G_OBJECT(w),"builder",builder);
+       g_signal_connect_swapped(G_OBJECT(w),"destroy",(GCallback)g_object_unref,builder);
        gtk_builder_connect_signals(builder,w);
        return w;
 }
@@ -1554,13 +1555,13 @@ static void linphone_gtk_check_soundcards(){
 
 static void linphone_gtk_quit(void){
        linphone_gtk_uninit_instance();
-       gdk_threads_leave();
        linphone_gtk_destroy_log_window();
        linphone_core_destroy(the_core);
        linphone_gtk_log_uninit();
 #ifdef HAVE_NOTIFY
        notify_uninit();
 #endif
+       gdk_threads_leave();
 }
 
 #ifdef HAVE_GTK_OSX
index 6bd4cf9dae08daf09ac3f0c6cd48a2731a86b069..1a8fe13c65e7fbb11219a58b8b93b8f0a479ac6d 100644 (file)
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <child>
-                  <object class="GtkHBox" id="in_call_animation">
+                  <object class="GtkHBox" id="incall_hbox1">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                     <child>
-                      <placeholder/>
+                      <object class="GtkVBox" id="in_call_animation">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <child>
+                          <placeholder/>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="in_call_uri">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">label</property>
+                        <property name="justify">center</property>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
                     </child>
                   </object>
                   <packing>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkLabel" id="in_call_uri">
-                    <property name="visible">True</property>
+                  <object class="GtkHBox" id="incall_audioview">
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">label</property>
-                    <property name="justify">center</property>
+                    <child>
+                      <object class="GtkButton" id="incall_mute">
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">True</property>
+                        <property name="use_action_appearance">False</property>
+                        <property name="relief">half</property>
+                        <signal name="clicked" handler="linphone_gtk_mute_clicked" swapped="no"/>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkProgressBar" id="mic_audiolevel">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkImage" id="incall_spk_icon">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="stock">gtk-missing-image</property>
+                        <property name="icon-size">1</property>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkProgressBar" id="spk_audiolevel">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="pack_type">end</property>
+                        <property name="position">3</property>
+                      </packing>
+                    </child>
                   </object>
                   <packing>
-                    <property name="expand">True</property>
-                    <property name="fill">True</property>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
                     <property name="position">1</property>
                   </packing>
                 </child>
                     <property name="position">2</property>
                   </packing>
                 </child>
-                <child>
-                  <object class="GtkHButtonBox" id="incall_hbuttonbox1">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <child>
-                      <object class="GtkButton" id="incall_mute">
-                        <property name="label" translatable="yes">Mute</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
-                        <signal name="clicked" handler="linphone_gtk_mute_clicked" swapped="no"/>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="fill">False</property>
-                    <property name="position">3</property>
-                  </packing>
-                </child>
                 <child>
                   <object class="GtkHButtonBox" id="mute_pause_buttons">
                     <property name="visible">True</property>
                     <child>
                       <object class="GtkButton" id="hold_call">
                         <property name="label" translatable="yes">Pause</property>
-                        <property name="visible">True</property>
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
                         <property name="use_action_appearance">False</property>
                   <packing>
                     <property name="expand">False</property>
                     <property name="fill">False</property>
-                    <property name="position">4</property>
+                    <property name="position">3</property>
                   </packing>
                 </child>
               </object>
index 85886f326d404708368f72f69c8e0b67af417da1..aadeaaa8b2de3b1e0cb9ffd5a0a22a85335e7951 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 85886f326d404708368f72f69c8e0b67af417da1
+Subproject commit aadeaaa8b2de3b1e0cb9ffd5a0a22a85335e7951
index 8a9201275903f62d44537cc9fb78cb324ede78c9..60194fcd866add4b5fe5f3caf9c72a23b8c5b6f4 100644 (file)
@@ -13,6 +13,7 @@ status-red.png \
 status-offline.png \
 contact-orange.png dialer-orange.png history-orange.png\
 startcall-green.png stopcall-red.png addcall-green.png linphone.icns \
-contact_starred.png contact_unstarred.png
+contact_starred.png contact_unstarred.png \
+speaker.png
 
 EXTRA_DIST=$(pixmap_DATA)
index 6625269932c25f6b9567d12822b961634a9b33b7..349daad4b1907b349f31bc59826e39156b6be9d1 100644 (file)
Binary files a/pixmaps/mic_active.png and b/pixmaps/mic_active.png differ
index f813691fc5c3ca6840ef2d25901780c77692abb4..e540d00312a56fba38d8126a55c91333fbf3a84e 100644 (file)
Binary files a/pixmaps/mic_muted.png and b/pixmaps/mic_muted.png differ
diff --git a/pixmaps/speaker.png b/pixmaps/speaker.png
new file mode 100644 (file)
index 0000000..acc92db
Binary files /dev/null and b/pixmaps/speaker.png differ