Commit graph

68 commits

Author SHA1 Message Date
Alex Ashley
0745d567a7 hlsdemux: correct the calculation of seek range of non-live streams
The seek range calculation for on-demand streams was incorrectly
excluding the last three segments of the stream. This three segment
rule should only be applied to live streams [1].

[1] https://tools.ietf.org/html/draft-pantos-http-live-streaming-17#section-6.3.3

https://bugzilla.gnome.org/show_bug.cgi?id=758386
2015-12-02 10:16:25 +02: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
efe62292a3 hls: rename plugin from fragmented to hls 2015-12-01 17:51:34 +00:00
Tim-Philipp Müller
3015cd75e4 hls: m3u8: don't leak GList nodes when matching up variant lists after master list update 2015-11-06 00:48:42 +00:00
André Draszik
e0b4290998 hlsdemux: don't crash or leak memory on broken master playlist
If a (master) playlist contains a variant list entry without a
URI then during parsing of the next variant list entry we are
a) leaking the entry we're currently parsing (new_list), and
b) free'ing the pointer to the previous list entry (list) without
   updating the pointer.

Hence when then adding the URI for the latest parsed entry, incorrect
information is stored, as the information is used from 'list' which
is not valid memory anymore, also leading to crashes.

Fix this by correctly storing the new variant list entry pointer
as needed.

https://bugzilla.gnome.org/show_bug.cgi?id=756861
2015-10-25 09:26:34 +00:00
Tim-Philipp Müller
1c8d844ece hlsdemux: m3u8: move file lookup by sequence directly into code
Nicer to read, two lines of code less, and also the callback
function should've been a GCompareFunc that returns a gint
and not a boolean (it did work correctly, was just confusing).
2015-10-23 18:20:01 +01:00
Tim-Philipp Müller
28ac033773 hlsdemux: m3u8: clean-up: remove unused argument in function call 2015-10-23 18:19:55 +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
Thiago Santos
d5f79b8529 hls: if media sequence is not specified, use 0
Allows playlists that are missing the mediasequence information to
be correctly parsed. If the playlist was updated without reseting
the mediasequence it would constantly increase over subsequent updates,
leading to issues during playback.
2015-10-14 21:33:27 -03:00
Edward Hervey
0e663fca94 hls: Allow debugging of the playlist
Helps debugging issues
2015-10-14 18:01:04 +02:00
Sebastian Dröge
f5dd41d710 Update GLib dependency to 2.40.0 2015-10-02 22:24:19 +03:00
Tim-Philipp Müller
536e3742aa Fix file permissions of some files 2015-08-28 19:55:59 +01:00
Athanasios Oikonomou
22456ce032 hlsdemux: select correct position for live streams that don't remove fragments
Some live streams (eg youtube) don't remove fragments in order to allow
seeking back in time (live + vod).

When gst_m3u8_client_has_next_fragment is called, we are getting wrong fragment
because current_file points in first file of the fragments list resulting in
watching the stream from the beginning again.

This patch sets current_file to nth fragment for live streams, then on
gst_m3u8_client_has_next_fragment will keep up with the live stream.

https://bugzilla.gnome.org/show_bug.cgi?id=753344
2015-08-26 12:11:57 +03:00
Thiago Santos
bc33d22635 hlsdemux: don't warn about duration if it is not known
And also print the values in case of warning
2015-08-07 11:24:52 -03:00
Thiago Santos
2ed8a819f6 hlsdemux: demote error to warning
It is not fatal and can be quite normal when the network is
too slow
2015-07-24 10:09:19 -03:00
Thiago Santos
581d8c0b8d Revert "hlsdemux: Simplify logic in process_manifest"
This reverts commit 4ca3a22b6b.

The connection-speed=0 is used as a special value in the property
of hlsdemux to mean 'automatic' selection, m3u8.c doesn't need
to know about that as it should be as simple as possible.

So this patch hides this automatic selection documented in hlsdemux
into m3u8 logic and I think the gets harder to understand the code.

It also makes the hlsdemux unit tests work again

https://bugzilla.gnome.org/show_bug.cgi?id=749328
2015-06-05 09:43:10 -03:00
Edward Hervey
04b010a883 hlsdemux: Search more when advancing fragment
In live situations, it is not uncommon for the current fragment to end
up out of the (updated) play range (lowest/highest sequence). But the next
fragment to play *is* present in the play range.

