pidgin: e990a9de: Fix unidirectional media sessions and ad...

maiku at pidgin.im maiku at pidgin.im
Thu Aug 13 03:32:05 EDT 2009


-----------------------------------------------------------------
Revision: e990a9de36ac03935b27af57118f0da148269839
Ancestor: acf4cce929cd032affb8793d84b0506d8867e04c
Author: maiku at pidgin.im
Date: 2009-08-13T04:55:29
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e990a9de36ac03935b27af57118f0da148269839

Modified files:
        libpurple/media.c libpurple/mediamanager.c
        libpurple/protocols/jabber/jingle/rtp.c

ChangeLog: 

Fix unidirectional media sessions and add a colorspace before the video sink.

-------------- next part --------------
============================================================
--- libpurple/media.c	516b1f88f185f1f0890efa4a8e74d1f30d9cfde6
+++ libpurple/media.c	abe09ca844b5a33aee5277181c968cb2350c2e41
@@ -2617,26 +2617,27 @@ purple_media_add_stream(PurpleMedia *med
 				0, PURPLE_MEDIA_STATE_NEW,
 				session->id, NULL);
 
-		session_type = purple_media_from_fs(media_type,
-				FS_DIRECTION_SEND);
-		src = purple_media_manager_get_element(
-				media->priv->manager, session_type,
-				media, session->id, who);
-		if (!GST_IS_ELEMENT(src)) {
-			purple_debug_error("media",
-					"Error creating src for session %s\n",
-					session->id);
-			purple_media_end(media, session->id, NULL);
-			return FALSE;
-		}
+		if (type_direction & FS_DIRECTION_SEND) {
+			session_type = purple_media_from_fs(media_type,
+					FS_DIRECTION_SEND);
+			src = purple_media_manager_get_element(
+					media->priv->manager, session_type,
+					media, session->id, who);
+			if (!GST_IS_ELEMENT(src)) {
+				purple_debug_error("media",
+						"Error creating src for session %s\n",
+						session->id);
+				purple_media_end(media, session->id, NULL);
+				return FALSE;
+			}
 
-		purple_media_set_src(media, session->id, src);
-		gst_element_set_state(session->src, GST_STATE_PLAYING);
-
-		purple_media_manager_create_output_window(
-				media->priv->manager,
-				session->media,
-				session->id, NULL);
+			purple_media_set_src(media, session->id, src);
+			gst_element_set_state(session->src, GST_STATE_PLAYING);
+			purple_media_manager_create_output_window(
+					media->priv->manager,
+					session->media,
+					session->id, NULL);
+		}
 	}
 
 	if (!(participant = purple_media_add_participant(media, who))) {
@@ -3002,14 +3003,23 @@ purple_media_codecs_ready(PurpleMedia *m
 
 		if (session == NULL)
 			return FALSE;
-
-		g_object_get(session->session, "codecs-ready", &ret, NULL);
+		if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
+				PURPLE_MEDIA_SEND_VIDEO))
+			g_object_get(session->session,
+					"codecs-ready", &ret, NULL);
+		else
+			ret = TRUE;
 	} else {
 		GList *values = g_hash_table_get_values(media->priv->sessions);
 		for (; values; values = g_list_delete_link(values, values)) {
 			PurpleMediaSession *session = values->data;
-			g_object_get(session->session,
-					"codecs-ready", &ret, NULL);
+			if (session->type & (PURPLE_MEDIA_SEND_AUDIO |
+					PURPLE_MEDIA_SEND_VIDEO))
+				g_object_get(session->session,
+						"codecs-ready", &ret, NULL);
+			else
+				ret = TRUE;
+
 			if (ret == FALSE)
 				break;
 		}
============================================================
--- libpurple/mediamanager.c	bc4d126cb3b56a5fd729f6c8f19a5da95ef0ff95
+++ libpurple/mediamanager.c	ec0118a0a25ee397dae80dda58908e8349d39dcd
@@ -714,7 +714,7 @@ purple_media_manager_create_output_windo
 				(participant == ow->participant)) &&
 				!strcmp(session_id, ow->session_id)) {
 			GstBus *bus;
-			GstElement *queue;
+			GstElement *queue, *colorspace;
 			GstElement *tee = purple_media_get_tee(media,
 					session_id, participant);
 
@@ -723,6 +723,8 @@ purple_media_manager_create_output_windo
 
 			queue = gst_element_factory_make(
 					"queue", NULL);
+			colorspace = gst_element_factory_make(
+					"ffmpegcolorspace", NULL);
 			ow->sink = purple_media_manager_get_element(
 					manager, PURPLE_MEDIA_RECV_VIDEO,
 					ow->media, ow->session_id,
@@ -743,7 +745,7 @@ purple_media_manager_create_output_windo
 			}
 
 			gst_bin_add_many(GST_BIN(GST_ELEMENT_PARENT(tee)),
-					queue, ow->sink, NULL);
+					queue, colorspace, ow->sink, NULL);
 
 			bus = gst_pipeline_get_bus(GST_PIPELINE(
 					manager->priv->pipeline));
