Commit graph

219 commits

Author SHA1 Message Date
Tim-Philipp Müller
d331f01e03 adaptivedemux: remove unprefix STATISTICS_MESSAGE_NAME after all
It was only added during 1.5.x so we might just as well remove it
immediately.

https://bugzilla.gnome.org/show_bug.cgi?id=754686
2015-09-17 17:54:36 +01: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
Sebastian Dröge
5674dd75d9 adaptivedemux: Fix playback of live streams
dashdemux seeks each live stream to its current fragment in the beginning, but
the base class does not know about this. Update the demuxer segment with this
seek so we generate the correct SEGMENT event and can actually play the
stream.

This needs some refactoring at some point.

https://bugzilla.gnome.org/show_bug.cgi?id=755047
2015-09-15 22:05:19 +02:00
Thiago Santos
0ed501ab03 adaptivedemux: Only overwrite last return if it was OK
Prevents overwriting other conditions that would be more important,
such as EOS.

https://bugzilla.gnome.org/show_bug.cgi?id=755042
2015-09-15 12:46:31 -03:00
Sebastian Dröge
d1c5669a38 adaptivedemux: Properly implement timestamping of multi-period streams
Each period will start again with pts 0 + period presentation offset, which is
also going to be the presentation time inside the container stream if any.
However all periods together should form a continuous timeline, with regard to
stream time and running time.

For making this possible we keep track of the "user requested segment", i.e.
the seek events, inside the demuxer without adjusting anything and taking this
demuxer segment only as orientation for modified segments per stream.

This per stream segments will have their segment.start at pts that would be
produced for this stream in this period, and the segment.base/time adjusted so
that this pts maps to the running and stream time this period should have in
the context of all other periods.

https://bugzilla.gnome.org/show_bug.cgi?id=754222
2015-09-14 19:53:03 +02:00
Edward Hervey
e276d02d28 adaptivedemux: Demote debugging level 2015-08-15 19:04:43 +02:00
Edward Hervey
69867f95e2 adaptivedemux: Actually wait for playlist update when requested
There are several cases where a HLS server could temporarily have wrong
fragments, or reconfigure the playlist. In those cases, when we get
fragment download failures, we *really* want to wait a bit (for the next
playlist update) before retrying to get fragments.

Previously this method was first checking to see if there was next fragments
(according to the previous manifest update) before waiting for the next update.
The problem was that if that if there is a temporary failure on the server,
that's uncorrelated to whether the manifest contains next fragments or not.
2015-08-15 19:04:42 +02:00
Tim-Philipp Müller
b4fe1b516b adaptivedemux: minor clean-up
No need for a foreach callback function that's just a few
lines of code and is only used once, just do the event
pushing inline.

https://bugzilla.gnome.org/show_bug.cgi?id=705991
2015-07-20 16:04:26 +01:00
Alex Ashley
71a1e3669a dashdemux: add support for generating Protection events from ContentProtection elements
If a ContentProtection element is present in an AdaptationSet element,
send Protection events on the source pad, so that qtdemux can use this
information to correctly generate its source caps for DASH CENC
encrypted streams.

This allows qtdemux to support CENC encrypted DASH streams where the
content protection specific information is carried in the MPD file
rather than in pssh boxes in the initialisation segments.

This commit adds a new function to the adaptivedemux base class to allow
a GstEvent to be queued for a stream. The queue of events are sent the
next time a buffer is pushed for that stream.

https://bugzilla.gnome.org/show_bug.cgi?id=705991
2015-07-20 16:04:22 +01:00
Sebastian Dröge
153bb7b273 adaptivedemux: Explicitly check for CUSTOM_ERROR when converting errors to EOS
We use things like CUSTOM_SUCCESS* in other places, and those are not errors
but should just be handled like OK.
2015-07-07 19:51:39 +03:00
Sebastian Dröge
a78c1bdad5 adaptivedemux: If downloading the last fragment fails, consider this as EOS and not ERROR
Sometimes the last fragment does not exist because of rounding errors with the
durations. Just finish the stream gracefully instead of erroring out instead.
2015-07-07 19:51:39 +03:00
Sebastian Dröge
f413129172 adaptivedemux: Move unref() into the right scope 2015-06-25 23:49:41 +02:00
Sebastian Dröge
548ed60e86 adaptivedemux: Properly handle presentationTimeOffset for seeking and multi-period streams
Segment start/time/position/base should only be modified if this is the first
time we send a segment, otherwise we will override values from the seek
segment if new streams have to be exposed as part of the seek.

Segment base should be calculated from the segment start based on the stream's
own segment, not the demuxer's segment. Both might differ slightly because of
the presentationTimeOffset.

