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 770627 - adaptivedemux: prevent to set source flag itself
adaptivedemux: prevent to set source flag itself
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gstreamer (core)
git master
Other Linux
: Normal blocker
: 1.10.0
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-08-31 07:31 UTC by Wonchul Lee
Modified: 2016-09-10 19:55 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
bin: don't set source flag on adaptive demuxer (1.97 KB, patch)
2016-08-31 07:31 UTC, Wonchul Lee
none Details | Review
bin: don't set source flag on adaptive demuxer (2.02 KB, patch)
2016-08-31 07:36 UTC, Wonchul Lee
none Details | Review
adaptivedemux: prevent to set source flag itself (927 bytes, patch)
2016-08-31 07:58 UTC, Wonchul Lee
none Details | Review
adaptivedemux: prevent to set source flag itself (1.01 KB, patch)
2016-08-31 08:39 UTC, Wonchul Lee
none Details | Review
adaptivedemux: prevent to set source flag itself (1.05 KB, patch)
2016-09-01 00:00 UTC, Wonchul Lee
none Details | Review
adaptivedemux: prevent to set source flag itself (1.01 KB, patch)
2016-09-01 06:31 UTC, Wonchul Lee
none Details | Review
bin: Add supress flags property (3.76 KB, patch)
2016-09-02 08:42 UTC, Wonchul Lee
none Details | Review
adaptivedemux: prevent to propagate source flag to itself (993 bytes, patch)
2016-09-02 08:43 UTC, Wonchul Lee
none Details | Review
bin: Add setter and getter to supress element flags (3.43 KB, patch)
2016-09-05 01:38 UTC, Wonchul Lee
none Details | Review
adaptivedemux: prevent to propagate source flag to itself (998 bytes, patch)
2016-09-05 01:40 UTC, Wonchul Lee
none Details | Review
adaptivedemux: prevent to propagate source flag to itself (1000 bytes, patch)
2016-09-09 02:08 UTC, Wonchul Lee
committed Details | Review
bin: Add setter and getter to supress element flags (4.02 KB, patch)
2016-09-09 02:12 UTC, Wonchul Lee
committed Details | Review

Description Wonchul Lee 2016-08-31 07:31:10 UTC
I ran some validate test cases with playbin3, then it failed when doing EOS action with below command. The reason was that there was two src elements in the Urisourcebin, Souphttpsrc and Dashdemux. So the Dashdemux got the event first and Souphttpsrc in front of DashDemux returned false due to the sinkpad of Dashdemux already received the event and returns GST_FLOW_EOS.

It was not a problem with Playbin2, Adaptivedemux (Dashdemux) is in the decodebin2 and there's only a single child source element on the Playbin point of view.

Test  case:
GST_VALIDATE_SCENARIOS_PATH=/home/wonchul/work/gst/gst-devtools/validate/data/scenarios: GST_GL_XINITTHREADS=1 GST_VALIDATE_OVERRIDE=/home/wonchul/gst-validate/gst-integration-testsuites/medias/defaults/online-streams-infos/dash/dash.exMPD_BIP_TC1.override DISPLAY=:0 GST_VALIDATE_SCENARIO=play_15s /home/wonchul/work/gst/gst-devtools/validate/tools/gst-validate-1.0-debug  playbin3 uri=http://127.0.0.1:8079/defaults/exMPD_BIP_TC1/exMPD_BIP_TC1.mpd audio-sink='fakesink sync=true' video-sink='fakesink sync=true' --set-media-info "/home/wonchul/gst-validate/gst-integration-testsuites/medias/defaults/online-streams-infos/dash/dash.exMPD_BIP_TC1.stream_info"
Comment 1 Wonchul Lee 2016-08-31 07:31:43 UTC
Created attachment 334502 [details] [review]
bin: don't set source flag on adaptive demuxer
Comment 2 Sebastian Dröge (slomo) 2016-08-31 07:35:57 UTC
Review of attachment 334502 [details] [review]:

