Commit graph

347 commits

Author SHA1 Message Date
Sebastian Dröge
0dcb1e4ecc dashdemux: Add assertion for preventing of access after the end of the sidx entries array
Better crash cleanly here than reading some random numbers from memory.
2017-03-15 13:27:23 +02:00
Seungha Yang
a9c34fb9e3 dashdemux: Advance subfragment only if any exist
SIDX based playback is not restricted to SegmentBase, but it possible
with SegmentList/SegmentTemplate. In the latter case, each fragment
has its own SIDX box and might be subdivided into subfragment.
So, demux should not assume that the end of subfragment is the end
of stream. Moreover, should try advance subfragment only if there
are remaining subfragments.

With additional fixes by Sebastian Dröge <sebastian@centricular.com>

https://bugzilla.gnome.org/show_bug.cgi?id=776200
2017-03-14 19:15:28 +02:00
Wojciech Przybyl
8eb87ce5dc dashdemux: fix default suggestedPresentationDelay
When MPD@suggestedPresentationDelay is not present in the MPD,
dashdemux can provide default suggestedPresentationDelay. However
when applying default value of suggestedPresentationDelay, the value
should be subtracted from current time, not added to it. When streams
setup is performed and live point is calculated, we have to go to the
wall clock (current time) minus suggestedPresentationDelay, if we tried
to start with current time plus suggestedPresentationDelay, we would
be asking for future stream, which has not yet been recorded. Also
the value needs to be converted from ms to us.

https://bugzilla.gnome.org/show_bug.cgi?id=764726
2017-03-02 20:11:55 +02:00
Sebastian Dröge
ef70cd48c6 dashdemux: Fix potential NULL pointer dereference
CID 1399700
2017-02-28 15:53:10 +02:00
Seungha Yang
fe9d778fa3 dashdemux: Do pending seek when SIDX is found
Parsing SIDX box was allowed even if "indexRange" attribute does not appear
for On-Demand profile. However, actual seeking using SIDX index did not happen
since download loop keep working on.
To use SIDX index in that case, demux should try it in the next download loop.

https://bugzilla.gnome.org/show_bug.cgi?id=777394
2017-01-18 13:14:44 +02:00
WeiChungChang
c9fbf3459a dashdemux: Fix issue when manifest update sets slow start without passing necessary header & caps changes downstream
https://bugzilla.gnome.org/show_bug.cgi?id=777206
2017-01-18 13:13:15 +02:00
Seungha Yang
4523cff147 dashdemux: Add first_offset of sidx box to base offset
sidx has "first_offset" syntax which represents the distance in bytes
from anchor point to media fragment. If present, we should adjust
sidx_base_offset.

https://bugzilla.gnome.org/show_bug.cgi?id=776431
2016-12-23 12:16:10 +02:00
Seungha Yang
c0540fb773 dashdemux: Ensure sidx parsing when updating fragment info
Fix seek fail with On-Demand profile mpd which has no indexRange attribute

https://bugzilla.gnome.org/show_bug.cgi?id=776431
2016-12-23 12:16:10 +02:00
Seungha Yang
998c8ce246 dashdemux: Drain remaining buffer in adapter
Previous patch allows sidx box parsing from incoming buffers.
Since the incoming buffer boundary might be over sidx box,
there can be remaining buffer in isobmff parser adapter.

https://bugzilla.gnome.org/show_bug.cgi?id=776352
2016-12-22 14:12:58 +02:00
Seungha Yang
124e386da8 dashdemux: Always parsing sidx for On-Demand profile
The indexRange attribute is optional and if it's not present, we should
extract the sidx box from incoming buffers.

https://bugzilla.gnome.org/show_bug.cgi?id=776200
2016-12-20 12:55:40 +02:00
Sebastian Dröge
788bb67639 dashdemux: Don't declare variables inside the for loop header
This is a C99 feature.
2016-12-13 22:21:25 +02:00
Seungha Yang
2b44392095 dashdemux: Fix leak in gst_dash_demux_stream_free
Free parsed moof and sync samples with _stream_free().

https://bugzilla.gnome.org/show_bug.cgi?id=774702
2016-11-19 12:01:20 +02:00
Nirbheek Chauhan
f790863755 Explicitly define float constants as float
With MSVC, this gives the following warning:

warning C4305: 'function': truncation from 'double' to 'gfloat'

