From cfda1aafa34563f98df738ebbdb409ab743b249b Mon Sep 17 00:00:00 2001 From: Thiago Santos Date: Mon, 3 Feb 2014 23:10:03 -0300 Subject: [PATCH] wrappercamerabinsrc: stop source to do internal reconfiguration safely In order to be able to change the caps on multiple capsfilters the source element needs to be stopped, otherwise it will get a few reconfigure events and might try to renegotiate while the bin is still transitioning its caps, leading to a not-negotiated failure and the image capture won't happen because the source will be unusable. The solution is to keep the source in paused while the caps are being changed in the bin, and then bring the element back to playing once it is done. Unfortunately this increases the image capture latency, but it should always work. A possible improvement to reduce the latency is to add another signal to be called before 'start-capture': 'prepare-capture'. At this step the camera source should set all caps it needs and get the source ready for doing the capture as soon as 'start-capture' is called. This can be done on a future commit --- gst/camerabin2/gstwrappercamerabinsrc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gst/camerabin2/gstwrappercamerabinsrc.c b/gst/camerabin2/gstwrappercamerabinsrc.c index 2e3dda64fd..c2111a0b7e 100644 --- a/gst/camerabin2/gstwrappercamerabinsrc.c +++ b/gst/camerabin2/gstwrappercamerabinsrc.c @@ -828,6 +828,7 @@ start_image_capture (GstWrapperCameraBinSrc * self) GstCaps *caps; GST_DEBUG_OBJECT (self, "Starting image capture"); + gst_element_set_state (self->src_vid_src, GST_STATE_READY); if (self->image_renegotiate) { /* clean capsfilter caps so they don't interfere here */ @@ -852,6 +853,7 @@ start_image_capture (GstWrapperCameraBinSrc * self) } if (photography) { + gst_element_set_state (self->src_vid_src, GST_STATE_PLAYING); GST_DEBUG_OBJECT (self, "prepare image capture caps %" GST_PTR_FORMAT, self->image_capture_caps); ret = gst_photography_prepare_for_capture (photography, @@ -863,6 +865,7 @@ start_image_capture (GstWrapperCameraBinSrc * self) self->image_capture_caps); g_mutex_lock (&bcamsrc->capturing_mutex); ret = TRUE; + gst_element_set_state (self->src_vid_src, GST_STATE_PLAYING); } return ret;