Commit graph

75 commits

Author SHA1 Message Date
Hosang Lee
f7a8ece5ef smoothstreaming: clear live adapter on seek
In live streaming, buffers sent by souphttpsrc are pushed to the live
adapter. The buffers in the adapter are sent out of mssdemux when it
is greater than 4096 bytes.

Occasionally, when seeking in live streams, if seek occurs just
after the last data chunk was received, and if this data chunk is
smaller than 4096 bytes, it will be kept in the live adapter.
This remaining data in the live adapter will be erroneously prepended
to the new data that is downloaded after seek and pushed out.
When qtdemux receives this data, since it does not start with
a moof box, it is impossible to demux the fragment, and bogus
size error will occur.

Clear out the live adapter on seek so that no unnecessary remaining
data is pushed out together with the new fragment after seeking.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1345>
2020-09-30 11:48:02 +00:00
Hosang Lee
d9dda36e02 smoothstreaming: start closer to the edge in live streams
It is more appropriate to start closer to the live edge in
live streams. Some live streams maintain a large dvr window
(over few hours in some cases), so starting from the first
fragment will be too far away from the live edge.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1346>
2020-08-10 16:13:30 +09:00
yychao
cb0e4bffea smoothstreaming: fix H264 CodecPrivateData parsing
Do not pass SPS nal_unit_type (0x67) into gst_h264_parse_sps()

Fixes #648
2020-03-10 12:55:05 +00:00
Jan Schmidt
8899a471e3 h264parse lib: Remove the SPS parse_vui_params flag
The SPS parsing functions take a parse_vui_param flag
to skip VUI parsing, but there's no indication in the output
SPS struct that the VUI was skipped.

The only caller that ever passed FALSE seems to be the
important gst_h264_parser_parse_nal() function, meaning - so the
cached SPS were always silently invalid. That needs changing
anyway, meaning noone ever passes FALSE.

I don't see any use for saving a few microseconds in
order to silently produce garbage, and since this is still
unstable API, let's remove the parse_vui_param.
2019-07-05 00:17:59 +10:00
Thibault Saunier
7fe3f36ac8 Minor documentation fixes 2019-05-13 11:36:27 -04:00
Edward Hervey
6e1e87d403 smoothstreaming: Handle invalid XML
Nothing guarantees the manifest is valid and will return a root node
2017-11-21 15:33:57 +01:00
Seungha Yang
0f1de50222 smoothstreaming: Use isoff to parse tfxd/tfrf
https://bugzilla.gnome.org/show_bug.cgi?id=777825
2017-08-25 17:21:41 -07:00
Matthew Waters
5199aa60d5 mss: always periodically update the manifest taking the new fragments
Without this, for streams where the content is stored indefinitely and
can be seeked on, the duration would never increase when in paused or,
until we reached near the end of the currently advertised stream (where
the internal fragment parser would see descriptions of new fragments).
2017-04-25 14:16:15 +10:00
Matthew Waters
0a25fe2893 mssdemux: only add live fragments after manifest fragments
A live manifest may have a set (> LookAheadFragmentCount) of fragments
that have already been served and are stored on the server, maybe
indefinitely.  Adding the parsed live fragments after the manifest
fragments breaks duration reporting and the seekable range.

Fix by only adding parsed fragments outside the list of fragments which
assumes that the fragment list in the manifest is accurate enough to not
stray too far off what's in the retrieved data.

https://bugzilla.gnome.org/show_bug.cgi?id=779447
2017-03-27 18:42:07 +11:00
Matthew Waters
fd8d35298f Revert "adaptivedemux: answer duration queries for live streams"
Completely disabling duration reporting with live streams is not cool.

This reverts commit e1b68d9a65.

https://bugzilla.gnome.org/show_bug.cgi?id=753879
2017-03-14 16:50:30 +11:00
Alex Ashley
e1b68d9a65 adaptivedemux: answer duration queries for live streams
For duration queries on live streams, adaptivedemux ignores the query.
The problem then is that the query is answered by the downstream
qtdemux element, with the duration of the currently passing fragment.

This commit changes the behaviour of adaptivedemux to answer the duration
queries for live streams, returning GST_CLOCK_TIME_NONE.

    https://bugzilla.gnome.org/show_bug.cgi?id=753879
2017-03-02 19:54:04 +02:00
Arun Raghavan
a3e33a0fc1 smoothstreaming: Fix minor use after free reference
Just a matter of reordering a g_free() /after/ cleaning out all the
members.

CID 1396746
2017-01-02 17:50:02 +05:30
Philippe Normand
73721ad4e9 mssdemux: improved live playback support
When a MSS server hosts a live stream the fragments listed in the
manifest usually don't have accurate timestamps and duration, except
for the first fragment, which additionally stores timing information
for the few upcoming fragments. In this scenario it is useless to
periodically fetch and update the manifest and the fragments list can
be incrementally built by parsing the first/current fragment.

https://bugzilla.gnome.org/show_bug.cgi?id=755036
2016-11-29 14:43:41 +01:00
Matthew Waters
0fbee8f374 smoothstreaming: use the duration from the list of fragments if not present in the manifest
Provides a more accurate duration for live streams that may be minutes
or hours in front of the earliest fragment.

