Commit graph

222 commits

Author SHA1 Message Date
Wang Chuan e89a64cd1f gstadaptivedemux: fix memory leak
GstQuery leaks when using invalid url

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5154>
2023-08-07 14:18:21 +08:00
Edward Hervey 176b884ec7 adaptivedemux2: Remove API lock
The various fields this was protecting were for the legacy design.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/5113>
2023-07-28 12:27:09 +00:00
Edward Hervey 711198a1a9 hlsdemux2: Ensure processed webvtt ends with empty new line
Parsers downstream will use empty new lines to detect where an entry
ends. Failure to have a newline would cause the entry to be either
discarded or (wrongly) concatenated with the next entry

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2752

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4963>
2023-07-04 10:57:01 +02:00
Elliot Chen c1a284a221 dashdemux2: fix some mpeg-ts issue with no audio output
For dashdemux2, one stream will create one track.
Maybe there are multiple tracks in one stream such as
some mpeg-ts streams, need add the function to check
and create the other tracks if needed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4706>
2023-06-26 10:52:08 +08:00
Edward Hervey 4b5352570a adaptivedemux2: Handle early SEEKING query
No pads are present yet, but we can still answer the query

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3914>
2023-06-22 06:56:33 +00:00
Edward Hervey 597b684cd6 adaptivedemux2: Fix non-accurate seeking
If no accurate positioning was required, default to snap to the previous segment
for improved responsiveness

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3914>
2023-06-22 06:56:33 +00:00
Edward Hervey adc07d77d5 adaptivedemux2: Handle return in seek handling
Various code path were repeating the same logic, and risk forgetting a lock
release.

Unify all of them

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3914>
2023-06-22 06:56:33 +00:00
Edward Hervey 630eb61273 adaptivedemux2: Move API lock usage
It is not needed so early

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3914>
2023-06-22 06:56:33 +00:00
Edward Hervey 2c9aef64c0 adaptivedemux2: Handle early key-unit seek
Is a seek is done on stream-collection post, there are no selected streams
yet. Therefore none would be chosen to adjust the key-unit seek.

If no streams are selected, fallback to a default stream (i.e. one which has
track(s) with GST_STREAM_FLAG_SELECT).

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3914>
2023-06-22 06:56:33 +00:00
Edward Hervey 39c8b060f4 adaptivedemux2: Fix early seeking
When seeking is handled by the collection posting thread, there is a possibility
that some leftover data will be pushed by the stream thread.

Properly detect and reject those early segments (and buffers) by comparing it to
the main segment seqnum

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3914>
2023-06-22 06:56:33 +00:00
Jonas Kvinge 513dd2c219 adaptivedemux2: Allow data dash+xml manifest for uri
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4811>
2023-06-13 11:32:23 +00:00
Ruben Gonzalez 059965fe53 doc: Fix newline char between authors
Found running `gst-inspect-1.0 -a |& grep -v ":" | grep @`

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4682>
2023-05-20 05:48:23 +00:00
Guillaume Desmottes 901383771d dash: mpdclient: fix divide by 0 if segment has no duration
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4436>
2023-04-18 06:37:27 +00:00
Guillaume Desmottes df3b2e2d41 adaptivedemux2: fix critical when using an unsupported URI
adaptivedemux2 only supports http(s), trying to use it with, say,
file:// was raising a CRITICAL in libsoup.

Fix #2476

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4396>
2023-04-12 06:33:39 +00:00
Jan Schmidt 8ec6ef8ca4 adaptivedemux: Don't parse URI unnecessarily
Short-circuit parsing and recreating the playlist URI if
no HLS directives are going to be applied to it.

Fixes problems playing some streams (YouTube) that have
unneeded escaped characters in the URI and then complain
when GStreamer removes the escaping

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4335>
2023-04-04 19:21:31 +00:00
Edward Hervey dd3542aa4d adaptivedemux2: Don't blindly set the main manifest URI as referer
There's no guarantee it will *actually* be the URI which refered to what we are
downloading. It could be a stream URI or anything else.

Instead of putting something wrong, put no (specific) referer as a better choice

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3972>
2023-03-20 07:59:27 +00:00
Edward Hervey bead28ad5c hlsdemux2: Don't set a referer when updating playlists
In the same way we don't for regular playlists in the base class.

If there is a referer specified by the app/user, the downloadhelper will set it
accordingly.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3972>
2023-03-20 07:59:26 +00:00
Sebastian Dröge ccad9a7338 plugins: Fix various trivial clang compiler warnings
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4210>
2023-03-18 16:16:55 +02:00
Seungha Yang 40300172ad adaptivedemux2: Fix MSVC build error
downloadrequest.c(497): error C4013: 'atoi' undefined; assuming extern returning int

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4107>
2023-03-03 23:15:42 +09:00
Rafał Dzięgiel 2d79f7d392 dashdemux2: mpdclient: Debug all restrictions when selecting rep
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3894>
2023-02-18 22:47:18 +01:00
Rafał Dzięgiel d86b2d4efa dashdemux2: Add start-bitrate property
Similarly to hlsdemux2 that has this property, also add it to dashdemux2
so users can use it to choose first alternate.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3894>
2023-02-18 22:47:07 +01:00
Rafał Dzięgiel 9d720554a0 dashdemux2: Improve initial representation selection
Do not always start with lowest quality possible. Use properties set
by user to select best allowed initial representation at startup too.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3894>
2023-02-18 21:05:25 +00:00
Rafał Dzięgiel 38028c9873 hlsdemux2: Make start-bitrate property work without connection-speed
Makes "start-bitrate" work without setting "connection-speed" property. Having
another property set as a requirement for this one to work is unexpected.

This commit allows to request some initial bitrate for first segment, then
go into adaptive streaming for the rest of media playback.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3895>
2023-02-17 17:48:40 +01:00
Edward Hervey f072b25940 adaptivedemux2: Use track ID for debugging
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3890>
2023-02-10 10:56:52 +00:00
Edward Hervey 5e193730db adaptivedemux2: Split track id from event stream-id
The id is used for naming of the various objects and debugging. We don't
want/need it to be obfuscated with the massive upstream id.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3890>
2023-02-10 10:56:52 +00:00
Edward Hervey 0639f117cb hlsdemux2: Remove enable-llhls property
This was only used for testing purposes

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
2023-02-03 16:52:24 +00:00
Edward Hervey 854683c871 hlsdemux2: Don't leak PDT datetime
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
2023-02-03 16:52:24 +00:00
Edward Hervey 96613c45fb adaptivedemux2: Don't leak taglist
Clarify the ownership in the documentation

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
2023-02-03 16:52:24 +00:00
Edward Hervey 123030feac adaptivedemux2: Don't leak track tags
The tags are fully transfered to this function

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
2023-02-03 16:52:23 +00:00
Jan Schmidt 6f6c0cbbaf adaptivedemux2: Log request duration in debug output
When completing, log how long a HTTP request took into the debug output.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
2023-02-03 16:52:23 +00:00
Edward Hervey 714628f1ec hlsdemux2: Improve live playlist update intervals
The live playlists should be updated at a defined interval. The problem is that
this interval was used *after* the playlist was finally received and processed,
which resulted in a gradual shift happening in playlist updates.

Instead store and use the time at which playlists were requested to determine
when the next one should be downloaded.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
2023-02-03 16:52:23 +00:00
Edward Hervey 6684aee14c hlsdemux2: Fix playlist reload interval when unchanged
When falling back to using the regular last segment, use that duration as the
identical-playlist reload interval (and not the playlist target duration which
could be much larger)

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3883>
2023-02-03 16:52:23 +00:00
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