Mercurial > pidgin
changeset 23874:64080c01ee50
Decouple stream direction. Allows send only or recv only streams.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Sun, 17 Aug 2008 00:49:29 +0000 |
parents | 89d873e217c1 |
children | eb289e9086bf |
files | libpurple/protocols/jabber/jingle.c pidgin/gtkmedia.c |
diffstat | 2 files changed, 81 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/jingle.c Sat Aug 16 20:22:41 2008 +0000 +++ b/libpurple/protocols/jabber/jingle.c Sun Aug 17 00:49:29 2008 +0000 @@ -847,9 +847,9 @@ 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 @@ 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 @@ 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"); }
--- a/pidgin/gtkmedia.c Sat Aug 16 20:22:41 2008 +0000 +++ b/pidgin/gtkmedia.c Sun Aug 17 00:49:29 2008 +0000 @@ -187,7 +187,7 @@ 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 @@ 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,21 +367,22 @@ 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); @@ -390,47 +394,51 @@ 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->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), - gtkmedia->priv->send_progress, FALSE, FALSE, 0); - gtk_box_pack_start(GTK_BOX(recv_widget), + gtk_box_pack_end(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 (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_box_pack_end(GTK_BOX(send_widget), + gtkmedia->priv->send_progress, FALSE, FALSE, 0); + gtk_widget_show(gtkmedia->priv->send_progress); + gst_element_set_state(audiosendbin, 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) {