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 657790 - [hlsdemux] Refactor element
[hlsdemux] Refactor element
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal major
: 0.10.24
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2011-08-31 09:23 UTC by Andoni Morales
Modified: 2012-10-06 11:57 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
refactor uri fetching (28.70 KB, patch)
2012-03-16 13:53 UTC, Gil Pedersen
none Details | Review
regression fix (679 bytes, patch)
2012-04-25 13:11 UTC, Gil Pedersen
committed Details | Review

Description Andoni Morales 2011-08-31 09:23:21 UTC
I have seen many changes in this element in the last week :) I had a refactoring branch pending to be submitted before the summer to fix the threading mess in this component but I have seen the Youness already sorted this out.

I was wondering if this refactor still makes sense:
  * Factor out all the fetcher code in a new GObject that can be than be reused by other components.
  * Start using a GstFragment to manage fragments. This allows for instance an easy way to compute the download duration of each fragments that can be later be used for the bitrate-switch algoritm.

You can find more details here:

http://gitorious.org/ylatuya-gstreamer/gst-plugins-bad/commit/88790881ede8a226e4f47de4c40e5b7c1615c089
Comment 1 Sebastian Dröge (slomo) 2011-08-31 09:47:01 UTC
IMHO the refactoring makes sense in general and makes the code easier to read. Please go ahead and attach patches to this bug (but make it one commit per change, i.e. one commit for the GstFragment, one for the fetcher, etc)
Comment 2 Youness Alaoui 2011-08-31 21:58:59 UTC
This definitely looks interesting, but that page is huge, it's almost impossible to review. Could you rebase on top of the latest git and rework your code into smaller patches, I'd be glad to review the changes.
Thanks for the suggestions!
Comment 3 Andoni Morales 2011-09-01 08:25:54 UTC
That's the reason why I didn't submit it before the summer, I needed to split it up in several patches and didn't find tme until now :) I'll post again as soon as I have everything ready to be reviewed.
Comment 4 Gil Pedersen 2012-03-16 13:53:25 UTC
Created attachment 209930 [details] [review]
refactor uri fetching

Patch sourced from http://gitorious.org/ylatuya-gstreamer/gst-plugins-bad/trees/hlswip/gst/hls

The only modification I have made from the source is to remove the dependency on GstFragment and use GstAdapter instead. I am not happy about how the canceling is managed, but I think this is the least intrusive way to patch the code in. Further optimisation & integration can be dealt with in new patches.
Comment 5 Andoni Morales 2012-03-16 18:37:11 UTC
I wouldn't remove the use of the GstFragment. GstFragment was used instead of a simple GstAdapter to collect statistics about the downloaded fragment and reuse them in the heuristics for the bitrate adaptation (which is currently a very dumb one).
An updated version of GstFragment can be found in #668094, where it was added to  a base class for fragmented streaming. Also, GstFragment uses internally a GstBufferList, which should result in less copies than using an adapter(not 100% sure about that)
Comment 6 Thibault Saunier 2012-03-16 20:14:58 UTC
I have also been working on that here: http://cgit.collabora.com/git/user/tsaunier/gst-plugins-bad/log/?h=hlsdemux

I just did a dumb rebase/commit split, and a few little changes. I still have a few known regressions, and I haven't taken the GstFragment from #668094 yet.

Gil do you want to carry on that work or I should do it?
Comment 7 Gil Pedersen 2012-03-19 12:55:32 UTC
(In reply to comment #5)
> I wouldn't remove the use of the GstFragment. GstFragment was used instead of a
> simple GstAdapter to collect statistics about the downloaded fragment and reuse
> them in the heuristics for the bitrate adaptation (which is currently a very
> dumb one).
> An updated version of GstFragment can be found in #668094, where it was added
> to  a base class for fragmented streaming. Also, GstFragment uses internally a
> GstBufferList, which should result in less copies than using an adapter(not
> 100% sure about that)

I am aware of this that GstFragment is a better alternative. I was simply trying to isolate some of your code into a manageable patch. The GstFragment should be easy to add on top of this.
Comment 8 Thibault Saunier 2012-04-05 20:12:23 UTC
commit 70056a37c47d085c917f94574b76afb8c5f707dc
Author: Thibault Saunier <thibault.saunier@collabora.com>
Date:   Thu Apr 5 11:51:40 2012 -0400

    hls: Some more debugging

commit f9b0d59e84211fb822ca61634c57fe128e4dfeb0
Author: Thibault Saunier <thibault.saunier@collabora.com>
Date:   Thu Mar 15 14:42:44 2012 -0400

    hlsdemux: Replace the fetcher code with a GstURIDownloader object

commit 2415f9080d3c772ad134b7283c07a8d58545198b
Author: Thibault Saunier <thibault.saunier@collabora.com>
Date:   Wed Mar 14 17:01:17 2012 -0400

    hls: Minor cleanup in GstUriDownloader

commit 71b9f57b63d472287c145245271c9ccc2ca6d483
Author: Andoni Morales Alastruey <ylatuya@gmail.com>
Date:   Wed Mar 14 17:06:22 2012 -0400

    hlsdemux: Factor out all the fetcher code in a GstURIDownloader class
    
    This class is meant to be reusable by other components

commit 5e85aaf11db9d2723e0ea01077ae34860a09da05
Author: Thibault Saunier <thibault.saunier@collabora.com>
Date:   Thu Apr 5 10:22:29 2012 -0400

    hls: Do not add reference to buffers passed in GstFragment
    
    We just steal the reference to the buffer, which means we can keep writing metadatas
    on the buffers.

commit fdaa60c44fb9b27d75193b69c030c08f5b7f7740
Author: Thibault Saunier <thibault.saunier@collabora.com>
Date:   Tue Mar 13 15:18:22 2012 -0400

    hls: Minor GstFragment cleanup

commit 501d42fa7809d1899cfd88459face69d5f37976d
Author: Andoni Morales Alastruey <ylatuya@gmail.com>
Date:   Fri Jul 8 01:09:00 2011 +0200

    hls: Add a GstFragment class that represents a fragment in a m3u playlist

commit fef060590f698b92458c8fdc345f34c2105de458
Author: Thibault Saunier <thibault.saunier@collabora.com>
Date:   Thu Mar 15 18:21:58 2012 -0400

    hls: Make the updates thread a GstTask
Comment 9 Gil Pedersen 2012-04-20 14:12:12 UTC
This slew of unannounced patches has broken the module. Playback simply stalls after the initial 3 segments have been displayed.

For example, it stalls on frame 897 with:
gst-launch-0.10 playbin2 uri=http://devimages.apple.com/iphone/samples/bipbop/gear4/prog_index.m3u8
Comment 10 Sebastian Dröge (slomo) 2012-04-24 14:03:05 UTC
Any news on this?
Comment 11 Gil Pedersen 2012-04-24 15:01:11 UTC
The brokeness might actually be caused by an incompatibility with the latest libsoup release which I updated at the same time. I will investigate further.
Comment 12 Gil Pedersen 2012-04-25 13:11:57 UTC
Created attachment 212776 [details] [review]
regression fix

The problem was caused by the stream_task which would pause itself on empty queues, while no one started it again. The attached patch fixes this issue, restoring functionality of the module.
Comment 13 Sebastian Dröge (slomo) 2012-04-25 13:58:37 UTC
commit f4dbfe947d7c085b568b58b09205aaef851896d1
Author: Gil Pedersen <git@gpost.dk>
Date:   Wed Apr 25 13:31:36 2012 +0200

    hlsdemux: start paused task on new data