Commit graph

113 commits

Author SHA1 Message Date
David Waring
c4ff5359aa dashdemux: Fix segfault introduced by segment iteration refactoring (2105a310).
The functions to get the next fragment, next fragment timestamp and to advance
to the next fragment need to work differently when stream->segments is NULL.
Use logic similar to that introduced by commit 2105a310 to perform these
functions.

https://bugzilla.gnome.org/show_bug.cgi?id=749684
2015-05-25 10:02:07 -03:00
Thiago Santos
0910540d58 dashdemux: use signed integet to represent segment index
We need to be able to represent -1 to check when we are EOS
on reverse playback and unsigned integer won't allow that.

CID #1298193
CID #1298194
CID #1298195

https://bugzilla.gnome.org/show_bug.cgi?id=749534
2015-05-25 09:02:30 -03:00
Thiago Santos
f4789d0430 dashdemux: avoid busy-looping when waiting for new fragment
When all fragments have already been downloaded on a live stream
dashdemux would busy loop as the default implementation of
has_next_fragment would return TRUE. Implement it to correctly
signal if adaptivedemux should wait for the manifest update before
trying to get new fragments.
2015-05-13 13:39:32 -03:00
Thiago Santos
23ad922b64 dashdemux: Improve live stream manifest update repositioning
When updating the manifest the timestamps on it might have changed a little
due to rounding and timescale conversions. If the change makes the timestamp
of the current segment to go up it makes dashdemux reposition to the previous
one causing one extra unnecessary download.

So when repositioning add an extra 10 microseconds to cover for that rounding
issues and increase the chance of falling in the same segment.

Additionally, also improve the time used when the client is already after the
last segment. Instead of using the last segment starting timestamp use the
final timestamp to make it reposition to the next one and not to the one that
has already been downloaded.
2015-05-13 13:39:31 -03:00
Thiago Santos
7de9fbc122 dashdemux: add more protection when acessing gptrarray entries
The glib structure doesn't do range checking so we have to do it
ourselves.

Also adds some more debugging messages
2015-05-13 13:39:24 -03:00
Thiago Santos
f298fca8ad dashdemux: remove unused functions
These functions of directly getting and setting segment indexes
are no longer useful as now we need 2 indexes: repeat and segment
index.

The only operations needed are advance_segment, going back to the
first one or seeking for a timestamp.
2015-05-13 13:39:18 -03:00
Thiago Santos
d617139ee7 dashdemux: reuse seeking function to reduce repeated code
Instead of writing a seek routine, just use the mpdparser function.

Also remove function that is not needed anymore
2015-05-13 13:35:14 -03:00
Thiago Santos
57a2105a31 dashdemux: refactor segment iteration for better performance
Segments are now stored with their repeat counts instead of spanding
them to multiple segments. This caused advancing to the next segment
using a single index to have to iterate over the whole list every time.

This commit addresses this by storing both the segment index as well
as the repeat index and makes advancing to next segment just an
increment of the repeat or the segment index.
2015-05-13 13:35:14 -03:00
Thiago Santos
6344f86e44 dashdemux: improve mpd parsing for repeated segment entries
Use a single segment to represent it internally to avoid using too
much memory. This has the drawback of issuing a linear search to
find the correct segment to play but this can be fixed by using
binary searches or caching the current position and just looking
for the next one.

https://bugzilla.gnome.org/show_bug.cgi?id=748369
2015-05-13 13:35:14 -03:00
Jun Xie
9e6198d9ef dashdemux: set default @startNumber and also avoid wrong overwrite
Set default @startNumber to 1, if @startNumber is missing at all level.
Also avoid incorrect overwriting inherited value.

https://bugzilla.gnome.org/show_bug.cgi?id=746347
2015-03-24 16:35:59 -03:00
xixi
5a1ed14c3c dashdemux: fetch wrong segment at the end of Period
Fix check for end of Period time to avoid trying
to fetch a segment that doesn't exist

https://bugzilla.gnome.org/show_bug.cgi?id=746038
2015-03-15 12:02:58 +00:00
Mathieu Duponchelle
bd70c73a8a dashdemux: implement get_presentation_offset.
To account for presentationTimeOffset as per section 7.2.1 .

https://bugzilla.gnome.org/show_bug.cgi?id=745455
2015-03-10 15:17:37 +01:00
Mathieu Duponchelle
793b4bca93 gstmpdparser: Really set the default value for startNumber.
+ The specs ask for a default of 1, the current code only did
 set a default when the field was present.

https://bugzilla.gnome.org/show_bug.cgi?id=745455
2015-03-10 15:17:37 +01:00
Thiago Santos
81b555838a dashdemux: protect against malformed isombff format
Be more careful around malformed mpds that announce using
isombff profile but actually are regular mpds
2015-02-18 08:19:59 -03:00
Thiago Santos
cb94de5d2f dashdemux: set proper stream type to streams
strncmp returns 0 when it compares equal and not a
boolean
2015-02-12 11:16:25 -03:00
Sebastian Dröge
80e02cbdf9 Constify some static arrays everywhere 2015-01-21 10:18:50 +01:00
Thiago Santos
3b920131f0 dashdemux: add log message about segment time information
For debugging purposes
2015-01-19 08:37:59 -03:00
David Waring
6dca8f5cce dashdemux: Fix detection for the end of segment.
The segment start time is calculated as the offset into the current segment.
The old condition to detect the end of period (i.e. segment start time >
period start + period duration) failed when the period start was not 0 since
the segment start time does not take the period start time into account.
Fix this detection by only comparing the segment start to the period duration.

