changeset 26064:4f013819e4e3

Create the media srcs inside PurpleMedia.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Fri, 30 Jan 2009 06:39:41 +0000
parents 685c8f5f85c7
children 09386489e6d1
files libpurple/media.c pidgin/gtkmedia.c
diffstat 2 files changed, 18 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Fri Jan 30 04:40:54 2009 +0000
+++ b/libpurple/media.c	Fri Jan 30 06:39:41 2009 +0000
@@ -1565,6 +1565,7 @@
 	FsParticipant *participant = NULL;
 	PurpleMediaStream *stream = NULL;
 	FsStreamDirection *direction = NULL;
+	PurpleMediaSessionType session_type;
 
 	if (!session) {
 		GError *err = NULL;
@@ -1621,6 +1622,12 @@
 		g_signal_emit(media, purple_media_signals[STATE_CHANGED],
 				0, PURPLE_MEDIA_STATE_CHANGED_NEW,
 				session->id, NULL);
+
+		session_type = purple_media_from_fs(type, FS_DIRECTION_SEND);
+		purple_media_set_src(media, session->id,
+				purple_media_manager_get_element(
+				purple_media_manager_get(), session_type));
+		gst_element_set_state(session->src, GST_STATE_PLAYING);
 	}
 
 	if (!(participant = purple_media_add_participant(media, who))) {
--- a/pidgin/gtkmedia.c	Fri Jan 30 04:40:54 2009 +0000
+++ b/pidgin/gtkmedia.c	Fri Jan 30 06:39:41 2009 +0000
@@ -411,35 +411,13 @@
 {
 	GstElement *pipeline = purple_media_get_pipeline(media);
 	GtkWidget *send_widget = NULL, *recv_widget = NULL;
-	GstElement *audiosendbin = NULL, *audiosendlevel = NULL;
-	GstElement *videosendbin = NULL;
-	gboolean audiorecvbool = FALSE;
-	gboolean videorecvbool = FALSE;
 	gboolean is_initiator;
-
-	PurpleMediaSessionType type = purple_media_get_session_type(media, sid);
-	if (type & PURPLE_MEDIA_AUDIO) {
-		if (!audiosendbin && (type & PURPLE_MEDIA_SEND_AUDIO)) {
-			purple_media_audio_init_src(&audiosendbin, &audiosendlevel);
-			purple_media_set_src(media, sid, audiosendbin);
-			gst_element_set_state(audiosendbin, GST_STATE_PLAYING);
-		}
-		if (!audiorecvbool && (type & PURPLE_MEDIA_RECV_AUDIO)) {
-			audiorecvbool = TRUE;
-		}
-	} else if (type & PURPLE_MEDIA_VIDEO) {
-		if (!videosendbin && (type & PURPLE_MEDIA_SEND_VIDEO)) {
-			purple_media_video_init_src(&videosendbin);
-			purple_media_set_src(media, sid, videosendbin);
-			gst_element_set_state(videosendbin, GST_STATE_PLAYING);
-		}
-		if (!videorecvbool && (type & PURPLE_MEDIA_RECV_VIDEO)) {
-			videorecvbool = TRUE;
-		}
-	}
+	PurpleMediaSessionType type =
+			purple_media_get_session_type(media, sid);
 
 	if (gtkmedia->priv->recv_widget == NULL
-			&& (videorecvbool || audiorecvbool)) {
+			&& type & (PURPLE_MEDIA_RECV_VIDEO |
+			PURPLE_MEDIA_RECV_AUDIO)) {
 		recv_widget = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);	
 		gtk_box_pack_start(GTK_BOX(gtkmedia->priv->display),
 				recv_widget, TRUE, TRUE, 0);
@@ -447,7 +425,8 @@
 	} else
 		recv_widget = gtkmedia->priv->recv_widget;
 	if (gtkmedia->priv->send_widget == NULL
-			&& (videosendbin || audiosendbin)) {
+			&& type & (PURPLE_MEDIA_SEND_VIDEO |
+			PURPLE_MEDIA_SEND_AUDIO)) {
 		send_widget = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
 		gtk_box_pack_start(GTK_BOX(gtkmedia->priv->display),
 				send_widget, TRUE, TRUE, 0);
@@ -455,7 +434,7 @@
 	} else
 		send_widget = gtkmedia->priv->send_widget;
 
-	if (videorecvbool) {
+	if (type & PURPLE_MEDIA_RECV_VIDEO) {
 		PidginMediaRealizeData *data;
 		GtkWidget *aspect;
 		GtkWidget *remote_video;
@@ -494,7 +473,7 @@
 
 		gtkmedia->priv->remote_video = remote_video;
 	}
-	if (videosendbin) {
+	if (type & PURPLE_MEDIA_SEND_VIDEO) {
 		PidginMediaRealizeData *data;
 		GtkWidget *aspect;
 		GtkWidget *local_video;
@@ -535,7 +514,7 @@
 		gtkmedia->priv->local_video = local_video;
 	}
 
-	if (audiorecvbool) {
+	if (type & PURPLE_MEDIA_RECV_AUDIO) {
 		gtkmedia->priv->recv_progress = gtk_progress_bar_new();
 		gtk_widget_set_size_request(gtkmedia->priv->recv_progress, 10, 70);
 		gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(gtkmedia->priv->recv_progress),
@@ -544,7 +523,7 @@
 				   gtkmedia->priv->recv_progress, FALSE, FALSE, 0);
 		gtk_widget_show(gtkmedia->priv->recv_progress);
 	}
-	if (audiosendbin) {
+	if (type & PURPLE_MEDIA_SEND_AUDIO) {
 		gtkmedia->priv->send_progress = gtk_progress_bar_new();
 		gtk_widget_set_size_request(gtkmedia->priv->send_progress, 10, 70);
 		gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(gtkmedia->priv->send_progress),
@@ -557,7 +536,7 @@
 	}
 
 
-	if (audiorecvbool || audiosendbin) {
+	if (type & PURPLE_MEDIA_AUDIO) {
 		GstBus *bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
 		g_signal_connect(G_OBJECT(bus), "message::element",
 				G_CALLBACK(level_message_cb), gtkmedia);