Commit graph

198 commits

Author SHA1 Message Date
Florin Apostol
19d604e92f dashdemux: remove unreachable code
The stream->cur_seg_template is set to the lowest available segment
template (representation or adaptation or period, in this order).
Because the template elements are inherited, the lowest template will
have all the elements the parents had, so there is no need to check the
parent for an element that is not found in the child (eg initialisation
or index).

https://bugzilla.gnome.org/show_bug.cgi?id=752714
2015-11-02 11:37:19 +00:00
Vincent Penquerc'h
045a03c14a mpdparser: add some checks to duration parsing
https://bugzilla.gnome.org/show_bug.cgi?id=752336
2015-11-02 11:36:12 +00:00
Florin Apostol
7dca9fb3f4 dashdemux: added duration format validation
https://bugzilla.gnome.org/show_bug.cgi?id=752336
2015-11-02 11:36:12 +00:00
Luis de Bethencourt
f28fad6e83 dashdemux: fix memory leak
Free new_mpd, allocated with g_slice_new(), before going out of scope in
goto error.

CID 1338050
2015-11-02 11:27:43 +00:00
Vincent Penquerc'h
e48e68416c mpdparser: make durations unsigned where appropriate
The standard does not seem to make any particular explicit not
implicit reference to the signedness of durations, and the code
does not rely on such, nor on the negativity of the -1 value
that's used as a placeholder when a duration property is not
present in the XML.

https://bugzilla.gnome.org/show_bug.cgi?id=750847
2015-10-30 16:29:46 +00:00
Florin Apostol
d6e805a283 dashdemux: inherit bitstreamSwitching from Period to AdaptationSet
https://bugzilla.gnome.org/show_bug.cgi?id=752340
2015-10-30 15:58:36 +00:00
Florin Apostol
013655d886 dashdemux: inherited segment URLs are ignored if they are defined again in a lower SegmentList
According to the standard:
"SegmentBase, SegmentTemplate and SegmentList shall inherit
attributes and elements from the same element on a higher level.
If the same attribute or element is present on both levels,
the one on the lower level shall take precedence over the one
on the higher level."

gst_mpdparser_parse_segment_list_node will now discard any inherited
segment URLs if the parsed element defines some too.

https://bugzilla.gnome.org/show_bug.cgi?id=751832
2015-10-30 14:31:21 +00:00
Alex Ashley
c8ef39cac7 dashdemux: provide a default suggestedPresentationDelay
If MPD@suggestedPresentationDelay is not present in the manifest,
dashdemux selects the fragment closest to the most recently generated
fragment. This causes a playback issue because this choice does not allow
the DASH client to build up any buffer of downloaded fragments without
pausing playback. This is because by definition new fragments appear on
the server in real-time (e.g. if segment duration is 4 seconds, a new
fragment will appear on the server every 4 seconds). If the starting
playback position was n*segmentDuration seconds behind "now", the DASH
client could download up to 'n' fragments faster than realtime before it
reached the point where it needed to wait for fragments to appear on the
server.

The MPD@suggestedPresentationDelay attribute allows a content publisher
to provide a suggested starting position that is behind the current
"live" position.

If the MPD@suggestedPresentationDelay attribute is not present, provide
a suitable default value as a property of the dashdemux element. To
allow the default presentation delay to be specified either using
fragments or seconds, the property is a string that contains a number
and a unit (e.g. "10 seconds", "4 fragments", "2500ms").
2015-10-29 13:26:46 +00:00
Vincent Penquerc'h
7443f35249 dash_mpd: restrict segment template format strings to %0[0-9]*d as per spec
https://bugzilla.gnome.org/show_bug.cgi?id=751735
2015-10-29 12:04:31 +00:00
Florin Apostol
4eea6c3833 dashdemux: segment template parsing: added support for %d
Added support for %d in template identifier.
Added testcases for %d, %3d, %0-4d identifier formats.
2015-10-29 11:58:47 +00:00
Florin Apostol
933d367440 dashdemux: corrected parsing of segment templates
Corrected the parsing of a segment template string.
Added unit tests to test the segment template parsing.
All reported problems are now correctly handled.

