[telepathy-stream-engine/master] Add video sink just in time
Olivier Crête
olivier.crete at collabora.co.uk
Mon Apr 6 15:28:33 PDT 2009
---
src/videostream.c | 64 ++++++++++++++++++++++++++++++++--------------------
1 files changed, 39 insertions(+), 25 deletions(-)
diff --git a/src/videostream.c b/src/videostream.c
index dbb1633..12f7707 100644
--- a/src/videostream.c
+++ b/src/videostream.c
@@ -207,7 +207,6 @@ tp_stream_engine_video_stream_constructor (GType type,
{
GObject *obj;
TpStreamEngineVideoStream *self = NULL;
- GstElement *sink = NULL;
GstPad *srcpad;
GstPad *sinkpad;
@@ -215,30 +214,6 @@ tp_stream_engine_video_stream_constructor (GType type,
self = (TpStreamEngineVideoStream *) obj;
- sink = tp_stream_engine_video_stream_make_sink (self, &self->priv->sinkpad);
-
- if (!sink)
- return obj;
-
- if (!gst_bin_add (GST_BIN (self->priv->bin), sink))
- {
- g_warning ("Could not add sink to bin");
- return obj;
- }
-
- self->priv->sink = sink;
-
- self->priv->receiving_probe_id =
- gst_pad_add_buffer_probe (self->priv->sinkpad,
- G_CALLBACK (receiving_data), self);
-
- if (gst_element_set_state (sink, GST_STATE_PLAYING) ==
- GST_STATE_CHANGE_FAILURE)
- {
- g_warning ("Could not start sink");
- return obj;
- }
-
self->priv->queue = gst_element_factory_make ("queue", NULL);
if (!self->priv->queue)
@@ -513,8 +488,47 @@ src_pad_added_cb (TfStream *stream, GstPad *pad, FsCodec *codec,
GstPad *ghost;
GstElement *funnel;
+ g_mutex_lock (self->priv->mutex);
+ if (!self->priv->sink)
+ {
+ GstElement *sink = NULL;
+
+ sink = tp_stream_engine_video_stream_make_sink (self,
+ &self->priv->sinkpad);
+
+ if (!sink)
+ {
+ g_mutex_unlock (self->priv->mutex);
+ return;
+ }
+
+ if (!gst_bin_add (GST_BIN (self->priv->bin), sink))
+ {
+ g_mutex_unlock (self->priv->mutex);
+ g_warning ("Could not add sink to bin");
+ return;
+ }
+
+ self->priv->sink = sink;
+
+ self->priv->receiving_probe_id =
+ gst_pad_add_buffer_probe (self->priv->sinkpad,
+ G_CALLBACK (receiving_data), self);
+
+ if (gst_element_set_state (sink, GST_STATE_PLAYING) ==
+ GST_STATE_CHANGE_FAILURE)
+ {
+ g_mutex_unlock (self->priv->mutex);
+ g_warning ("Could not start sink");
+ return;
+ }
+ }
+
funnel = gst_bin_get_by_name (GST_BIN (self->priv->sink), "funnel");
+ g_mutex_unlock (self->priv->mutex);
+
+
if (!funnel)
{
g_warning ("Could not get funnel");
--
1.5.6.5
More information about the telepathy-commits
mailing list