Mercurial > pidgin.yaz
changeset 25713:4eae2d40f11b
Added a mute button for the local microphone.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Wed, 23 Jul 2008 22:34:22 +0000 |
parents | 3ffe166a355e |
children | 97f3a3409a1d |
files | libpurple/media.c libpurple/media.h pidgin/gtkmedia.c |
diffstat | 3 files changed, 38 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/media.c Wed Jul 23 20:10:18 2008 +0000 +++ b/libpurple/media.c Wed Jul 23 22:34:22 2008 +0000 @@ -757,6 +757,7 @@ purple_media_audio_init_src(GstElement **sendbin, GstElement **sendlevel) { GstElement *src; + GstElement *volume; GstPad *pad; GstPad *ghost; const gchar *audio_device = purple_prefs_get_string("/purple/media/audio/device"); @@ -765,9 +766,11 @@ *sendbin = gst_bin_new("purplesendaudiobin"); src = gst_element_factory_make("alsasrc", "asrc"); + volume = gst_element_factory_make("volume", "purpleaudiovolume"); *sendlevel = gst_element_factory_make("level", "sendlevel"); - gst_bin_add_many(GST_BIN(*sendbin), src, *sendlevel, NULL); - gst_element_link(src, *sendlevel); + gst_bin_add_many(GST_BIN(*sendbin), src, volume, *sendlevel, NULL); + gst_element_link(src, volume); + gst_element_link(volume, *sendlevel); pad = gst_element_get_pad(*sendlevel, "src"); ghost = gst_ghost_pad_new("ghostsrc", pad); gst_element_add_pad(*sendbin, ghost); @@ -1253,4 +1256,20 @@ return TRUE; } +void purple_media_mute(PurpleMedia *media, gboolean active) +{ + GList *sessions = g_hash_table_get_values(media->priv->sessions); + purple_debug_info("media", "Turning mute %s\n", active ? "on" : "off"); + + for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { + PurpleMediaSession *session = sessions->data; + if (session->type & PURPLE_MEDIA_SEND_AUDIO) { + GstElement *volume = gst_bin_get_by_name( + GST_BIN(session->src), + "purpleaudiovolume"); + g_object_set(volume, "mute", active, NULL); + } + } +} + #endif /* USE_VV */
--- a/libpurple/media.h Wed Jul 23 20:10:18 2008 +0000 +++ b/libpurple/media.h Wed Jul 23 22:34:22 2008 +0000 @@ -149,6 +149,8 @@ gboolean purple_media_set_send_codec(PurpleMedia *media, const gchar *sess_id, FsCodec *codec); +void purple_media_mute(PurpleMedia *media, gboolean active); + G_END_DECLS #endif /* USE_VV */
--- a/pidgin/gtkmedia.c Wed Jul 23 20:10:18 2008 +0000 +++ b/pidgin/gtkmedia.c Wed Jul 23 22:34:22 2008 +0000 @@ -58,6 +58,7 @@ GtkWidget *accept; GtkWidget *reject; GtkWidget *hangup; + GtkWidget *mute; GtkWidget *send_progress; GtkWidget *recv_progress; @@ -157,6 +158,12 @@ g_type_class_add_private(klass, sizeof(PidginMediaPrivate)); } +static void +pidgin_media_mute_toggled(GtkToggleButton *toggle, PidginMedia *media) +{ + purple_media_mute(media->priv->media, + gtk_toggle_button_get_active(toggle)); +} static void pidgin_media_init (PidginMedia *media) @@ -166,11 +173,16 @@ media->priv->hangup = gtk_button_new_with_label("Hangup"); media->priv->accept = gtk_button_new_with_label("Accept"); media->priv->reject = gtk_button_new_with_label("Reject"); + media->priv->mute = gtk_toggle_button_new_with_label("Mute"); + + g_signal_connect(media->priv->mute, "toggled", + G_CALLBACK(pidgin_media_mute_toggled), media); gtk_box_pack_start(GTK_BOX(media), media->priv->calling, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(media), media->priv->hangup, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(media), media->priv->accept, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(media), media->priv->reject, FALSE, FALSE, 0); + gtk_box_pack_end(GTK_BOX(media), media->priv->mute, FALSE, FALSE, 0); gtk_widget_show_all(media->priv->accept); gtk_widget_show_all(media->priv->reject); @@ -572,18 +584,21 @@ gtk_widget_hide(gtkmedia->priv->accept); gtk_widget_hide(gtkmedia->priv->reject); gtk_widget_show(gtkmedia->priv->hangup); + gtk_widget_hide(gtkmedia->priv->mute); break; case PIDGIN_MEDIA_REQUESTED: gtk_widget_hide(gtkmedia->priv->calling); gtk_widget_show(gtkmedia->priv->accept); gtk_widget_show(gtkmedia->priv->reject); gtk_widget_hide(gtkmedia->priv->hangup); + gtk_widget_hide(gtkmedia->priv->mute); break; case PIDGIN_MEDIA_ACCEPTED: gtk_widget_show(gtkmedia->priv->hangup); gtk_widget_hide(gtkmedia->priv->calling); gtk_widget_hide(gtkmedia->priv->accept); gtk_widget_hide(gtkmedia->priv->reject); + gtk_widget_show(gtkmedia->priv->mute); break; default: break;