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 777213 - adaptivedemux: Enable reuse pad for "streams-aware" usecase
adaptivedemux: Enable reuse pad for "streams-aware" usecase
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
: 796000 (view as bug list)
Depends on: 775132
Blocks:
 
 
Reported: 2017-01-13 10:48 UTC by Seungha Yang
Modified: 2018-11-03 14:03 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
adaptivedemux: Do not expose/remove static streams (2.89 KB, patch)
2017-01-13 10:50 UTC, Seungha Yang
none Details | Review
hlsdemux: Re-expose only variant stream with bitrate switching (3.78 KB, patch)
2017-01-13 10:50 UTC, Seungha Yang
none Details | Review
hlsdemux: Re-expose only variant stream with bitrate switching (10.68 KB, patch)
2017-07-13 14:06 UTC, Seungha Yang
none Details | Review
urisourcebin: Set streams-aware flag (972 bytes, patch)
2017-07-13 14:07 UTC, Seungha Yang
none Details | Review

Description Seungha Yang 2017-01-13 10:48:49 UTC
We don't need to re-expose streams in EXT-X-MEDIA, since only variant streams
can be changed with bitrate switching
Comment 1 Seungha Yang 2017-01-13 10:50:10 UTC
Created attachment 343424 [details] [review]
adaptivedemux: Do not expose/remove static streams

Depending on streaming protocol (i.e., hls) there might be streams
which don't need to be re-exposed/removed during playback
Comment 2 Seungha Yang 2017-01-13 10:50:28 UTC
Created attachment 343425 [details] [review]
hlsdemux: Re-expose only variant stream with bitrate switching
Comment 3 Seungha Yang 2017-01-13 10:53:59 UTC
remove/expose streams on EXT-X-MEDIA tag seems to unnecessary.
Do I missing something?
Comment 4 Seungha Yang 2017-07-13 14:06:42 UTC
Created attachment 355514 [details] [review]
hlsdemux: Re-expose only variant stream with bitrate switching

Re-exposing all streams per variant change is very inefficient
operation because:
* EXT-X-MEDIA streams will not be changed during playback.
* baseclass should wait the preparation of task for new streams
  until all download tasks for old streams are finished.
  This might be able to break seamless bitrate switching.

