soc.2008.vv: bb951c69: Decouple stream direction. Allows send o...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Sat Aug 16 21:35:46 EDT 2008


-----------------------------------------------------------------
Revision: bb951c695ca37cb37503370768894976a000527e
Ancestor: ff590a90a6aa3b7dfa2f25f23daae27d3276f5b2
Author: maiku at soc.pidgin.im
Date: 2008-08-17T00:49:29
Branch: im.pidgin.soc.2008.vv
URL: http://d.pidgin.im/viewmtn/revision/info/bb951c695ca37cb37503370768894976a000527e

Modified files:
        libpurple/protocols/jabber/jingle.c pidgin/gtkmedia.c

ChangeLog: 

Decouple stream direction. Allows send only or recv only streams.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle.c	f6b3635b7aa719517a22ec766cfb53753c25cf0d
+++ libpurple/protocols/jabber/jingle.c	494c5a27f19840f164f43ca76522b72553fca5e2
@@ -847,9 +847,9 @@ jabber_jingle_session_content_create_med
 	gchar sender[10] = "";
 
 	if (type & PURPLE_MEDIA_AUDIO) {
-		if (type == PURPLE_MEDIA_SEND_AUDIO)
+		if ((type & PURPLE_MEDIA_AUDIO) == PURPLE_MEDIA_SEND_AUDIO)
 			strcpy(sender, "initiator");
-		else if (type == PURPLE_MEDIA_RECV_AUDIO)
+		else if ((type & PURPLE_MEDIA_AUDIO) == PURPLE_MEDIA_RECV_AUDIO)
 			strcpy(sender, "responder");
 		else
 			strcpy(sender, "both");
@@ -858,9 +858,9 @@ jabber_jingle_session_content_create_med
 				TRANSPORT_ICEUDP, JINGLE_RTP, "audio");
 	}
 	if (type & PURPLE_MEDIA_VIDEO) {
-		if (type == PURPLE_MEDIA_SEND_VIDEO)
+		if ((type & PURPLE_MEDIA_VIDEO) == PURPLE_MEDIA_SEND_VIDEO)
 			strcpy(sender, "initiator");
-		else if (type == PURPLE_MEDIA_RECV_VIDEO)
+		else if ((type & PURPLE_MEDIA_VIDEO) == PURPLE_MEDIA_RECV_VIDEO)
 			strcpy(sender, "responder");
 		else
 			strcpy(sender, "both");
@@ -947,16 +947,35 @@ jabber_jingle_session_initiate_media_int
 	for (; contents; contents = g_list_delete_link(contents, contents)) {
 		JingleSessionContent *jsc = contents->data;
 		gboolean result = FALSE;
+		const gchar *sender = jabber_jingle_session_content_get_sender(jsc);
+		FsStreamDirection direction = FS_DIRECTION_NONE;
 
+		if (!strcmp(sender, "initiator"))
+			direction = FS_DIRECTION_SEND;
+		else if(!strcmp(sender, "responder"))
+			direction = FS_DIRECTION_RECV;
+		else
+			direction = FS_DIRECTION_BOTH;
+
+		if (!jabber_jingle_session_is_initiator(session)
+				&& direction != FS_DIRECTION_BOTH) {
+			if (direction == FS_DIRECTION_SEND)
+				direction = FS_DIRECTION_RECV;
+			else
+				direction = FS_DIRECTION_SEND;
+		}
+
 		/* these will need to be changed to "nice" once the libnice transmitter is finished */
 		if (jabber_jingle_session_content_is_vv_type(jsc, "audio")) {
 			result = purple_media_add_stream(media, "audio-content", remote_jid,
-							 PURPLE_MEDIA_AUDIO, "rawudp");
+					purple_media_from_fs(FS_MEDIA_TYPE_AUDIO, direction),
+					"rawudp");
 			purple_debug_info("jingle", "Created Jingle audio session\n");
 		}
 		else if (jabber_jingle_session_content_is_vv_type(jsc, "video")) {
 			result = purple_media_add_stream(media, "video-content", remote_jid,
-							 PURPLE_MEDIA_VIDEO, "rawudp");
+					purple_media_from_fs(FS_MEDIA_TYPE_VIDEO, direction),
+					"rawudp");
 			purple_debug_info("jingle", "Created Jingle video session\n");
 		}
 
