pidgin.vv: 4dbef520: Replace the ready signal in PidginMedia.

maiku at soc.pidgin.im maiku at soc.pidgin.im
Tue Jan 13 06:35:55 EST 2009


-----------------------------------------------------------------
Revision: 4dbef5200fa1106b8cc1926e91928aa7becef507
Ancestor: 35c21b92337345a511b36a989a534f2744c58dd4
Author: maiku at soc.pidgin.im
Date: 2009-01-13T10:42:20
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/4dbef5200fa1106b8cc1926e91928aa7becef507

Modified files:
        pidgin/gtkmedia.c

ChangeLog: 

Replace the ready signal in PidginMedia.

-------------- next part --------------
============================================================
--- pidgin/gtkmedia.c	306f9e6fd117718825bbdee318f399d8c2ffe18b
+++ pidgin/gtkmedia.c	dd163b9397a60d79933a3dac84094a06910aba03
@@ -67,6 +67,8 @@ struct _PidginMediaPrivate
 	PidginMediaState state;
 
 	GtkWidget *display;
+	GtkWidget *send_widget;
+	GtkWidget *recv_widget;
 	GtkWidget *local_video;
 	GtkWidget *remote_video;
 };
@@ -389,7 +391,7 @@ static void
 }
 
 static void
-pidgin_media_ready_cb(PurpleMedia *media, PidginMedia *gtkmedia)
+pidgin_media_ready_cb(PurpleMedia *media, PidginMedia *gtkmedia, const gchar *sid)
 {
 	GstElement *pipeline = purple_media_get_pipeline(media);
 	GtkWidget *send_widget = NULL, *recv_widget = NULL;
@@ -399,43 +401,43 @@ pidgin_media_ready_cb(PurpleMedia *media
 	gboolean videorecvbool = FALSE;
 	GstBus *bus;
 
-	GList *sessions = purple_media_get_session_names(media);
-
-	for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
-		PurpleMediaSessionType type = purple_media_get_session_type(media, sessions->data);
-		if (type & PURPLE_MEDIA_AUDIO) {
-			if (!audiosendbin && (type & PURPLE_MEDIA_SEND_AUDIO)) {
-				purple_media_audio_init_src(&audiosendbin, &audiosendlevel);
-				purple_media_set_src(media, sessions->data, 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);
-				gst_element_set_locked_state(videosendbin, TRUE);
-				purple_media_set_src(media, sessions->data, videosendbin);
-			}
-			if (!videorecvbool && (type & PURPLE_MEDIA_RECV_VIDEO)) {
-				videorecvbool = TRUE;
-			}
+	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);
+			gst_element_set_locked_state(videosendbin, TRUE);
+			purple_media_set_src(media, sid, videosendbin);
+		}
+		if (!videorecvbool && (type & PURPLE_MEDIA_RECV_VIDEO)) {
+			videorecvbool = TRUE;
+		}
 	}
 
-	if (videorecvbool || audiorecvbool) {
-		recv_widget = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
+	if (gtkmedia->priv->recv_widget == NULL
+			&& (videorecvbool || audiorecvbool)) {
+		recv_widget = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);	
 		gtk_box_pack_start(GTK_BOX(gtkmedia->priv->display),
 				recv_widget, TRUE, TRUE, 0);
 		gtk_widget_show(recv_widget);
-	}
-	if (videosendbin || audiosendbin) {
+	} else
+		recv_widget = gtkmedia->priv->recv_widget;
+	if (gtkmedia->priv->send_widget == NULL
+			&& (videosendbin || audiosendbin)) {
 		send_widget = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
 		gtk_box_pack_start(GTK_BOX(gtkmedia->priv->display),
 				send_widget, TRUE, TRUE, 0);
 		gtk_widget_show(send_widget);
-	}
+	} else
+		send_widget = gtkmedia->priv->send_widget;
 
 	if (videorecvbool) {
 		GtkWidget *aspect;
@@ -535,12 +537,11 @@ pidgin_media_ready_cb(PurpleMedia *media
 				G_CALLBACK(level_message_cb), gtkmedia);
 
 	gst_object_unref(bus);
-}
 
-static void
-pidgin_media_wait_cb(PurpleMedia *media, PidginMedia *gtkmedia)
-{
-	pidgin_media_set_state(gtkmedia, PIDGIN_MEDIA_WAITING);
+	if (send_widget != NULL)
+		gtkmedia->priv->send_widget = send_widget;
+	if (recv_widget != NULL)
+		gtkmedia->priv->recv_widget = recv_widget;
 }
 
 static void
@@ -583,6 +584,9 @@ pidgin_media_state_changed_cb(PurpleMedi
 			pidgin_media_emit_message(gtkmedia,
 					_("You have rejected the call."));
 		}
+	} else if (type == PURPLE_MEDIA_STATE_CHANGED_NEW &&
+			sid != NULL && name != NULL) {
+		pidgin_media_ready_cb(media, gtkmedia, sid);
 	} else if (type == PURPLE_MEDIA_STATE_CHANGED_CONNECTED) {
 		GstElement *audiosendbin = NULL, *audiorecvbin = NULL;
 		GstElement *videosendbin = NULL, *videorecvbin = NULL;
@@ -630,8 +634,6 @@ pidgin_media_set_property (GObject *obje
 
 			g_signal_connect(G_OBJECT(media->priv->media), "error",
 				G_CALLBACK(pidgin_media_error_cb), media);
-			g_signal_connect(G_OBJECT(media->priv->media) ,"ready",
-				G_CALLBACK(pidgin_media_ready_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "got-request",
 				G_CALLBACK(pidgin_media_got_request_cb), media);
 			g_signal_connect(G_OBJECT(media->priv->media), "state-changed",


More information about the Commits mailing list