Commit graph

175 commits

Author SHA1 Message Date
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
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
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
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
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
Sebastian Dröge
fac4ed18d4 hlsdemux: Always give timestamps if we're discont and don't mark stream discont if a playlist change was not successful
If the stream is discont, we must provide a timestamp in any case. Elements
like tsdemux are not going to output anything if we give a NONE timestamp
after a discont.

Also marking a stream as discont if a playlist change was not successful would
lead to the above situation, but in that case we are not required at all to
mark the stream discont as we're still at the old playlist.
2015-12-01 19:47:59 +02:00
Reynaldo H. Verdejo Pinochet
86ec812429 Remove unnecessary NULL checks before g_free()
g_free() is NULL-safe
2015-11-18 16:05:42 -08:00
Florin Apostol
eab158a669 adaptivedemux: fixed multithread support
https://bugzilla.gnome.org/show_bug.cgi?id=755169
2015-10-29 10:20:45 +00:00
Tim-Philipp Müller
344d100b1c hlsdemux: change dispose function to finalize 2015-10-23 18:51:43 +01:00
Tim-Philipp Müller
b8a155c17d hlsdemux: remove helper function only used once 2015-10-23 18:51:43 +01:00
Tim-Philipp Müller
917b034238 hlsdemux: remove deprecated 'fragments-cache' property
It's been non-functional for two cycles now, let's
get rid of it.
2015-10-23 18:51:18 +01:00
Edward Hervey
8d86a8b75d hlsdemux: Avoid negative sequence numbers
For live streams, we want to make sure there's a certain distance
between the sequence to play and the last (earliest) fragment.

The problem is that it assumes there are at least 3 fragments in
the playlist, which might not always be the case (like in the case
of a server restarting and gradually adding fragments).

In order to avoid ending up with negative sequence numbers (which
will just loop forever), limit the new target sequence number to
the highest of:
* either the first sequence number of the playlist (fallback)
* or 3 fragments from the last one (standard behaviour)
2015-10-14 18:01:04 +02:00
Philippe Normand
261d8daca0 adaptivedemux: prefix the statistics message name macro
Keep old define around for now.

https://bugzilla.gnome.org/show_bug.cgi?id=754686
2015-09-17 17:39:27 +01:00
Arnaud Vrac
a4cb032355 hlsdemux: abort playlist update when cancelled
Otherwise the download thread will get stuck, since the downloader is
disabled.
2015-08-19 16:22:44 +03:00
Jimmy Ohn
1270afae44 hlsdemux: Fix wrong gst-launch command in the description
Fix wrong gst-lauch command in the description.
This patch may help people to get right testing results using the script.

https://bugzilla.gnome.org/show_bug.cgi?id=750143
2015-06-05 12:21:41 -03:00
Thiago Santos
0a63fa7a01 hlsdemux: drop TODO that doesn't need a solution
Connection speed is only checked at that point in hlsdemux so there
is no real need to refactor it.

https://bugzilla.gnome.org/show_bug.cgi?id=749328
2015-06-05 09:43:31 -03:00
Thiago Santos
581d8c0b8d Revert "hlsdemux: Simplify logic in process_manifest"
This reverts commit 4ca3a22b6b.

The connection-speed=0 is used as a special value in the property
of hlsdemux to mean 'automatic' selection, m3u8.c doesn't need
to know about that as it should be as simple as possible.

So this patch hides this automatic selection documented in hlsdemux
into m3u8 logic and I think the gets harder to understand the code.

It also makes the hlsdemux unit tests work again

https://bugzilla.gnome.org/show_bug.cgi?id=749328
2015-06-05 09:43:10 -03:00
Thiago Santos
6f1c58dedf hlsdemux: remove more unused attributes
Those are not used or only read
2015-05-27 06:17:49 -03:00
Thiago Santos
030700a24b hlsdemux: remove unused attribute
It is never read for anything useful
2015-05-27 05:36:10 -03:00
Jimmy Ohn
4ca3a22b6b hlsdemux: Simplify logic in process_manifest
Simplify logic in process_manifest and remove a TODO item.

https://bugzilla.gnome.org/show_bug.cgi?id=749328
2015-05-18 10:52:35 +03:00
Sebastian Dröge
7c2a5da125 hlsdemux: Use the downloader of the base class instead of creating our own
The one of the base class is completely unused because we override all
the downloading here, so let's just use that one instead.
2015-04-23 17:47:18 +02:00