Always add the presentationTimeOffset (relative to the period start, not
timestamp 0) to the segment start after resetting the stream's segment based
on the demuxer's segment (i.e. after seeks or stream restart). Also make sure
to keep the stream's segment up to date and not just send a new segment event
without storing the segment in the stream.

https://bugzilla.gnome.org/show_bug.cgi?id=745455
2015-06-25 23:36:25 +02:00
Sebastian Dröge
8c6b39215e adaptivedemux: Also update segment.base and segment.time when switching periods
And include the presentation offset in the last known position for each
stream, and just because we can also keep track of the latest known position
inside the demuxer segment.
2015-06-23 18:19:35 +02:00
Sebastian Dröge
281a13efa1 adaptivedemux: Remember the last return value of gst_adaptive_demux_stream_update_fragment_info()
It's going to return EOS if the period ended or otherwise there is just no
next fragment left. If we don't store the last return value, it will always
stay OK and gst_adaptive_demux_combine_flows() will always return OK instead
of EOS once all streams are done.

This partially switches period changes in DASH by at least trying to switch
instead of just stopping. What is still left is that after a period change
with DASH the times all start at 0 again instead of continuing.
2015-06-23 13:15:55 +02:00
Sebastian Dröge
4dd355cea2 adaptivedemux: Error out if downloading a segment failed too often in live mode
It's true that we shouldn't consider errors fatal immediately, but if we
always ignore them we will loop infinitely on live streams with segments
that can't be downloaded at all.
2015-06-05 11:26:11 +02:00
Sebastian Dröge
fc67e1db8b adaptivedemux: Release the manifest mutex before waiting for a download
Otherwise we will hurt parallel downloads in the best case, and often cause
deadlocks.
2015-06-04 12:36:41 +02:00
Luis de Bethencourt
6857048079 adaptivedemux: 'for' loop initial declaration
'for' loop initial declarations are only allowed in C89, moving the declaration
to before the 'for' loop.
2015-05-26 15:24:55 +01:00
Thiago Santos
61cad123d7 adaptivedemux: drop debug message that was wrong
EOS doesn't necessarily mean that no fragment was downloaded
2015-05-13 13:35:14 -03:00
Thiago Santos
8331b083ee adaptivedemux: run gst-indent
To allow commiting on this file cleanly
2015-05-13 13:35:14 -03:00
Jimmy Ohn
868472affb adaptivedemux: only update stream position if query success
We don't need to check about the query fail case.
because it is update to segment position even though query fail.

https://bugzilla.gnome.org/show_bug.cgi?id=748529
2015-05-05 14:33:41 -03:00
Edward Hervey
38c97f5fa5 adaptivedemux: Fix comparision logic
We can't answer the SEEKING query if we do *not* have the manifest
2015-04-29 15:41:07 +02:00
Tim-Philipp Müller
699452ef31 Remove obsolete Android build cruft
This is not needed any longer.
2015-04-26 18:59:32 +01:00
Sebastian Dröge
235506e912 adaptivedemux: Only answer the duration query in non-live mode 2015-04-26 19:08:35 +02:00
Sebastian Dröge
6c8eeb448d adaptivedemux: Don't claim to be live when answering the LATENCY query
Even for "live" streams we are not live in the GStreamer meaning of the word.
We don't produce buffers that are timestamped based on their "capture time"
and our clock, but just based on whatever timestamps the stream might contain.

Also even if we wanted to claim to be live, that wouldn't work well as we
would have to return GST_STATE_CHANGE_NO_PREROLL when going from READY to
PAUSED, which we can't. We first need data to know if we are "live" or not.
2015-04-23 17:47:18 +02:00
Sebastian Dröge
0cd3938345 adaptivedemux: Allow subclasses to override how a new manifest would be downloaded 2015-04-23 17:47:18 +02:00
Sebastian Dröge
c1f98daa74 adaptivedemux: Expose downloader
This allows subclasses to use it and share connections if possible.
2015-04-23 17:47:18 +02:00
Sebastian Dröge
3c639d3235 adaptivedemux: Don't stop all tasks and streams from the update task on errors
It will deadlocks as we will then join() the update task from itself. Instead
just post an actual error message on the bus and only stop the update task.

The application is then responsible for shutting down the element, and thus
all the other tasks and everything, based on the error message it gets.
2015-04-21 22:04:56 +02:00
Thiago Santos
66b01c9a0c adaptivedemux: do not try to advance fragment if there is none
It might return OK from subclasses and it could cause a bitrate
renegotiation. For DASH and MSS that is ok as they won't expose
new pads as part of this but it can cause issues for HLS as
it will expose new pads, leading to pads that will only have EOS
that cause decodebin to fail

