diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/empathy-audio-sink.c | 47 | ||||
-rw-r--r-- | src/empathy-audio-src.c | 47 |
2 files changed, 65 insertions, 29 deletions
diff --git a/src/empathy-audio-sink.c b/src/empathy-audio-sink.c index f8b5d1c39..c9d720310 100644 --- a/src/empathy-audio-sink.c +++ b/src/empathy-audio-sink.c @@ -25,6 +25,8 @@ #include <gst/audio/audio.h> #include <telepathy-glib/telepathy-glib.h> +#include <libempathy-gtk/empathy-call-utils.h> + #include "empathy-audio-sink.h" #define DEBUG_FLAG EMPATHY_DEBUG_VOIP @@ -187,6 +189,35 @@ empathy_audio_sink_get_volume (EmpathyGstAudioSink *sink) return volume; } +static GstElement * +create_sink (const gchar *description) +{ + GstElement *sink; + + if (description != NULL) + { + GError *error = NULL; + + sink = gst_parse_bin_from_description (description, TRUE, &error); + if (sink == NULL) + { + DEBUG ("Failed to create bin %s: %s", description, error->message); + g_error_free (error); + } + + return sink; + } + + /* Use pulsesink as default */ + sink = gst_element_factory_make ("pulsesink", NULL); + if (sink == NULL) + return NULL; + + empathy_call_set_stream_properties (sink); + + return sink; +} + static GstPad * empathy_audio_sink_request_new_pad (GstElement *element, GstPadTemplate *templ, @@ -196,7 +227,6 @@ empathy_audio_sink_request_new_pad (GstElement *element, GstElement *bin, *volume, *resample, *audioconvert0, *audioconvert1; GstPad *pad = NULL; GstPad *subpad, *filterpad; - const gchar *sink_element; bin = gst_bin_new (NULL); @@ -224,23 +254,10 @@ empathy_audio_sink_request_new_pad (GstElement *element, gst_bin_add (GST_BIN (bin), volume); - sink_element = g_getenv ("EMPATHY_AUDIO_SINK"); - if (sink_element == NULL) - sink_element = "pulsesink"; - - self->priv->sink = gst_element_factory_make (sink_element, NULL); + self->priv->sink = create_sink (g_getenv ("EMPATHY_AUDIO_SINK")); if (self->priv->sink == NULL) goto error; - if (!tp_strdiff (sink_element, "pulsesink")) - { - GstStructure *props; - - props = gst_structure_from_string ("props,media.role=phone", NULL); - g_object_set (self->priv->sink, "stream-properties", props, NULL); - gst_structure_free (props); - } - gst_bin_add (GST_BIN (bin), self->priv->sink); if (!gst_element_link_many (audioconvert0, resample, audioconvert1, diff --git a/src/empathy-audio-src.c b/src/empathy-audio-src.c index 98ff24eca..5da424810 100644 --- a/src/empathy-audio-src.c +++ b/src/empathy-audio-src.c @@ -26,6 +26,7 @@ #include <pulse/glib-mainloop.h> #include <libempathy/empathy-utils.h> +#include <libempathy-gtk/empathy-call-utils.h> #include "empathy-audio-src.h" @@ -377,32 +378,50 @@ empathy_audio_src_source_output_index_notify (GObject *object, empathy_audio_src_source_output_info_cb, self); } +static GstElement * +create_src (const gchar *description) +{ + GstElement *src; + + if (description != NULL) + { + GError *error = NULL; + + src = gst_parse_bin_from_description (description, TRUE, &error); + if (src == NULL) + { + DEBUG ("Failed to create bin %s: %s", description, error->message); + g_error_free (error); + } + + return src; + } + + /* Use pulsesrc as default */ + src = gst_element_factory_make ("pulsesrc", NULL); + if (src == NULL) + return NULL; + + empathy_call_set_stream_properties (src); + + return src; +} + static void empathy_audio_src_init (EmpathyGstAudioSrc *obj) { EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (obj); GstPad *ghost, *src; - const gchar *src_element; priv->peak_level = -G_MAXDOUBLE; priv->lock = g_mutex_new (); - src_element = g_getenv ("EMPATHY_AUDIO_SRC"); - if (src_element == NULL) - src_element = "pulsesrc"; + priv->src = create_src (g_getenv ("EMPATHY_AUDIO_SRC")); + if (priv->src == NULL) + return; - priv->src = gst_element_factory_make (src_element, NULL); gst_bin_add (GST_BIN (obj), priv->src); - if (!tp_strdiff (src_element, "pulsesrc")) - { - GstStructure *props; - - props = gst_structure_from_string ("props,media.role=phone", NULL); - g_object_set (priv->src, "stream-properties", props, NULL); - gst_structure_free (props); - } - priv->volume = gst_element_factory_make ("volume", NULL); g_object_ref (priv->volume); |