Commit graph

80 commits

Author SHA1 Message Date
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
Thiago Santos
2b73e86881 hlsdemux: properly stop tasks by stopping fragment download
Issue a signal to the fragment download cond to stop
the task earlier
2014-04-29 18:49:15 -03:00
Thiago Santos
60eec1443a hlsdemux: decrypt before typefinding
Make sure typefinding gets the decrypted content instead of
trying to typefind the encrypted data.
2014-04-29 18:49:15 -03:00
Thiago Santos
cc262b0923 hlsdemux: fix decryption function return
Correctly return the decrypted buffer when it succeeds and
return NULL otherwise
2014-04-29 18:49:15 -03:00
Thiago Santos
f6b0cae8b6 hlsdemux: keep connection alive between downloads
Use the same properties as uridownloader to keep connections alive
between consecutive fragments downloads.

1) set keep-alive property to true
2) keep the element in READY instead of in NULL
2014-04-29 18:17:07 -03:00
Thiago Santos
4b9d91d497 hlsdemux: create sources from uri
Instead of using always an http source, create it dynamically from
uri when needed. If not needed just replace the URI on the current
element
2014-04-29 18:17:07 -03:00
Thiago Santos
671f8c0e35 hlsdemux: do not try to run typefind again if caps is the same
Always reset the do_typefind flag if hls did typefind because
trying it on non-zero offsets doesn't make sense and will cause
assertions
2014-04-29 18:17:07 -03:00
Thiago Santos
cc033c7ca0 hlsdemux: enable download bitrate measure
Measure the download bitrate to be able to select
the best playlist.

As the buffers are directly pushed downstream and it
might block. The time is only measured from the download
until the pad push and it is started again after the push
returns.
2014-04-29 18:17:07 -03:00
Thiago Santos
c93c222786 hlsdemux: re-enable decryption after uridownloader removal
Now the decryption is done buffer by buffer instead of on the
whole fragment at once. As it expects multiples of 16 bytes a
GstAdapter was added to properly chunk the buffers.

Also the last buffer must be resized depending on the value of the
last byte of the fragment, so hlsdemux always keeps a pending buffer
as it doesn't know if it is the last one yet
2014-04-29 18:17:07 -03:00
Thiago Santos
3611759557 hlsdemux: replace uridownloader with a GstElement
The GstElement is directly linked into a ghost pad and
its buffers are pushed as received downstream. This way the
buffers are small enough and not a whole fragment that usually
causes extra latency and makes buffering harder
2014-04-29 18:17:07 -03:00
Sebastian Dröge
b47c92df82 hlsdemux: Set Referer in requests to the playlist URI 2014-04-28 10:04:28 +02:00
Tim-Philipp Müller
dbe6fdd6bf docs: remove outdated and pointless 'Last reviewed' lines from docs
They are very confusing for people, and more often than not
also just not very accurate. Seeing 'last reviewed: 2005' in
your docs is not very confidence-inspiring. Let's just remove
those comments.
2014-04-27 00:36:32 +01:00
Sebastian Dröge
f82d9ec4a9 hlsdemux: Also update the sequence position when updating non-live playlists 2014-04-10 16:53:42 +02:00
Sebastian Dröge
a06d4ea408 hlsdemux: Try reloading the playlist first if downloading a fragment fails
But only add this for non-live playlists. For live playlists we already
have another thread that is periodically updating playlists.

Reason for this is that sometimes downloading a fragment can fail because
the URIs have changed or expired since last time.
2014-04-10 15:06:53 +02:00
Sebastian Dröge
864399f299 hlsdemux: When updating a non-live playlist make sure to find the current sequence by time
Sequence numbers in different playlists are not guaranteed to be the same for the
same position, e.g. fragments could have different durations in different playlists.

