changeset 25694:72e738dac5f7

Wait to set up the voice and video GUI until the responder has accepted the session.
author Mike Ruprecht <maiku@soc.pidgin.im>
date Fri, 27 Jun 2008 18:44:49 +0000
parents b8e0a56cd6cf
children 13936e4405b7
files libpurple/media.c pidgin/gtkmedia.c
diffstat 2 files changed, 48 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/media.c	Fri Jun 27 18:01:13 2008 +0000
+++ b/libpurple/media.c	Fri Jun 27 18:44:49 2008 +0000
@@ -436,15 +436,22 @@
 purple_media_get_elements(PurpleMedia *media, GstElement **audio_src, GstElement **audio_sink,
                                                   GstElement **video_src, GstElement **video_sink)
 {
-	 if (audio_src) 
-		g_object_get(G_OBJECT(media), "audio-src", *audio_src, NULL);
-	 if (audio_sink) 
-		g_object_get(G_OBJECT(media), "audio-sink", *audio_sink, NULL);
-	 if (video_src) 
-		g_object_get(G_OBJECT(media), "video-src", *video_src, NULL);
-	 if (video_sink) 
-		g_object_get(G_OBJECT(media), "video-sink", *video_sink, NULL);
+	GList *values = g_hash_table_get_values(media->priv->sessions);
+
+	for (; values; values = values->next) {
+		PurpleMediaSession *session = (PurpleMediaSession*)values->data;
 
+		if (session->type & PURPLE_MEDIA_SEND_AUDIO && audio_src)
+			*audio_src = session->src;
+		if (session->type & PURPLE_MEDIA_RECV_AUDIO && audio_sink)
+			*audio_sink = session->sink;
+		if (session->type & PURPLE_MEDIA_SEND_VIDEO && video_src)
+			*video_src = session->src;
+		if (session->type & PURPLE_MEDIA_RECV_VIDEO && video_sink)
+			*video_sink = session->sink;
+	}
+
+	g_list_free(values);
 }
 
 void 
--- a/pidgin/gtkmedia.c	Fri Jun 27 18:01:13 2008 +0000
+++ b/pidgin/gtkmedia.c	Fri Jun 27 18:44:49 2008 +0000
@@ -289,7 +289,6 @@
 pidgin_media_ready_cb(PurpleMedia *media, PidginMedia *gtkmedia)
 {
 	GstElement *element = purple_media_get_pipeline(media);
-	GtkWidget *send_widget = NULL, *recv_widget = NULL;
 
 	GstElement *audiosendbin = NULL, *audiosendlevel = NULL;
 	GstElement *audiorecvbin = NULL, *audiorecvlevel = NULL;
@@ -324,6 +323,39 @@
 				       NULL);
 	}
 
+	bus = gst_pipeline_get_bus(GST_PIPELINE(element));
+	gst_bus_add_signal_watch(GST_BUS(bus));
+	g_signal_connect(G_OBJECT(gst_pipeline_get_bus(GST_PIPELINE(element))),
+			 "message", G_CALLBACK(level_message_cb), gtkmedia);
+	if (videorecvbin || videosendbin)
+		gst_bus_set_sync_handler(bus, (GstBusSyncHandler)create_window, gtkmedia);
+	gst_object_unref(bus);
+}
+
+static void
+pidgin_media_wait_cb(PurpleMedia *media, PidginMedia *gtkmedia)
+{
+	pidgin_media_set_state(gtkmedia, PIDGIN_MEDIA_WAITING);
+}
+
+/* maybe we should have different callbacks for when we received the accept
+    and we accepted ourselves */
+static void
+pidgin_media_accept_cb(PurpleMedia *media, PidginMedia *gtkmedia)
+{
+	GtkWidget *send_widget = NULL, *recv_widget = NULL;
+
+	GstElement *audiosendbin = NULL;
+	GstElement *audiorecvbin = NULL;
+	GstElement *videosendbin = NULL;
+	GstElement *videorecvbin = NULL;
+
+	pidgin_media_emit_message(gtkmedia, _("Call in progress."));
+	pidgin_media_set_state(gtkmedia, PIDGIN_MEDIA_ACCEPTED);
+
+	purple_media_get_elements(media, &audiosendbin, &audiorecvbin,
+				  &videosendbin, &videorecvbin);
+
 	recv_widget = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
 	send_widget = gtk_hbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
 
@@ -385,29 +417,6 @@
 		gtk_widget_show(gtkmedia->priv->send_progress);
 		gtk_widget_show(gtkmedia->priv->recv_progress);
 	}
-
-	bus = gst_pipeline_get_bus(GST_PIPELINE(element));
-	gst_bus_add_signal_watch(GST_BUS(bus));
-	g_signal_connect(G_OBJECT(gst_pipeline_get_bus(GST_PIPELINE(element))),
-			 "message", G_CALLBACK(level_message_cb), gtkmedia);
-	if (videorecvbin || videosendbin)
-		gst_bus_set_sync_handler(bus, (GstBusSyncHandler)create_window, gtkmedia);
-	gst_object_unref(bus);
-}
-
-static void
-pidgin_media_wait_cb(PurpleMedia *media, PidginMedia *gtkmedia)
-{
-	pidgin_media_set_state(gtkmedia, PIDGIN_MEDIA_WAITING);
-}
-
-/* maybe we should have different callbacks for when we received the accept
-    and we accepted ourselves */
-static void
-pidgin_media_accept_cb(PurpleMedia *media, PidginMedia *gtkmedia)
-{
-	pidgin_media_emit_message(gtkmedia, _("Call in progress."));
-	pidgin_media_set_state(gtkmedia, PIDGIN_MEDIA_ACCEPTED);
 }
 
 static void