pidgin.vv: 094ca19c: Added media functions to set input and o...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Sat Dec 13 05:40:50 EST 2008


-----------------------------------------------------------------
Revision: 094ca19cc431d185c7b94947bfcd7cfc2d2f4a0b
Ancestor: 2149cf9a6d4604f6e78ed9a2bdb0bbc3d6041a36
Author: maiku at soc.pidgin.im
Date: 2008-12-13T08:37:57
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/094ca19cc431d185c7b94947bfcd7cfc2d2f4a0b

Modified files:
        libpurple/media.c libpurple/media.h pidgin/gtkprefs.c

ChangeLog: 

Added media functions to set input and output volume.

-------------- next part --------------
============================================================
--- libpurple/media.c	52e4aadf6c0e94b4d673a9045958a6c38e1e4f85
+++ libpurple/media.c	b47f425b666c49fd6eb4fdbde62d6bff6848942c
@@ -451,6 +451,25 @@ purple_media_get_stream(PurpleMedia *med
 	return NULL;
 }
 
+static GList *
+purple_media_get_streams(PurpleMedia *media, const gchar *session,
+		const gchar *participant)
+{
+	GList *streams = media->priv->streams;
+	GList *ret = NULL;
+
+	for (; streams; streams = g_list_next(streams)) {
+		PurpleMediaStream *stream = streams->data;
+		if ((session == NULL ||
+				!strcmp(stream->session->id, session)) &&
+				(participant == NULL ||
+				!strcmp(stream->participant, participant)))
+			ret = g_list_append(ret, stream);
+	}
+
+	return ret;
+}
+
 static void
 purple_media_add_session(PurpleMedia *media, PurpleMediaSession *session)
 {
@@ -1378,4 +1397,46 @@ void purple_media_mute(PurpleMedia *medi
 	}
 }
 
+void purple_media_set_input_volume(PurpleMedia *media,
+		const gchar *session_id, double level)
+{
+	GList *sessions;
+
+	if (session_id == NULL)
+		sessions = g_hash_table_get_values(media->priv->sessions);
+	else
+		sessions = g_list_append(NULL,
+				purple_media_get_session(media, session_id));
+
+	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),
+					"purpleaudioinputvolume");
+			g_object_set(volume, "volume", level, NULL);
+		}
+	}
+}
+
+void purple_media_set_output_volume(PurpleMedia *media,
+		const gchar *session_id, const gchar *participant,
+		double level)
+{
+	GList *streams = purple_media_get_streams(media,
+				session_id, participant);
+
+	for (; streams; streams = g_list_delete_link(streams, streams)) {
+		PurpleMediaStream *stream = streams->data;
+
+		if (stream->session->type & PURPLE_MEDIA_RECV_AUDIO) {
+			GstElement *volume = gst_bin_get_by_name(
+					GST_BIN(stream->session->sink),
+					"purpleaudiooutputvolume");
+			g_object_set(volume, "volume", level, NULL);
+		}
+	}
+}
+
 #endif  /* USE_VV */
============================================================
--- libpurple/media.h	89d5851603ab4310df24b766affde0545c7d0209
+++ libpurple/media.h	d23cbaa40ac76a574c44cc91a77e4cd9e048714e
@@ -479,6 +479,26 @@ void purple_media_mute(PurpleMedia *medi
  */
 void purple_media_mute(PurpleMedia *media, gboolean active);
 
+/**
+ * Sets the input volume of all the selected sessions.
+ *
+ * @param media The media object the sessions are in.
+ * @param session_id The session to select (if any).
+ * @param level The level to set the volume to.
+ */
+void purple_media_set_input_volume(PurpleMedia *media, const gchar *session_id, double level);
+
+/**
+ * Sets the output volume of all the selected streams.
+ *
+ * @param media The media object the streams are in.
+ * @param session_id The session to limit the streams to (if any).
+ * @param participant The participant to limit the streams to (if any).
+ * @param level The level to set the volume to.
+ */
+void purple_media_set_output_volume(PurpleMedia *media, const gchar *session_id,
+		const gchar *participant, double level);
+
 #ifdef __cplusplus
 }
 #endif
============================================================
--- pidgin/gtkprefs.c	a4e601cd83981b968d4c26c96ad23a6649b079c5
+++ pidgin/gtkprefs.c	7a128c9282757c569a277232a06b6f107f539e99
@@ -2197,17 +2197,7 @@ prefs_media_input_volume_changed(GtkRang
 	val /= 10.0;
 	for (; medias; medias = g_list_next(medias)) {
 		PurpleMedia *media = PURPLE_MEDIA(medias->data);
-		GList *sessions = purple_media_get_session_names(media);
-		for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
-			const gchar *session = sessions->data;
-			if (purple_media_get_session_type(media, session)
-					& PURPLE_MEDIA_SEND_AUDIO) {
-				GstElement *volume = gst_bin_get_by_name(
-						GST_BIN(purple_media_get_src(media, session)),
-						"purpleaudioinputvolume");
-				g_object_set(volume, "volume", val, NULL);
-			}
-		}
+		purple_media_set_input_volume(media, NULL, val);
 	}
 }
 
@@ -2221,17 +2211,7 @@ prefs_media_output_volume_changed(GtkRan
 	val /= 10.0;
 	for (; medias; medias = g_list_next(medias)) {
 		PurpleMedia *media = PURPLE_MEDIA(medias->data);
-		GList *sessions = purple_media_get_session_names(media);
-		for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
-			const gchar *session = sessions->data;
-			if (purple_media_get_session_type(media, session)
-					& PURPLE_MEDIA_RECV_AUDIO) {
-				GstElement *volume = gst_bin_get_by_name(
-						GST_BIN(purple_media_get_sink(media, session)),
-						"purpleaudiooutputvolume");
-				g_object_set(volume, "volume", val, NULL);
-			}
-		}
+		purple_media_set_output_volume(media, NULL, NULL, val);
 	}
 }
 


More information about the Commits mailing list