Commit graph

264 commits

Author SHA1 Message Date
Sebastian Dröge
4f6ae1f48c adaptivedemux: Enable bitrate selection for trick mode streaming again
And scale the bitrate with the absolute rate (if it's bigger than 1.0) to get
to the real bitrate due to faster playback.

This allowed in my tests to play a stream with 10x speed without buffering as
the lowest bitrate is chosen, instead of staying/selecting the highest bitrate
and then buffering all the time.

It was previously disabled for not very well specified reasons, which seem to
be not valid anymore nowadays.
2016-08-25 19:52:37 +03:00
Nirbheek Chauhan
42af2d66d8 Add support for Meson as alternative/parallel build system
https://github.com/mesonbuild/meson

With contributions from:

Tim-Philipp Müller <tim@centricular.com>
Matej Knopp <matej.knopp@gmail.com>
Jussi Pakkanen <jpakkane@gmail.com> (original port)

Highlights of the features provided are:
* Faster builds on Linux (~40-50% faster)
* The ability to build with MSVC on Windows
* Generate Visual Studio project files
* Generate XCode project files
* Much faster builds on Windows (on-par with Linux)
* Seriously fast configure and building on embedded

... and many more. For more details see:

http://blog.nirbheek.in/2016/05/gstreamer-and-meson-new-hope.html
http://blog.nirbheek.in/2016/07/building-and-developing-gstreamer-using.html

Building with Meson should work on both Linux and Windows, but may
need a few more tweaks on other operating systems.
2016-08-20 11:35:54 +01:00
xlazom00
94d11f87c7 hls, timecode: fix linking
https://bugzilla.gnome.org//show_bug.cgi?id=769587
2016-08-07 16:45:25 +01:00
Jan Schmidt
f2dc791479 hls: Avoid potential NULL pointer dereference.
Fixes CID 1364753
2016-08-04 22:28:13 +10:00
Jan Schmidt
d78686f7d4 hls: Avoid coverity warning about access off the end of an array.
Fixes CID 1364755
2016-08-04 22:22:44 +10:00
Luis de Bethencourt
2ed4135237 hls: m3u8: remove impossible condition
After the check in line 1,111,  media->uri can't be NULL. So the two checks
for GST_HLS_MEDIA_TYPE_CLOSED_CAPTIONS are the same, removing the redundant
one which goes to cc_unsupported.

CID 1364752
2016-08-04 11:17:56 +01:00
Jan Schmidt
35c82fee32 hlsdemux: Don't output pending data after error
If the last_ret status is not OK, skip output
of any pending PCR scan buffer, similarly to how
the pending decryption buffer is handled above.
2016-08-04 04:53:50 +10:00
Jan Schmidt
2df53e5a7d hlsdemux: Include config.h and add header in utils
In gsthlsdemux-util.c, include config.h before any
other headers, and add a copyright / license header.
2016-08-04 01:54:28 +10:00
Jan Schmidt
ebab5b17f4 hls: Fix compiler warning for possibly uninit variable 2016-08-03 23:51:14 +10:00
Michael Olbrich
89727ee9a3 hlsdemux: seek all streams 2016-08-03 23:49:54 +10:00
Michael Olbrich
decafb5f4c hlsdemux: simplify gst_hls_demux_seek()
Don't initialize current_sequence. It is always overwritten in the walk
loop.
2016-08-03 23:49:54 +10:00
Michael Olbrich
4704634f43 hlsdemux: don't download the last fragment when seeking beyond the end of the track
It's not used anyways.
2016-08-03 23:49:54 +10:00
Jan Schmidt
1d4eb71a05 hlsdemux: Add support for ID3 tag parsing
Parse start PTS out of the ID3 tags in
audio fragments. Informational only for now.
2016-08-03 23:49:54 +10:00
Jan Schmidt
8cf50dbc44 hlsdemux: Do some reading and dumping of PCRs
Read PCRs out of the MPEG-TS stream in a basic way
and (for now) just log them
2016-08-03 23:49:54 +10:00
Jan Schmidt
d9daa5d0b3 hlsdemux: Only use the primary stream for bitrate selection.
When playing alternate rendition auxilliary streams, ignore
them in bitrate measurement (for now).
2016-08-03 23:49:54 +10:00
Jan Schmidt
e91bddbcfd hlsdemux: Only select video and audio streams by default
Ignore subtitle streams for now, because the
different fragment duration causes problems
switching bitrates w/ decodebin2 group draining.
2016-08-03 23:49:54 +10:00
Jan Schmidt
216195b7b2 hlsdemux: Publish all media for alternate renditions.
Create an output stream for each media when alternate renditions
are present. Update the manifests for all those streams, and
make sure that typefinding is still done for files smaller than 2KB
such as small WebVTT files.
2016-08-03 23:49:54 +10:00
Jan Schmidt
f32c7aa88a hlsdemux: Adjust downstream buffer offsets
When fetching a byte-region from a server resource,
adjust the downstream buffer offsets so that downstream
doesn't know. This is because id3demux insists on the
first offset being 0. Later we might strip ID3 headers
entirely and this will be unneeded.
2016-08-03 23:49:54 +10:00
Jan Schmidt
f3397e0d54 hlsdemux: Choose the default variant and track it when updating
Modify playlist updating to track information across updates
better, although still hackish.

When connection_speed == 0, choose the default variant
not the first one in the (now sorted) variant list, as that
will have the lowest bitrate.
2016-08-03 23:49:54 +10:00
Tim-Philipp Müller
4df6f1ee93 hlsdemux: move variant list handling over to new master playlist code
Adapt hlsdemux for the m3u8 playlist changes.
2016-08-03 23:49:54 +10:00
Tim-Philipp Müller
f0fcf1d718 hls: m3u8: Rework m3u8 parsing and storage.
Make M3U8 and GstM3U8MediaFile refcounted. The contents
of it and GstM3U8MediaFile are pretty much immutable
already, but if we make it refcounted we can just
return a ref to the media file from _get_next_fragment()
instead of copying over all fields one-by-one, and then
copying them all into the adaptive stream structure fields again.

Move state from client into m3u8 structure.  This will
be useful later when we'll have multiple media playlists
being streamed at the same time, as will be the case with
alternative renditions.

This has the downside that we need to copy over some
state when we switch between variant streams.

The GstM3U8Client structure is gone, and main/current
lists are not directly in hlsdemux. hlsdemux had as
many CLIENT_LOCK/UNLOCK as the m3u8 code anyway...
2016-08-03 23:49:54 +10:00
Jan Schmidt
41644cfa70 hlsdemux: Fix clearing of decryption state
Don't clear decryption state immediately after
initialising it in the start_fragment. Don't clear
the state of all streams when we want to only clear
the current stream.

https://bugzilla.gnome.org//show_bug.cgi?id=768757
2016-07-19 02:14:17 +10:00
Tim-Philipp Müller
6697feae5f hlsdemux: make decryption key handling per-stream
Add demuxer instance-wide decryption key cache. The current and
last key url are per-stream, so make a shared cache. Move the
decryption handling into the stream object, and use the shared
cache for the keys.
2016-07-15 14:33:23 +10:00
Jan Schmidt
463f48c148 hlsdemux: add hlsdemux-specific AdaptiveDemuxStream subclass
Prepare hlsdemux for more than one single stream. Currently hlsdemux
assumes there'll only ever be one stream and most of the stream-specific
state is actually in the hlsdemux structure. Add a stream subclass
instead and move some stream-specific members there instead.
2016-07-15 14:33:23 +10:00
Sebastian Dröge
8344854c4c hlsdemux: Properly keep track of current offset
GstAdapter does not guarantee to pass through all the offsets, we have to keep
track of it ourselves.

https://bugzilla.gnome.org/show_bug.cgi?id=764684
2016-07-01 14:10:31 +02:00
Sebastian Dröge
3469104a47 hlsdemux: Clear pending data when needed
When switching fragments we don't want to keep any data around from the last
one, and also forget about all data when doing flushing seeks or selecting new
bitrates.

https://bugzilla.gnome.org/show_bug.cgi?id=764684
2016-07-01 14:10:31 +02:00
Sebastian Dröge
ca9f62e1d0 adaptivedemux: Get rid of internal stream adapter and let subclasses handle this directly
This allows subclasses to have more control and especially ensure that they
push data downstream with the correct offsets.

https://bugzilla.gnome.org/show_bug.cgi?id=764684
2016-07-01 14:10:31 +02:00
Vineeth TM
8cdfb13658 bad: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=763081
2016-03-24 14:56:51 +02:00
Joe Gorse
71bf7ffe14 hls: Add OPENSSL_CFLAGS to CFLAGS
https://bugzilla.gnome.org/show_bug.cgi?id=763079
2016-03-04 09:26:34 +02:00
Thiago Santos
b7a0be23c6 adaptivedemux: replace ghostpad with a standard pad
Handling the ghostpad and its internal pad was causing more issues
than helping because of their coupled activation/deactivation
actions.

As we have to install custom chain,event and query functions it is
better to use a floating sink pad internally in the demuxer and just
use those pad functions to push through a standard pad in the demuxer

https://bugzilla.gnome.org/show_bug.cgi?id=757951
2016-01-15 11:32:37 -03:00
Tim-Philipp Müller
17f0faa368 hlsdemux: put boolean values into gboolean variables
And remove superfluous assignments.
2016-01-06 15:25:04 +00:00
Thiago Santos
bf57be7fc7 hlsdemux: fix reverse playback seek with snap flags
Properly handle snap flags during reverse seeking. In this case
the before/after are also reversed, so handle those as such.

For example: with a sequence of 1s fragments:

|-- 0 --|-- 1 --|-- 2 --|-- 3 --|

If you seek to 1.5s it is inside fragment 1. With reverse and

snap-before: should play from the end of fragment 1
snap-after: should play from the end of fragment 0
2016-01-06 10:23:13 -03:00
Thiago Santos
5d87f68f6c hlsdemux: simplify snap flags checking
Replace:
if (boolean) var = true;

with:
var = (boolean);
2016-01-06 10:23:13 -03:00
Thiago Santos
b8e0c365c4 hlsdemux: respect keyunit flag for position
Set the segment start position when keyunit flag is active
2016-01-06 10:23:13 -03:00
Alex Ashley
f6bff8f5f5 hlsdemux: unquote all the quoted-string attributes
The URI attribute from the EXT-X-KEY tag and the URI attribute from the
EXT-X-I-FRAMES-ONLY tag are both quoted-string attibutes that have their
quotation marks removed during parsing. The CODECS attribute of the
EXT-X-STREAM-INF is also a quoted-string attribute, but this attribute
was not being un-quoted.

This commit changes the parser to always unquote all quoted-string
attributes and adjusts the unit tests to this new bevahiour for the
CODECS attribute.

An additional test is added to check that parsing of all of the fields
in the EXT-X-STREAM tag is correct, including those that contain comma
characters.

https://bugzilla.gnome.org/show_bug.cgi?id=758384
2015-12-22 11:15:32 -03:00
Thiago Santos
a072101441 hlsdemux: make sure every bad update_playlist return sets an error
Otherwise it segfaults when reporting the error in the bus
2015-12-22 10:16:16 -03:00
Tim-Philipp Müller
d5e115171b hlsdemux: reflow update_playlist a bit
Reduce indentation by erroring out directly on failure.
2015-12-19 21:12:17 +00:00
Tim-Philipp Müller
8be5551dff hlsdemux: fix potential error leak
Clear error as soon as we determine that the download failed,
otherwise there are code paths where we might return without
clearing it ever, which would leak the GError then. Also, we
can pass a NULL GError pointer to _fetch_uri(), so just do that
instead of passing one that we're going to just free again
right away anyway.
2015-12-19 21:06:02 +00:00
Thiago Santos
29de588e2f hlsdemux: always set timestamp on reverse playback
Downstream needs to be able to restore the timestamps after a discont
to do reverse playback

https://bugzilla.gnome.org/show_bug.cgi?id=759592
2015-12-18 18:52:03 -03:00
Duncan Palmer
612f16936c hlsdemux: add support for seeking to fragment boundaries
Setting the seek flags to GST_SEEK_FLAG_SNAP_* will change the seek
target time to a segment boundary.

Based on original work by Ben Willers <bwillers@digisoft.tv>.

https://bugzilla.gnome.org/show_bug.cgi?id=759108
2015-12-08 09:57:24 +02:00
Sebastian Dröge
821320fbc4 hlsdemux: Resync live playlists to the 3rd newest fragment if we fall off the playlist
As HLS does not provide any way of knowing the server's clock, and we do
buffering of "live" streams, at some point we will fall behind the server in
many cases and would have to advance to a fragment that is not in the playlist
anymore.

Previously we would've just resynced to the next oldest fragment that is still
there, but this causes problems as from this point onwards we would always
fall off the playlist again all the time.
Instead we now resync and move to the 3rd newest fragment like we would do
when starting playback of a live stream.

https://bugzilla.gnome.org/show_bug.cgi?id=758987
2015-12-04 18:06:30 +02:00
Tim-Philipp Müller
fe1923e1e6 hls: m3u8: remove superfluous gst_m3u8_copy() implementation
No need to implement _copy() when we just copy a list that
we're freeing three lines later anyway. Instead just steal
the new main list.
2015-12-03 18:25:12 +00:00
Maroš Ondrášek
905158a055 hlsdemux: update current variant if connection speed is set
If connection speed is set, playlist according
to connection speed is selected as current playlist.

Problem is that the current variant of main playlist still
points to previously set variant.
If previously set variant doesn't correspond to current
playlist, then it causes unnecessary change of playlist
to the same playlist after first fragment is downloaded,
because of not updated current variant.

To fix this, we need to make sure that current variant
of main playlist corresponds to the current playlist

https://bugzilla.gnome.org/show_bug.cgi?id=758946
2015-12-02 14:39:12 +02:00
Jan Schmidt
77b302b5da hlsdemux: Tell the base class the fragment duration
adaptivedemux uses the fragment duration as a delay
in some cases, so make sure to set it.
2015-12-02 22:29:38 +11:00
Jan Schmidt
952275ad99 hlsdemux: When switching bitrate variants, don't jump back
Don't jump backward to 3 files from the end of the playlist
when switching variants - it just means we downloaded
fragments fast and caught up to the end of the playlist.

Disable that by treating a variant switch as a playlist
update, not a restart due to a seek or so.
2015-12-02 22:29:38 +11:00
Alex Ashley
0745d567a7 hlsdemux: correct the calculation of seek range of non-live streams
The seek range calculation for on-demand streams was incorrectly
excluding the last three segments of the stream. This three segment
rule should only be applied to live streams [1].

[1] https://tools.ietf.org/html/draft-pantos-http-live-streaming-17#section-6.3.3

https://bugzilla.gnome.org/show_bug.cgi?id=758386
2015-12-02 10:16:25 +02:00
Tim-Philipp Müller
64adb1998d hlsdemux: fix crash when decryption key can't be downloaded
Happened with
http://sslhls.m6tv.cdn.sfr.net/hls-live/livepkgr/_definst_/m6_hls_aes/m6_hls_aes_856.m3u8
if glib-networking was not installed (since key has https uri).
2015-12-01 18:01:36 +00:00
Tim-Philipp Müller
97ea56e91c hls: m3u8: remove pointless client_has_main() function
We always have a main list.
2015-12-01 17:51:34 +00:00
Tim-Philipp Müller
0ed4620033 hls: m3u8: remove unused _get_current_fragment_duration() function 2015-12-01 17:51:34 +00:00
Tim-Philipp Müller
e68914eeec hls: m3u8: remove unused m3u8 client update_failed_count field 2015-12-01 17:51:34 +00:00