Apparently, MSVC does not figure out what type to use for constants
based on the assignment. This warning is very spammy, so let's try to
fix it.
2016-10-27 23:06:26 +05:30
Sebastian Dröge
4734b10c6f dashdemux: Add properties to select maximum allowed width/height and framerate
https://bugzilla.gnome.org/show_bug.cgi?id=770408
2016-08-26 18:12:23 +03:00
Sebastian Dröge
4f6ae1f48c adaptivedemux: Enable bitrate selection for trick mode streaming again
And scale the bitrate with the absolute rate (if it's bigger than 1.0) to get
to the real bitrate due to faster playback.

This allowed in my tests to play a stream with 10x speed without buffering as
the lowest bitrate is chosen, instead of staying/selecting the highest bitrate
and then buffering all the time.

It was previously disabled for not very well specified reasons, which seem to
be not valid anymore nowadays.
2016-08-25 19:52:37 +03:00
Sebastian Dröge
e786f737ae dashdemux: In KEY_UNITS trick mode, download all I-frames and not only IDR 2016-08-18 13:21:54 +03:00
Sebastian Dröge
02f688ee9d Revert "Revert "dashdemux: When doing SIDX seeking, return instead of overriding the timestamp with 0 from the MPD seeking method""
This reverts commit aea2c13fc1.
2016-08-11 12:11:22 +02:00
Sebastian Dröge
18e5e64b05 dashdemux: When doing chunked downloading on SIDX, clip requests on the SIDX entry boundaries
https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
9c04d1e13c dashdemux: Collect average moof and first sync sample sizes
And always request those in the beginning so that ideally we get the moof and
the first sync sample all together with the first HTTP request.

https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
7f1f777b92 dashdemux: Download any sync-sample following the moof directly in key-units only mode
We don't have to do yet another additional request but can just download the
data directly.

Also unify the key-unit only mode buffer pushing and extract it into its own
function now that it became more complicated.

https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
f8eddabe29 dashdemux: If a fragment contains no sync samples, disable key-unit mode
https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
cfad48ce5a dashdemux: Remember if for a stream we could do key-units only mode
This makes sure we don't even try going into that mode if we previously saw
that the stream does not have the suitable metadata.

https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
b936c00f51 dashdemux: Also allow key-unit only mode if (some) sample flags are given by trex but we can still find sync frames
https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
47ef88f20e dashdemux: Use chunked downloading for the moof in KEY_UNITS mode
Allows us to reuse the HTTP connection and reduce latencies a lot.

https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
7b4fe1e02f dashdemux: Mark every first buffer of moov, sidx, moof and mdat as DISCONT in keyframe-only mode
We need to mark every first buffer of a key unit as discont, and also every
first buffer of a moov and moof. This ensures that qtdemux takes note of our
buffer offsets for each of those buffers instead of keeping track of them
itself from the first buffer. We need offsets to be consistent between moof
and mdat

https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
12c2415251 dashdemux: Only enable key-unit trick mode for video streams
https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
9dd8789323 dashdemux: Only do keyframe-only playback if the corresponding seek flag is given
https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
70bc183a52 dashdemux: Implement downloading of only sync samples
https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
5b943135ac dashdemux: Store parsed moof and extract offsets of sync samples in it
https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:55 +02:00
Sebastian Dröge
fff814bbe5 dashdemux: Implement parsing of moof box
https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:54 +02:00
Sebastian Dröge
c4ad30d6b4 dashdemux: Store box fourccs in the header at a central place
https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:54 +02:00
Sebastian Dröge
0b0a1a52d3 dashdemux: Implement parsing of ISOBMFF boxes
https://bugzilla.gnome.org/show_bug.cgi?id=741104
2016-08-11 11:56:54 +02:00
Edward Hervey
aea2c13fc1 Revert "dashdemux: When doing SIDX seeking, return instead of overriding the timestamp with 0 from the MPD seeking method"
This reverts commit 947656cfd2.

This makes all dash seeking tests fail. Needs more testing to fully understand
what's going wrong. Revert ok'd by Sebastian
2016-08-05 09:16:58 +02:00
Sebastian Dröge
947656cfd2 dashdemux: When doing SIDX seeking, return instead of overriding the timestamp with 0 from the MPD seeking method
We don't need to call the latter at all as we're definitely in this period and
the segment is selected via the SIDX.

This is especially important when doing SNAP seeks, as otherwise we would
always start from the beginning of the period (usually 0) again.
2016-08-04 15:10:02 +03:00
Alex Ashley
d9bcf4dbd9 dashdemux: include segment duration when calculating seek range
The gst_dash_demux_get_live_seek_range () function returns a stop value
that is beyond the available range. The functions
gst_mpd_client_check_time_position() and
gst_mpd_client_get_next_segment_availability_end_time() in
gstmpdparser.c include the segment duration when checking if a segment
is available. The gst_dash_demux_get_live_seek_range() function
in gstdashdemux.c ignores the segment duration.

According to the DASH specification, if maxSegmentDuration is not present,
then the maximum Segment duration is the maximum duration of any Segment
documented in the MPD.

https://bugzilla.gnome.org/show_bug.cgi?id=753751
2016-08-02 12:52:34 +01:00
Sebastian Dröge
a7adb5cb60 dashdemux: Skip audio streams if TRICKMODE_NO_AUDIO is given in the seek event
We just don't expose pads for audio streams, or even download them.
2016-07-28 20:44:29 +03:00
Sebastian Dröge
269a8c5fdf dashdemux: Reset number of subtitle streams counter on reset() too
Otherwise we will continue increasing forever the number of subtitle streams
when reusing the element for another DASH manifest.
2016-07-28 11:17:15 +03:00
Sebastian Dröge
91e398ddd6 dashdemux: Implement SIDX tracking based on buffer offset
This simplifies the code but also removes a bug with tracking of the remaining
size for the initial subfragment: we were not considering the size between the
index and the start of the first moof here.

https://bugzilla.gnome.org/show_bug.cgi?id=764684
2016-07-01 14:10:31 +02:00
Sebastian Dröge
9374643089 dashdemux: 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
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
Florin Apostol
74d62b9144 adaptivedemux: use GstSystemClock to all real-time calculations
A realtime clock is used in many places, such as deciding which
fragment to select at start up and deciding how long to sleep
before a fragment becomes available. For example dashdemux needs
sample the client's estimate of UTC when selecting where to start
in a live DASH stream.

The problem with dashdemux calculating the client's idea of UTC is
that it makes it difficult to create unit tests, because the passage
of time is a factor in the test.

This commit changes dashdemux and adaptivedemux to use the
GstSystemClock, so that a unit test can replace the system clock when
it needs to be able to control the clock.

This commit makes no change to the behaviour under normal usage, as
GstSystemClock is based upon the system time.

https://bugzilla.gnome.org/show_bug.cgi?id=762147
2016-04-21 16:46:09 -03: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
Florin Apostol
72e46a4478 dashdemux: correctly handle an HTTP-XSDATE that is exactly the size of the date string
The code in the gst_dash_demux_parse_http_xsdate() was trying to
handle the case where the string is not null terminated by resizing
the buffer and appending a zero byte. This does not work if the buffer
is exactly the length of the string because the gst_buffer_resize()
function does not re-allocate the buffer, it just changes its size.

If a buffer is passed to gst_dash_demux_parse_http_xsdate() that is
exactly the length of the string, the function fails with an assert
failure in gst_buffer_resize().

https://bugzilla.gnome.org/show_bug.cgi?id=762148
2016-02-23 14:41:35 +02:00
Florin Apostol
88e21e6089 dashdemux: gst_dash_demux_get_live_seek_range returns positive values
https://bugzilla.gnome.org/show_bug.cgi?id=752374
2016-02-10 14:34:48 -03:00
Thiago Santos
632111ae14 dashdemux: plug mpd client leak
On parsing error, free the mpd client object

https://bugzilla.gnome.org/show_bug.cgi?id=760120
2016-02-09 17:30:14 -03:00
Florin Apostol
3191051828 dashdemux: fix memory leak in gst_dash_demux_update_manifest_data
new_client local variable was not freed in case of errors.
Also, the buffer is not unmapped.

https://bugzilla.gnome.org/show_bug.cgi?id=760120
2016-02-09 17:05:13 -03:00
Florin Apostol
9ccd541980 mpdparser: renamed gst_mpd_client_get_next_segment_availability_end_time to gst_mpd_client_get_next_segment_availability_start_time
The function actually returns the segment availability start time (as defined by the standard).
That is at the end of the segment, but it is called availability start time.

Availability end time is something else (the time when the segment is no longer
available on the server). The function name was misleading.

https://bugzilla.gnome.org/show_bug.cgi?id=757655
2016-02-09 16:49:37 -03:00
Thiago Santos
40faf9e09b dashdemux: implement snap seek handling
Handle snap seeking at the stream_seek method and let superclass
do the rest to support snap seeking

https://bugzilla.gnome.org/show_bug.cgi?id=759158
2016-02-04 14:09:35 -03:00
Thiago Santos
731ab94cc3 adaptivedemux: handle snap seeks
Adaptive demuxers need to start downloading from specific positions
(fragments) for every stream, this means that all streams can snap-seek
to a different position when requested. Snap seeking in this case will
be done in 2 steps:

1) do the snap seeking on the pad that received the seek event and
   get the final position

