Commit graph

64 commits

Author SHA1 Message Date
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
bd54a212d3 hlsdemux: Fix comparison in bitrate selection 2014-03-09 20:50:44 +01:00
Sebastian Dröge
c9bb878fe5 m3u8: Fix off-by-one in the download range end 2014-03-07 16:24:19 +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
Alex Ashley
b7ef52c515 hlsdemux: Segfaults if playlist has no media files
hlsdemux causes a null pointer dereference if the media playlist
does not contain any media files. The gst_m3u8_client_get_duration
function assumes that demux->client->current->files is valid when
computing duration.

gst_m3u8_client_update needed to be modified to check for the
case of downloading an M3U8 file that doesn't contain any media
files, and returning an error to gsthlsdemux.c

This bug can be reproduced by creating a master m3u8 file that
contains one media playlist that points back to the master m3u8
file.  For example create a file called bug725134.m3u8:
  #EXTM3U
  #EXT-X-VERSION:4
  #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=1251135, CODECS="avc1.42001f mp4a.40.2", RESOLUTION=640x352
  bug725134.m3u8

https://bugzilla.gnome.org/show_bug.cgi?id=725134
2014-03-01 16:34:59 +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
Alex Ashley
161254d7c0 hlsdemux: Fix parsing of CODECS and RESOLUTION
hlsdemux does not check for the '"' character in #EXT-X-STREAM-INF
attributes. The CODECS parameter is an example of an attribute
that might use the '"' symbol and might contain a ',' character
inside this quoted string.

For example: CODECS="avc1.77.30, mp4a.40.2"

hlsdemux does not correctly parse the RESOLUTION attribute, it
assumes that an '=' character is used to delineate the width
and height values, but the HLS RFC states that a 'x' character
must be used as the delimiter between width and height.