https://bugzilla.gnome.org/show_bug.cgi?id=745905
2015-03-27 16:22:57 -03:00
Jan Schmidt
f150cf2d2e Remove a bunch of silly ';;' typos at the end of lines 2015-03-12 01:33:03 +11:00
Mathieu Duponchelle
a8604bc4f8 adaptivedemux: fix get_presentation_offset check.
And return 0 isntead of FALSE.

https://bugzilla.gnome.org/show_bug.cgi?id=745455
2015-03-10 15:31:21 +01:00
Mathieu Duponchelle
b4d8c04f08 adaptivedemux: [API]: get_presentation_offset virtual method.
Asks the subclass for a potential time offset to apply to each
separate stream, in dash streams can have "presentation time offsets",
which can be different for each stream.

https://bugzilla.gnome.org/show_bug.cgi?id=745455
2015-03-10 15:17:37 +01: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
Mathieu Duponchelle
b6f2a962b5 adaptivedemux: Fix logic in fragment_download_finish.
This was preventing us from surfacing a meaningful error.

https://bugzilla.gnome.org/show_bug.cgi?id=743703
2015-02-12 23:07:36 +01:00
Mathieu Duponchelle
6b864813cc adaptivedemux: Set first segment time to segment start.
Otherwise as long as a seek wasn't executed, the position was
reported incorrectly:

gst-validate-1.0 playbin \
uri=http://dev-iplatforms.kw.bbc.co.uk/dash/news24-avc3/news24.php

https://bugzilla.gnome.org/show_bug.cgi?id=744362
2015-02-12 22:47:26 +01:00
Mathieu Duponchelle
c98348c141 adaptivedemux: track per-fragment bitrates.
And use the average to go up in resolution, and the last fragment
bitrate to go down.

This allows the demuxer to react rapidly to bitrate loss, and
be conservative for bitrate improvements.

+ Add a construct only property to define the number of fragments
  to consider when calculating the average moving bitrate.

https://bugzilla.gnome.org/show_bug.cgi?id=742979
2015-02-12 00:07:15 +01:00
Thiago Santos
9ebbce381a adaptivedemux: do not skip the first fragment
Avoid advancing fragment right after downloading the header. If it
is the header, by default, don't advance to the next fragment.
2015-01-20 14:55:05 -03:00
Thiago Santos
919b93ae35 adaptivedemux: add explicit cast to make clang happy
Fixes compilation
2015-01-20 09:23:02 -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
Thiago Santos
9336077057 adaptivedemux: fix multi-period playback
If we say it is the first segment after a new period it will resync
the segment.start value and all buffers will be late for the new period
we are trying to play. Otherwise we want to keep the segment.start with
the previous value to allow the running time to smoothly increase
2015-01-19 08:36:42 -03:00
Thiago Santos
3a79bd91c7 adaptivedemux: prevent early EOS when switching at last fragment
Check if there is a next fragment before advancing to avoid causing
a bitrate switch (and maybe exposing new pads) only to push EOS.
This causes playback to stop with an error instead of properly
finishing with EOS message.
2015-01-16 17:07:22 -03:00
Thiago Santos
516f1ae0f4 adaptivedemux: add a special return to signal subsegment boundary
The subsegment boundary return tells the adaptivedemux that it can
try to switch to another representation as the stream is at a suitable
position for starting from another bitrate.
2015-01-16 15:00:11 -03:00
Thiago Santos
9b260d1ba5 adaptivedemux: Actually use the byte range for the fragment url
Otherwise we would always download the full fragment. This would
make handling subsegments in DASH impossible.
2015-01-16 15:00:11 -03:00
Thiago Santos
5c3a87c117 adaptivedemux: allow downloads of headers only
In order to get some subsegment information, subclasses might want
to download only the headers to have enough data (the index)
to decide where to start downloading from the subsegment.
2015-01-16 15:00:11 -03:00
Thiago Santos
f7e9a58c58 adaptivedemux: refactor common code to function
Reuse the same function when finishing downloading and signaling to
the download loop thread to get the next fragment or abort
2015-01-16 15:00:11 -03:00
Thiago Santos
5823f8b408 adaptivedemux: inform subclass when headers/index are being downloaded
This allows the subclasses to know if the chunks that are downloaded are
part of the header or of the index and will parse the parts that are
of their interest.
2015-01-16 15:00:11 -03:00
Thiago Santos
c1251ab861 adaptivedemux: only update segment if we have a valid PTS
Otherwise we set the position to GST_CLOCK_TIME_NONE and it disrupts
bitrate switching
2015-01-07 09:30:40 -03:00
Thiago Santos
af78e2501c adaptivedemux: prepare for supporting seeks in live streams
Add function to allow subclasses to specify seeking range for
live streams

