Mercurial > pidgin
diff libpurple/mediamanager.c @ 29298:fb99a0067812
propagate from branch 'im.pidgin.pidgin' (head 70d69397ed952b26b453423c381c70d6783eb66d)
to branch 'im.pidgin.cpw.attention_ui' (head 1cf0dea282a0d0e4aeac4770e0150d6d0c10830a)
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Thu, 13 Aug 2009 17:42:44 +0000 |
parents | f77978e6968e |
children | 8c991e09efcb |
line wrap: on
line diff
--- a/libpurple/mediamanager.c Tue Jul 28 20:52:33 2009 +0000 +++ b/libpurple/mediamanager.c Thu Aug 13 17:42:44 2009 +0000 @@ -39,6 +39,7 @@ #ifdef USE_VV #include <gst/farsight/fs-conference-iface.h> +#include <gst/farsight/fs-element-added-notifier.h> #include <gst/interfaces/xoverlay.h> /** @copydoc _PurpleMediaManagerPrivate */ @@ -156,6 +157,12 @@ media->priv = PURPLE_MEDIA_MANAGER_GET_PRIVATE(media); media->priv->medias = NULL; media->priv->next_output_window_id = 1; + + purple_prefs_add_none("/purple/media"); + purple_prefs_add_none("/purple/media/audio"); + purple_prefs_add_none("/purple/media/audio/volume"); + purple_prefs_add_int("/purple/media/audio/volume/input", 10); + purple_prefs_add_int("/purple/media/audio/volume/output", 10); } static void @@ -229,6 +236,10 @@ g_return_val_if_fail(PURPLE_IS_MEDIA_MANAGER(manager), NULL); if (manager->priv->pipeline == NULL) { + FsElementAddedNotifier *notifier; + gchar *filename; + GError *err = NULL; + GKeyFile *keyfile; GstBus *bus; manager->priv->pipeline = gst_pipeline_new(NULL); @@ -241,6 +252,38 @@ gst_bus_sync_signal_handler, NULL); gst_object_unref(bus); + filename = g_build_filename(purple_user_dir(), + "fs-element.conf", NULL); + keyfile = g_key_file_new(); + if (!g_key_file_load_from_file(keyfile, filename, + G_KEY_FILE_NONE, &err)) { + if (err->code == 4) + purple_debug_info("mediamanager", + "Couldn't read " + "fs-element.conf: %s\n", + err->message); + else + purple_debug_error("mediamanager", + "Error reading " + "fs-element.conf: %s\n", + err->message); + g_error_free(err); + } + g_free(filename); + + /* Hack to make alsasrc stop messing up audio timestamps */ + if (!g_key_file_has_key(keyfile, + "alsasrc", "slave-method", NULL)) { + g_key_file_set_integer(keyfile, + "alsasrc", "slave-method", 2); + } + + notifier = fs_element_added_notifier_new(); + fs_element_added_notifier_add(notifier, + GST_BIN(manager->priv->pipeline)); + fs_element_added_notifier_set_properties_from_keyfile( + notifier, keyfile); + gst_element_set_state(manager->priv->pipeline, GST_STATE_PLAYING); } @@ -356,15 +399,19 @@ GstElement *parent = GST_ELEMENT_PARENT(pad); GstIterator *iter; GstPad *remaining_pad; + GstIteratorResult result; gst_element_release_request_pad(GST_ELEMENT_PARENT(pad), pad); - iter = gst_element_iterate_pads(parent); + iter = gst_element_iterate_src_pads(parent); - if (gst_iterator_next(iter, (gpointer)&remaining_pad) - == GST_ITERATOR_DONE) { + result = gst_iterator_next(iter, (gpointer)&remaining_pad); + + if (result == GST_ITERATOR_DONE) { gst_element_set_locked_state(parent, TRUE); gst_element_set_state(parent, GST_STATE_NULL); gst_bin_remove(GST_BIN(GST_ELEMENT_PARENT(parent)), parent); + } else if (result == GST_ITERATOR_OK) { + gst_object_unref(remaining_pad); } gst_iterator_free(iter); @@ -426,7 +473,6 @@ gst_element_link(tee, fakesink); ret = bin; - gst_element_set_locked_state(ret, TRUE); gst_object_ref(ret); gst_bin_add(GST_BIN(purple_media_manager_get_pipeline( manager)), ret); @@ -667,7 +713,7 @@ (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); @@ -676,6 +722,8 @@ 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, @@ -696,7 +744,7 @@ } 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)); @@ -704,9 +752,11 @@ G_CALLBACK(window_id_cb), ow); gst_object_unref(bus); - gst_element_sync_state_with_parent(ow->sink); - gst_element_link(queue, ow->sink); - gst_element_sync_state_with_parent(queue); + 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(colorspace, ow->sink); + gst_element_link(queue, colorspace); gst_element_link(tee, queue); } } @@ -775,8 +825,14 @@ 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); @@ -785,6 +841,9 @@ 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)),