Commit graph

34 commits

Author SHA1 Message Date
Stéphane Cerveau
7e499b9a66 hls: allow per feature registration
Split plugin into features including
dynamic types which can be indiviually
registered during a static build.

More details here:

https://gitlab.freedesktop.org/gstreamer/gst-build/-/merge_requests/199
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2038>
2021-03-23 14:19:17 +00:00
Edward Hervey
f1fdbfc5bd m3u8: Make a debug function usable elsewhere
The rest of the code might want to use this

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1757>
2020-11-11 04:06:05 +00:00
Seungha Yang
f9dc67c372 hls: m3u8: Parsing EXT-X-MAP tag to store initialization data
EXT-X-MAP tag informs media initialization data,
such as moov box in ISOBMFF case and PAT/PMT for MPEG TS stream.

https://bugzilla.gnome.org/show_bug.cgi?id=776928
2019-06-18 07:14:28 +00:00
Thomas Bluemel
9ce5646a0f hlsdemux: Add support for EXT-X-DISCONTINUITY-SEQUENCE
https://bugzilla.gnome.org/show_bug.cgi?id=772811
2017-03-02 19:05:57 +02:00
Jan Schmidt
f3397e0d54 hlsdemux: Choose the default variant and track it when updating
Modify playlist updating to track information across updates
better, although still hackish.

When connection_speed == 0, choose the default variant
not the first one in the (now sorted) variant list, as that
will have the lowest bitrate.
2016-08-03 23:49:54 +10:00
Tim-Philipp Müller
4df6f1ee93 hlsdemux: move variant list handling over to new master playlist code
Adapt hlsdemux for the m3u8 playlist changes.
2016-08-03 23:49:54 +10:00
Tim-Philipp Müller
f0fcf1d718 hls: m3u8: Rework m3u8 parsing and storage.
Make M3U8 and GstM3U8MediaFile refcounted. The contents
of it and GstM3U8MediaFile are pretty much immutable
already, but if we make it refcounted we can just
return a ref to the media file from _get_next_fragment()
instead of copying over all fields one-by-one, and then
copying them all into the adaptive stream structure fields again.

Move state from client into m3u8 structure.  This will
be useful later when we'll have multiple media playlists
being streamed at the same time, as will be the case with
alternative renditions.

This has the downside that we need to copy over some
state when we switch between variant streams.

The GstM3U8Client structure is gone, and main/current
lists are not directly in hlsdemux. hlsdemux had as
many CLIENT_LOCK/UNLOCK as the m3u8 code anyway...
2016-08-03 23:49:54 +10:00
Tim-Philipp Müller
97ea56e91c hls: m3u8: remove pointless client_has_main() function
We always have a main list.
2015-12-01 17:51:34 +00:00
Tim-Philipp Müller
0ed4620033 hls: m3u8: remove unused _get_current_fragment_duration() function 2015-12-01 17:51:34 +00:00
Tim-Philipp Müller
e68914eeec hls: m3u8: remove unused m3u8 client update_failed_count field 2015-12-01 17:51:34 +00:00
Tim-Philipp Müller
5443cca406 hls: m3u8: remove helper var that's only used during parsing from structure
Just keep that local to the parsing function.
2015-12-01 17:51:34 +00:00
Tim-Philipp Müller
28ac033773 hlsdemux: m3u8: clean-up: remove unused argument in function call 2015-10-23 18:19:55 +01:00
Tim-Philipp Müller
da682fc130 hlsdemux: m3u8: clean-up: reindent header for better readability
And remove duplicate define.
2015-10-23 18:19:49 +01:00
Edward Hervey
f7c4bb5ac6 hls/m3u8: Update current position in all cases
In order to ensure the sequence_position will always be consistently updated,
store the current file duration.

This way, when we advance, we can always increment the position based on what
was previously outputted.

https://bugzilla.gnome.org/show_bug.cgi?id=752132
2015-10-19 14:45:42 +02:00
Tim-Philipp Müller
536e3742aa Fix file permissions of some files 2015-08-28 19:55:59 +01:00
Alex Ashley
a08dd85608 hlsdemux: select correct starting position for live streams
When playing live HLS streams, the media playback starts from the
beginning of the media playlist. When playing a live HLS stream,
media playback should start from 3 fragments from the end of the
playlist.

See section 6.3.3. of the HLS draft [1]

This commit changes the logic to select 3 fragments from the end when
playing a live stream.

[1] http://tools.ietf.org/html/draft-pantos-http-live-streaming-12#page-29

https://bugzilla.gnome.org/show_bug.cgi?id=727742
2015-02-20 19:00:01 -03:00
Thiago Santos
d310c0c460 hlsdemux: cache current file position in the list
Avoids iterating the list everytime to look for the next segment
to be used (or to advance to the next one).
2015-01-08 17:55:33 -03:00
Thiago Santos
e21abb62e0 hlsdemux: cache total duration to avoid iterating at every query
Duration queries can be done a few times per second and would cause
the segment list to be traversed for every one. Caching the duration
prevents that.
2015-01-08 17:55:33 -03:00
Thiago Santos
dd7cb8f632 hlsdemux: implement _has_next_fragment to avoid busy looping
It will allow the demuxer to wait for a fragment to be available instead
of busy looping polling the playlist for a new fragment
2015-01-08 09:59:01 -03:00
Alex Ashley
50b5d94b2a hlsdemux: Implement live seeking
hlsdemux assumes that seeking is not allowed for live streams,
however seek is possible if there are sufficient fragments in the
manifest. For example the BBC have live streams that contain 2 hours
of fragments.