When streams-aware flag is set on parent bin (i.e., playbin3),
since it's allowed that dynamic pad exposing, only the variant streams
will be re-exposed and all the other rendition streams will be reused.
Comment 5 Seungha Yang 2017-07-13 14:07:37 UTC
Created attachment 355515 [details] [review]
urisourcebin: Set streams-aware flag
Comment 6 Seungha Yang 2017-07-13 14:12:09 UTC
I missed one thing on commit message. In case playbin 3, I allowed hlsdemux to be able to expose subtitle streams.
Comment 7 CARD 2017-10-13 09:19:44 UTC
Hi, how about subtitle streams, now my m3u8 file has eight subtitles, it can be displayed by playbin, but when i switch to another, the subtitle disappeared, why?
Comment 8 CARD 2017-10-13 09:41:30 UTC
what's the meaning of GST_BIN_FLAG_STREAMS_AWARE? 
I added GST_BIN_FLAG_STREAMS_AWARE to the code refer according to your method, but the value of demux->streams_aware is FALSE, when the code is running
Comment 9 Seungha Yang 2017-10-16 01:01:14 UTC
(In reply to tianyahai from comment #7)
> Hi, how about subtitle streams, now my m3u8 file has eight subtitles, it can
> be displayed by playbin, but when i switch to another, the subtitle
> disappeared, why?

AFAIK, subtitle is disabled in current hlsdemux. Need more context such as your m3u8 and your playbin usecase (playbin or playbin3).


(In reply to tianyahai from comment #8)
> what's the meaning of GST_BIN_FLAG_STREAMS_AWARE? 
> I added GST_BIN_FLAG_STREAMS_AWARE to the code refer according to your
> method, but the value of demux->streams_aware is FALSE, when the code is
> running

You can refer to its meaning at https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/GstBin.html
My understanding about it is that, it's used in playbin3 (not playbin) to indicate that corresponding element/bin can handle GstStreams API and also can handle stream add/removal during playback without any interruption.

I guess you are now use playbin (not playbin3). The playbin doesn't use urisourcebin but do uridecodebin. Please not that my patch aims to set the flag at urisourcebin and read it by adaptivedemux (this is urisourcebin's child bin)
Comment 10 CARD 2017-10-16 02:00:48 UTC
(In reply to Seungha Yang from comment #9)
> (In reply to tianyahai from comment #7)
> > Hi, how about subtitle streams, now my m3u8 file has eight subtitles, it can
> > be displayed by playbin, but when i switch to another, the subtitle
> > disappeared, why?
> 
> AFAIK, subtitle is disabled in current hlsdemux. Need more context such as
> your m3u8 and your playbin usecase (playbin or playbin3).
> 
> 
Thank you for your reply, in deeded, the subtitles are closed by default, but in the code of gsthlsdemux.c file i enabled subtitle like this:
  select = demux->streams_aware ? TRUE : (media->mtype == GST_HLS_MEDIA_TYPE_VIDEO ||
          media->mtype == GST_HLS_MEDIA_TYPE_AUDIO || media->mtype == GST_HLS_MEDIA_TYPE_SUBTITLES);

In my m3u8 there are eight subtitles, the subtitles can be displayed when the code is running, but if i switch subtitle to another it will be disappear, i used playbin or playbin2, not playbin3

> (In reply to tianyahai from comment #8)
> > what's the meaning of GST_BIN_FLAG_STREAMS_AWARE? 
> > I added GST_BIN_FLAG_STREAMS_AWARE to the code refer according to your
> > method, but the value of demux->streams_aware is FALSE, when the code is
> > running
> 
> You can refer to its meaning at
> https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/
> GstBin.html
> My understanding about it is that, it's used in playbin3 (not playbin) to
> indicate that corresponding element/bin can handle GstStreams API and also
> can handle stream add/removal during playback without any interruption.
> 
> I guess you are now use playbin (not playbin3). The playbin doesn't use
> urisourcebin but do uridecodebin. Please not that my patch aims to set the
> flag at urisourcebin and read it by adaptivedemux (this is urisourcebin's
> child bin)

Yes,as you say,i used playbin,can i add "GST_OBJECT_FLAG_SET (dec, GST_ELEMENT_FLAG_SOURCE | GST_BIN_FLAG_STREAMS_AWARE)" to gsturidecodebin.c file according to your urisourcebin file? 
How can hlsdemux achieve switch subtitles...
Comment 11 CARD 2017-10-16 02:02:54 UTC
I submitted it in this: https://bugzilla.gnome.org/show_bug.cgi?id=788869
Comment 12 CARD 2017-10-16 02:41:12 UTC
I try playbin3 to play my m3u8, if it only contain one stream as MediaPlaylist, it's ok, if contains variant streams, it failed like below:
 ...
PREROLLING ...
... 100%  
(gst-launch-1.0:22408): GStreamer-CRITICAL **: gst_stream_collection_get_stream: assertion 'GST_IS_STREAM_COLLECTION (collection)' failed
Caught SIGSEGV
  • #0 __kernel_vsyscall
  • #1 poll
    at ../sysdeps/unix/syscall-template.S line 84
  • #2 g_poll
    from /lib/i386-linux-gnu/libglib-2.0.so.0
  • #3 ??
    from /lib/i386-linux-gnu/libglib-2.0.so.0
  • #4 g_main_loop_run
    from /lib/i386-linux-gnu/libglib-2.0.so.0
  • #5 gst_bus_poll
  • #6 ??
  • #7 ??
  • #8 __libc_start_main
  • #9 ??

Why it's not ok, does playbin3 not support multi-rate m3u8 file?
Comment 13 Seungha Yang 2017-10-16 03:19:08 UTC
(In reply to tianyahai from comment #10)
> Thank you for your reply, in deeded, the subtitles are closed by default,
> but in the code of gsthlsdemux.c file i enabled subtitle like this:
>   select = demux->streams_aware ? TRUE : (media->mtype ==
> GST_HLS_MEDIA_TYPE_VIDEO ||
>           media->mtype == GST_HLS_MEDIA_TYPE_AUDIO || media->mtype ==
> GST_HLS_MEDIA_TYPE_SUBTITLES);
> 
> In my m3u8 there are eight subtitles, the subtitles can be displayed when
> the code is running, but if i switch subtitle to another it will be
> disappear, i used playbin or playbin2, not playbin3
This comment might be helpful for you :)
https://bugzilla.gnome.org/show_bug.cgi?id=779011#c7

> Yes,as you say,i used playbin,can i add "GST_OBJECT_FLAG_SET (dec,
> GST_ELEMENT_FLAG_SOURCE | GST_BIN_FLAG_STREAMS_AWARE)" to gsturidecodebin.c
> file according to your urisourcebin file? 
You can try it but it doesn't make sense because uridecodebin doesn't "STREAMS_AWARE".

> How can hlsdemux achieve switch subtitles...
It's totally dependent on adaptivdemux's track switch method. Firstly, adaptivdemux(hlsdemux) will expose all available tracks during preroll state. Then, stop streaming for non-activated track depending on flow return "not-linked". It's well described on comment of gstadaptivedemux.c

Then, if you try switch track, it will trigger "reconfigure" event which also trigger re-streaming for newly activated track in adaptivedemux. Basically, this is how adaptivedemux switch tracks. But when I saw comment above, there seems weak point (maybe bug?) in playbin's subtitle track change behavior.
Comment 14 CARD 2017-10-16 03:49:08 UTC
(In reply to Seungha Yang from comment #13)
> (In reply to tianyahai from comment #10)
> > Thank you for your reply, in deeded, the subtitles are closed by default,
> > but in the code of gsthlsdemux.c file i enabled subtitle like this:
> >   select = demux->streams_aware ? TRUE : (media->mtype ==
> > GST_HLS_MEDIA_TYPE_VIDEO ||
> >           media->mtype == GST_HLS_MEDIA_TYPE_AUDIO || media->mtype ==
> > GST_HLS_MEDIA_TYPE_SUBTITLES);
> > 
> > In my m3u8 there are eight subtitles, the subtitles can be displayed when
> > the code is running, but if i switch subtitle to another it will be
> > disappear, i used playbin or playbin2, not playbin3
> This comment might be helpful for you :)
> https://bugzilla.gnome.org/show_bug.cgi?id=779011#c7

Thank you,i will try it follow this comment
> 
> > Yes,as you say,i used playbin,can i add "GST_OBJECT_FLAG_SET (dec,
> > GST_ELEMENT_FLAG_SOURCE | GST_BIN_FLAG_STREAMS_AWARE)" to gsturidecodebin.c
> > file according to your urisourcebin file? 
> You can try it but it doesn't make sense because uridecodebin doesn't
> "STREAMS_AWARE".
> 
...indeed it doesn't work...
> > How can hlsdemux achieve switch subtitles...
> It's totally dependent on adaptivdemux's track switch method. Firstly,
> adaptivdemux(hlsdemux) will expose all available tracks during preroll
> state. Then, stop streaming for non-activated track depending on flow return
> "not-linked". It's well described on comment of gstadaptivedemux.c
> 
> Then, if you try switch track, it will trigger "reconfigure" event which
> also trigger re-streaming for newly activated track in adaptivedemux.
> Basically, this is how adaptivedemux switch tracks. But when I saw comment
> above, there seems weak point (maybe bug?) in playbin's subtitle track
> change behavior.
Have you tested m3u8 file that contains mulit bitrate streams and subtitles, and can you switch subtile seccessfully? thank you again, have a nice day^_^
Comment 15 Seungha Yang 2017-10-16 06:54:32 UTC
(In reply to tianyahai from comment #14)
> Have you tested m3u8 file that contains mulit bitrate streams and subtitles,
> and can you switch subtile seccessfully? thank you again, have a nice day^_^

I think current gstreamer is not good enough for hls subtitle track change.... DASH + multi TTML case might have similar issue I guess...

In my opinion, current adaptivedemux structure has problem from subtitle track change point of view.
First, at adaptivedemux side, streaming progress of subtitle is not fully synchornized with A/V. (since subtitle data is too small, downloading the subtitle is too faster than A/V).
Adaptivedemux's track change method is that, it tries to download new stream from 1) last matching streams time position or 2) depending on query position.
This can cause mismatch between old/new subtitle stream's time position.
Second, the fact that multiqueue element doesn't fully consider synchronization of sparse stream (subtitle stream).

Since I'm not expert... above comment might be incorrect. It's just my opinion.
Comment 16 CARD 2017-10-16 07:50:37 UTC
(In reply to Seungha Yang from comment #15)
> (In reply to tianyahai from comment #14)
> > Have you tested m3u8 file that contains mulit bitrate streams and subtitles,
> > and can you switch subtile seccessfully? thank you again, have a nice day^_^
> 
> I think current gstreamer is not good enough for hls subtitle track
> change.... DASH + multi TTML case might have similar issue I guess...
> 
> In my opinion, current adaptivedemux structure has problem from subtitle
> track change point of view.
> First, at adaptivedemux side, streaming progress of subtitle is not fully
> synchornized with A/V. (since subtitle data is too small, downloading the
> subtitle is too faster than A/V).
> Adaptivedemux's track change method is that, it tries to download new stream
> from 1) last matching streams time position or 2) depending on query
> position.
> This can cause mismatch between old/new subtitle stream's time position.
> Second, the fact that multiqueue element doesn't fully consider
> synchronization of sparse stream (subtitle stream).
> 
> Since I'm not expert... above comment might be incorrect. It's just my
> opinion.

Ok,thank you for your help,next i will try playbin3 play m3u8...
but as you said "subtitle is not fully synchornized with A/V.."
even if it switch subtitles successful by playbin3,subtitle display maybe have some problem..
Comment 17 Seungha Yang 2018-05-11 01:39:21 UTC
Comment on attachment 355514 [details] [review]
hlsdemux: Re-expose only variant stream with bitrate switching

Will be updated again
Comment 18 Edward Hervey 2018-05-11 05:12:37 UTC
*** Bug 796000 has been marked as a duplicate of this bug. ***
Comment 19 GStreamer system administrator 2018-11-03 14:03:36 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/508.