2) use this position to do a regular seek on the other streams to
   make sure they all start from the same position

More arguments were added to the stream_seek function, allowing better control
of how seeking is done. Knowing the flags and the playback direction allows
subclasses to handle snap-seeking.
And also adds a new return parameter to inform of the final
selected seeking position that is used to align the other streams.

https://bugzilla.gnome.org/show_bug.cgi?id=759158
2016-02-04 14:05:08 -03:00
Thiago Santos
d4b4069041 dashdemux: only update current reading position when needed
If the seek doesn't set the start/stop position, no need to
reposition the download index.
2016-02-01 14:36:48 -03:00
Thiago Santos
fc72e48a48 dashdemux: respect seeking parameter
Instead of using the segment values, use the parameter
requested in the seeking argument
2016-02-01 14:36:48 -03:00
Florin Apostol
88f509a710 dashdemux: added check that availabilityStartTime is present for live streams
https://bugzilla.gnome.org/show_bug.cgi?id=757602
2016-01-18 15:12:07 -03: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
Florin Apostol
ef06d2a855 dashdemux: removed unnecessary space trimming in gst_dash_demux_parse_http_head
sscanf has removed all spaces when it has constructed zone string. There is
no need to search for leading spaces.

https://bugzilla.gnome.org/show_bug.cgi?id=759743
2015-12-28 14:10:58 +02:00
Florin Apostol
09b21eacae dashdemux: accept 2 or 4 digit year when using HTTP HEAD for calculating clock compensation
Convert year from 2 digits to 4 digits in gst_dash_demux_parse_http_head

