Commit graph

118 commits

Author SHA1 Message Date
Thiago Santos
f79d9522c5 hlsdemux: remove unused define 2015-02-17 11:53:49 -03:00
Thiago Santos
f7a1649c77 adaptivedemux: add bitrate-limit property
Move the property from subclasses to adaptivedemux, it allows
selecing the percentage of the measured bitrate to be used when
selecting stream bitrates
2015-02-17 11:12:42 -03:00
Thiago Santos
e9ab79dc36 adaptivedemux: add connection-speed property
Allows to set a bitrate directly instead of measuring it internally
based on the received chunks. The connection-speed was removed from
mssdemux and hlsdemux as it is now in the base class
2015-02-17 11:12:41 -03:00
Thiago Santos
229a15b393 adaptivedemux: refactor chunk downloading flow
Add more power to the chunk_received function (renamed to data_received)
and also to the fragment_finish function.

The data_received function must parse/decrypt the data if necessary and
also push it using the new push_buffer function that is exposed now. The
default implementation gets data from the stream adapter (all available)
and pushes it.

The fragment_finish function must also advance the fragment. The default
implementation only advances the fragment.

This allows the subsegment handling in dashdemux to continuously download
the same file from the server instead of stopping at every subsegment
boundary and starting a new request
2015-01-19 15:30:04 -03:00
Vincent Penquerc'h
b5860af143 hlsdemux: a few leak fixes 2015-01-16 11:43:22 +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
Thomas Bluemel
cd6069f5af hlsdemux: Don't use approximate duration for fragment buffer pts
The duration values in playlists are approximate only, and for
playlist versions 2 and older they are only rounded integer values.
They cannot be used to timestamp buffers.  This resulted in playback
gaps and skips because the actual duration of fragments is slightly
different.  The solution is to only set the pts of the very first
buffer processed, not for each fragment.
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
Thiago Santos
104bd7cf02 hlsdemux: only typefind when we have a minimum amount of data
For small amounts some data might be mistyped and it would cause
the pipeline to fail. For example if you have AAC inside mpegts,
for small amounts, the AAC samples would cause the typefinder to
think it is AAC and not mpegts.

https://bugzilla.gnome.org/show_bug.cgi?id=736061
2014-12-30 08:35:21 -03:00
Vijay Jayaraman
68e77265a0 hlsdemux: typefind might fail if first buffer is too short
If typefind fails, check to see if the buffer is too short for typefind. If this is the case,
prepend the decrypted buffer to the pending buffer and try again the next time around.

https://bugzilla.gnome.org/show_bug.cgi?id=740458
2014-12-23 10:08:57 -03:00
Thiago Santos
1e9ce11efd hlsdemux: port to adaptive base class
Conflicts:
	ext/hls/gsthlsdemux.c
	ext/hls/gsthlsdemux.h
2014-12-23 10:08:57 -03:00
Tim-Philipp Müller
f216b7bb11 Sprinkle some G_PARAM_DEPRECATED and #ifndef GST_REMOVE_DEPRECATED 2014-11-02 17:19:34 +00:00
Tim-Philipp Müller
69ee564d5c hls: fix indentation 2014-11-02 17:17:46 +00:00
Matthieu Bouron
7fb584b087 hlsdemux: reset end_of_playlist attribute when we receive a seek
https://bugzilla.gnome.org/show_bug.cgi?id=738696
2014-10-21 12:55:42 +02: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
Philippe Normand
6d67b5263f hlsdemux: lock client mutex before entering the retry_failover block
This is consistent with the case where the block execution is
triggered by the goto invoked after the current_variant update.

https://bugzilla.gnome.org/show_bug.cgi?id=736919
2014-09-18 23:28:15 +01:00
George Kiagiadakis
f4546b64ea hlsdemux: synchronize with the download loop thread to signal it to continue
If EOS or ERROR happens before the download loop thread has reached its
g_cond_wait() call, then the g_cond_signal doesn't have any effect and
the download loop thread stucks later.