In theory we should do exactly the same for live playlists, but unfortunately we can't
because doing this kind of seeking requires the complete playlist since we started
playback. For live playlists the server is however dropping fragments in the beginning
over time and we have no absolute time references.
2014-04-10 15:06:53 +02:00
Vincent Penquerc'h
c319b1cc8f hls: only set DISCONT flag on a valid buffer
Recent refactoring causes this code to be called with either a NULL
fragment, or a non NULL fragment. In the former case, we don't have
a buffer. In the latter case, the original code dealing with DISCONT
assumed the buffer was valid. Testing for a NULL buffer here thus
does not seem to change the intent, and fixes:

Coverity 1195147
2014-04-08 16:56:04 +01:00
Sebastian Dröge
b86e502a8b hlsdemux: Handle errors when switching playlists properly 2014-03-30 19:22:25 +02:00
Sebastian Dröge
89ca4535eb hlsdemux: Go EOS if the end of the segment is reached 2014-03-30 19:22:25 +02:00
Sebastian Dröge
911023eb88 hlsdemux: Store buffer end position in segment.position 2014-03-30 19:22:24 +02:00
Sebastian Dröge
f701755b83 hlsdemux: Don't set the segment offset
It's causing wrong running times after seeks or bitrate
switches.
2014-03-29 10:33:45 +01:00
Sebastian Dröge
e11a99e26a hlsdemux: Set DISCONT flag on all buffers in reverse playback mode 2014-03-29 10:33:45 +01:00
Sebastian Dröge
6039734f3e hlsdemux: Unset DTS of all buffers
We won't get a valid DTS from the source.
2014-03-29 10:33:45 +01:00
Sebastian Dröge
cad284e843 hlsdemux: Send flush start event before waiting for the tasks to finish
Otherwise we'll wait until buffers are completely processed downstream,
which might take quite some time.
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
7ddd67baef hlsdemux: Always calculate the current download rate
Also take into account the last download rate when
calculating it.
2014-03-12 12:35:22 +01:00
Sebastian Dröge
d2880dce68 hlsdemux: Implement proper segment handling
https://bugzilla.gnome.org/show_bug.cgi?id=695846
https://bugzilla.gnome.org/show_bug.cgi?id=723268
2014-03-06 23:16:56 +01:00
Sebastian Dröge
cd02546089 hlsdemux: Implement handling of byte ranges 2014-03-06 16:36:10 +01:00
Zallesov
7ed08a1326 hlsdemux: Fix seeking further than track duration
Don't fail the seek but instead send an EOS event from the streaming thread.
2014-03-06 09:39:22 +01:00
Sebastian Dröge
5d5ca5139e hlsdemux: Switch playlists after pushing the fragment
Makes sure we properly set the discont flag for the next buffer,
not the current one.
2014-03-05 20:44:02 +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
874af7db4e hlsdemux: Init and clear a mutex
GLib initialises automatically for us for some reason... but of course
does not clear the mutex once the demuxer is destroyed.
2014-02-27 15:50:12 +01:00
Sebastian Dröge
5f0a5c3594 hlsdemux: Unref seek events before returning from the seek handler
Otherwise we leak them all.
2014-02-27 15:41:30 +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
090bf91974 hlsdemux: Deprecate fragments-cache property
The buffering/caching is handling completely different now and
outside of hlsdemux.
2014-02-23 11:01:57 +01:00
Sebastian Dröge
b47a4faf5f ext: Use Codec/Demuxer/Adaptive for the adaptive streaming demuxers 2014-02-23 00:11:04 +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
Sebastian Dröge
76e74547c7 hlsdemux: Only switch pads if the caps are changing 2014-02-23 00:10:45 +01:00
Andoni Morales Alastruey
99feef2d08 hlsdemux: fix update interval with respect of the spec 2014-02-14 13:07:39 +01:00
Sebastian Dröge
13997abbf9 hlsdemux: Give a proper name to the srcpads and remove it when resetting the element 2014-02-12 18:27:21 +01:00