https://bugzilla.gnome.org/show_bug.cgi?id=725140
2014-02-26 09:23:22 +01:00
Alex Ashley
91775a1abd hlsdemux: Fix for URLs that contain a '/' in the query parameter
If the URL for the master manifest files contains a '/' character
in the query parameter (for example
http://example.net/1054559_h264_1500k.mp4/master.m3u8?acl=/*1054559_h264_1500k.mp4),
hlsdemux is incorrectly converting the relative URLs of the media
playlists in to absolute URLs. It is incorrectly using the last '/' it
finds in the URL. According to RFC3986 the '/' character is allowed in
the query part of the URL.

https://bugzilla.gnome.org/show_bug.cgi?id=725137
2014-02-26 09:20:58 +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
e40b72bc9b hlsdemux: Ignore empty lines in the playlist
Based on a patch by Andoni Morales.
2014-02-12 18:50:09 +01:00
Sebastian Dröge
65c1faf553 hlsdemux: Make sure to ignore \r in line endings in every case 2014-02-12 18:47:45 +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
Sebastian Dröge
adea24cdf8 hlsdemux: Stop leaking GErrors in some error paths 2014-02-12 16:46:31 +01:00
Gil Pedersen
62ddd34807 hlsdemux: don't pause task when it is stopped
This fixes a potential dead-lock situation from GstTask

https://bugzilla.gnome.org/show_bug.cgi?id=675869
2014-02-12 16:04:52 +01:00
Sebastian Dröge
281f2f3590 hlsdemux: Wait for the update task to finish when shutting down 2014-02-12 16:01:05 +01:00
Sebastian Dröge
4dcacc1773 hlsdemux: Prevent rounding errors due to division by using gst_util_uint64_scale() 2014-02-12 15:33:06 +01:00
Arnaud Vrac
6e54b8ee53 hlsdemux: schedule next update based on the fragment duration 2014-02-12 15:18:29 +01:00
Sebastian Dröge
05efcbf757 hlsdemux: Properly error out if caps can't be typefind instead of using NULL caps 2014-02-12 15:16:23 +01:00
Arnaud Vrac
63e18bb7bf hlsdemux: log fragment timestamp 2014-02-12 14:39:15 +01:00
Sebastian Dröge
dc45d236d2 hlsdemux: Use g_ascii_xdigit_value() instead of our own version of it 2014-02-12 14:10:02 +01:00
Sebastian Dröge
a84220a658 hlsdemux: Error out if the key is not 16 bytes large 2014-02-12 13:40:41 +01:00
Sebastian Dröge
8c3ef21a68 hlsdemux: Download playlists with compression, keys and fragments without 2014-02-12 13:13:30 +01:00
Sebastian Dröge
245a7d94f5 hlsdemux: Don't set the element private data on the srcpads
It's not used anyway.
2014-02-12 11:26:04 +01:00
Sebastian Dröge
60f1dadd1c hlsdemux: Use gst_pad_use_fixed_caps() on the srcpads 2014-02-12 11:25:41 +01:00
Sebastian Dröge
bc42a18f92 hlsdemux: Cache the key fragment instead of downloading it over and over again 2014-02-12 10:59:38 +01:00
Sebastian Dröge
792d1e0109 hlsdemux: Fix cleanup when decryption fails
First unmap buffers, then unref them. And also unref the
key fragment.
2014-02-12 10:58:45 +01:00
Sebastian Dröge
5e55bae14b hlsdemux: Don't try decryption if an unsupported method is found 2014-02-11 18:15:45 +01:00
Sebastian Dröge
56faad51bb hlsdemux: Properly parse IV from the playlist
Without this every fragment's first 16 bytes will be corrupted
if not the fallback IV is used by the playlist.
2014-02-11 18:15:07 +01:00
Sebastian Dröge
591598da48 hlsdemux: Propagate download errors properly and post error messages if they're fatal 2014-02-11 14:57:16 +01:00
Sebastian Dröge
3a5abc233d ext: Update for GstUriDownloader API changes 2014-02-11 14:18:32 +01:00
Sebastian Dröge
73d9a8b0c9 hlsdemux: Start downloading the next fragment immediately after caching the initial fragments
And only afterwards wait until a fragment was played. Otherwise we're keeping
our cache most of the time at "fragments-cache" fragments minus one.

Also allow setting "fragments-cache" to 1 now to start playback even faster.
2014-02-10 18:30:21 +01:00
Sebastian Dröge
4f04f3e68e hlsdemux: Start fetching new fragments whenever we have less fragments cached than given by the fragments-cache property
Waiting until our cache is empty before starting to fetch the next fragment
kind of defeats the purpose of caching multiple fragments.
2014-02-10 18:27:58 +01:00
Sebastian Dröge
89c592ccdd hlsdemux: Fix bitrate calculation
g_get_monotonic_time() returns microseconds, not nanoseconds.
2014-02-10 18:21:38 +01:00
Sebastian Dröge
a4847fd4db hlsdemux: Actually store doubles as such and don't truncate them to ints
Fixes broken duration reporting.
2014-02-10 17:27:10 +01:00
Sebastian Dröge
a5387eb372 hlsdemux: Use locale-independent int/float parsing functions from GLib 2014-02-10 17:27:10 +01:00
Sebastian Dröge
6799e3b879 hlsdemux: Prefer to use nettle for decryption but fall-back to libgcrypt
nettle is used by newer versions of gnutls, while older versions of gnutls
used libgcrypt. Support both for now as not every distro has nettle yet.

nettle is preferred as it is more efficient to use and much smaller.
2014-02-09 18:52:24 +01:00
Sebastian Dröge
6abed8da20 hlsdemux: Update to non-deprecated GLib thread API 2014-02-09 18:19:33 +01:00
Sebastian Dröge
e8befb7ce3 hlsdemux: Use libgcrypt directly instead of going through gnutls
gnutls is also just wrapping gcrypt, but we don't need any of
the TLS related functionality. We just need to be able to decrypt
AES128-CBC.
2014-02-09 18:09:36 +01:00
Thiago Santos
d59af97930 hlssink: do not lose ref to the multifilesink
It is needed to update location properties and it was being lost on
state changes, causing issues if the pipeline was to be reused
2013-11-07 12:50:55 -03:00
Thiago Santos
805e313cce hlssink: make sure it is handled as a sink
It only gets the sink flag set when it adds the multifilesink, that
happens in null->ready and it might be too late. Set the flag
explicitly on the constructor.

https://bugzilla.gnome.org/show_bug.cgi?id=711086
2013-11-07 12:50:55 -03:00