https://bugzilla.gnome.org/show_bug.cgi?id=759743

Also updated references to Rfc822 to Rfc5322
2015-12-28 14:10:58 +02:00
Florin Apostol
f85fc4a543 dashdemux: clock_cond is not used and should be removed
There are no threads waiting on clock_cond. It is just initialised and
signalled. It should be removed.

https://bugzilla.gnome.org/show_bug.cgi?id=759537
2015-12-16 11:45:21 +01:00
Florin Apostol
7c1b511e96 adaptivedemux: fixed clock compensation in get_fragment_waiting_time
Clock compensation is calculated in usec but is added to a GstClockTime value.

https://bugzilla.gnome.org/show_bug.cgi?id=759534
2015-12-16 11:36:35 +01:00
suhwang.kim
6cbaec7593 dashdemux: Suggestion for setting the framerate information.
Dashdemux has set the width and height information from MPD manifest.
Some embedded devices which are not insufficient H/W resources need more information such as framerate
to assign H/W resources. So I suggested that dashdemux also needs to set the framerate information from MDP manifest.

https://bugzilla.gnome.org/show_bug.cgi?id=758515
2015-12-08 09:51:02 +02:00
Jimmy Ohn
7093ad482b dashdemux: Add binary search for stream_sidx_seek
Add binary search to optimize in stream_sidx_seek.

https://bugzilla.gnome.org/show_bug.cgi?id=749653
2015-11-19 16:07:31 -03:00
Florin Apostol
fe6adec702 dashdemux: marked PROP_BANDWIDTH_USAGE property as deprecated
https://bugzilla.gnome.org/show_bug.cgi?id=753890
2015-10-30 15:25:14 +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
Florin Apostol
e7745a5720 dashdemux: improve detection of stream language
Improved the detection of stream's language if the AdaptationSet
contains more than 1 ContentComponent

https://bugzilla.gnome.org/show_bug.cgi?id=752367
2015-10-29 12:14:50 +00: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
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
7c9525830e dashdemux: Properly handle relative and non-HTTP URIs for the headers/indices
gst_uri_join_strings() will return the second parameter if it is an absolute
URI. No need to do a (wrong) check if the URI is absolute or not beforehand.