::: gst/gstbin.c
@@ +1194,3 @@
+              GST_ELEMENT_METADATA_KLASS), "Demux")
+      && strstr (gst_element_class_get_metadata (bclass,
+              GST_ELEMENT_METADATA_KLASS), "Adaptive")) {

That's not the right approach, GstBin should not need to know about any such things.

This is something that would have to be solved in adaptivedemux by making sure to unset the SOURCE flag after adding elements, etc.
Comment 3 Wonchul Lee 2016-08-31 07:36:10 UTC
Created attachment 334503 [details] [review]
bin: don't set source flag on adaptive demuxer
Comment 4 Sebastian Dröge (slomo) 2016-08-31 07:42:32 UTC
Comment on attachment 334503 [details] [review]
bin: don't set source flag on adaptive demuxer

Same as before, fix needs to be in adaptivedemux
Comment 5 Wonchul Lee 2016-08-31 07:58:24 UTC
Created attachment 334507 [details] [review]
adaptivedemux: prevent to set source flag itself

yes, it should be handled in adaptivedemux, I fixed it to unset source flag of uri_handler before adding it to adaptivedemux.
Comment 6 Sebastian Dröge (slomo) 2016-08-31 08:17:16 UTC
Comment on attachment 334507 [details] [review]
adaptivedemux: prevent to set source flag itself

Does this really help? I would assume that you have to set it *after* adding the source element, as adding it will cause the flag to be set AFAIU?
Comment 7 Wonchul Lee 2016-08-31 08:39:56 UTC
Created attachment 334509 [details] [review]
adaptivedemux: prevent to set source flag itself

It works, removed source_flag of source element(uri_handler) before adding it to demux, but yes it seems better to unset the flag of adaptivedemux element like you said after adding source element. (without touching source element flag)

update patchset.
Comment 8 Sebastian Dröge (slomo) 2016-08-31 08:51:05 UTC
Review of attachment 334509 [details] [review]:

::: gst-libs/gst/adaptivedemux/gstadaptivedemux.c
@@ +2543,3 @@
     gst_bin_add (GST_BIN_CAST (stream->src), uri_handler);
 
+    GST_OBJECT_FLAG_UNSET (stream->src, GST_ELEMENT_FLAG_SOURCE);

Doing it a few lines below for demux after adding stream->src seems more correct. stream->src is technically a source.
Comment 9 Wonchul Lee 2016-09-01 00:00:31 UTC
Created attachment 334569 [details] [review]
adaptivedemux: prevent to set source flag itself

yes, thanks for the review, I fixed it to unset source flag of demux, not a source
Comment 10 Thiago Sousa Santos 2016-09-01 01:28:01 UTC
This is going to be racy between gst_bin_add and GST_OBJECT_FLAG_UNSET. As this can happen while in PLAYING there is a chance the user tries to do some operation and gets an unexpected behavior if it hits this window.

I guess to properly solve this we need to have it done inside gst_bin_add, a variant that would allow suppressing some flags propagation.

This is also done in camerabin IIRC, though I'm not sure if it is racy there as it is done during startup.
Comment 11 Sebastian Dröge (slomo) 2016-09-01 06:19:41 UTC
That's indeed a good point, thanks! So maybe the solution for now would indeed be to keep the flag unset on stream->stream before adding it as that can't be observed from the outside.

Adding a gst_bin_add() variant for this seems a bit problematic. What would you call it, and it would also have to come with a vfunc :) A add_full() that takes a GstBinAddPropagateElementFlags? A GstBinAddFlags that contains a flag for propagating the SINK/SOURCE/PROVIDES_CLOCK/etc flags?
Comment 12 Wonchul Lee 2016-09-01 06:31:38 UTC
Created attachment 334585 [details] [review]
adaptivedemux: prevent to set source flag itself

So, unset the source flag on stream->src before adding demux.
Comment 13 Sebastian Dröge (slomo) 2016-09-01 06:34:36 UTC
Comment on attachment 334585 [details] [review]
adaptivedemux: prevent to set source flag itself

Seems good to go for the time being, what do you think Thiago? Additionally we should try to find good GstBin API for this issue and keep this bug open.