https://bugzilla.gnome.org/show_bug.cgi?id=774178
2016-11-11 00:18:47 +11:00
Matthew Waters
e9178fa082 smoothstreaming: implement adaptivedemux's get_live_seek_range()
Allows seeking through the available fragments that are still available
on the server as specified by the DVRWindowLength attribute in the
manifest.

https://bugzilla.gnome.org/show_bug.cgi?id=774178
2016-11-11 00:18:35 +11:00
Tim-Philipp Müller
7d46d67c59 smoothstreaming: update fps calculation for h264 codec parser API changes
Use new gst_h264_video_calculate_framerate() API instead of fps_n/fps_d
fields in SPS struct which are to be removed.

Apparently H264 content in MSS is always non-interlaced/progressive,
so we can just pass 0 for field_pic_flag and don't need to parse any
slice headers first if there's no external signalling. But even if
that's not the case the new code is not worse than the existing code.

https://msdn.microsoft.com/en-us/library/cc189080%28VS.95%29.aspx

https://bugzilla.gnome.org/show_bug.cgi?id=723352
2016-05-28 10:29:20 +01:00
Luis de Bethencourt
8d445ee758 mssdemux: remove unnecessary check
stream->current_fragment has the value of g_list_previous (iter) which has
just been checked. No need to check it again.

Just to be safe, use a g_assert() to check fragment before dereferencing.

CID #1352041
2016-02-09 21:41:33 +00:00
Thiago Santos
ac2734f5cb mssdemux: implement snap seeking
Implement snap seek flags handling in stream_seek to allow the
parent class to handle it for us

https://bugzilla.gnome.org/show_bug.cgi?id=759158
2016-02-04 14:20:16 -03:00
Thiago Santos
86fb14f5ed mssdemux: do not assert on fragment reloads for non-live
It can be used as a resource to verify if the server has updated
something in the Manifest when downloads are failing
2016-02-04 14:20:16 -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
Maroš Ondrášek
b902c4a293 mssdemux: add depth field to audio caps if available
depth field can be retrieved from "BitsPerSample" or
from "WaveFormatEx" structure, if provided in Manifest

https://bugzilla.gnome.org/show_bug.cgi?id=758586
2015-11-24 09:13:06 -03:00
Tim-Philipp Müller
734d5a79c5 Fix code indentation 2015-11-06 19:29:49 +00:00
Philippe Normand
ae7d938842 mssdemux: PlayReady WRM parsing support
If the manifest has a ProtectionHeader node then parse it and emit
protection events according to the specified protection SystemID.

https://bugzilla.gnome.org/show_bug.cgi?id=753613
2015-09-30 16:49:11 +01:00
Philippe Normand
5d4388bf9e mssdemux: always use timescale for gst timestamp calculation
Not doing this can lead the demuxer to attempt downloading fragments
for an invalid start time. The server would then send a HTTP
Precondition failed error, the demuxer would try some more times to
download the invalid fragment and eventually error out.

https://bugzilla.gnome.org/show_bug.cgi?id=754523
2015-09-30 10:04:37 +01: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
Rajat Verma
de246c6741 mssdemux: fix crash while setting bitrate in caps structure
q->bitrate is a guint64, but G_TYPE_INT may read fewer bits
off the stack, and if we pass more then the NULL sentinel
may not be found at the right place, which in turn might
lead to crashes.

https://bugzilla.gnome.org/show_bug.cgi?id=741751
2015-01-07 10:08:20 +00:00
Thiago Santos
8b63a16af0 mssdemux: fix reverse playback fragment tracking
Rework reverse fragment traversing with repetition fields to prevent
NULL pointer deref and avoid never advancing a fragment as the variable
is unsigned and would always be non-negative.

CID #1257627
CID #1257628
2014-12-10 15:27:49 -03:00
Thiago Santos
8c49c79d7e mssdemux: add live support
Implement the functions of adaptivedemux to have live support
enabled. This allows mssdemux to refresh the Manifest periodically
2014-12-04 19:52:33 -03:00
Thiago Santos
a105af22f2 mssdemux: fix getting current position in segments when after last one
For live streams this makes a difference when resyncing after a
Manifest refresh, otherwise it doesn't know where to restart
2014-12-04 14:28:25 -03:00
Thiago Santos
a2c31e38d1 mssdemux: support manifests with repetition fragments
Read the "r" attribute from fragments to support fragments nodes
that use repetition to have a shorter Manifest xml.

Instead of doing:
<c d="100" />
<c d="100" />