https://bugzilla.gnome.org/show_bug.cgi?id=751735
2015-10-29 11:54:34 +00:00
Florin Apostol
566e84cec1 dashdemux: fixed crash when segment timeline list is greater than segment url list
When building the media segment list using a SegmentList node, the
gst_mpd_client_setup_representation function will iterate through the
list of S nodes and will expect to find a matching SegmentUrl node. If
one does not exist, the code made an illegal memory access.

https://bugzilla.gnome.org/show_bug.cgi?id=752496
2015-10-29 10:20:45 +00:00
Vincent Penquerc'h
5c8f702116 mpdparser: do not dereference profiles is absent
These are used to apply restrictions on what the MPD file may
use, so no profile means no restrictions.

Besides, nothing actually uses the profiles (yet) anyway.

https://bugzilla.gnome.org/show_bug.cgi?id=750869
2015-10-29 10:20:45 +00:00
Florin Apostol
cdfec06092 dashdemux: parser rejects negative values for mediaPresentationDuration
https://bugzilla.gnome.org/show_bug.cgi?id=752326
2015-10-29 10:20:45 +00:00
Florin Apostol
7c2746f741 dashdemux: corrected parsing of negative values into unsigned data
https://bugzilla.gnome.org/show_bug.cgi?id=752429
2015-10-29 10:20:45 +00:00
Vincent Penquerc'h
54d93f597d mpdparser: forbid negative values for duration
https://bugzilla.gnome.org/show_bug.cgi?id=752492
2015-10-28 15:43:00 +00:00
Florin Apostol
c763d1e8fd dashdemux: parser rejects XMLs with negative period duration
https://bugzilla.gnome.org/show_bug.cgi?id=752329
2015-10-28 15:41:17 +00:00
Vincent Penquerc'h
60133b1472 mpdparser: check segment lists have either duration or timeline
And add error checking along the way.

Add duration where appropriate so unit tests still pass.

https://bugzilla.gnome.org/show_bug.cgi?id=751650
2015-10-28 15:34:29 +00:00
Vincent Penquerc'h
b8df6cc316 mpdparser: validate representation set identifier
It must have no whitespace, and must comply with RFC 1738 when
used to build a URL.

https://bugzilla.gnome.org/show_bug.cgi?id=750852
2015-10-28 15:11:50 +00:00
Sebastian Dröge
1f7156d478 mpdparser: Set default last_byte_pos to -1
The value is optional in the range, and if it is absent it means we should
download until the end of stream. Not until position 0.

https://bugzilla.gnome.org/show_bug.cgi?id=748316
2015-10-14 16:57:56 +03:00
Florin Apostol
1d1094b71b dashdemux: fixed has_next_period
gst_mpd_client_has_next_period now calls gst_mpd_client_setup_media_presentation
to refresh the period information.

https://bugzilla.gnome.org/show_bug.cgi?id=756186
2015-10-07 15:50:08 +01:00
Chris Bass
69f86e51b2 dashdemux: create src pads for subtitle streams.
Create src pads for Representations that contain timed-text subtitles,
both when the subtitles are encapsulated in ISO BMFF (i.e., the
Representation has mimeType "application/mp4") and when they are
unencapsulated (i.e., the Representation has mimeType
"application/ttml+xml").

https://bugzilla.gnome.org/show_bug.cgi?id=747774
2015-09-26 00:50:55 +02:00
Sebastian Dröge
93d85bd361 dashdemux: Implement lazy-loading of external periods
https://bugzilla.gnome.org/show_bug.cgi?id=752230
2015-09-25 23:52:28 +02:00
Sebastian Dröge
b70dab8f27 mpdparser: Load OnLoad external resources immediately instead of on demand
https://bugzilla.gnome.org/show_bug.cgi?id=752230
2015-09-25 23:52:28 +02:00
Sebastian Dröge
49931eda69 mpdparser: Add support for loading external SegmentLists
https://bugzilla.gnome.org/show_bug.cgi?id=752230
2015-09-25 23:52:28 +02:00
Sebastian Dröge
51e8624d56 mpdparser: Add support for loading external AdaptationSets
https://bugzilla.gnome.org/show_bug.cgi?id=752230
2015-09-25 23:52:28 +02:00
Sebastian Dröge
97f5b82bf6 mpdparser: Implement loading of external Period nodes
The same has to be done for AdaptationSet and SegmentList nodes still.

