Mercurial > pidgin
changeset 23856:1c68f78414b7
Set the media pipeline to PLAYING immediately after initialization
(and a few other changes to make it actually work and not hang).
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Thu, 17 Jul 2008 21:01:46 +0000 |
parents | e23b447aa5ca |
children | 001064185ad4 |
files | libpurple/media.c libpurple/mediamanager.c libpurple/protocols/jabber/jingle.c pidgin/gtkmedia.c |
diffstat | 4 files changed, 51 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/media.c Wed Jul 16 21:55:08 2008 +0000 +++ b/libpurple/media.c Thu Jul 17 21:01:46 2008 +0000 @@ -219,10 +219,22 @@ purple_media_finalize (GObject *media) { PurpleMediaPrivate *priv = PURPLE_MEDIA_GET_PRIVATE(media); + GList *sessions = g_hash_table_get_values(priv->sessions); purple_debug_info("media","purple_media_finalize\n"); g_free(priv->name); + for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { + PurpleMediaSession *session = sessions->data; + GList *streams = g_hash_table_get_values(session->streams); + + for (; streams; streams = g_list_delete_link(streams, streams)) { + g_object_unref(streams->data); + } + + g_object_unref(session->session); + } + if (priv->pipeline) { gst_element_set_state(priv->pipeline, GST_STATE_NULL); gst_object_unref(priv->pipeline); @@ -928,11 +940,9 @@ purple_media_src_pad_added_cb(FsStream *stream, GstPad *srcpad, FsCodec *codec, PurpleMediaSession *session) { - GstElement *pipeline = purple_media_get_pipeline(session->media); GstPad *sinkpad = gst_element_get_static_pad(session->sink, "ghostsink"); purple_debug_info("media", "connecting new src pad: %s\n", gst_pad_link(srcpad, sinkpad) == GST_PAD_LINK_OK ? "success" : "failure"); - gst_element_set_state(pipeline, GST_STATE_PLAYING); } static gboolean
--- a/libpurple/mediamanager.c Wed Jul 16 21:55:08 2008 +0000 +++ b/libpurple/mediamanager.c Thu Jul 17 21:01:46 2008 +0000 @@ -135,20 +135,24 @@ { PurpleMedia *media; FsConference *conference = FS_CONFERENCE(gst_element_factory_make(conference_type, NULL)); - GstStateChangeReturn ret = gst_element_set_state(GST_ELEMENT(conference), GST_STATE_READY); - - if (ret == GST_STATE_CHANGE_FAILURE) { - purple_conv_present_error(remote_user, - purple_connection_get_account(gc), - _("Error creating conference.")); - return NULL; - } + GstStateChangeReturn ret; media = PURPLE_MEDIA(g_object_new(purple_media_get_type(), "screenname", remote_user, "connection", gc, "farsight-conference", conference, NULL)); + + ret = gst_element_set_state(purple_media_get_pipeline(media), GST_STATE_PLAYING); + + if (ret == GST_STATE_CHANGE_FAILURE) { + purple_conv_present_error(remote_user, + purple_connection_get_account(gc), + _("Error creating conference.")); + g_object_unref(media); + return NULL; + } + manager->priv->medias = g_list_append(manager->priv->medias, media); g_signal_emit(manager, purple_media_manager_signals[INIT_MEDIA], 0, media); return media;
--- a/libpurple/protocols/jabber/jingle.c Wed Jul 16 21:55:08 2008 +0000 +++ b/libpurple/protocols/jabber/jingle.c Thu Jul 17 21:01:46 2008 +0000 @@ -819,8 +819,7 @@ if (purple_media_candidates_prepared(media, remote_jid)) { jabber_iq_send(jabber_jingle_session_create_session_accept(session)); - purple_debug_info("jingle", "Sent session accept, starting stream\n"); - gst_element_set_state(purple_media_get_pipeline(session->media), GST_STATE_PLAYING); + purple_debug_info("jingle", "Sent session accept.\n"); jabber_jingle_session_set_state(session, ACTIVE); } else jabber_jingle_session_set_state(session, ACCEPTED); @@ -922,9 +921,7 @@ jabber_jingle_session_get_remote_jid(session))) { jabber_iq_send(jabber_jingle_session_create_session_accept(session)); - purple_debug_info("jingle", "Sent session accept, starting stream\n"); - gst_element_set_state(purple_media_get_pipeline(session->media), - GST_STATE_PLAYING); + purple_debug_info("jingle", "Sent session accept.\n"); jabber_jingle_session_set_state(session, ACTIVE); } } @@ -1223,9 +1220,7 @@ if (!strcmp(action, "session-accept")) { purple_media_got_accept(jabber_jingle_session_get_media(session)); - purple_debug_info("jingle", "Got session-accept, starting stream\n"); - gst_element_set_state(purple_media_get_pipeline(session->media), - GST_STATE_PLAYING); + purple_debug_info("jingle", "Got session-accept"); } jabber_iq_send(jabber_jingle_session_create_ack(session, jingle)); @@ -1332,8 +1327,6 @@ /* maybe we should look at the reasoncode to determine if it was a hangup or a reject, and call different callbacks to purple_media */ - gst_element_set_state(purple_media_get_pipeline(session->media), GST_STATE_NULL); - purple_media_got_hangup(jabber_jingle_session_get_media(session)); jabber_iq_send(jabber_jingle_session_create_ack(session, jingle)); jabber_jingle_session_destroy(session);
--- a/pidgin/gtkmedia.c Wed Jul 16 21:55:08 2008 +0000 +++ b/pidgin/gtkmedia.c Thu Jul 17 21:01:46 2008 +0000 @@ -288,15 +288,12 @@ static void pidgin_media_ready_cb(PurpleMedia *media, PidginMedia *gtkmedia) { - GstElement *element = purple_media_get_pipeline(media); - GstElement *audiosendbin = NULL, *audiosendlevel = NULL; GstElement *audiorecvbin = NULL, *audiorecvlevel = NULL; GstElement *videosendbin = NULL; GstElement *videorecvbin = NULL; GList *sessions = purple_media_get_session_names(media); - GstBus *bus; for (; sessions; sessions = g_list_delete_link(sessions, sessions)) { if (purple_media_get_session_type(media, sessions->data) & PURPLE_MEDIA_AUDIO) { @@ -306,6 +303,9 @@ 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); } else if (purple_media_get_session_type(media, sessions->data) & PURPLE_MEDIA_VIDEO) { if (!videosendbin) purple_media_video_init_src(&videosendbin); @@ -313,6 +313,9 @@ 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); } } @@ -321,14 +324,6 @@ "recv-level", audiorecvlevel, 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 @@ -344,10 +339,12 @@ { GtkWidget *send_widget = NULL, *recv_widget = NULL; + GstElement *pipeline = purple_media_get_pipeline(media); GstElement *audiosendbin = NULL; GstElement *audiorecvbin = NULL; GstElement *videosendbin = NULL; GstElement *videorecvbin = NULL; + GstBus *bus; pidgin_media_emit_message(gtkmedia, _("Call in progress.")); pidgin_media_set_state(gtkmedia, PIDGIN_MEDIA_ACCEPTED); @@ -392,6 +389,9 @@ 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) { @@ -415,7 +415,20 @@ 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); } + + bus = gst_pipeline_get_bus(GST_PIPELINE(pipeline)); + if (audiorecvbin || audiosendbin) { + gst_bus_add_signal_watch(GST_BUS(bus)); + g_signal_connect(G_OBJECT(bus), "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