https://bugzilla.gnome.org/show_bug.cgi?id=755134
2015-09-25 23:52:28 +02:00
Thiago Santos
bd710e5e1b dashdemux: fix return when trying to advance in subfragmented stream
Even if it doesn't actually advance the subfragment in the default way
for streams that have subfragments, it can help the base class to return
EOS when there is no more fragments instead of signaling it that it should
continue downloading.

https://bugzilla.gnome.org/show_bug.cgi?id=755042
2015-09-15 12:46:31 -03: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
Thiago Santos
cc599bb5b5 dashdemux: also check for subfragments on has_next_fragment
In dash isombff profile the fragment is split into subframents where
bitrate switching is possible. Also take that into consideration
when checking if a stream has next fragments.
2015-09-14 13:56:10 -03:00
Tim-Philipp Müller
ef7f5fc4c7 dashdemux: don't meddle with the class struct from an instance
Fix some very dubious code. The class methods should always
be set, and the instance-specific check should then be done
inside the method. For data_received that's there already, for
finish_fragment we need to add it.

https://bugzilla.gnome.org/show_bug.cgi?id=753937
2015-08-27 00:35:02 +01:00
Thiago Santos
ae5befef5f dashdemux: fix off by one seeking issue
When seeking to the last second of a mpd it would reject the seek
because the comparison was < instead of <=

This fails the important use case of seeking to the end of a file
to play it back in reverse from the end
2015-08-16 08:49:35 -03:00
Alex Ashley
93edd99bf7 dashdemux: add support for HTTP HEAD method of time sync
The urn:mpeg:dash:utc:http-head:2014 method of time synchronisation
uses an HTTP HEAD request to a specified URL and then parses the
Date: HTTP response header.

This commit adds support to dashdemux for this method of time
synchronisation by making a HEAD request and then parsing the Date:
response.

This commit adds support to gstfragment to return the HTTP headers
and to uridownloader to support HEAD requests. To avoid creating a
new API, the RANGE get function is re-used (abused?) with start=-1
and end=-1 to indicate a HEAD request.

https://bugzilla.gnome.org/show_bug.cgi?id=752413
2015-08-14 06:47:21 -03:00
Alex Ashley
1640ee2b33 dashdemux: post-review fixup of UTCTiming element
This commit addresses the following items from the code review:
    use a portable way to define NTP_TO_UNIX_EPOCH,
    fix memory leak on error, and
    add documentation to UTCTiming parse functions

Using LL is not portable, so the G_GUINT64_CONSTANT needs to be instead.

If an error occurs during DNS resolution, the GError was not being
released, causing a memory leak.

https://bugzilla.gnome.org/show_bug.cgi?id=752413
2015-08-14 06:47:20 -03: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
Florin Apostol
93c10d3f0e dashdemux: Fix leak in gst_dash_demux_stream_update_fragment_info()
The gst_dash_demux_stream_update_fragment_info function could call
gst_dash_demux_stream_update_headers_info function twice. The
gst_dash_demux_stream_update_headers_info function will set header_uri and
index_uri to some newly allocated strings. The values set by the first call of
gst_dash_demux_stream_update_headers_info will leak when the function is
called for a second time.

The solution is to call gst_adaptive_demux_stream_fragment_clear before the
second call of gst_dash_demux_stream_update_headers_info

https://bugzilla.gnome.org/show_bug.cgi?id=753188
2015-08-06 01:24:28 +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
Luis de Bethencourt
a01133dd8f dashdemux: remove redundant else statement
Else statement is redundant when the if block finishes with an return.
2015-07-08 11:33:04 +01:00
Sebastian Dröge
9e8e1c452d dashdemux: Seek on the new streams if the seek caused a period switch
Seeking on the old streams is pointless, they are going to be freed on the
next opportunity.
2015-06-25 23:35:02 +02:00
Thiago Santos
53451500ee dashdemux: avoid assertion when splitting buffer
Pass size=-1 as is if that is the case instead of subtracting
the offset. Otherwise we have an invalid size passed for that
buffer.
2015-05-29 09:02:42 -03:00
Suhwang Kim
f6cc8d13e0 dashdemux: fix outdated example launch line
https://bugzilla.gnome.org/show_bug.cgi?id=749809
2015-05-25 11:12:47 +01:00
Jimmy Ohn
be90a12916 dashdemux: remove unnecessary semicolon
https://bugzilla.gnome.org/show_bug.cgi?id=749691
2015-05-22 09:40:35 +01: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
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
Sebastian Dröge
0cd3938345 adaptivedemux: Allow subclasses to override how a new manifest would be downloaded 2015-04-23 17:47:18 +02:00
Yujin Lee
218a89fcd9 dashdemux: enable playback of content with text streams
There is a playback error when trying to play a content that
has 'application' mimeType. This commit prevents an exception from
setup text streams.