Also this does not correctly implement the semantics: by default Period (and
other nodes) should only be loaded when needed, not in the very beginning. We
need to implement lazy loading for them, which means adjusting
gst_mpd_client_setup_media_presentation().

https://bugzilla.gnome.org/show_bug.cgi?id=752230
2015-09-25 23:52:28 +02:00
Sebastian Dröge
572e54574b mpdparser: Store an URI downloader in the parser for downloading additional MPD resources if needed
https://bugzilla.gnome.org/show_bug.cgi?id=752230
2015-09-25 23:52:28 +02:00
Sebastian Dröge
07ee57228b mpdparser: Parse xlink attributes from Period, AdaptationSet and SegmentList
We still have to do something useful with them, like actually loading the
content behind the URL.

https://bugzilla.gnome.org/show_bug.cgi?id=752230
2015-09-25 23:52:28 +02:00
Sebastian Dröge
6cafc64416 mpdparser: If no Initialization is present in the SegmentBase, assume it is before the indexRange
https://bugzilla.gnome.org/show_bug.cgi?id=755132
2015-09-25 23:52:28 +02:00
Sebastian Dröge
a25253130b mpdparser: Only check stream->segments for a repeated last segment if we have a static list of segments
Otherwise we'll crash, trying to derefence NULL. And if we have no static list
of segments, we can't have repeated segments anyway.

Regression introduced by cfe2871a5e

https://bugzilla.gnome.org/show_bug.cgi?id=755411
2015-09-22 15:03:13 +02:00
Vincent Penquerc'h
50400fa2a6 mpdparser: support for negative repeat count in segments
Implements negative repeat segment fields, defined in 5.3.9.6.1.
2015-09-16 09:44:20 +01:00
Vincent Penquerc'h
69bfa8222f mpdparser: properly read signed r values for S elements
The spec defines these as signed in 5.3.9.6.1.
Since we don't support this behavior, warn and default to 0
(non repeating), which is the spec's default when the value
is not present.

https://bugzilla.gnome.org/show_bug.cgi?id=752480
2015-09-16 09:44:19 +01:00
Vincent Penquerc'h
23ea8ccb43 mdpparser: catch failures to parse
https://bugzilla.gnome.org/show_bug.cgi?id=752480
2015-09-16 09:44:19 +01:00
Sebastian Dröge
c9f60db2d4 mpdparser: Don't consider period start times in periods with segment lists either
https://bugzilla.gnome.org/show_bug.cgi?id=754222
2015-09-14 19:53:18 +02:00
Sebastian Dröge
0d0455e346 dashdemux: Export the period start time to the base class
https://bugzilla.gnome.org/show_bug.cgi?id=754222
2015-09-14 19:53:03 +02:00
Sebastian Dröge
b5697b8ced Revert "dashdemux: Subtract the period start time from the presentation offset"
This reverts commit 626a8f0a74.

This allows us to get the plain presentation offset and the period start time
separately. We have to adjust the timestamp by the presentation offset, but
the period start time should only adjust the stream time and running time.

https://bugzilla.gnome.org/show_bug.cgi?id=752409
2015-09-14 19:53:03 +02:00
Sebastian Dröge
bb05bbafd5 Revert "dashdemux: Include the period start in the fragment timestamps in all cases"
This reverts commit e671ad25a9.

The timestamps should restart at 0 again for each period, but we have to
adjust the segment to map those timestamps to the actual stream time and
running time of that period.

Otherwise we would have timestamps that conflict with the ones from the tfdt
inside the MP4 container, which are restarting at 0 for each period.

https://bugzilla.gnome.org/show_bug.cgi?id=752409
2015-09-14 19:53:03 +02:00
Sebastian Dröge
cfe2871a5e mpdparser: Consider the repeat count when checking if a segment is the last one
Otherwise we play only the first repetition of the last segment and then EOS.

https://bugzilla.gnome.org/show_bug.cgi?id=752480
2015-09-14 19:49:14 +02:00
Vincent Penquerc'h
6d1eda9391 mpdparser: fix period start time scaling
This GstStreamPeriod start value is expressed in nanoseconds,
and the glib time addition function expects microseconds.
There seems to have been a confusion with GstPeriodNode's start
field, which is expressed in milliseconds.

