GNOME Bugzilla – Bug 732741
camerabin2: Fails reconfiguring the source
Last modified: 2014-07-11 16:13:01 UTC
Starting back the source fails on EBUSY when doing quick PLAYING->READY->PLAYING transition. This seems to break many uses cases in camerabin/cheese. (Blocker ?)
The following test seems to work fine for me (not quite master, but pretty recent). Does it fail for you ? #! /usr/bin/python import gobject gobject.threads_init() import gst import sys def reswitch_pipeline(): print "changing state to PLAYING" playbin.set_state(gst.STATE_PLAYING) playbin.get_state() print "Now in PLAYING" def switch_pipeline(): print "changing state to READY" playbin.set_state(gst.STATE_READY) playbin.get_state() print "Now in READY" gobject.timeout_add(1, reswitch_pipeline) if __name__ == '__main__': print "start" playbin = gst.element_factory_make("playbin") v4l2src = gst.element_factory_make("v4l2src") fakesink = gst.element_factory_make("fakesink") #playbin.set_property('video-sink',fakesink) playbin.set_property("uri","v4l2:///dev/video0") print "changing state to PAUSED" playbin.set_state(gst.STATE_PAUSED) print "changing state to PLAYING" playbin.set_state(gst.STATE_PLAYING) print "Now in PLAYING" gobject.timeout_add_seconds(2, switch_pipeline) loop = gobject.MainLoop() loop.run() playbin.set_state(gst.STATE_NULL) print "done"
It can be reproduced with gst-plugins-bad/tests/examples/camerabin2/gst-camerabin2.
Also, this python script is written for older Gst. Please use "from gi.repository import Gst"
I confirm simple PLAYING->READY->PLAYING transition works. This is with tested with: ./playback-test 1 "v4l2src ! xvimagesink"
Ok, some more investigating showed the camerabin2 will only set the src to READY. This won't work, as some buffers are still being used downstream. This prevent the pool from being shut down. Hence, when the pool is created again, we get EBUSY.
Created attachment 280074 [details] [review] [PATCH] camerabin2: Flush downstream after setting src to READY v4l2src requires all buffers to come back in order to cleanly stop streaming. Flushing the pipline should force all buffers to come back. https://bugzilla.gnome.org/show_bug.cgi?id=732741 --- gst/camerabin2/gstwrappercamerabinsrc.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
This fixes gst-camera2 test application. Still fails in cheese, but I'm unsure if it's related or not.
Cheese failure was due to cheese forcing I420 but not adding a converter. Works in presence of libv4l2, as it will provide an emulated format.
Thanks for looking at this! I'm at the point where I might have some time to dedicate - anything useful I can do at this point? Does your most recent comment suggest that its a bug in cheese?
No this one is a bug in camerabin/gstreamer, but it breaks cheese, so I wanted you to be aware. I'll file seperate bugs and will CC you.
Comment on attachment 280074 [details] [review] [PATCH] camerabin2: Flush downstream after setting src to READY Please merge after adding a big comment above this code that this is just a hack and a real solution yet has to be found. It shouldn't cause any issues and at least make things work somehow...
commit 5e4e572335bed642dfab36c4f325fde342a370e5 Author: Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> Date: Mon Jul 7 11:52:18 2014 -0400 camerabin2: Flush downstream after setting src to READY v4l2src requires all buffers to come back in order to cleanly stop streaming. Flushing the pipline should force all buffers to come back. https://bugzilla.gnome.org/show_bug.cgi?id=732741
Created attachment 280514 [details] [review] [PATCH] wrappercamerabinsrc: Fix caps filter caps proxying The notify signal is triggered when caps is changed. But instead of proxying the fixed caps, we query for the caps. Hence, when we go to READY state, we endup setting template caps on the proxied caps filter instead of NULL, which leads to negoitation failure. Correctly proxy NULL caps if this is the new caps. Fixes not negotiated error when running in cheese. Also fix a leak of caps string in one of the trace. https://bugzilla.gnome.org/show_bug.cgi?id=732741 --- gst/camerabin2/gstwrappercamerabinsrc.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
Comment on attachment 280514 [details] [review] [PATCH] wrappercamerabinsrc: Fix caps filter caps proxying Reviewed by Thiago, a small change, I do if (caps) unref (caps) instead of replace. commit 362951b9ec7139da43b0a72b6b80c06a67d05b04 Author: Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> Date: Fri Jul 11 10:40:42 2014 -0400 wrappercamerabinsrc: Fix caps filter caps proxying The notify signal is triggered when caps is changed. But instead of proxying the fixed caps, we query for the caps. Hence, when we go to READY state, we endup setting template caps on the proxied caps filter instead of NULL, which leads to negoitation failure. Correctly proxy NULL caps if this is the new caps. Fixes not negotiated error when running in cheese. Also fix a leak of caps string in one of the trace. https://bugzilla.gnome.org/show_bug.cgi?id=732741