Commit graph

63 commits

Author SHA1 Message Date
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
Louis-Francis Ratté-Boulianne 4a630f86f8 mssdemux: add conditions to prevent some crashes 2013-05-07 21:09:47 -03:00
Louis-Francis Ratté-Boulianne 218f2dee0c mssdemux: use standard glib methods 2013-05-07 21:09:47 -03:00
Louis-Francis Ratté-Boulianne 44d02efee0 mssdemux: fix some memory leaks and use right free function 2013-05-07 21:09:47 -03:00
Louis-Francis Ratté-Boulianne ea5f2718bf mssdemux: make codec private data from manifest attributes with AAC-LC
When the codec is AAC-LC, some server implementation (e.g. Microsoft IIS) doesn't add the CodecPrivateData attribute. The element needs to re-create the codec data from the Quality Level attributes (channels and sampling rate).
2013-05-07 21:09:47 -03:00
Thiago Santos aa1713068a mssdemux: implement live streams handling
Live streams force the demuxer to keep reloading the Manifest from
time to time, as the new fragments are being added as they are recorded.
The demuxer should also try to keep up and detect when it had to skip
fragments, marking the discont flag when that happens.

Curiously, the spec doesn't seem to mention when/how a live stream is supposed
to end, so keep trying downloads until the demuxer errors out.
2013-05-07 21:05:12 -03:00
Thiago Santos 21872e78b8 mssdemux: fix issue on fragment timestamping parsing
Use guint64 as the fragments can start at very high numbers,
specially on live streams
2013-05-07 21:05:12 -03:00
Thiago Santos b9aec0ad0d mssdemux: add connection-speed property
This speed limits the maximum bitrate of streams. Currently it
is only read when starting the pipeline, but it should be used
for switching bitrates during playback to adapt to network
changes.
2013-05-07 21:05:11 -03:00
Thiago Santos 4b6900999a mssdemux: add an 'active' flag to manifest stream
mssdemux should set the streams it has exposed as active so that
the manifest won't use the non-active streams to compute total bitrates
or providing fragments
2013-05-07 21:05:11 -03:00
Thiago Santos eec8164d9c mssmanifest: Keep the stream qualities list sorted by bitrate
This will help making adaptive streaming chose the best rate
for a particular connection speed
2013-05-07 21:05:11 -03:00
Thiago Santos 013c11f7dd mssdemux: also consider fourcc AVC1 as H264
H264 can be represented by both fourccs H264 and AVC1, use both.
2013-05-07 21:05:11 -03:00
Thiago Santos 4293cfa763 mssmanifest: add support for VC-1 and WmaPro formats parsing
VC-1 should map to WMV3 and WmaPro to WMA2
2013-05-07 21:05:11 -03:00
Thiago Santos b2ba96bb85 mssmanifest: do not set codec_data when it is empty
Some manifests contain empty codec datas, better not set them
2013-05-07 21:05:11 -03:00