Edward Hervey
5935c8049a
hlsdemux2: Fix position searching
...
The scanning is done in a reverse order, the proper full checks to do are
therefore:
* If the position is beyond half a "segment duration", it's in the following
segment
* If the position is within the first half of a segment, it's in that one
* If the segment is the first one and the position is within half a duration
backwards, we consider the position as being within that first segment
Also handle the case where a "partial only" segment doesn't have a reliable
duration, and therefore use the playlist target duration instead.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Edward Hervey
1c6364673d
hlsdemux2: Handle all cases for starting segment calculation
...
The implementation wouldn't work with regular HLS streams (i.e. the final
fallback).
Now that the implementation uses time to search for the starting
segment (instead of just the n-th from the end), we can specify the correct
hold_back fallback value from the RFC
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Edward Hervey
3129970c8a
hlsdemux2: Fix buffering threshold calculation and handling
...
* The checks for smaller values were wrong
* Properly initialize the stream default recommended buffering threshold so that
a default (10s) value is used until the subclass can provide a proper value
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Edward Hervey
eb1eb64506
hlsdemux2: Make sure simple media playlist is properly primed
...
By setting/propagating stream time initially
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
3d0e8aa07e
adaptivedemux2: Fix manifest access during seeking query
...
Avoid a deadlock if a downstream seeking query happens while the scheduler
thread is holding the manifest lock (for example during a seek back to live).
Instead, do a more elaborate fix where the external calls that need access to a
'manifest' access a copy that's updated during a manually triggered manifest
update callback.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
5334007a0b
adaptivedemux2: Symbol hygiene cleanup
...
Rename track_dequeue_data_locked() to
gst_adaptive_demux_track_dequeue_data_locked(), since it's non-static.
Make find_stream_for_track_locked() static since it's only used in the main
gstadaptivedemux.c file.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
6bb74ed2a0
adaptivedemux2: Fix download error handling more
...
gst_adaptive_demux2_stream_finish_download() will already schedule another
fragment download if it can so don't fall through to the retry code that will
also try and schedule a download (triggering an assert).
Fix the logic in general to retry advancing into the live seek range once.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
b1354058e1
hlsdemux2: Immediately request playlist after URI changes
...
When the stream switches to a new playlist / variant while the loader is waiting
on a timer to refresh the old playlist, cancel the timer and submit the request
for the new URI.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
6d7d3d93e6
hlsdemux2: Re-add support for fallback variant URLs
...
fallback variant URLs get accumulated into a list in the variant now. If there's
one available, switch to it after a variant update failure (failure to load the
variant 3 times)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
d5b8929315
hlsdemux2: Demote log message
...
Don't complain loudly about replacing the current pending playlist, just log it
at debug level
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
91c8f3f990
hlsdemux2: Wait for playlist load after a switch
...
Check in update_fragment_info() if the playlist we want has actually been loaded
yet, and return BUSY if not.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
2b93dae59a
hlsdemux2: Handle async playlist loading failures
...
Add failed variant playlists to a list and failover to other variants until
there is none left
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
454779f094
hlsdemux2: Wait for playlist switch during seek.
...
When switching to/from an iframe variant to do seeking, wait for the target
playlist to load before handling the seek.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
fe41db92db
hlsdemux2/playlist-loader: Implement more features
...
Implement limited retries on download errors before reporting it, and remember
permanent redirects, with LL-HLS directives removed.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
9ae3978c72
hlsdemuxdemux2: Consider the hold-back when calculating seek range
...
When calculating the seek range for a live stream, use the same hold-back logic
as when choosing a starting segment, including low-latency segments if
enabled. Permits seeking closer to the live edge when re-synching or catching
up.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
083538df9e
hlsdemux2: Continue reworking code for async playlist updates
...
Everything is working again now except for corner cases:
- Failing over to another playlist after a load failure
- Remembering playlist redirects and using that URI
directly next time.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
93d92d5ddf
adaptivedemux2: Handle more async stream cases
...
Handle BUSY flow returns when making calls from external threads, and inhibit
fragment downloads during stream prepare
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
7b3a1bac0a
hlsdemux2: Add llhls-enabled property to streams
...
Tidying: Make the llhls-enabled setting configurable through a stream property
instead of set manually after construction.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
d5edd48f13
hlsdemux2: Add gst_hls_demux_stream_set_playlist_uri
...
Add a method that configures the new playlist URI for a stream.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Edward Hervey
2c822735ba
hlsdemux2: Add HLS playlist loader
...
Add a helper that asynchronously loads and refreshes the playlist for HLS
streams.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
52d577eee1
adaptivedemux2: Fix for failed download handling
...
When playing at the live edge of a live playlist, and a download fails, we don't
expect there to be a next fragment. That case is handled lower down anyway, so
don't retry infinitely on spurious http errors at the live edge.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
ceda805abb
adaptivedemux2: Drop segment lock on stream_seek error.
...
If stream_seek() fails, make sure to drop the segment lock before bailing out.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
44d3751d68
adaptivedemux2: Add gst_adaptive_demux2_stream_wait_prepared()
...
Add a method that waits for a stream to signal the prepare_cond after it returns
a BUSY flow return.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
d3acafbb5a
adaptivedemux2: Remove gst_adaptive_demux2_stream_has_selected_tracks
...
Use gst_adaptive_demux2_stream_is_selected_locked() instead, which is identical
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
8d0c7d9d93
adaptivedemux2: Move GST_ADAPTIVE_DEMUX_FLOW_BUSY to adaptivedemux.h
...
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
0962908e62
adaptivedemux2: Add start/stop vfuncs
...
Remove the can_start() vfunc, in favour of vfuncs when the stream starts/stops,
allowing the sub-class to do custom logic before (or preventing) the stream from
starting and stopping.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
fa0e9e2ec5
hlsdemux2: Remove unused function argument
...
Remove the demux argument from the
gst_hls_demux_stream_update_rendition_playlist() method
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
67bc8d7cc0
adaptivedemux2: Add gst_adaptive_demux_get_loop()
...
Add an accessor function for retrieving the demuxer's scheduler thread loop.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
2082c8912d
adaptivedemux2: Add gst_adaptive_demux_period_add_stream()
...
Make a function for adding a stream to a period, for better encapsulation.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
82839fb82f
adaptivedemux2: Add new flow return value for BUSY and PREPARE stream state
...
Neither are used yet, they're just placeholders.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Edward Hervey
b03e68ea8c
hlsdemux2: support old compilers
...
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:23 +00:00
Jan Schmidt
1cede1d0cf
hlsdemux2: Place HLS delivery directives in UTF-8 order.
...
Use new GstURI gst_uri_to_string_with_keys() API to produce the playlist URI
with query arguments in UTF-8 order.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
21cb739830
hlsdemux2: Avoid assert in _has_next_fragment()
...
gst_hls_demux_stream_has_next_fragment() can be called with a NULL
current_segment if we're past the end of the current playlist. In that case,
just return FALSE instead of hitting a critical in the playlist code.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
018a6192bd
hlsdemux2: Include skipped segments in MSN calculation
...
When a playlist has skipped segments, increment the MSN to account for them so
the remaining segments end up with the right sequence numbers.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
268a25b979
hlsdemux2: Use partial segment for playlist update interval
...
When playing LL-HLS playlists in LL-HLS mode, update the playlist more often (on
the partial segment interval) or else we end up downloading them in bursts and
playing further from the live edge than intended.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
55f6cd9243
hlsdemux2: Do a full playlist reload if delta fails
...
If we do a delta playlist request but then can't merge the result with the
existing playlist, retry with a full playlist request.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
874b665710
hlsdemux2: Fill in skipped segments if possible
...
After reloading a playlist using a delta request, use the previous playlist to
fill in skipped segments if possible.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
703d29549a
hlsdemux2: Add gst_hls_media_playlist_sync_skipped_segments()
...
Add a method that transfers over skipped segments from a reference playlist,
used to repopulate a delta playlist
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
7496d2750e
hlsdemux2: Parse EXT-X-SKIP tag
...
Parse the attributes from the EXT-X-SKIP tag
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
8a0190b521
hlsdemux2: Use skip and blocking playlist delivery directives
...
Detect when we can use a blocking request and delta playlist update requests and
add the required delivery directives to the request URI.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
c16366e5f3
hlsdemux2: Add gst_hls_media_playlist_get_next_msn_and_part()
...
Add a function that computes the media sequence number and/or part index that
are immediately after the end of the playlist, for use in blocking playlist
requests
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
d41def562c
hlsdemux2: Use stream llhls_enabled flag
...
Use the stream's copy of the llhls_enabled flag when deciding whether to do
preload requests - the value that was cached when the stream started
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
42b0dd8c41
hlsdemux2: Split the stream object out
...
Move the stream object to a separate file to split the demux level behaviour
from the stream behaviour better.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
5baf5f4b1e
hlsdemux2: Add a timestamp to the playlist
...
Store the timestamp for this playlist. If valid it represents the monotonic time
at which the data was retrieved, minus any proxy cache Age field.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
a3770523c0
adaptivedemux2/downloadrequest: add a helper to retrieve the Age header
...
Add a method to look at HTTP response headers and parse and return any Age
header, provided by caching proxy servers if the data was provided from a cache.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
90bedcb2bc
hlsdemux2: Fix missed segment match for partial-only segment
...
Fix a case where the matching code might not select the final partial-only
segment because it has too short a duration (while it's still being created)
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
9edb2f6690
hlsdemux2: In live, match buffering to the hold back distance
...
When playing a live stream, make the recommended buffering threshold at most the
hold-back distance from live. If we start 3 seconds from the live edge, there's
no point trying to buffer more - we'll just hit the live edge and have to wait
for more data to be available anyway.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
1e6550f623
hlsdemux2: Resync stream time on partial segment boundaries
...
When resyncing stream times in a playlist, support at any partial segment
position, not just at full segment boundaries.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
bdec75f9dc
hlsdemux2: Calculate / transfer timing info for preloads
...
When fulfilling data requests, transfer timing information so the stream can
calculate data bitrates.
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00
Jan Schmidt
5192181ef5
adaptivedemux2: Add most recent data time and offset helper
...
Add a field to the DownloadRequest that reports the most recent time at which
data arrived. Update it in the DownloadHelper.
Add a method to retrieve the GST_BUFFER_OFFSET() for the DownloadRequest's data
buffer (if any).
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883 >
2023-02-03 16:52:22 +00:00