You can use:
<c d="100" r="2" />
2014-12-04 14:24:42 -03:00
Thiago Santos
b418c88b26 mssdemux: port to adaptivedemux base class 2014-12-04 14:24:42 -03:00
Thiago Santos
613b110b25 mssdemux: seeks in the manifest never fail
Set void as the return and remove error handling as it could
never fail
2014-11-07 19:30:18 -03:00
Tim-Philipp Müller
efbae700a6 smoothstreaming: initialise new GstH264NalUnit fields
CID #1251107.
2014-11-07 00:16:12 +00:00
Thiago Santos
a38ada61e3 mssdemux: add type of stream to debug log
Makes it faster to debug why certain streams are not showing
2014-10-31 17:33:55 -03:00
Thiago Santos
628461b4d1 mssdemux: fix segfault when trying to access codec_data
Check if codec_data was obtained before trying to use it to
prevent a segfault
2013-12-18 18:52:19 -03:00
Thiago Santos
5948a07324 mssdemux: also generate caps from audiotag attribute
Some audio will have its audio format defined by the AudioTag
instead of the Fourcc. Fallback to using AudioTag if Fourcc
isn't available
2013-12-18 18:52:19 -03:00
Guillaume Desmottes
d6a9f17d8a mssmanifest: store the language of the stream
https://bugzilla.gnome.org/show_bug.cgi?id=712358
2013-12-18 18:52:19 -03:00
Antonio Ospite
c4fbff50df mssdemux: fix setting codec_data when using WaveFormatEx
When using WaveFormatEx the actual codec private data is at the end of
the wav header structure, after the cbSize field, see for example the
notes at http://wiki.multimedia.cx/index.php?title=WAVEFORMATEX

The previous code was erroneously passing the whole WAVEFORMATEX
structure as codec_data.

The smoothstreaming specifications[1,2,3] always mention WAVEFORMATEX
and never smaller structures like WAVEFORMAT or PCMWAVEFORMAT, so the
buffer can assumed to be at least 18 bytes and always consuming the wav
header gives the (possibly empty) codec private data.

[1] http://web.archive.org/web/20120907004742/http://www.iis.net/community/files/media/smoothspecs/%5BMS-SMTH%5D.pdf
[2] http://download.microsoft.com/download/B/0/B/B0B199DB-41E6-400F-90CD-C350D0C14A53/%5BMS-SSTR%5D.pdf
[3] http://download.microsoft.com/download/9/5/E/95EF66AF-9026-4BB0-A41D-A4F81802D92C/%5BMS-SSTR%5D.pdf

https://bugzilla.gnome.org/show_bug.cgi?id=699924
2013-11-27 09:26:36 -03:00
Antonio Ospite
f02e7a2439 mssdemux: use mssdemux_debug debug category for gstmssmanifest.c too 2013-11-27 09:26:36 -03:00
Antonio Ospite
8345c5acfb mssdemux: fix coding style 2013-11-27 09:26:36 -03:00
Thiago Santos
750137c4be mssdemux: fix wma pro caps creation
WmaPro is actually wmaversion 3, and can also be found by the
WMAP fourcc.

Some manifests also contain the block_align field as "PacketSize"
in the audio track description, the libav decoders require it
to be present in caps.

Fixes #699921
2013-05-17 12:08:10 -03:00
Thiago Santos
27d726fbfa mssdemux: parse block_align, channels and rate from waveformatex if possible
wma v2 expects block_align, channels and rate fields set to its caps.
This isn't present direclty on the manifests, so mssdemux should parse
it from the waveformatex structure

https://bugzilla.gnome.org/show_bug.cgi?id=699924
2013-05-16 15:00:39 -03:00
Thiago Santos
f74f9cd3ab mssdemux: add bitrate info to audio streams
bitrate info is always present on the QualityLevel xml node as part
of the adaptive selection processing, put it into caps as some
decoders require it (avdec_wmav2 for example)

https://bugzilla.gnome.org/show_bug.cgi?id=699924
2013-05-16 15:00:39 -03:00
Tim-Philipp Müller
43fea50c8a smoothstreaming: pass width, height, channels and rate as integer
g_ascii_strtoull() returns a long long integer, but we need to
pass a normal int to gst_structure_set() for fields of G_TYPE_INT,
so cast appropriately.
2013-05-08 15:42:01 +01:00
Tim-Philipp Müller
99c1dce8db smoothstreaming: fix WMV caps
Makes this show at least a picture:
http://playready.directtaps.net/smoothstreaming/TTLSS720VC1/To_The_Limit_720.ism/Manifest
2013-05-08 10:55:16 +01:00
Thiago Santos
4545f4bf4e smoothstreaming: port to 1.0 2013-05-07 21:09:49 -03:00
Thiago Santos
001da5a239 mssdemux: remove already fixed TODO comment 2013-05-07 21:09:49 -03:00
Thiago Santos
210f6c510c mssdemux: replace gst_value_deserialize with simpler function
The deserialization was only used to convert hex strings into
GstBuffers. Replace gst_value_deserialize with a simpler, direct
function.
2013-05-07 21:09:49 -03:00
Wim Taymans
6d56eba653 mss: avoid GValue leak 2013-05-07 21:09:48 -03:00
Thiago Santos
255eb4b161 mssdemux: use streams bitrate individually
connection setup times seem to matter when measuring the download
rate of different streams. Streams with longer fragments have a
*relatively* lower connection setup time and achieve higher bitrates.

Using the average seems unfair here, so use each stream's measured bitrate
to select its best quality option.
2013-05-07 21:09:48 -03:00