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 638749 - (Duration) queries on a source-only bin are currently not supported
(Duration) queries on a source-only bin are currently not supported
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal normal
: 1.1.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-01-05 14:49 UTC by Simon Hausmann
Modified: 2013-02-12 09:34 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
bin: query sink elements and source pads of the bin (5.90 KB, patch)
2011-01-05 16:36 UTC, Philippe Normand
none Details | Review
bin: query sink elements and source pads of the bin (5.98 KB, patch)
2011-01-05 16:54 UTC, Philippe Normand
needs-work Details | Review
bin: query sink elements and source pads of the bin (6.34 KB, patch)
2013-02-09 17:15 UTC, Philippe Normand
committed Details | Review

Description Simon Hausmann 2011-01-05 14:49:12 UTC
GstBin's gst_bin_query() handler currently only supports forwarding queries to sink children.

In WebKit's GStreamer back-end we have a source-only bin, on which we would like to do a duration query.

It would be nice if the gst_bin_query() handler would support this, for example perhaps by falling back to what the gst_element_default_query() function does.
Comment 1 Simon Hausmann 2011-01-05 14:52:33 UTC
This affects WebKitGtk upstream at
https://bugs.webkit.org/show_bug.cgi?id=51926
Comment 2 Philippe Normand 2011-01-05 16:36:34 UTC
Created attachment 177591 [details] [review]
bin: query sink elements and source pads of the bin

gst_bin_query() now forwards the query to the source pads as well if
none of the sinks of the bin satisfied the query. This helps in the
case of DURATION queries done a bin containing a source element.

Fixes bug 638749
Comment 3 Philippe Normand 2011-01-05 16:54:07 UTC
Created attachment 177594 [details] [review]
bin: query sink elements and source pads of the bin

gst_bin_query() now forwards the query to the source pads as well if
none of the sinks of the bin satisfied the query. This helps in the
case of DURATION queries done a bin containing a source element.

Fixes bug 638749
Comment 4 Philippe Normand 2011-01-05 16:55:19 UTC
This second version uses GST_IS_PAD instead of the slower GST_IS_ELEMENT macro and always forwards the query to src pads, as advised by Sebastian.
Comment 5 Philippe Normand 2011-01-05 17:12:31 UTC
This patch needs some more work, I think the fold data might be reset unexpectedly during the second iteration if a RESYNC is emitted by the gst_iterator.
Comment 6 Sebastian Dröge (slomo) 2011-01-08 17:26:25 UTC
I talked to Wim and he said that this change makes sense too for the DURATION queries. And that GstElement's query handler should also iterate over all srcpads and take the maximum instead of just taking a random element like it does now.

You might also want to pass the pad-or-element information via the user data of the fold function btw. And really just do two folds with completely reinitialized state and everything and then just take the maximum of both results
Comment 7 Philippe Normand 2011-01-10 10:02:22 UTC
(In reply to comment #6)
> I talked to Wim and he said that this change makes sense too for the DURATION
> queries. And that GstElement's query handler should also iterate over all
> srcpads and take the maximum instead of just taking a random element like it
> does now.
> 

Ok, but only for DURATION queries, right?

> You might also want to pass the pad-or-element information via the user data of
> the fold function btw. And really just do two folds with completely
> reinitialized state and everything and then just take the maximum of both
> results

I made those changes in my branch, thanks :)
Comment 8 Sebastian Dröge (slomo) 2011-01-11 17:15:46 UTC
Well, for all query types that are currently handled in a special way, e.g. LATENCY.
While you're at it you could also add this to GstElement's default query function btw ;)

Also, where's your branch?
Comment 9 Philippe Normand 2011-01-13 14:06:01 UTC
I moved the "query iterate folding" code out of gstbin so it can be used in gstelement default query handler. The branch is there:

http://git.igalia.com/cgi-bin/gitweb.cgi?p=user/pnormand/gstreamer.git;a=shortlog;h=refs/heads/bug/638749
Comment 10 Sebastian Dröge (slomo) 2011-01-24 18:49:58 UTC
Is your branch ready for review and committing?
Comment 11 Philippe Normand 2011-01-24 19:07:00 UTC
I was thinking of fixing position queries wrt negative playback rate too but maybe it can be done later on?