============================================================
--- pidgin/gtkmedia.c	b912cd4fc26c8e4d942cd3478092856c298315bd
+++ pidgin/gtkmedia.c	eaf1226d948f017313a0517ccf40e8c0a163e0e7
@@ -187,7 +187,7 @@ pidgin_media_init (PidginMedia *media)
 	gtk_widget_show_all(media->priv->accept);
 	gtk_widget_show_all(media->priv->reject);
 
-	media->priv->display = gtk_vbox_new(FALSE, PIDGIN_HIG_BOX_SPACE);
+	media->priv->display = gtk_vbox_new(TRUE, PIDGIN_HIG_BOX_SPACE);
 }
 
 static gboolean
@@ -308,30 +308,33 @@ pidgin_media_ready_cb(PurpleMedia *media
 	GList *sessions = purple_media_get_session_names(media);
 
 	for (; sessions; sessions = g_list_delete_link(sessions, sessions)) {
-		if (purple_media_get_session_type(media, sessions->data) & PURPLE_MEDIA_AUDIO) {
-			if (!audiosendbin)
+		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);
-			if (!audiorecvbin)
+				purple_media_set_src(media, sessions->data, audiosendbin);
+				gst_element_set_state(audiosendbin, GST_STATE_READY);
+			}
+			if (!audiorecvbin && (type & PURPLE_MEDIA_RECV_AUDIO)) {
 				purple_media_audio_init_recv(&audiorecvbin, &audiorecvlevel);
-			purple_media_set_src(media, sessions->data, audiosendbin);
-			purple_media_set_sink(media, sessions->data, audiorecvbin);
-
-			gst_element_set_state(audiosendbin, GST_STATE_READY);
-			gst_element_set_state(audiorecvbin, GST_STATE_READY);
+				purple_media_set_sink(media, sessions->data, audiorecvbin);
+				gst_element_set_state(audiorecvbin, GST_STATE_READY);
+			}
 		} else if (purple_media_get_session_type(media, sessions->data) & PURPLE_MEDIA_VIDEO) {
-			if (!videosendbin)
+			if (!videosendbin && (type & PURPLE_MEDIA_SEND_VIDEO)) {
 				purple_media_video_init_src(&videosendbin);
-			if (!videorecvbin)
+				purple_media_set_src(media, sessions->data, videosendbin);
+				gst_element_set_state(videosendbin, GST_STATE_READY);
+			}
+			if (!videorecvbin && (type & PURPLE_MEDIA_RECV_VIDEO)) {
 				purple_media_video_init_recv(&videorecvbin);
-			purple_media_set_src(media, sessions->data, videosendbin);
-			purple_media_set_sink(media, sessions->data, videorecvbin);
-
-			gst_element_set_state(videosendbin, GST_STATE_READY);
-			gst_element_set_state(videorecvbin, GST_STATE_READY);
+				purple_media_set_sink(media, sessions->data, videorecvbin);
+				gst_element_set_state(videorecvbin, GST_STATE_READY);
+			}
 		}
 	}
 