https://bugzilla.gnome.org/show_bug.cgi?id=747525
2015-04-13 09:24:53 -03: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
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
a48a361256 dashdemux: depracate bandwidth-usage in favor of bitrate-limit
Bitrate-limit is already available in the baseclass and, even though
the bandwidth-usage name is better, hls and mss already used
bitrate-limit. This patch deprecates the bandwidth-usage and maps
it to the baseclass bitrate-limite.
2015-02-17 11:12:42 -03:00
Mathieu Duponchelle
7ca6d9634a dashdemux: Fix handling of live streams with timeshift buffers.
By implementing get_live_seek_range.

As shown by :

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

This patch handles live seeking, by setting a live seek range
comprised between now - timeShiftBufferDepth and now.

The inteersting thing with this stream is that one can actually
ask fragments up to availabilityStartTime, but it seems quite clear
in the spec that content is only guaranteed to exist up to
timeShiftBufferDepth.

One can test live seeking this way :

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

with scenario being:

description, seek=true
seek, playback-time=position+5.0, start="position-600.0",
flags=accurate+flush

This example will play the stream, wait for five seconds, then seek back
to a position 10 minutes earlier.

https://bugzilla.gnome.org/show_bug.cgi?id=744362
2015-02-12 22:47:26 +01:00
Thiago Santos
85bb450a44 dashdemux: use audio_%02u and video_%02u names for pads
Instead of using the default ghostpad%u naming. The audio_/video_
names are more common in demuxers
2015-01-26 18:03:40 -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
Sebastian Dröge
cd3930969a dashdemux: Fix compiler warning with clang
gstdashdemux.c:1330:13: error: implicit conversion from enumeration type 'enum _GstAdaptiveDemuxFlowReturn' to different enumeration type
      'GstFlowReturn' [-Werror,-Wenum-conversion]
      ret = GST_ADAPTIVE_DEMUX_FLOW_SUBSEGMENT_END;
          ~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2015-01-19 11:23:52 +01:00
Thiago Santos
fb760a563c dashdemux: remove unused segment attribute
It was never used, only initialized
2015-01-16 17:07:22 -03:00
Thiago Santos
3055bb331a dashdemux: implement ISOBMFF profile handling
The ISOBMFF profile allows definind subsegments in a segment. At those
subsegment boundaries the client can switch from one representation to
another as they have aligned indexes.

To handle those the 'sidx' index is parsed from the stream and the
entries point to pts/offset of the samples in the stream. Knowing that
the entries are aligned in the different representation allows the client
to switch mid fragment. In this profile a single fragment is used per
representation and the subsegments are contained in this fragment.

To notify the superclass about the subsegment boundary the chunk_received
function returns a special flow return that indicates that. In this case,
the super class will check if a more suitable bitrate is available and will
change to the same subsegment in this new representation.

It also requires special handling of the position in the stream as the
fragment advancing is now done by incrementing the index of the subsegment.
It will only advance to the next fragment once all subsegments have been
downloaded.

https://bugzilla.gnome.org/show_bug.cgi?id=741248
2015-01-16 17:07:05 -03:00
Thiago Santos
f5b98f24c2 dashdemux: parse the sidx index from isobmff streams
Allows dashdemux to identify the subsegments in the stream and
switch bitrates when needed
2015-01-16 15:00:11 -03:00
David Waring
b03acbf584 dashdemux: Find current segment in the streams that have just been setup
Using demux->streams will just skip the whole loop as demux->streams will
always be NULL at that point

https://bugzilla.gnome.org/show_bug.cgi?id=741285
2014-12-09 21:08:10 -03:00
Thiago Santos
f48fa7e763 dashdemux: fix double unref of object
the datetime is already released by the end of the function
2014-12-02 15:52:54 -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