https://bugzilla.gnome.org/show_bug.cgi?id=725435
2015-01-05 17:58:54 -03:00
Thiago Santos
c65aeedb6f adaptivedemux: check if element exists before setting it to null
Under certain error conditions it might happen that the element
has been freed already and trying to set it to NULL causes an
assertion
2014-12-23 10:08:57 -03:00
Thiago Santos
3dfab51b92 adaptivedemux: make sure task has stopped before freeing it
Otherwise the thread will be running and its memory will get freed.
This leads to memory corruption
2014-12-23 10:08:56 -03:00
Thiago Santos
0bef1974e2 adaptivedemux: fix segment start when exposing new streams
Segment start needs only to be updated when starting the streams
or after a seek, doing it during bitrate changes will cause the
running time to go discontinuous (jump back to a previous ts)
and QOS will drop buffers
2014-12-23 10:08:56 -03:00
Thiago Santos
73fb0850c9 adaptivedemux: allow subclass to use new pads group when switching bitrate
Fix pad groups switching when bitrate changes to allow HLS to use this feature
2014-12-23 10:08:51 -03:00
Thiago Santos
75b0bac7f8 adaptivedemux: fix seek event handling
Properly do seeking and avoid only seeking when the segment was updated.
It would cause seeks after the stream was EOS to fail, for example.

https://bugzilla.gnome.org/show_bug.cgi?id=738920
2014-12-11 21:09:26 -03:00
Thiago Santos
c8fa688d26 adaptivedemux: check the return from update_manifest correctly
It is a GstFlowReturn and not a boolean
2014-12-10 18:23:02 -03:00
Thiago Santos
d30ec9f9f7 adaptivedemux: do not try to unlock not locked mutex
A misplaced unlock was causing an assertion for playback with a
set stop time
2014-12-08 08:53:00 -03:00
Thiago Santos
66f40b798d adaptivedemux: release threads waiting for manifest update on shutdown
For live streams, also unblock threads that might be waiting for a manifest
update when stopping the pipeline.

Also add some more debug messages
2014-12-04 01:48:07 -03:00
Thiago Santos
a7712c2983 adaptivedemux: use gst_task_stop instead of gst_task_pause
To avoid race conditions with gst_task_stop(); gst_task_join() with
another thread doing gst_task_pause(), the joining thread would be
waiting for the task to stop but it would never happen. So just
use gst_task_stop() everywhere to prevent more mutexes
2014-12-04 01:48:07 -03:00
Thiago Santos
87df15a214 adaptivedemux: fix deadlock when stopping streams
Remember to unlock the manifest's lock when leaving the download task.
2014-12-04 01:48:07 -03:00
Thiago Santos
92fd73ab5f adaptivedemux: remove unused error variable
CID #1256556
2014-12-03 10:06:09 -03:00
Thiago Santos
d9944506c8 adaptivedemux: remove more get_duration checks
Subclasses must implement get_duration function. If they do not know
the duration they can return GST_CLOCK_TIME_NONE
2014-12-03 09:45:58 -03:00
Thiago Santos
9afed503ed adaptivedemux: all subclasses must implement get_duration
CID #1256557
2014-12-03 09:42:39 -03:00
Thiago Santos
e11c311c31 adaptivedemux: make sure to always stop the stream on EOS
For On-Demand streams, always stop the tasks for streams that reached
EOS
2014-12-03 09:42:39 -03:00
Edward Hervey
87694c2232 gst-libs: Fix dependency build
adaptivedemux depends on uridownloader and video depends on base
2014-12-01 10:32:30 +01:00
Thiago Santos
df66909129 adaptivedemux: reworking live manifest update wait
Check if the stream is live before checking if it is EOS as a live
stream might be considered EOS when it just needs to wait for a manifest
update to proceed with the next fragments
2014-11-30 21:56:25 -03:00
Thiago Santos
66202d4c1b adaptivedemux: fix manifest update locking
To avoid unlocking a not locked mutex
2014-11-30 21:56:25 -03:00
Thiago Santos
5f3cce2e58 adaptivedemux: Fix segment for manifests that won't start at 0
For live streams, the manifest might start at an advanced position. Avoid
using segment start=0 to have playback start immediately
2014-11-30 21:56:25 -03:00
Thiago Santos
023b284c2d adaptivedemux: also clear flushing state on pads before restarting
During flushing seeks the flushing flow return will propagate up to the
source element and all pads are going to have the flushing flag set.

So before restarting also remove that flag together with the EOS one.

We don't do that when pushing the flush stop event because our event
handler for the proxypad will drop all events.
2014-11-30 21:56:03 -03:00
Thiago Santos
9ec9f3f119 adaptivedemux: add adaptivedemux base class
https://bugzilla.gnome.org/show_bug.cgi?id=735848
2014-11-30 21:56:01 -03:00