@@ -752,8 +754,10 @@ purple_media_manager_create_output_windo
 			gst_object_unref(bus);
 
 			gst_element_set_state(ow->sink, GST_STATE_PLAYING);
+			gst_element_set_state(colorspace, GST_STATE_PLAYING);
 			gst_element_set_state(queue, GST_STATE_PLAYING);
-			gst_element_link(queue, ow->sink);
+			gst_element_link(colorspace, ow->sink);
+			gst_element_link(queue, colorspace);
 			gst_element_link(tee, queue);
 		}
 	}
@@ -822,8 +826,14 @@ purple_media_manager_remove_output_windo
 		GstPad *pad = gst_element_get_static_pad(
 				output_window->sink, "sink");
 		GstPad *peer = gst_pad_get_peer(pad);
-		GstElement *queue = GST_ELEMENT_PARENT(peer);
+		GstElement *colorspace = GST_ELEMENT_PARENT(peer), *queue;
 		gst_object_unref(pad);
+		gst_object_unref(peer);
+		pad = gst_element_get_static_pad(colorspace, "sink");
+		peer = gst_pad_get_peer(pad);
+		queue = GST_ELEMENT_PARENT(peer);
+		gst_object_unref(pad);
+		gst_object_unref(peer);
 		pad = gst_element_get_static_pad(queue, "sink");
 		peer = gst_pad_get_peer(pad);
 		gst_object_unref(pad);
@@ -832,6 +842,9 @@ purple_media_manager_remove_output_windo
 		gst_element_set_locked_state(queue, TRUE);
 		gst_element_set_state(queue, GST_STATE_NULL);
 		gst_bin_remove(GST_BIN(GST_ELEMENT_PARENT(queue)), queue);
+		gst_element_set_locked_state(colorspace, TRUE);
+		gst_element_set_state(colorspace, GST_STATE_NULL);
+		gst_bin_remove(GST_BIN(GST_ELEMENT_PARENT(colorspace)), colorspace);
 		gst_element_set_locked_state(output_window->sink, TRUE);
 		gst_element_set_state(output_window->sink, GST_STATE_NULL);
 		gst_bin_remove(GST_BIN(GST_ELEMENT_PARENT(output_window->sink)),
============================================================
--- libpurple/protocols/jabber/jingle/rtp.c	e7a8115d8ded3c16a65a5e84d206ede32b83fb6c
+++ libpurple/protocols/jabber/jingle/rtp.c	f20cca5138b1d953b7ae104bb8e6a8d112bbb381
@@ -589,8 +589,8 @@ jingle_rtp_init_media(JingleContent *con
 	if (!strcmp(senders, "both"))
 		type = is_audio == TRUE ? PURPLE_MEDIA_AUDIO
 				: PURPLE_MEDIA_VIDEO;
-	else if (!strcmp(senders, "initiator")
-			&& jingle_session_is_initiator(session))
+	else if ((strcmp(senders, "initiator") == 0) ==
+			jingle_session_is_initiator(session))
 		type = is_audio == TRUE ? PURPLE_MEDIA_SEND_AUDIO
 				: PURPLE_MEDIA_SEND_VIDEO;
 	else


More information about the Commits mailing list