https://bugzilla.gnome.org/show_bug.cgi?id=735663
2014-09-18 13:38:27 -03:00
Thiago Santos
07b59c93c2 hlsdemux: fix clearing of eos state in pads
The internal pad still keeps its EOS flag and event as it can be assigned
after the flush-start/stop pair is sent. The EOS is assigned from the streaming
thread so this is racy.

To be sure to clear it, it has to be done after setting the source to READY to
be sure that its streaming thread isn't running.

https://bugzilla.gnome.org/show_bug.cgi?id=736012
2014-09-18 12:14:30 -03:00
Sebastian Dröge
775c5600c9 hlsdemux: Also refetch the playlist after the first fragment failure
Previously we only refetched the playlist if downloading a fragment
has failed once. We should also do that if it failed a second or third time,
chances are that the playlist was updated now and contains new URIs.
2014-09-15 13:33:45 +03:00
Sebastian Dröge
d4a53a16dd hls: Actually retry 3 times as advertised instead of 2 2014-09-15 11:59:46 +03:00
Sebastian Dröge
f6c6d9c280 hlsdemux: Don't send flush events to deactivated pads
https://bugzilla.gnome.org/show_bug.cgi?id=736012
2014-09-04 18:20:58 +03:00
Thomas Bluemel
04ca723461 hlsdemux: Support OpenSSL for AES decryption of HLS fragments
https://bugzilla.gnome.org//show_bug.cgi?id=735248
2014-08-28 10:34:55 +03:00
Thibault Saunier
16201cec34 hlsdemux: Do not switch playlist on trick modes
Instead always use the low bandwith playlist making things go smoother
as the current heuristic is rather set for normal playback, and
currently it does not behave properly.

https://bugzilla.gnome.org/show_bug.cgi?id=734445
2014-08-13 17:49:12 +02:00
Thibault Saunier
123953d429 hlsdemux: No need to have a I-Frame list to do trick modes
It just works cleanly without any index and there is no real reason for
that limitation. Also, there are very few stream with that feature.

https://bugzilla.gnome.org/show_bug.cgi?id=734445
2014-08-13 17:49:05 +02:00
Sebastian Dröge
429f20531f hlsdemux: Make statistics message more generic for other adaptive streaming demuxers to reuse
https://bugzilla.gnome.org/show_bug.cgi?id=725828
2014-07-21 09:37:51 +02:00
Alexander Zallesov
7f4f9f09e3 hlsdemux: Provide statistics about time to download playlists and fragments
https://bugzilla.gnome.org/show_bug.cgi?id=725828
2014-07-21 09:37:51 +02:00
Thomas Bluemel
b1fac8c781 hlsdemux: Fix decrypting fragments
Only reset the decryption engine on the first buffer of a fragment,
not again for the second buffer.  This fixes corrupting the second
buffer of a fragment.

https://bugzilla.gnome.org/show_bug.cgi?id=731968
2014-06-22 14:21:35 +02:00
Sebastian Dröge
95404609c0 hlsdemux: Include the debug string in the error messages we propagate from the
source
2014-06-19 18:34:05 +02:00
Sebastian Dröge
48987fd5a1 hlsdemux: Include a more descriptive error message 2014-06-19 18:34:05 +02:00
Sebastian Dröge
1e795ccce1 hlsdemux: Propagate error messages from the source element up in the hierarchy
Instead of inventing our own generic error strings which are mostly useless.
2014-06-19 18:34:05 +02:00
Sebastian Dröge
213883eb51 hlsdemux: Directly convert GErrors to error messages
This will make sure that we don't leak debug information into the actual
error message string and keep it behind the debug string.
2014-06-19 18:34:05 +02: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
9cb3d745db hlsdemux: Don't set base URI if there was no redirect 2014-05-28 12:47:22 +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
Thiago Santos
7dfd308e8c hlsdemux: fix internal source event leaks 2014-05-06 19:24:55 -03:00
Thiago Santos
b891bd04d5 hlsdemux: Only set the segment position if there is a timestamp
Only the first buffer of a fragment has its timestamp set, so only
update the segment.position when pushing those buffers to avoid
having GST_CLOCK_TIME_NONE set to the position