Apart from that the branch would need a rebase, I'll do that tomorrow and check the patches again before pinging you.
Comment 12 Philippe Normand 2011-01-25 12:16:55 UTC
Hi Sebastian, I updated the branch with some changes:

- rebased against master
- renamed the test element to mocksrc
- fixed 2 leaks in the test
- and some minor other changes

The position query fixing should be part of another patch I believe now.
Can you review the branch when you have some time please?
Comment 13 Sebastian Dröge (slomo) 2011-04-01 08:28:21 UTC
* You're adding the query iterate stuff as public API. Not a good idea, please put the header in noinst_HEADERS (or put the content in gstprivate.h)
* Add some (non-gtkdoc) documentation to the query iteration API
* You should probably do the srcpad iteration only when necessary, i.e. for duration queries so far
* In the GstElement default query handler, maybe do the iteration stuff for the sinkpads too instead of taking a random pad?
* Well... and the position query stuff. Just add another commit to your branch, no need for a new bug. It's easy enough :)

* I'm not 100% sure but I think most of this can be in the GstElement default query handler and the GstBin query handler can just chain up to it in most cases. Could you check this?

Other than that this looks good
Comment 14 Philippe Normand 2011-04-08 09:04:17 UTC
(In reply to comment #13)
> * You're adding the query iterate stuff as public API. Not a good idea, please
> put the header in noinst_HEADERS (or put the content in gstprivate.h)

Hum it's in noinst_HEADERS already :)

> * Add some (non-gtkdoc) documentation to the query iteration API

OK

> * You should probably do the srcpad iteration only when necessary, i.e. for
> duration queries so far

This contradicts your comment 8 or am I misunderstanding something?

> * In the GstElement default query handler, maybe do the iteration stuff for the
> sinkpads too instead of taking a random pad?
> * Well... and the position query stuff. Just add another commit to your branch,
> no need for a new bug. It's easy enough :)
> 

OK!

> * I'm not 100% sure but I think most of this can be in the GstElement default
> query handler and the GstBin query handler can just chain up to it in most
> cases. Could you check this?
> 

OK I'll check.
Comment 15 Sebastian Dröge (slomo) 2011-04-08 12:03:05 UTC
(In reply to comment #14)
> (In reply to comment #13)
> > * You're adding the query iterate stuff as public API. Not a good idea, please
> > put the header in noinst_HEADERS (or put the content in gstprivate.h)
> 
> Hum it's in noinst_HEADERS already :)

Sorry, you're right :)

> > * You should probably do the srcpad iteration only when necessary, i.e. for
> > duration queries so far
> 
> This contradicts your comment 8 or am I misunderstanding something?

Well, for non-duration queries you're currently iterating the srcpads but you don't use the result. That's what I mean, if you don't use the result anyway you can skip the iterating too.

In comment #8 I meant that you should do the srcpad iterations for other queries too but of course you have to do something with the result then. And it was about doing it in GstElement too
Comment 16 Philippe Normand 2013-02-09 17:13:28 UTC
(In reply to comment #13)
> * In the GstElement default query handler, maybe do the iteration stuff for the
> sinkpads too instead of taking a random pad?
> 
> * I'm not 100% sure but I think most of this can be in the GstElement default
> query handler and the GstBin query handler can just chain up to it in most
> cases. Could you check this?
> 

Indeed it seems that most of the GstQuery management of GstBin could move to GstElement. But maybe we can do that move as a follow-up of this patch?

I'm going to upload a new version now.
Comment 17 Philippe Normand 2013-02-09 17:15:19 UTC
Created attachment 235589 [details] [review]
bin: query sink elements and source pads of the bin

gst_bin_query() now forwards the query to the source pads as well if
none of the sinks of the bin satisfied the query. This helps in the
case of DURATION queries done a bin containing a source element.

Fixes bug 638749
Comment 18 Sebastian Dröge (slomo) 2013-02-12 09:34:29 UTC
commit f3d268de7f7fb1161778a9a95e0d54d8c89ef626
Author: Philippe Normand <philn@igalia.com>
Date:   Sat Feb 9 18:14:09 2013 +0100

    bin: query sink elements and source pads of the bin
    
    gst_bin_query() now forwards the query to the source pads as well if
    none of the sinks of the bin satisfied the query. This helps in the
    case of DURATION queries done a bin containing a source element.
    
    Fixes bug 638749