diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2011-03-14 20:57:55 +0800 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2011-03-14 20:57:55 +0800 |
commit | 706bdd3ad6d9c788015a5e8733046e653dcbbd21 (patch) | |
tree | b84d11fc6518af85bc589a1d3a9cdb7e0b307587 | |
parent | e28558ffcd25c365ca6992e6e03ce59ec9e8d9fb (diff) | |
parent | a340eeee18728a1fc59ddcb641b49537d03dd60a (diff) | |
download | gsoc2013-empathy-706bdd3ad6d9c788015a5e8733046e653dcbbd21.tar gsoc2013-empathy-706bdd3ad6d9c788015a5e8733046e653dcbbd21.tar.gz gsoc2013-empathy-706bdd3ad6d9c788015a5e8733046e653dcbbd21.tar.bz2 gsoc2013-empathy-706bdd3ad6d9c788015a5e8733046e653dcbbd21.tar.lz gsoc2013-empathy-706bdd3ad6d9c788015a5e8733046e653dcbbd21.tar.xz gsoc2013-empathy-706bdd3ad6d9c788015a5e8733046e653dcbbd21.tar.zst gsoc2013-empathy-706bdd3ad6d9c788015a5e8733046e653dcbbd21.zip |
Merge branch 'remove-liveadder' into gnome-2-34
-rw-r--r-- | src/empathy-audio-sink.c | 302 | ||||
-rw-r--r-- | src/empathy-audio-sink.h | 2 | ||||
-rw-r--r-- | src/empathy-call-handler.c | 17 | ||||
-rw-r--r-- | src/empathy-call-window.c | 119 | ||||
-rw-r--r-- | src/empathy-streamed-media-window.c | 119 |
5 files changed, 308 insertions, 251 deletions
diff --git a/src/empathy-audio-sink.c b/src/empathy-audio-sink.c index 1d2169593..c410d7a30 100644 --- a/src/empathy-audio-sink.c +++ b/src/empathy-audio-sink.c @@ -22,6 +22,7 @@ #include <stdio.h> #include <stdlib.h> +#include <gst/audio/audio.h> #include <gst/farsight/fs-element-added-notifier.h> #include "empathy-audio-sink.h" @@ -38,20 +39,61 @@ enum static guint signals[LAST_SIGNAL] = {0}; #endif +typedef struct { + GstPad *pad; + GstElement *bin; + GstElement *volume; + GstElement *sink; +} AudioBin; + +static AudioBin * +audio_bin_new (GstPad *pad, + GstElement *bin, + GstElement *volume, + GstElement *sink) +{ + AudioBin *result = g_slice_new0 (AudioBin); + + result->pad = pad; + result->bin = bin; + result->volume = gst_object_ref (volume); + result->sink = sink; + + return result; +} + +static void +audio_bin_free (AudioBin *bin) +{ + gst_object_unref (bin->volume); + g_slice_free (AudioBin, bin); +} + + +static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE( + "sink%d", + GST_PAD_SINK, + GST_PAD_REQUEST, + GST_STATIC_CAPS ( GST_AUDIO_INT_PAD_TEMPLATE_CAPS " ; " + GST_AUDIO_FLOAT_PAD_TEMPLATE_CAPS) +); enum { PROP_VOLUME = 1, }; -/* private structure */ -typedef struct _EmpathyGstAudioSinkPrivate EmpathyGstAudioSinkPrivate; - struct _EmpathyGstAudioSinkPrivate { gboolean dispose_has_run; - GstElement *sink; - GstElement *volume; FsElementAddedNotifier *notifier; + + gdouble volume; + + /* Pad -> *owned* subbin hash */ + GHashTable *audio_bins; + + /* Mutex to hold while change the hash table */ + GMutex *audio_bins_lock; }; #define EMPATHY_GST_AUDIO_SINK_GET_PRIVATE(o) \ @@ -66,54 +108,72 @@ empathy_audio_sink_element_added_cb (FsElementAddedNotifier *notifier, if (g_object_class_find_property (G_OBJECT_GET_CLASS (element), "volume")) { - gdouble volume; - - volume = empathy_audio_sink_get_volume (self); - empathy_audio_sink_set_volume (self, 1.0); - - if (priv->volume != NULL) - g_object_unref (priv->volume); - priv->volume = g_object_ref (element); - - if (volume != 1.0) - empathy_audio_sink_set_volume (self, volume); + /* An element was added with a volume property, lets find its subbin and + * update the volume in it */ + GHashTableIter iter; + AudioBin *audio_bin = NULL; + gpointer value; + + g_mutex_lock (self->priv->audio_bins_lock); + g_hash_table_iter_init (&iter, priv->audio_bins); + + while (g_hash_table_iter_next (&iter, NULL, &value)) + { + AudioBin *b = value; + + if (gst_object_has_ancestor (GST_OBJECT (element), + GST_OBJECT (b->bin))) + { + audio_bin = b; + break; + } + } + + if (audio_bin == NULL) + { + g_warning ("Element added that doesn't belong to us ?"); + return; + } + + /* Set the old volume to 1 and the new volume to the volume */ + g_object_set (audio_bin->volume, "volume", 1.0, NULL); + gst_object_unref (audio_bin->volume); + + audio_bin->volume = gst_object_ref (element); + g_object_set (audio_bin->volume, "volume", self->priv->volume, NULL); + g_mutex_unlock (self->priv->audio_bins_lock); } } static void -empathy_audio_sink_init (EmpathyGstAudioSink *obj) +empathy_audio_sink_init (EmpathyGstAudioSink *self) { - EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (obj); - GstElement *resample; - GstPad *ghost, *sink; - - priv->notifier = fs_element_added_notifier_new (); - g_signal_connect (priv->notifier, "element-added", - G_CALLBACK (empathy_audio_sink_element_added_cb), obj); - - resample = gst_element_factory_make ("audioresample", NULL); + EmpathyGstAudioSinkPrivate *priv; - priv->volume = gst_element_factory_make ("volume", NULL); - g_object_ref (priv->volume); + priv = self->priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (self); - priv->sink = gst_element_factory_make ("gconfaudiosink", NULL); + priv->volume = 1.0; - fs_element_added_notifier_add (priv->notifier, GST_BIN (priv->sink)); + priv->audio_bins = g_hash_table_new_full (g_direct_hash, g_direct_equal, + NULL, (GDestroyNotify) audio_bin_free); - gst_bin_add_many (GST_BIN (obj), resample, priv->volume, priv->sink, NULL); - gst_element_link_many (resample, priv->volume, priv->sink, NULL); + priv->audio_bins_lock = g_mutex_new (); - sink = gst_element_get_static_pad (resample, "sink"); - - ghost = gst_ghost_pad_new ("sink", sink); - gst_element_add_pad (GST_ELEMENT (obj), ghost); - - gst_object_unref (G_OBJECT (sink)); + priv->notifier = fs_element_added_notifier_new (); + g_signal_connect (priv->notifier, "element-added", + G_CALLBACK (empathy_audio_sink_element_added_cb), self); } static void empathy_audio_sink_dispose (GObject *object); static void empathy_audio_sink_finalize (GObject *object); +static GstPad * empathy_audio_sink_request_new_pad (GstElement *self, + GstPadTemplate *templ, + const gchar* name); + +static void empathy_audio_sink_release_pad (GstElement *self, + GstPad *pad); + static void empathy_audio_sink_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec) @@ -149,8 +209,13 @@ empathy_audio_sink_class_init (EmpathyGstAudioSinkClass *empathy_audio_sink_class) { GObjectClass *object_class = G_OBJECT_CLASS (empathy_audio_sink_class); + GstElementClass *element_class = + GST_ELEMENT_CLASS (empathy_audio_sink_class); GParamSpec *param_spec; + gst_element_class_add_pad_template (element_class, + gst_static_pad_template_get (&sink_template)); + g_type_class_add_private (empathy_audio_sink_class, sizeof (EmpathyGstAudioSinkPrivate)); @@ -160,6 +225,9 @@ empathy_audio_sink_class_init (EmpathyGstAudioSinkClass object_class->set_property = empathy_audio_sink_set_property; object_class->get_property = empathy_audio_sink_get_property; + element_class->request_new_pad = empathy_audio_sink_request_new_pad; + element_class->release_pad = empathy_audio_sink_release_pad; + param_spec = g_param_spec_double ("volume", "Volume", "volume control", 0.0, 5.0, 1.0, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); @@ -181,9 +249,13 @@ empathy_audio_sink_dispose (GObject *object) g_object_unref (priv->notifier); priv->notifier = NULL; - if (priv->volume != NULL) - g_object_unref (priv->volume); - priv->volume = NULL; + if (priv->audio_bins != NULL) + g_hash_table_unref (priv->audio_bins); + priv->audio_bins = NULL; + + if (priv->audio_bins_lock != NULL) + g_mutex_free (priv->audio_bins_lock); + priv->audio_bins_lock = NULL; if (G_OBJECT_CLASS (empathy_audio_sink_parent_class)->dispose) G_OBJECT_CLASS (empathy_audio_sink_parent_class)->dispose (object); @@ -219,17 +291,157 @@ void empathy_audio_sink_set_volume (EmpathyGstAudioSink *sink, gdouble volume) { EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (sink); + GHashTableIter iter; + gpointer value; + + priv->volume = volume; + + g_mutex_lock (priv->audio_bins_lock); - g_object_set (G_OBJECT (priv->volume), "volume", volume, NULL); + g_hash_table_iter_init (&iter, priv->audio_bins); + while (g_hash_table_iter_next (&iter, NULL, &value)) + { + AudioBin *b = value; + g_object_set (b->volume, "volume", volume, NULL); + } + + g_mutex_unlock (priv->audio_bins_lock); } gdouble empathy_audio_sink_get_volume (EmpathyGstAudioSink *sink) { EmpathyGstAudioSinkPrivate *priv = EMPATHY_GST_AUDIO_SINK_GET_PRIVATE (sink); - gdouble volume; + return priv->volume; +} + +static GstPad * +empathy_audio_sink_request_new_pad (GstElement *element, + GstPadTemplate *templ, + const gchar* name) +{ + EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (element); + GstElement *bin, *sink, *volume, *resample, *audioconvert0, *audioconvert1; + GstPad *pad = NULL; + GstPad *subpad, *filterpad; + AudioBin *audiobin; + + bin = gst_bin_new (NULL); + + audioconvert0 = gst_element_factory_make ("audioconvert", NULL); + if (audioconvert0 == NULL) + goto error; + + gst_bin_add (GST_BIN (bin), audioconvert0); + + resample = gst_element_factory_make ("audioresample", NULL); + if (resample == NULL) + goto error; + + gst_bin_add (GST_BIN (bin), resample); + + audioconvert1 = gst_element_factory_make ("audioconvert", NULL); + if (audioconvert1 == NULL) + goto error; + + gst_bin_add (GST_BIN (bin), audioconvert1); + + volume = gst_element_factory_make ("volume", NULL); + if (volume == NULL) + goto error; + + gst_bin_add (GST_BIN (bin), volume); + + sink = gst_element_factory_make ("gconfaudiosink", NULL); + if (sink == NULL) + goto error; + + gst_bin_add (GST_BIN (bin), sink); + fs_element_added_notifier_add (self->priv->notifier, GST_BIN (sink)); + + if (!gst_element_link_many (audioconvert0, resample, audioconvert1, + volume, sink, NULL)) + goto error; + + filterpad = gst_element_get_static_pad (audioconvert0, "sink"); + + if (filterpad == NULL) + goto error; + + subpad = gst_ghost_pad_new ("sink", filterpad); + if (!gst_element_add_pad (GST_ELEMENT (bin), subpad)) + goto error; + + + /* Ensure that state changes only happen _after_ the element has been added + * to the hash table. But add it to the bin first so we can create our + * ghostpad (if we create the ghostpad before adding it to the bin it will + * get unlinked) */ + gst_element_set_locked_state (GST_ELEMENT (bin), TRUE); + gst_bin_add (GST_BIN (self), bin); + + pad = gst_ghost_pad_new (name, subpad); + g_assert (pad != NULL); + + audiobin = audio_bin_new (pad, bin, volume, sink); + + g_mutex_lock (self->priv->audio_bins_lock); + g_hash_table_insert (self->priv->audio_bins, pad, audiobin); + g_mutex_unlock (self->priv->audio_bins_lock); + + gst_element_set_locked_state (GST_ELEMENT (bin), FALSE); + + if (!gst_element_sync_state_with_parent (bin)) + goto error; + + if (!gst_pad_set_active (pad, TRUE)) + goto error; + + if (!gst_element_add_pad (GST_ELEMENT (self), pad)) + goto error; + + + return pad; + +error: + if (pad != NULL) + { + g_mutex_lock (self->priv->audio_bins_lock); + g_hash_table_remove (self->priv->audio_bins, pad); + g_mutex_unlock (self->priv->audio_bins_lock); + + gst_object_unref (pad); + } + + gst_object_unref (bin); + g_warning ("Failed to create output subpipeline"); + return NULL; +} + +static void +empathy_audio_sink_release_pad (GstElement *element, + GstPad *pad) +{ + EmpathyGstAudioSink *self = EMPATHY_GST_AUDIO_SINK (element); + AudioBin *abin; + + g_mutex_lock (self->priv->audio_bins_lock); + abin = g_hash_table_lookup (self->priv->audio_bins, pad); + g_hash_table_steal (self->priv->audio_bins, pad); + g_mutex_unlock (self->priv->audio_bins_lock); + + if (abin == NULL) + { + g_warning ("Releasing a pad that doesn't belong to us ?"); + return; + } + + gst_pad_set_active (pad, FALSE); + gst_element_remove_pad (element, pad); - g_object_get (G_OBJECT (priv->volume), "volume", &volume, NULL); + gst_element_set_locked_state (abin->bin, TRUE); + gst_element_set_state (abin->bin, GST_STATE_NULL); + gst_bin_remove (GST_BIN (self), abin->bin); - return volume; + audio_bin_free (abin); } diff --git a/src/empathy-audio-sink.h b/src/empathy-audio-sink.h index 21ebf2b5a..cc21fc467 100644 --- a/src/empathy-audio-sink.h +++ b/src/empathy-audio-sink.h @@ -28,6 +28,7 @@ G_BEGIN_DECLS typedef struct _EmpathyGstAudioSink EmpathyGstAudioSink; typedef struct _EmpathyGstAudioSinkClass EmpathyGstAudioSinkClass; +typedef struct _EmpathyGstAudioSinkPrivate EmpathyGstAudioSinkPrivate; struct _EmpathyGstAudioSinkClass { GstBinClass parent_class; @@ -35,6 +36,7 @@ struct _EmpathyGstAudioSinkClass { struct _EmpathyGstAudioSink { GstBin parent; + EmpathyGstAudioSinkPrivate *priv; }; GType empathy_audio_sink_get_type (void); diff --git a/src/empathy-call-handler.c b/src/empathy-call-handler.c index eeb13ba82..752405727 100644 --- a/src/empathy-call-handler.c +++ b/src/empathy-call-handler.c @@ -167,6 +167,18 @@ on_get_contacts_cb (TpConnection *connection, } static void +on_call_state_changed_cb (TpyCallChannel *call, + TpyCallState state, + TpyCallFlags flags, + const GValueArray *call_state_reason, + GHashTable *call_state_details, + EmpathyCallHandler *handler) +{ + if (state == TPY_CALL_STATE_ENDED) + tp_channel_close_async (TP_CHANNEL (call), NULL, NULL); +} + +static void on_members_changed_cb (TpyCallChannel *call, GHashTable *members, EmpathyCallHandler *self) @@ -233,7 +245,12 @@ empathy_call_handler_set_property (GObject *object, priv->members = g_value_get_boxed (value); break; case PROP_CALL_CHANNEL: + g_return_if_fail (priv->call == NULL); + priv->call = g_value_dup_object (value); + + tp_g_signal_connect_object (priv->call, "state-changed", + G_CALLBACK (on_call_state_changed_cb), object, 0); break; case PROP_INITIAL_AUDIO: priv->initial_audio = g_value_get_boolean (value); diff --git a/src/empathy-call-window.c b/src/empathy-call-window.c index ef6222344..6db01d2ef 100644 --- a/src/empathy-call-window.c +++ b/src/empathy-call-window.c @@ -178,7 +178,6 @@ struct _EmpathyCallWindowPriv GstElement *video_tee; GstElement *funnel; - GstElement *liveadder; GList *notifiers; @@ -623,17 +622,6 @@ create_video_output_widget (EmpathyCallWindow *self) } static void -create_audio_output (EmpathyCallWindow *self) -{ - EmpathyCallWindowPriv *priv = GET_PRIV (self); - - g_assert (priv->audio_output == NULL); - priv->audio_output = empathy_audio_sink_new (); - gst_object_ref (priv->audio_output); - gst_object_sink (priv->audio_output); -} - -static void create_video_input (EmpathyCallWindow *self) { EmpathyCallWindowPriv *priv = GET_PRIV (self); @@ -1115,7 +1103,6 @@ empathy_call_window_init (EmpathyCallWindow *self) create_pipeline (self); create_video_output_widget (self); create_audio_input (self); - create_audio_output (self); create_video_input (self); /* The call will be started as soon the pipeline is playing */ @@ -1657,17 +1644,12 @@ empathy_call_window_dispose (GObject *object) tp_clear_object (&priv->pipeline); tp_clear_object (&priv->video_input); tp_clear_object (&priv->audio_input); - tp_clear_object (&priv->audio_output); tp_clear_object (&priv->video_tee); tp_clear_object (&priv->ui_manager); tp_clear_object (&priv->fullscreen); g_list_free_full (priv->notifiers, g_object_unref); - if (priv->liveadder != NULL) - gst_object_unref (priv->liveadder); - priv->liveadder = NULL; - if (priv->timer_id != 0) g_source_remove (priv->timer_id); priv->timer_id = 0; @@ -1792,7 +1774,6 @@ empathy_call_window_reset_pipeline (EmpathyCallWindow *self) gtk_widget_destroy (priv->video_preview); priv->video_preview = NULL; - priv->liveadder = NULL; priv->funnel = NULL; create_pipeline (self); @@ -1891,7 +1872,8 @@ empathy_call_window_disconnected (EmpathyCallWindow *self, /* destroy the video output; it will be recreated when we'll redial */ disconnect_video_output_motion_handler (self); - gtk_widget_destroy (priv->video_output); + if (priv->video_output != NULL) + gtk_widget_destroy (priv->video_output); priv->video_output = NULL; gtk_widget_show (priv->remote_user_avatar_widget); @@ -1957,14 +1939,12 @@ empathy_call_window_sink_removed_cb (EmpathyCallHandler *handler, } else if (media_type == FS_MEDIA_TYPE_AUDIO) { - if (priv->liveadder != NULL) + if (priv->audio_output != NULL) { gst_element_set_state (priv->audio_output, GST_STATE_NULL); - gst_element_set_state (priv->liveadder, GST_STATE_NULL); gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output); - gst_bin_remove (GST_BIN (priv->pipeline), priv->liveadder); - priv->liveadder = NULL; + priv->audio_output = NULL; return TRUE; } } @@ -2059,112 +2039,47 @@ empathy_call_window_get_audio_sink_pad (EmpathyCallWindow *self) { EmpathyCallWindowPriv *priv = GET_PRIV (self); GstPad *pad; - GstElement *filter; - GError *gerror = NULL; + GstPadTemplate *template; - if (priv->liveadder == NULL) + if (priv->audio_output == NULL) { - priv->liveadder = gst_element_factory_make ("liveadder", NULL); + priv->audio_output = empathy_audio_sink_new (); - if (!gst_bin_add (GST_BIN (priv->pipeline), priv->liveadder)) - { - g_warning ("Could not add liveadder to the pipeline"); - goto error_add_liveadder; - } if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output)) { g_warning ("Could not add audio sink to pipeline"); + g_object_unref (priv->audio_output); goto error_add_output; } - if (gst_element_set_state (priv->liveadder, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) - { - g_warning ("Could not start liveadder"); - goto error; - } - if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { g_warning ("Could not start audio sink"); goto error; } - - if (GST_PAD_LINK_FAILED ( - gst_element_link (priv->liveadder, priv->audio_output))) - { - g_warning ("Could not link liveadder to audio output"); - goto error; - } } - filter = gst_parse_bin_from_description ( - "audioconvert ! audioresample ! audioconvert", TRUE, &gerror); - if (filter == NULL) - { - g_warning ("Could not make audio conversion filter: %s", gerror->message); - g_clear_error (&gerror); - goto error; - } + template = gst_element_class_get_pad_template ( + GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d"); - if (!gst_bin_add (GST_BIN (priv->pipeline), filter)) - { - g_warning ("Could not add audio conversion filter to pipeline"); - gst_object_unref (filter); - goto error; - } - - if (gst_element_set_state (filter, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) - { - g_warning ("Could not start audio conversion filter"); - goto error_filter; - } - - if (!gst_element_link (filter, priv->liveadder)) - { - g_warning ("Could not link audio conversion filter to liveadder"); - goto error_filter; - } - - pad = gst_element_get_static_pad (filter, "sink"); + pad = gst_element_request_pad (priv->audio_output, + template, NULL, NULL); if (pad == NULL) { - g_warning ("Could not get sink pad from filter"); - goto error_filter; + g_warning ("Could not get sink pad from sink"); + return NULL; } return pad; - error_filter: - - gst_element_set_locked_state (filter, TRUE); - gst_element_set_state (filter, GST_STATE_NULL); - gst_bin_remove (GST_BIN (priv->pipeline), filter); - - error: - - gst_element_set_locked_state (priv->liveadder, TRUE); +error: gst_element_set_locked_state (priv->audio_output, TRUE); - - gst_element_set_state (priv->liveadder, GST_STATE_NULL); gst_element_set_state (priv->audio_output, GST_STATE_NULL); - gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output); + priv->audio_output = NULL; - error_add_output: - - gst_bin_remove (GST_BIN (priv->pipeline), priv->liveadder); - - gst_element_set_locked_state (priv->liveadder, FALSE); - gst_element_set_locked_state (priv->audio_output, FALSE); - - error_add_liveadder: - - if (priv->liveadder != NULL) - { - gst_object_unref (priv->liveadder); - priv->liveadder = NULL; - } +error_add_output: return NULL; } diff --git a/src/empathy-streamed-media-window.c b/src/empathy-streamed-media-window.c index e203bdc5f..1566da40a 100644 --- a/src/empathy-streamed-media-window.c +++ b/src/empathy-streamed-media-window.c @@ -189,7 +189,6 @@ struct _EmpathyStreamedMediaWindowPriv GstElement *video_tee; GstElement *funnel; - GstElement *liveadder; FsElementAddedNotifier *fsnotifier; @@ -639,17 +638,6 @@ create_video_output_widget (EmpathyStreamedMediaWindow *self) } static void -create_audio_output (EmpathyStreamedMediaWindow *self) -{ - EmpathyStreamedMediaWindowPriv *priv = GET_PRIV (self); - - g_assert (priv->audio_output == NULL); - priv->audio_output = empathy_audio_sink_new (); - gst_object_ref (priv->audio_output); - gst_object_sink (priv->audio_output); -} - -static void create_video_input (EmpathyStreamedMediaWindow *self) { EmpathyStreamedMediaWindowPriv *priv = GET_PRIV (self); @@ -1131,7 +1119,6 @@ empathy_streamed_media_window_init (EmpathyStreamedMediaWindow *self) create_pipeline (self); create_video_output_widget (self); create_audio_input (self); - create_audio_output (self); create_video_input (self); priv->fsnotifier = fs_element_added_notifier_new (); @@ -1725,18 +1712,10 @@ empathy_streamed_media_window_dispose (GObject *object) g_object_unref (priv->audio_input); priv->audio_input = NULL; - if (priv->audio_output != NULL) - g_object_unref (priv->audio_output); - priv->audio_output = NULL; - if (priv->video_tee != NULL) g_object_unref (priv->video_tee); priv->video_tee = NULL; - if (priv->liveadder != NULL) - gst_object_unref (priv->liveadder); - priv->liveadder = NULL; - if (priv->fsnotifier != NULL) g_object_unref (priv->fsnotifier); priv->fsnotifier = NULL; @@ -1867,7 +1846,6 @@ empathy_streamed_media_window_reset_pipeline (EmpathyStreamedMediaWindow *self) gtk_widget_destroy (priv->video_preview); priv->video_preview = NULL; - priv->liveadder = NULL; priv->funnel = NULL; create_pipeline (self); @@ -2031,14 +2009,12 @@ empathy_streamed_media_window_channel_stream_closed_cb (EmpathyStreamedMediaHand } else if (media_type == TP_MEDIA_STREAM_TYPE_AUDIO) { - if (priv->liveadder != NULL) + if (priv->audio_output != NULL) { gst_element_set_state (priv->audio_output, GST_STATE_NULL); - gst_element_set_state (priv->liveadder, GST_STATE_NULL); gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output); - gst_bin_remove (GST_BIN (priv->pipeline), priv->liveadder); - priv->liveadder = NULL; + priv->audio_output = NULL; } } } @@ -2130,112 +2106,47 @@ empathy_streamed_media_window_get_audio_sink_pad (EmpathyStreamedMediaWindow *se { EmpathyStreamedMediaWindowPriv *priv = GET_PRIV (self); GstPad *pad; - GstElement *filter; - GError *gerror = NULL; + GstPadTemplate *template; - if (priv->liveadder == NULL) + if (priv->audio_output == NULL) { - priv->liveadder = gst_element_factory_make ("liveadder", NULL); + priv->audio_output = empathy_audio_sink_new (); - if (!gst_bin_add (GST_BIN (priv->pipeline), priv->liveadder)) - { - g_warning ("Could not add liveadder to the pipeline"); - goto error_add_liveadder; - } if (!gst_bin_add (GST_BIN (priv->pipeline), priv->audio_output)) { g_warning ("Could not add audio sink to pipeline"); + g_object_unref (priv->audio_output); goto error_add_output; } - if (gst_element_set_state (priv->liveadder, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) - { - g_warning ("Could not start liveadder"); - goto error; - } - if (gst_element_set_state (priv->audio_output, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) { g_warning ("Could not start audio sink"); goto error; } - - if (GST_PAD_LINK_FAILED ( - gst_element_link (priv->liveadder, priv->audio_output))) - { - g_warning ("Could not link liveadder to audio output"); - goto error; - } - } - - filter = gst_parse_bin_from_description ( - "audioconvert ! audioresample ! audioconvert", TRUE, &gerror); - if (filter == NULL) - { - g_warning ("Could not make audio conversion filter: %s", gerror->message); - g_clear_error (&gerror); - goto error; } - if (!gst_bin_add (GST_BIN (priv->pipeline), filter)) - { - g_warning ("Could not add audio conversion filter to pipeline"); - gst_object_unref (filter); - goto error; - } + template = gst_element_class_get_pad_template ( + GST_ELEMENT_GET_CLASS (priv->audio_output), "sink%d"); - if (gst_element_set_state (filter, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) - { - g_warning ("Could not start audio conversion filter"); - goto error_filter; - } - - if (!gst_element_link (filter, priv->liveadder)) - { - g_warning ("Could not link audio conversion filter to liveadder"); - goto error_filter; - } - - pad = gst_element_get_static_pad (filter, "sink"); + pad = gst_element_request_pad (priv->audio_output, + template, NULL, NULL); if (pad == NULL) { - g_warning ("Could not get sink pad from filter"); - goto error_filter; + g_warning ("Could not get sink pad from sink"); + return NULL; } return pad; - error_filter: - - gst_element_set_locked_state (filter, TRUE); - gst_element_set_state (filter, GST_STATE_NULL); - gst_bin_remove (GST_BIN (priv->pipeline), filter); - - error: - - gst_element_set_locked_state (priv->liveadder, TRUE); +error: gst_element_set_locked_state (priv->audio_output, TRUE); - - gst_element_set_state (priv->liveadder, GST_STATE_NULL); gst_element_set_state (priv->audio_output, GST_STATE_NULL); - gst_bin_remove (GST_BIN (priv->pipeline), priv->audio_output); + priv->audio_output = NULL; - error_add_output: - - gst_bin_remove (GST_BIN (priv->pipeline), priv->liveadder); - - gst_element_set_locked_state (priv->liveadder, FALSE); - gst_element_set_locked_state (priv->audio_output, FALSE); - - error_add_liveadder: - - if (priv->liveadder != NULL) - { - gst_object_unref (priv->liveadder); - priv->liveadder = NULL; - } +error_add_output: return NULL; } |