This however should get a FIXME comment added that explains why and links to this bug.
Comment 14 Thiago Sousa Santos 2016-09-01 13:25:31 UTC
(In reply to Sebastian Dröge (slomo) from comment #11)
> That's indeed a good point, thanks! So maybe the solution for now would
> indeed be to keep the flag unset on stream->stream before adding it as that
> can't be observed from the outside.
> 
> Adding a gst_bin_add() variant for this seems a bit problematic. What would
> you call it, and it would also have to come with a vfunc :) A add_full()
> that takes a GstBinAddPropagateElementFlags? A GstBinAddFlags that contains
> a flag for propagating the SINK/SOURCE/PROVIDES_CLOCK/etc flags?

I'd prefer the opposite to tell which ones to suppress. gst_bin_add_suppress_flags() but the vfunc thing makes this a bit more involved.

Another option is to allow setting this as a property in GstBin. No matter how many sources/sinks we set to adatpvidedemux it should not be considered a source or a sink. So maybe we want a property to prevent it from propagating flags at every add.

What do you think?
Comment 15 Sebastian Dröge (slomo) 2016-09-01 14:50:01 UTC
A property on the bin would seem useful, yes. A value and mask of flags that should not be handled automatically.
Comment 16 Wonchul Lee 2016-09-01 23:43:26 UTC
It seems to be better to use property in GstBin to prevent propagating flags
Comment 17 Sebastian Dröge (slomo) 2016-09-02 06:46:20 UTC
Question is mostly how the API would look like. Would you like to propose a patch?
Comment 18 Sebastian Dröge (slomo) 2016-09-02 06:47:09 UTC
Marking as blocker for now. Either we should get the GstBin part in, or the existing patch.
Comment 19 Wonchul Lee 2016-09-02 08:42:16 UTC
Created attachment 334621 [details] [review]
bin: Add supress flags property
Comment 20 Wonchul Lee 2016-09-02 08:43:36 UTC
Created attachment 334622 [details] [review]
adaptivedemux: prevent to propagate source flag to itself

added the property 'supress-flags' on the bin to prevent propagation of element's specific flags when it added to the bin.
Comment 21 Thiago Sousa Santos 2016-09-02 13:28:44 UTC
Thanks for working on this. The implementation looks correct, just wondering if we want to have a discoverable property (will appear at every bin's property list) or a less discoverable set/get pair for use only when writing bin-derived elements?

I'm more in favor of the later.
Comment 22 Sebastian Dröge (slomo) 2016-09-02 13:55:19 UTC
I also prefer a setter/getter (or even a class variable ;) ) over a property, especially as you need more than a property to actually set those flags correctly.
Comment 23 Wonchul Lee 2016-09-05 01:38:55 UTC
Created attachment 334760 [details] [review]
bin: Add setter and getter to supress element flags
Comment 24 Wonchul Lee 2016-09-05 01:40:08 UTC
Created attachment 334761 [details] [review]
adaptivedemux: prevent to propagate source flag to itself

Fixed it to add setter/getter for 'supress flags' to the bin instead of discoverable property.
Comment 25 Thiago Sousa Santos 2016-09-08 14:21:04 UTC
Review of attachment 334760 [details] [review]:

Just some minor stuff to fix.

::: gst/gstbin.c
@@ +1412,3 @@
 
+void
+gst_bin_set_supress_flags (GstBin * bin, GstElementFlags flags)

Missing documentation, remember to add the Since marker. Same for the getter function.

Will this be a 1.10 or 1.12 addition?