-	if (audiosendlevel && audiorecvlevel) {
+	if (audiosendlevel || audiorecvlevel) {
 		g_object_set(gtkmedia, "send-level", audiosendlevel,
 				       "recv-level", audiorecvlevel,
 				       NULL);
@@ -364,22 +367,23 @@ pidgin_media_accept_cb(PurpleMedia *medi
 	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);
+	if (videorecvbin || audiorecvbin) {
+		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) {
+		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);
+	}
 
-	gtk_box_pack_start(GTK_BOX(gtkmedia->priv->display), recv_widget, TRUE, TRUE, 0);
-	gtk_box_pack_start(GTK_BOX(gtkmedia->priv->display), send_widget, TRUE, TRUE, 0);
-
-	gtk_widget_show(recv_widget);
-	gtk_widget_show(send_widget);
-
-	if (videorecvbin || videosendbin) {
+	if (videorecvbin) {
 		GtkWidget *aspect;
 		GtkWidget *remote_video;
-		GtkWidget *local_video;
 
-		gtk_widget_show(gtkmedia->priv->display);
-
 		aspect = gtk_aspect_frame_new(NULL, 0.5, 0.5, 4.0/3.0, FALSE);
 		gtk_frame_set_shadow_type(GTK_FRAME(aspect), GTK_SHADOW_IN);
 		gtk_box_pack_start(GTK_BOX(recv_widget), aspect, TRUE, TRUE, 0);
@@ -390,48 +394,52 @@ pidgin_media_accept_cb(PurpleMedia *medi
 		gtk_widget_show(remote_video);
 		gtk_widget_show(aspect);
 
+		gtkmedia->priv->remote_video = remote_video;
+		gst_element_set_state(videorecvbin, GST_STATE_PLAYING);
+	}
+	if (videosendbin) {
+		GtkWidget *aspect;
+		GtkWidget *local_video;
+
 		aspect = gtk_aspect_frame_new(NULL, 0.5, 0.5, 4.0/3.0, FALSE);
 		gtk_frame_set_shadow_type(GTK_FRAME(aspect), GTK_SHADOW_IN);
 		gtk_box_pack_start(GTK_BOX(send_widget), aspect, TRUE, TRUE, 0);
 
 		local_video = gtk_drawing_area_new();
 		gtk_container_add(GTK_CONTAINER(aspect), local_video);
+		gtk_widget_set_size_request (GTK_WIDGET(local_video), 100, -1);
 		gtk_widget_show(local_video);
 		gtk_widget_show(aspect);
 
 		gtkmedia->priv->local_video = local_video;
-		gtkmedia->priv->remote_video = remote_video;
 
 		gst_element_set_state(videosendbin, GST_STATE_PLAYING);
-		gst_element_set_state(videorecvbin, GST_STATE_PLAYING);
 	}
 
-	if (audiorecvbin || audiosendbin) {
-		gtk_widget_show(gtkmedia->priv->display);
-
-		gtkmedia->priv->send_progress = gtk_progress_bar_new();
+	if (audiorecvbin) {
 		gtkmedia->priv->recv_progress = gtk_progress_bar_new();
-
-		gtk_widget_set_size_request(gtkmedia->priv->send_progress, 10, 70);
 		gtk_widget_set_size_request(gtkmedia->priv->recv_progress, 10, 70);
-
+		gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(gtkmedia->priv->recv_progress),
+						 GTK_PROGRESS_BOTTOM_TO_TOP);
+		gtk_box_pack_end(GTK_BOX(recv_widget),
+				   gtkmedia->priv->recv_progress, FALSE, FALSE, 0);
+		gtk_widget_show(gtkmedia->priv->recv_progress);
+		gst_element_set_state(audiorecvbin, GST_STATE_PLAYING);
+	}
+	if (audiosendbin) {
+		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),
 						 GTK_PROGRESS_BOTTOM_TO_TOP);
-		gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(gtkmedia->priv->recv_progress),
-						 GTK_PROGRESS_BOTTOM_TO_TOP);
-
-		gtk_box_pack_start(GTK_BOX(send_widget),
+		gtk_box_pack_end(GTK_BOX(send_widget),
 				   gtkmedia->priv->send_progress, FALSE, FALSE, 0);
-		gtk_box_pack_start(GTK_BOX(recv_widget),
-				   gtkmedia->priv->recv_progress, FALSE, FALSE, 0);
-
 		gtk_widget_show(gtkmedia->priv->send_progress);
-		gtk_widget_show(gtkmedia->priv->recv_progress);
-
 		gst_element_set_state(audiosendbin, GST_STATE_PLAYING);
-		gst_element_set_state(audiorecvbin, GST_STATE_PLAYING);
 	}
 
+	if (audiorecvbin || audiosendbin || videorecvbin || videosendbin)
+		gtk_widget_show(gtkmedia->priv->display);
+
 	bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline));
 	if (audiorecvbin || audiosendbin) {
 		gst_bus_add_signal_watch(GST_BUS(bus));


More information about the Commits mailing list