https://bugzilla.gnome.org/show_bug.cgi?id=733369
2015-01-16 17:07:22 -03:00
Thiago Santos
b40e5decb2 dashdemux: check for profiles
Check for available profiles to enable certain features for
dash playback. For now we check for the ISOFF On Demand 2011 profile.
2015-01-16 15:00:11 -03:00
Thiago Santos
afc392c47b dashdemux: do not try to ref null pointer
Playlists might be missing the availability start time, so check for
it before trying to ref the object
2014-12-29 11:39:22 -03:00
Thiago Santos
a862ba4b45 dashdemux: run gst-indent on mpdparser
Run gst-indent on mpdparser to have it stop complaining on every
commit
2014-12-29 11:39:22 -03:00
David Waring
1c0c6b6f48 dashdemux: Change period when setting by period id.
Make gst_mpd_client_set_period_id set the current period index when it finds a
period with a matching period id.

https://bugzilla.gnome.org/show_bug.cgi?id=741322
2014-12-10 16:22:31 -03:00
David Waring
95c3fdc193 dashdemux: Find the current period in a live stream
Start from the correct period on a live stream

https://bugzilla.gnome.org/show_bug.cgi?id=737421
2014-12-02 14:22:09 -03:00
Thiago Santos
58a1b0d058 dashdemux: port to adaptive demux 2014-11-30 21:56:25 -03:00
David Waring
29f1f4533e dash: Use GstUri to join URIs 2014-09-29 12:22:19 +03:00
George Kiagiadakis
ea90ceac01 dashdemux: support downloading segments in reverse order
When a seek with a negative rate is requested, find the target
segment where gstsegment.stop belongs in and then download from
this segment backwards until the first segment.

This allows proper reverse playback.
2014-08-07 16:52:37 +03:00
Sebastian Dröge
ae679506b1 dashdemux: Always use the redirect target to resolve relative URIs
But redownload the playlists from the original URI if it's not
a permanent redirect.
2014-05-28 12:47:51 +02:00
Thiago Santos
16d969b945 dashdemux: mpdparser: properly unref gstdatetime
Avoid leaking the GstDateTime instances when summing dates

CID #1212143
2014-05-13 11:22:58 -03:00
Thiago Santos
288e8d5c0e dashdemux: mpdparser: avoid double free of segment timeline node
The parsing function already frees the old value (if any), avoid a double
free by not freeing it before calling the function without setting the
pointer to NULL

Coverity ID: 1212178
2014-05-13 10:45:29 -03:00
Thiago Santos
64bea0252b dashdemux: mpdparser: avoid double free
The _parse_url function already frees the previous pointer, avoid
freeing it before without setting to null or we have a double free.

Coverity ID: 1212181
Coverity ID: 1212180
Coverity ID: 1212179
2014-05-13 10:13:37 -03:00
Edward Hervey
651a4ae2e7 dash: Don't leak GstActiveStream
CID #1212142
2014-05-13 13:52:48 +02:00
Wim Taymans
6c014f7e36 mpdparse: only add location when node existed
Actually return FALSE when the location node was non-existing
Only add the location node when it existed
2014-04-03 11:48:07 +02:00
Thiago Santos
3d2f3bcf62 dashdemux: remove unnecessary variable
Instead of using 2 indexes that were actually the same, use only
one. Saves a variable.
2014-01-09 09:13:48 -03:00
Thiago Santos
cea909b877 dashdemux: fix seeking when the mpd uses a segment template
Remove the dashdemux seeking function to use the one implemented
in mpdparser as it is more complete. This also makes dashdemux not
crash when seeking on streams that use segment templates.
2014-01-09 09:11:23 -03:00
Thiago Santos
d353d229b1 dash: detect EOS when segments are generated by template
Use the Period duration do know when to end the stream
2013-12-24 17:07:52 -03:00
Thiago Santos
1d2de4a034 dashdemux: run gst-indent
Lots of indentation issues making it very annoying to commit
because of the indent hook. Fix this for once.
2013-12-24 17:07:51 -03:00
Thiago Santos
08636f3bab dashdemux: expose all streams
always expose all streams instead of only exposing one of each type.

This is more aligned with gstreamer's way of working. Allows the user
to select the stream that it wants to use by linking its pad and leaving
the unused ones as unlinked.
2013-12-24 17:07:51 -03:00
Alex Ashley
42fd04ce48 dashdemux: stop fetching live fragments that don't yet exist
There is an issue for live streams where download_loop will keep
downloading segments until it gets a 404 error for a segment
that has not yet been published. This is a problem because this
request for a segment that doesn't exist will propagate all the
way back to the origin server(s). This means that dashdemux causes
extra load on the origin server(s) for segments that aren't yet
available.

