cpw.maiku.media_refactor: 44c96507: Move volume setting functionality to the...

maiku at pidgin.im maiku at pidgin.im
Tue Oct 27 20:27:40 EDT 2009


-----------------------------------------------------------------
Revision: 44c96507d5457ea7774c1cda8e4ac44722918cf5
Ancestor: 1f4c2359022747b140aef8e53cf96a1b1d092367
Author: maiku at pidgin.im
Date: 2009-10-27T21:16:27
Branch: im.pidgin.cpw.maiku.media_refactor
URL: http://d.pidgin.im/viewmtn/revision/info/44c96507d5457ea7774c1cda8e4ac44722918cf5

Modified files:
        libpurple/media/backend-fs2.c libpurple/media/backend-fs2.h
        libpurple/media/media.c

ChangeLog: 

Move volume setting functionality to the Fs2 media backend.

-------------- next part --------------
============================================================
--- libpurple/media/backend-fs2.c	32960548146f318e667bc6e5769eafe59c29fc39
+++ libpurple/media/backend-fs2.c	65d2902cc138f51b0fd732b0f7a368eeaa39b426
@@ -1960,3 +1960,62 @@ purple_media_backend_fs2_get_tee(PurpleM
 
 	g_return_val_if_reached(NULL);
 }
+
+void
+purple_media_backend_fs2_set_input_volume(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, double level)
+{
+	PurpleMediaBackendFs2Private *priv;
+	GList *sessions;
+
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self));
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+
+	purple_prefs_set_int("/purple/media/audio/volume/input", level);
+
+	if (sess_id == NULL)
+		sessions = g_hash_table_get_values(priv->sessions);
+	else
+		sessions = g_list_append(NULL, _get_session(self, sess_id));
+
+	for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
+		PurpleMediaBackendFs2Session *session = sessions->data;
+
+		if (session->type & PURPLE_MEDIA_SEND_AUDIO) {
+			gchar *name = g_strdup_printf("volume_%s",
+					session->id);
+			GstElement *volume = gst_bin_get_by_name(
+					GST_BIN(priv->confbin), name);
+			g_free(name);
+			g_object_set(volume, "volume", level/10.0, NULL);
+		}
+	}
+}
+
+void
+purple_media_backend_fs2_set_output_volume(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, const gchar *who, double level)
+{
+	
+	PurpleMediaBackendFs2Private *priv;
+	GList *streams;
+
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(self));
+
+	priv = PURPLE_MEDIA_BACKEND_FS2_GET_PRIVATE(self);
+
+	purple_prefs_set_int("/purple/media/audio/volume/output", level);
+
+	streams = _get_streams(self, sess_id, who);
+
+	for (; streams; streams = g_list_delete_link(streams, streams)) {
+		PurpleMediaBackendFs2Stream *stream = streams->data;
+
+		if (stream->session->type & PURPLE_MEDIA_RECV_AUDIO
+				&& GST_IS_ELEMENT(stream->volume)) {
+			g_object_set(stream->volume, "volume",
+					level/10.0, NULL);
+		}
+	}
+}
============================================================
--- libpurple/media/backend-fs2.h	e6d4f6d05cc17c3716c14a0776ebfc42a7a2449a
+++ libpurple/media/backend-fs2.h	8e59f3233787679b1f089524a23b2a791bf91bda
@@ -71,6 +71,10 @@ GstElement *purple_media_backend_fs2_get
 GstElement *purple_media_backend_fs2_get_tee(
 		PurpleMediaBackendFs2 *self,
 		const gchar *sess_id, const gchar *who);
+void purple_media_backend_fs2_set_input_volume(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, double level);
+void purple_media_backend_fs2_set_output_volume(PurpleMediaBackendFs2 *self,
+		const gchar *sess_id, const gchar *who, double level);
 /* end tmp */
 
 G_END_DECLS
============================================================
--- libpurple/media/media.c	ff0e04399f0109df562dc9fc60c9330284b93e24
+++ libpurple/media/media.c	c9b7747c76d3db3c3fad9c83759bd6d81b724144
@@ -1176,31 +1176,13 @@ void purple_media_set_input_volume(Purpl
 		const gchar *session_id, double level)
 {
 #ifdef USE_VV
-	GList *sessions;
-
 	g_return_if_fail(PURPLE_IS_MEDIA(media));
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(media->priv->backend));
 
-	purple_prefs_set_int("/purple/media/audio/volume/input", level);
-
-	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) {
-			gchar *name = g_strdup_printf("volume_%s",
-					session->id);
-			GstElement *volume = gst_bin_get_by_name(
-					GST_BIN(session->media->priv->confbin),
-					name);
-			g_free(name);
-			g_object_set(volume, "volume", level/10.0, NULL);
-		}
-	}
+	purple_media_backend_fs2_set_input_volume(
+			PURPLE_MEDIA_BACKEND_FS2(
+			media->priv->backend),
+			session_id, level);
 #endif
 }
 
@@ -1209,23 +1191,13 @@ void purple_media_set_output_volume(Purp
 		double level)
 {
 #ifdef USE_VV
-	GList *streams;
-
 	g_return_if_fail(PURPLE_IS_MEDIA(media));
+	g_return_if_fail(PURPLE_IS_MEDIA_BACKEND_FS2(media->priv->backend));
 
-	purple_prefs_set_int("/purple/media/audio/volume/output", level);
-
-	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
-				&& GST_IS_ELEMENT(stream->volume)) {
-			g_object_set(stream->volume, "volume", level/10.0, NULL);
-		}
-	}
+	purple_media_backend_fs2_set_output_volume(
+			PURPLE_MEDIA_BACKEND_FS2(
+			media->priv->backend),
+			session_id, participant, level);
 #endif
 }
 


More information about the Commits mailing list