Commit graph

133 commits

Author SHA1 Message Date
Sebastian Dröge
95eb1aa49c dashdemux: Subtract the period start when seeking based on a template
Otherwise we will look for segments after the period usually. The seek
timestamp is relative to the start of the first period and we have to
select a segment relative to the current period's start.
2015-06-25 23:36:09 +02:00
Sebastian Dröge
e671ad25a9 dashdemux: Include the period start in the fragment timestamps in all cases
We didn't do this for fragments that are generated on demand from a template,
only for the other cases when they were all generated upfront. This caused
fragment timestamps to start from 0 again for each new period.
2015-06-25 23:35:46 +02:00
Florin Apostol
fa9b03186a dash: Correct check for valid timeShiftBufferDepth
If not set, the timeShiftBufferDepth has a default value of -1.
The standard says that this should be interpreted as infinite.

The gst_mpd_client_check_time_position function incorrectly compares
timeShiftBufferDepth with 0 instead of -1 to determine if it was set.

https://bugzilla.gnome.org/show_bug.cgi?id=751500
2015-06-25 16:27:18 +02:00
Florin Apostol
dbf12ab760 dashdemux: Corrected duration argument for gst_mpd_client_add_media_segment call
The last parameter of gst_mpd_client_add_media_segment function is a
duration. But when called from gst_mpd_client_setup_representation, the
last argument was wrongly set to PeriodEnd

https://bugzilla.gnome.org/show_bug.cgi?id=751449
2015-06-25 10:16:24 +02:00
Florin Apostol
93f08347de dashdemux: incorrect use of period start
The period start information, calculated in gst_mpd_client_setup_media_presentation
function is stored in stream_period->start. The information read from
xml file and stored in stream_period->period->start is not changed.

If the xml file does not contain the period start information,
stream_period->period->start will be -1.

The function gst_mpd_client_get_next_segment_availability_end_time wants to
use period start time, but incorrectly uses stream_period->period->start
(value from xml file, which could be -1) instead of stream_period->start
(computed value)

https://bugzilla.gnome.org/show_bug.cgi?id=751465
2015-06-25 10:14:30 +02:00
Florin Apostol
8336d7a60b dashdemux: corrected computation of period's duration
According to ISO/IEC 23009-1:2014(E), chapter 5.3.2.1
"The Period extends until the PeriodStart of the next Period, or until
the end of the Media Presentation in the case of the last Period."

This means that a configured value for optional attribute period duration
should be ignored if the next period contains a start attribute or it is
the last period and the MPD contains a mediaPresentationDuration attribute.

https://bugzilla.gnome.org/show_bug.cgi?id=750797
2015-06-22 13:47:54 +02:00
Florin Apostol
d268f812eb dashdemux: added warnings in gst_mpd_client_setup_streaming function
Added some warning messages in gst_mpd_client_setup_streaming to help
debug situations when the function will return FALSE.

Renamed a wrongly spelled variable.

https://bugzilla.gnome.org/show_bug.cgi?id=751149
2015-06-18 12:40:01 -03:00
Florin Apostol
9f56cc27ab dashdemux: fixed getting representation based on max bandwidth
The gst_mpdparser_get_rep_idx_with_max_bandwidth function assumes
representations are ordered by bandwidth and incorrectly returns the
first one when wanting the one with minimum bandwidth.

Corrected gst_mpdparser_get_rep_idx_with_max_bandwidth function to get the
correct representation in case max_bandwidth parameter is 0.

https://bugzilla.gnome.org/show_bug.cgi?id=751153
2015-06-18 11:29:45 -03:00
Florin Apostol
b23e4452a2 dashdemux: fixed segfault for missing default namespace
Added a check for a_node->ns before accessing a_node->ns->href in
gst_mpdparser_get_xml_node_namespace. This could happen if the xml
is missing the default namespace.

https://bugzilla.gnome.org/show_bug.cgi?id=750866
2015-06-12 22:45:51 +02:00
Alex Ashley
5beeccdba2 dashdemux: fix error calculating large presentationTimeOffset values
If the presentationTimeOffset attribute of a DASH manifest contains
a value that is larger than 2^32, gstmpdparser incorrectly calculates
the stream's presentation time offset. This is due to two bugs:

1: Using gst_mpdparser_get_xml_prop_unsigned_integer rather than
   gst_mpdparser_get_xml_prop_unsigned_integer_64 to parse the
   attribute
2: gst_mpd_client_setup_representation multiplying the value by
   GST_SECOND and then dividing by timescale

https://bugzilla.gnome.org/show_bug.cgi?id=750804
2015-06-11 19:41:11 +02:00
Sebastian Dröge
9bcddde9bc mpdparser: Fix inverted logic introduced in last commit 2015-06-05 14:33:57 +02:00
Sebastian Dröge
15de547760 mpdparser: Calculate the number of segments we have when a segment template instead of a list is used
Otherwise we would just continue downloading new files forever until we get
404 for the first one, and then error out instead of going EOS.
2015-06-05 14:11:47 +02:00
Sebastian Dröge
ec226e856d Revert "mpdparser: Don't consider streams with a known media presentation duration as live"
This reverts commit 37011e5198.

This change was actually completely unnecessary, the streams in question are
marked as static and are not considered live anyway.
2015-06-05 13:28:39 +02:00
Sebastian Dröge
37011e5198 mpdparser: Don't consider streams with a known media presentation duration as live 2015-06-05 13:21:55 +02:00
Sebastian Dröge
2b207c0b65 mpdparser: Don't crash in debug output if stream->segments is NULL 2015-06-04 15:58:46 +02:00
Sebastian Dröge
64a2dcf582 mpdparse: Clamp seek times to the availabilityStartTime
Otherwise we will seek to negative times, which are interpreted as unsigned
integers later.
2015-06-04 13:36:05 +02:00
Sebastian Dröge
f9ada426d4 mpdparser: Improve debug output a bit when advancing segments 2015-06-04 13:13:39 +02:00
Sebastian Dröge
60047b6b92 mpdparser: Use 64 bit integer format strings when passing a 64 bit integer
Otherwise we'll only get half of its bits printed on 32 bit architectures.

For this, promote the %d-style format strings to something that accepts
64 bit integers with G_GINT64_MODIFIER.
2015-06-04 11:05:07 +02:00
Sebastian Dröge
1be223fdc3 mpdparse: Validate format strings before using them
Using format strings from an untrusted source without validation is
calling for problems, and at least allows to remotely crash your application.
If not worse.
2015-06-04 10:47:07 +02:00
Sebastian Dröge
88d8dfd9c6 mpdparser: Add the startNumber as offset to the segment index when using a template 2015-06-03 20:03:59 +02:00
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