This patch uses availabilityStartTime, period
and the host's idea of UTC to decide if a fragment is available to
be requested from an HTTP server and filter out requests for fragments
that are not yet available.

https://bugzilla.gnome.org/show_bug.cgi?id=701404
2013-10-03 09:15:37 -03:00
Josep Torra
0b54b0568d dashdemux: Fix warnings when building in OS X Snow Leopard
gstmpdparser.h:530: warning: type qualifiers ignored on function return type
gstmpdparser.c:4177: warning: type qualifiers ignored on function return type
2013-08-30 21:36:19 +02:00
Chris Bass
7f21226956 dashdemux: offset segment numbers by startNumber
For SegmentTemplate elements containing a startNumber attribute, the
`number' member of GstMediaSegments should be offset by the value of
startNumber; however, this is not currently the case. As a result, the
first URI(s) requested by the download loop will be wrong.

This commit ensures that segment numbers will be offset by startNumber
when one is present in a SegmentTemplate element.

https://bugzilla.gnome.org/show_bug.cgi?id=705661
2013-08-16 11:15:47 -03:00
Chris Bass
19a45554bf dashdemux: remove incorrect timestamp scaling.
When using a SegmentTemplate element, the timestamps of the buffers
output by dashdemux are incorrect, causing problems downstream.

The reason is that GstMediaSegment start times are calculated (in
gst_mpdparser_get_chunk_by_index) by multiplying segment index by
segment duration and then scaling the result according the `timebase'
attribute from the MPD. However, the segment duration is already a
GstClockTime (i.e., it has already been scaled according to the timebase
from the MPD and converted to a nanosecond value), so multiplying it by
the segment index will give the correct timestamp without the need for
any further scaling.

https://bugzilla.gnome.org/show_bug.cgi?id=705679
2013-08-16 10:22:21 -03:00
Edward Hervey
97426a1caa all: Fix for GST_DISABLE_GST_DEBUG
Where applicable, remove methods that don't do anything different than
the default implementation.
2013-07-29 09:42:12 +02:00
Thiago Santos
5a5e66ec90 dashdemux: handle live playback resync
During a live stream it is possible for dashdemux to lag behind on a
slow connection or to rush ahead of the connection os too fast.

For the first case it is necessary to jump some segments ahead to be able to
continue playback as old segments are usually deleted from the server.

For the later, dashdemux should wait a little before attempting another
download do give time to the server to produce a new segment
2013-07-08 23:40:14 -03:00
Thiago Santos
b316d8a677 dashdemux: fix template based segment generation
When using a template based segment list, do not try to
contruct a finite segment list for the limits of the available periods.

We might not know when the period ends (for live streams) and we can
always create the segment on demand when requested by dashdemux,
avoiding use of some memory and cpu when re-creating this list.
2013-07-08 23:39:49 -03:00
Thiago Santos
a8a355108a dashdemux: use more appropriate data structures for parsing
Replaces the 2 likely larger lists with more appropriate structures
to improve performance.

Replaces S nodes GList for a GQueue, this reduces latency to startup
because of traversing the list just append an element.

Replaces the processed media segments GList for a GPtrArray as it is
constantly acessed by index during playback.
2013-07-08 23:39:49 -03:00
Thiago Santos
9a38127467 dashdemux: prevent assertion when duration is unknown
Duration from segment being unknown is a issue from the MPD and not
a programming issue, so the assert isn't useful here. Instead check
and return an error code so the caller can fallback to alternatives
2013-07-03 19:11:45 -03:00
Thiago Santos
788757dc1f dashdemux: various cleanups
Removing unused function, replacing // comments with /* */ and
replacing some GST_WARNING with GST_INFO/_DEBUG as they are meant
to be
2013-07-03 15:34:41 -03:00
Alex Ashley
5ad2a2d161 dashdemux: Change first fragment selection for live streams
When dashdemux selects its first fragment, it always selects the
first fragment listed in the manifest. For on-demand content,
this is the correct behaviour. However for live content, this
behaviour is undesirable because the first fragment listed in the
manifest might be some considerable time behind "now".

The commit uses the host's idea of UTC and tries to find the
oldest fragment that contains samples for this time of day.

https://bugzilla.gnome.org/show_bug.cgi?id=701509
2013-07-03 15:34:30 -03:00
Thiago Santos
5c480dfc13 dashdemux: only generate index segment uri if there is a template
Simple fix to avoid an assertion.
2013-07-03 10:23:45 -03:00
Greg Rutz
5920ee2777 dashdemux: Implement inheritance for certain MPD elements
According to the MPEG-DASH spec, certain elements (i.e.
SegmentBase, SegmentTemplate, and SegmentList) should inherit
attributes from the same elements in the containing AdaptationSet
or Period.

Updated the SegmentBase, SegmentTemplate, and SegmentList parsers
to properly inherit attributes from the corresponding elements in
AdaptationSet and/or Period.

https://bugzilla.gnome.org/show_bug.cgi?id=702677
2013-07-03 10:23:45 -03:00