The seek code for both live and on-demand is common code. The
difference between them is that an offset has to be calculated
for the timecode of the first fragment in the live playlist.

When hlsdemux starts to play a live stream, the possible seek range
is between 0 and A seconds. After some time has passed, the beginning of
the stream will no longer be available in the playlist and the seek
range is between B and C seconds.

Seek range:
start          0 ........... A
later               B ........... C

This commit adds code to keep a note of the B and C values
and the highest sequence number it has seen. Every time it updates the
media playlist, it walks the list of fragments, seeing if there is a
fragment with sequence number > highest_seen_sequence. If so, the values
of B and C are updated. The value of B is used when timestamping
buffers.

It also makes sure the seek range is never closer than three fragments
from the end of the playlist - see 6.3.3. "Playing the Playlist file"
of the HLS draft.

https://bugzilla.gnome.org/show_bug.cgi?id=725435
2015-01-05 17:59:08 -03:00
Thomas Bluemel
c87835a79f hlsdemux: Fix accessing invalidated memory
In gst_hls_demux_get_next_fragment() the next fragment URI gets
stored in next_fragment_uri, but the gst_hls_demux_updates_loop()
can at any time update the playlist, rendering this string invalid.
Therefore, any data (like key, iv, URIs) that is taken from a
GstM3U8Client needs to be copied. In addition, accessing the
internals of a GstM3U8Client requires locking.

https://bugzilla.gnome.org/show_bug.cgi?id=737793
2014-10-07 15:22:27 +03:00
Sebastian Dröge
37ffe063f6 hlsdemux: Don't store the current key in the playlist
It's per fragment and applying to all following fragments
until the next key is specified.
2014-06-06 13:08:04 +03:00
Thomas Bluemel
babd8969f2 hlsdemux: Reload the variant playlist if refreshing a playlist or downloading a fragment fails
This can happen if the playlists have moved due to the variant playlist
now being redirected to another target. This currently only works as long
as the referenced playlists don't change in relation to the variant
playlist, and the new location is purely due to a new path triggered by a
new redirection target of the variant playlist, or a new redirection
target of the playlist itself.

https://bugzilla.gnome.org/show_bug.cgi?id=731164
2014-06-06 13:02:47 +03:00
Sebastian Dröge
2f39a3d711 hlsdemux: Always use the redirect target to resolve relative URIs
But redownload the playlists from the original URI if it's not
a permanent redirect.
2014-05-28 10:19:40 +02:00
Sebastian Dröge
816000f726 hls: Store allowcache playlist field in a boolean 2014-05-05 09:41:51 +02:00
Sebastian Dröge
91ec00a0c0 hlsdemux: Implement trick modes via I-frame variant lists 2014-03-29 10:33:45 +01:00
Sebastian Dröge
77231ab957 hlsdemux: Implement parsing of #EXT-X-I-FRAME-STREAM-INF
These are I-frame-only variant lists that can be used
for trick mode playback.
2014-03-29 10:33:45 +01:00
Sebastian Dröge
cd02546089 hlsdemux: Implement handling of byte ranges 2014-03-06 16:36:10 +01:00
Sebastian Dröge
0a32c5f7a4 hlsdemux: Implement proper handling of discontinuities
It's not really correct yet for seeks but better than what
we had before.

See https://bugzilla.gnome.org/show_bug.cgi?id=695846
2014-03-01 17:15:54 +01:00
Sebastian Dröge
b3a7242910 hlsdemux: Keep track of timestamps by adding them up during playback
...instead of adding them from the start of playlist every time. This
among other things fixes timestamps for live streams, where the playlist
is some kind of ringbuffer of fragments and thus adding from the beginning
of the playlist will miss the past fragments.

https://bugzilla.gnome.org/show_bug.cgi?id=724983
2014-02-23 15:18:22 +01:00
Sebastian Dröge
a51116add3 hlsdemux: Refactor threading and downloading
We now download fragments as fast as possible and push them downstream
while another thread is just responsible for updating live playlists
every now and then.

This simplifies the code a lot and together with the new buffering
mode for adaptive streams in multiqueue makes streams start much faster.

Also simplify threading a bit and hopefully make the GstTask usage safer.
2014-02-23 00:10:45 +01:00
Arnaud Vrac
6e54b8ee53 hlsdemux: schedule next update based on the fragment duration 2014-02-12 15:18:29 +01:00
Sebastian Dröge
6abed8da20 hlsdemux: Update to non-deprecated GLib thread API 2014-02-09 18:19:33 +01:00
Alessandro Decina
d2d6798087 Make the hls plugin depend on gnutls and move to ext/hls/
gnutls is used to implement AES decryption
2013-03-19 10:54:18 +01:00
Renamed from gst/hls/m3u8.h (Browse further)