After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 732741 - camerabin2: Fails reconfiguring the source
camerabin2: Fails reconfiguring the source
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.3.90
Other Linux
: Normal blocker
: 1.3.91
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2014-07-04 14:22 UTC by Nicolas Dufresne (ndufresne)
Modified: 2014-07-11 16:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] camerabin2: Flush downstream after setting src to READY (1.63 KB, patch)
2014-07-07 15:53 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review
[PATCH] wrappercamerabinsrc: Fix caps filter caps proxying (2.87 KB, patch)
2014-07-11 14:43 UTC, Nicolas Dufresne (ndufresne)
committed Details | Review

Description Nicolas Dufresne (ndufresne) 2014-07-04 14:22:57 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 ?)
Comment 1 Vincent Penquerc'h 2014-07-07 09:17:59 UTC
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"
Comment 2 Nicolas Dufresne (ndufresne) 2014-07-07 11:35:56 UTC
It can be reproduced with gst-plugins-bad/tests/examples/camerabin2/gst-camerabin2.
Comment 3 Nicolas Dufresne (ndufresne) 2014-07-07 11:38:05 UTC
Also, this python script is written for older Gst. Please use "from gi.repository import Gst"
Comment 4 Nicolas Dufresne (ndufresne) 2014-07-07 11:54:41 UTC
I confirm simple PLAYING->READY->PLAYING transition works. This is with tested with:

./playback-test 1 "v4l2src ! xvimagesink"
Comment 5 Nicolas Dufresne (ndufresne) 2014-07-07 12:32:44 UTC
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.
Comment 6 Nicolas Dufresne (ndufresne) 2014-07-07 15:53:49 UTC
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(+)
Comment 7 Nicolas Dufresne (ndufresne) 2014-07-07 15:55:12 UTC
This fixes gst-camera2 test application. Still fails in cheese, but I'm unsure if it's related or not.
Comment 8 Nicolas Dufresne (ndufresne) 2014-07-07 18:20:18 UTC
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.
Comment 9 Daniel Drake 2014-07-07 19:13:35 UTC
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?
Comment 10 Nicolas Dufresne (ndufresne) 2014-07-07 19:47:34 UTC
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 11 Sebastian Dröge (slomo) 2014-07-09 07:25:45 UTC
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...
Comment 12 Nicolas Dufresne (ndufresne) 2014-07-10 22:35:06 UTC
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
Comment 13 Nicolas Dufresne (ndufresne) 2014-07-11 14:43:36 UTC
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 14 Nicolas Dufresne (ndufresne) 2014-07-11 16:13:01 UTC
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