diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2011-11-05 02:46:24 +0800 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2011-11-08 04:07:19 +0800 |
commit | 7577ba45e2046a19caac1b360901669d12e0f3d1 (patch) | |
tree | bd5cd3114af150f19433ac2f70cc31b86bc79416 | |
parent | ab7098222f1b01f87956331ae7c1e095fbf1c9a5 (diff) | |
download | gsoc2013-empathy-7577ba45e2046a19caac1b360901669d12e0f3d1.tar gsoc2013-empathy-7577ba45e2046a19caac1b360901669d12e0f3d1.tar.gz gsoc2013-empathy-7577ba45e2046a19caac1b360901669d12e0f3d1.tar.bz2 gsoc2013-empathy-7577ba45e2046a19caac1b360901669d12e0f3d1.tar.lz gsoc2013-empathy-7577ba45e2046a19caac1b360901669d12e0f3d1.tar.xz gsoc2013-empathy-7577ba45e2046a19caac1b360901669d12e0f3d1.tar.zst gsoc2013-empathy-7577ba45e2046a19caac1b360901669d12e0f3d1.zip |
When reset the source remove and re-insert it
Setting an element to NULL resets various internal values (the clock,
the base time etc). To make sure everything is reset as expected simply
yank it from the bin and re-insert it (which will reset the values)
-rw-r--r-- | src/empathy-video-src.c | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/src/empathy-video-src.c b/src/empathy-video-src.c index e2842114f..23b4dca52 100644 --- a/src/empathy-video-src.c +++ b/src/empathy-video-src.c @@ -444,13 +444,20 @@ empathy_video_src_set_resolution (GstElement *src, { EmpathyGstVideoSrcPrivate *priv = EMPATHY_GST_VIDEO_SRC_GET_PRIVATE (src); GstCaps *caps; - GstClock *gst_clock; + GstPad *srcpad, *peer; g_return_if_fail (priv->capsfilter != NULL); gst_element_set_locked_state (priv->src, TRUE); gst_element_set_state (priv->src, GST_STATE_NULL); + srcpad = gst_element_get_static_pad (priv->src, "src"); + peer = gst_pad_get_peer (srcpad); + + /* Keep a ref as removing it from the bin will loose our reference */ + gst_object_ref (priv->src); + gst_bin_remove (GST_BIN (src), priv->src); + g_object_get (priv->capsfilter, "caps", &caps, NULL); caps = gst_caps_make_writable (caps); @@ -461,13 +468,15 @@ empathy_video_src_set_resolution (GstElement *src, g_object_set (priv->capsfilter, "caps", caps, NULL); - /* Reset clock an base time, this is require for videotestsrc and hopefully - * has no side effect */ - gst_clock = gst_element_get_clock (src); - gst_element_set_clock (priv->src, gst_clock); - gst_element_set_base_time (priv->src, gst_element_get_base_time (src)); - gst_object_unref (gst_clock); + gst_bin_add (GST_BIN (src), priv->src); + /* We as the bin own the source again, so drop the temporary ref */ + gst_object_unref (priv->src); + + gst_pad_link (srcpad, peer); gst_element_set_locked_state (priv->src, FALSE); gst_element_sync_state_with_parent (priv->src); + + gst_object_unref (srcpad); + gst_object_unref (peer); } |