https://bugzilla.gnome.org/show_bug.cgi?id=729364
2014-05-05 11:35:35 -03:00
Sebastian Dröge
0ce2b0632e hlsdemux: Set Cache-Control header according to the caching requirements of the playlist 2014-05-05 09:46:06 +02:00
Sebastian Dröge
1aacd0a963 hlsdemux: Update for URI downloader API changes
And make sure to set refresh=TRUE when updating the playlist.
2014-05-02 10:44:41 +02:00
Sebastian Dröge
9c7da93b9d hlsdemux: Always succeed the LATENCY event
Upstream and our internal source is irrelevant for the latency
and we don't want the LATENCY event to ever fail.
2014-05-01 16:18:37 +02:00
Sebastian Dröge
126891e9a5 hlsdemux: Reset the last flow return before restarting the internal source
Otherwise we will never recover from previous errors, and especially
will never start again after a flushing seek if downstream returned
GST_FLOW_FLUSHING to us.
2014-05-01 16:18:37 +02:00
Sebastian Dröge
0d5dcba778 hlsdemux: Only set PTS on the first buffer of a fragment instead of setting the same on all of them 2014-05-01 16:18:37 +02:00
Thiago Santos
aea14053d1 hlsdemux: Always flush the internal proxy pads before downloading
hlsdemux can't rely on the source to push flushes on a seek on ready
as that might not make sense. So always resort to flushing the
internal proxy pads by pushing flush events from the source's src pad.

Also as the seeking is not required anymore, only seek if there is
really a byte range to be used. And store a ref to the source's
src pad to avoid doing get_static_pad for every fragment.
2014-05-01 16:18:16 +02:00
Sebastian Dröge
fc38c22f1b hlsdemux: Only unref pending buffer if there is one 2014-04-30 10:14:12 +02:00
Thiago Santos
940576244c hlsdemux: Do not push last buffer after error
In decryption scenario, a buffer is always stored to be sent later
to wait for more data or EOS to be able to strip the final bytes
if requested. In case an error hapenned this buffer can be ignored
and not pushed downstream.
2014-04-29 18:49:15 -03:00
Thiago Santos
bb8887baa7 hlsdemux: flush the adapter in the end of a fragment
In case of error there might be some data left in the
adapter when EOS is received. Clear the adapter to be
able to restart again later if requested.
2014-04-29 18:49:15 -03:00
Thiago Santos
4ab1d9f21f hlsdemux: handle more error cases
Handle some more error cases:

1) When the source element fails to go to ready
2) When decryption fails
3) When there is no source to handle a specific URI
4) When the URI is invalid
2014-04-29 18:49:15 -03:00
Thiago Santos
4431388cab hlsdemux: handle errors from internal source
Set up a message handling function to catch errors from the internal
source and store the last return code to identify error situations
when returning from a fragment download.

Also moves the duration increase to after the download when we
know if it was successful or not
2014-04-29 18:49:15 -03:00
Thiago Santos
f16560c520 hlsdemux: Improve pad switching conditions
When using the internal source, hlsdemux doesn't know the caps of
the input before adding the pad, so remove the arguments that would
use that as it is always NULL.

And use an specific flag to signal when a pad switch is required.
Using the discont flag is a bad idea now because when a fragment
download fails it will lead to exposing a pad group without any
data, causing decodebin to abort.
2014-04-29 18:49:15 -03:00
Thiago Santos
587851ba10 hlsdemux: properly flush decryption status on seeks
Avoids mixing decryption of different fragments when seeking happens
and leading to broken stream output.
2014-04-29 18:49:15 -03:00
Thiago Santos
ff395a7565 hlsdemux: Track fragments duration
When receving EOS from the internal src, increase the current positon
by the fragment duration to allow correct restoring of download position
if the bitrate changes
2014-04-29 18:49:15 -03:00