When advancing, if we can't find the current GstM3U8MediaFile, don't abort
straight away. Instead, look if a GstM3U8MediaFile with the next sequence value
is present, and if so switch to it.

https://bugzilla.gnome.org/show_bug.cgi?id=750028
2015-05-28 14:56:36 +02:00
Jimmy Ohn
4ca3a22b6b hlsdemux: Simplify logic in process_manifest
Simplify logic in process_manifest and remove a TODO item.

https://bugzilla.gnome.org/show_bug.cgi?id=749328
2015-05-18 10:52:35 +03:00
Sebastian Dröge
5fd2fc3050 hlsdemux: Don't error out if we can't match variant playlists after updating
It's better to just select some random variant playlist instead of stopping,
chances are that it's still continuing to work and we might just have to
select a different variant again later.
2015-04-23 17:47:18 +02: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
308b2e5aaf hlsdemux: simplify next segment checking functions
Optimize loop by moving condition outside of it and reuse the
find_next_fragment function to check if there is next instead of
replicating the same loop
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
Luis de Bethencourt
9dcf650a17 hlsdemux: g_return_if_fail in function with return type
Need to use g_return_val_if_fail() when the function returns a type, in this
case a gboolean
2015-01-08 15:54:18 +00: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
Thiago Santos
3a6c2b6b67 hlsdemux: remove duplicate call to uri_join 2015-01-07 10:23:31 -03:00
Thiago Santos
3e9b89111a hlsdemux: skip checking '#EXT-X-' token for all entries
Put this common check before to avoid repeating it for all possible
entries to save some cycles
2015-01-07 09:39:56 -03:00
Thiago Santos
c79e8a78ac hlsdemux: avoid using g_list_append for creating segments list
Use g_list_prepend and reverse it at the end to skip traversing the
same list for every new segment
2015-01-07 09:30:40 -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
46b0310acd hlsdemux: Properly assign offsets to the files if we accumulate them instead of reading from the playlist 2014-09-04 17:49:23 +03:00
Tim-Philipp Müller
309395ed4d hls: fix build with GLib 2.32
Provide internal copy of g_list_copy_deep() until we
bump the GLib requirement.

https://bugzilla.gnome.org/show_bug.cgi?id=731555
2014-06-12 10:17:10 +01:00
Damian Ziobro
be28578942 hlsdemux: Improve parsing quoted key URIs and apply it for I-frame-based stream URI
https://bugzilla.gnome.org/show_bug.cgi?id=730830
2014-06-06 13:13:56 +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
Sebastian Dröge
008edeadae hlsdemux: Fix compiler warnings 2014-06-06 13:04: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
Damian Ziobro
5ca7684b7d hlsdemux: Make parsing of "-quoted key URIs more resilient
https://bugzilla.gnome.org/show_bug.cgi?id=730830
2014-05-28 10:58:21 +02: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
Damian Ziobro
5b547a553d hlsdemux: Fix storing of the IV based on the media sequence number
https://bugzilla.gnome.org/show_bug.cgi?id=730574
2014-05-22 13:27:37 +02:00
Sebastian Dröge
951bb53057 hls: Remove invalid free
data does not have to be freed at all here, it's a pointer to
an arbitrary position inside the current line. Also don't reuse
the data variable for anything else, that will cause crashes
in playlists that have the I-frame playlist URI followed by
other attributes.

CID 1212127
2014-05-09 15:30:00 +02:00
Sebastian Dröge
816000f726 hls: Store allowcache playlist field in a boolean 2014-05-05 09:41:51 +02:00
Vincent Penquerc'h
a78e516cbf hls: restore NULL test mistakenly removed
Thanks to tpm for point out I'm an idiot.
2014-04-08 17:10:27 +01:00
Vincent Penquerc'h
45b8225a02 hls: bring NULL test before dereference
Coverity 1195168
2014-04-08 16:46:56 +01:00
Sebastian Dröge
8109ed8785 hlsdemux: Fix forwards and backwards searching in the files list 2014-03-29 10:33:45 +01: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
bd54a212d3 hlsdemux: Fix comparison in bitrate selection 2014-03-09 20:50:44 +01:00