Additionally, add a warning if the timestamp modification did
not succeed, and NULL was returned.
2015-09-07 12:52:03 +01:00
Sebastian Dröge
551e7b97f3 dashdemux: Handle encoding specified in the <xml> element when dumping nodes
Previous patch did not handle the case where an encoding (e.g. UTF-8) is
specified in the <xml ?> element. Added an extra test for with and without
encoding.

https://bugzilla.gnome.org/show_bug.cgi?id=753813
2015-08-19 21:33:47 +03:00
Alex Ashley
2ebebdbfbb dashdemux: replace xmlNodeDump with xmlNodeDumpOutput
When running on an STB, the function
gst_mpdparser_get_xml_node_as_string causes a segmentation fault. This
code works correctly on a Linux desktop.

Looking at the libxml documentation, the xmlNodeDump is deprecated.
Replacing the use of xmlNodeDump with xmlNodeDumpOutput fixes the
segfault on the STB and removes the use of the deprecated function.
2015-08-19 16:30:58 +03:00
Sebastian Dröge
31d381d5f8 mpdparser: Free UTCTiming struct if there are no values associated with it
CID 1316479
2015-08-16 12:52:51 +02:00
Alex Ashley
95c705ae8f dashdemux: add support for UTCTiming elements for clock drift compensation
Unless the DASH client can compensate for the difference between its
clock and the clock used by the server, the client might request
fragments that either not yet on the server or fragments that have
already been expired from the server. This is an issue because these
requests can propagate all the way back to the origin

ISO/IEC 23009-1:2014/Amd 1 [PDAM1] defines a new UTCTiming element to allow
a DASH client to track the clock used by the server generating the
DASH stream. Multiple UTCTiming elements might be present, to indicate
support for multiple methods of UTC time gathering. Each element can
contain a white space separated list of URLs that can be contacted
to discover the UTC time from the server's perspective.

This commit provides parsing of UTCTiming elements, unit tests of this
parsing and a function to poll a time server. This function
supports the following methods:
    urn:mpeg:dash:utc:ntp:2014
    urn:mpeg:dash:utc:http-xsdate:2014
    urn:mpeg:dash:utc:http-iso:2014
    urn:mpeg:dash:utc:http-ntp:2014

The manifest update task is used to poll the clock time server,
to save having to create a new thread.

When choosing the starting fragment number and when waiting for a
fragment to become available, the difference between the server's idea
of UTC and the client's idea of UTC is taken into account. For example,
if the server's time is behind the client's idea of UTC, we wait for
longer before requesting a fragment

[PDAM1]: http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=66068

dashdemux: support NTP time servers in UTCTiming elements

Use the gst_ntp_clock to support the use of an NTP server.

https://bugzilla.gnome.org/show_bug.cgi?id=752413
2015-08-14 06:47:20 -03:00
Thiago Santos
620af5b04b dash: mpdparser: plug leak in segmenttemplate parsing
Only copy the values from the parent if the current node doesn't
have that value, they were being copied from the parent and
then overwriten by the child node, leaking the parent's copy
2015-08-01 16:11:07 -03:00
Florin Apostol
a7751aa967 dashdemux: gst_mpdparser_get_xml_prop_duration sets default value in case of parsing errors
The gst_mpdparser_get_xml_prop_duration function will set the
property_value to the default_value in case the parsing fails.

https://bugzilla.gnome.org/show_bug.cgi?id=752426
2015-07-27 12:37:09 -03:00
Florin Apostol
90b7c137b6 dahdemux: avoid overflows in computation of segment start time and duration
Used gst_util_uint64_scale to avoid overflows when segment start time
or duration is computed.

https://bugzilla.gnome.org/show_bug.cgi?id=752620
2015-07-24 10:09:19 -03: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
Florin Apostol
e12d3d9be2 dashdemux: default timescale is 1
default timescale value should be 1, not 0.

https://bugzilla.gnome.org/show_bug.cgi?id=752414
2015-07-16 20:05:58 +01:00
Florin Apostol
8b558d68cb dashdemux: free prop_string only after it's no longer needed
https://bugzilla.gnome.org/show_bug.cgi?id=752419
2015-07-16 19:57:40 +01:00