@@ +1414,3 @@
+gst_bin_set_supress_flags (GstBin * bin, GstElementFlags flags)
+{
+  g_return_val_if_fail (GST_IS_BIN (bin), NULL);

This should be a g_return_if_fail as the function has no return value.

@@ +1420,3 @@
+  GST_OBJECT_UNLOCK (bin);
+
+  GST_DEBUG_OBJECT (bin, "set supress flags(%d) to bin '%s'", flags,

flags are usually better read in hex format.

::: gst/gstbin.h
@@ +211,3 @@
+/* set and get supress flags */
+void            gst_bin_set_supress_flags (GstBin * bin, GstElementFlags flags);
+GstElementFlags gst_bin_get_supress_flags (GstBin * bin);

<bikeshed>
I'd prefer:

gst_bin_set/get_supressed_flags
</bikeshed>
Comment 26 Wonchul Lee 2016-09-09 02:08:54 UTC
Created attachment 335151 [details] [review]
adaptivedemux: prevent to propagate source flag to itself
Comment 27 Wonchul Lee 2016-09-09 02:12:36 UTC
Created attachment 335152 [details] [review]
bin: Add setter and getter to supress element flags

Added the documentation for setter and getter related with supressed flags, fixed the name supress_flag to supressed_flag. I'm not sure what Since marker should be, I just wrote it to 1.10 here. Thanks for the review!
Comment 28 Thiago Sousa Santos 2016-09-09 16:45:34 UTC
Review of attachment 335152 [details] [review]:

Looks good, some minor typos on the docs that can be fixed when pushing.
Comment 29 Thiago Sousa Santos 2016-09-09 16:46:49 UTC
Review of attachment 335151 [details] [review]:

Looks good
Comment 30 Arnaud Vrac 2016-09-09 21:03:04 UTC
s/supress/suppress/ ?
Comment 31 Sebastian Dröge (slomo) 2016-09-10 08:07:14 UTC
Looks good to me too except the typos, Thiago go ahead with merging (and don't forget the typos) :)
Comment 32 Thiago Sousa Santos 2016-09-10 16:29:22 UTC
commit 29c3b8b4d572a93bb7d0f374ffc0d2894abce3da
Author: Thiago Santos <thiagossantos@gmail.com>
Date:   Sat Sep 10 11:59:11 2016 -0300

    tests: gstbin: add tests for suppressed flags
    
    Some simple tests to make sure it keeps working

commit 978b7ace5210f2a6a3204fd22c5699a5b487aa07
Author: Wonchul Lee <wonchul.lee@collabora.com>
Date:   Fri Sep 2 17:39:17 2016 +0900

    bin: Add setter and getter to suppress element flags
    
    Suppress-flags is for preventing propagation of child element's specific
    flag when it is added to the bin.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770627


commit aa314c43baf37ed4ebf9ac359edb1784dd4e3bf4
Author: Wonchul Lee <wonchul.lee@collabora.com>
Date:   Mon Sep 5 10:31:40 2016 +0900

    adaptivedemux: prevent to propagate source flag to itself
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770627
Comment 33 Thiago Sousa Santos 2016-09-10 16:29:54 UTC
Comment on attachment 335152 [details] [review]
bin: Add setter and getter to supress element flags

Committed with typo fixes.
Comment 34 Emmanuele Bassi (:ebassi) 2016-09-10 19:26:06 UTC
This is breaking the build in Continuous.

The GStreamer API in commit:

https://cgit.freedesktop.org/gstreamer/gstreamer/commit/?id=978b7ace5210f2a6a3204fd22c5699a5b487aa07

has:

  gst_bin_get_suppressed_flags
  gst_bin_set_suppressed_flags

but the gst-plugins-bad commit:

https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=aa314c43baf37ed4ebf9ac359edb1784dd4e3bf4

has:

  gst_bin_set_supressed_flags

I'll tag gst-plugins-bad in Continuous in the meantime.
Comment 35 Thiago Sousa Santos 2016-09-10 19:42:07 UTC
Sorry, my mistake. Made the changes locally and forgot to amend before pushing. Follow up fix in a min.
Comment 36 Thiago Sousa Santos 2016-09-10 19:55:00 UTC
commit 08da51452879bc53dfaf1635598cf0b7184e4196
Author: Thiago Santos <thiagossantos@gmail.com>
Date:   Sat Sep 10 16:41:28 2016 -0300

    adaptivedemux: fix typo in new API
    
    Fixes supressed -> suppressed typo in previous commit
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770627


Done, thanks for noticing.