Commit graph

329 commits

Author SHA1 Message Date
Jan Alexander Steffens (heftig)
3f9a7e5c73 hlssink2: Actually release splitmuxsink's pads
It was looking at the "outer" peer of the ghost pad, not the "inner"
peer (the target).

It provided the wrong pad to gst_element_release_request_pad.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1551>
2020-09-09 01:06:21 +00:00
Sebastian Dröge
6e412d42c7 hlssink2: Don't assert if we don't have a current location when receiving the fragment-closed message
This can happen if the application did not provide an output stream for
the fragment and didn't handle the error message before splitmuxsink
decided to consider the fragment closed.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1469>
2020-08-03 11:23:36 +00:00
Seungha Yang
4fc3aa6ef4 hls: Check nettle version to ensure AES128 support
AES128 support was added since nettle version 3.0

../subprojects/gst-plugins-bad/ext/hls/gsthlsdemux.h:110:10: error: field ‘ctx’ has incomplete type
   struct CBC_CTX (struct aes128_ctx, AES_BLOCK_SIZE) aes_ctx;
2020-01-10 16:03:48 +09:00
Sebastian Dröge
66775f3e72 hlssink2: Add signals for allowing custom playlist/fragment handling
Instead of always going through the file system API we allow the
application to modify the behaviour. For the playlist itself and
fragments, the application can provide a GOutputStream. In addition the
sink notifies the application whenever a fragment can be deleted.
2019-12-31 13:23:17 +00:00
Edward Hervey
b55f380b20 hlsdemux: Don't use deprecated SSL methods
And instead use the fixed-size variants (which aren't deprecated)
2019-11-08 10:43:08 +00:00
Aaron Boxer
6d3429af34 documentation: fixed a heap o' typos 2019-11-05 09:11:25 -05:00
Tim-Philipp Müller
f218ec2794 Remove autotools build system 2019-10-14 13:54:27 +01:00
Seungha Yang
2c394df69d hlssink2: Respect requested max-files property for decision on removing old fragments from disk
hlssink2 defined "max-files" property to decide the maximum number
of fragments which should be stored in disk. But we've not used
the property. Instead, the size has been maintained by "playlist-length".
Since "max-files" and "playlist-length" have different meaning,
the decision should be done by "max-files" property.

For example, an user might want expose only 3 fragments via playlist
but might want to keep more files than 3 in disk.
2019-10-07 14:29:57 +09:00
Seungha Yang
d763aeee4b hlssink,hlssink2: Ensure writing ENDLIST tag at the end
hlssink* elements could be finalized without EOS event, and in that case
the final playlist might not include the EXT-X-ENDLIST tag.
Since missing ENDLIST tag means it's live stream, but we did't intend it,
hlssink* elements should put the tag at the end.
2019-10-01 17:16:05 +09:00
Seungha Yang
15c10618a2 hlsdemux: Post error message if hlsdemux could not start decryption
_decrypt_start() failure will lead to decryption failure eventually
but catching it earlier if possible. The decrpytion start failure means
that the hls plugin was built without crypto library or crypto library
does not want to accept given key and IV.
2019-08-21 23:47:45 +09:00
Seungha Yang
98b303498a hls: Make crypto dependency optional when hls-crypto is auto
crypto libraries are not required for hlssink and hlssink2.
Also, hlsdemux with nonencrypted stream can work without crpyto.

Make an error only when users set "hls-crpyto" with non-auto option explicitly,
but no crpyto library was found.
2019-08-21 22:55:50 +09:00
Charlie Turner
659d76a633 adaptivedemux: remove some deadlocks using webkitwebsrc.
WebKit's websrc depends on the main-thread for download completion
rendezvous. This exposed a number of deadlocks in adaptivedemux due to
it holding the MANIFEST_LOCK during network requests, and also needing
to hold it to change_state and resolve queries, which frequently occur
during these download windows.

Make demux->running MT-safe so that it can be accessed without using the
MANIFEST_LOCK. In case a source is downloading and requires a MT-thread
notification for completion of the fragment download, a state change
during this download window will deadlock unless we cancel the downloads
and ensure they are not restarted before we finish the state-change.

Also make demux->priv->have_manifest MT-safe. A duration query happening
in the window described above can deadlock for the same reason. Other
src queries (like SEEKING) that happen in this window also could
deadlock, but I haven't hit this scenario.

Increase granularity of API_LOCK'ing in change_state as well. We need to
cancel downloads before trying to take this lock, since sink events
(EOS) will hold it before starting a fragment download.
2019-07-29 13:19:41 +01:00
Seungha Yang
e779160434 tests: Enable hls m3u8 unit test with meson build 2019-06-18 07:14:28 +00:00
Seungha Yang
48657bf846 hlsdemux: Set fragment header uri if exists
To allow downloading fragment hearder, set its uri if there is
available "Media Initialization" parsed from EXT-X-MAP tag

https://bugzilla.gnome.org/show_bug.cgi?id=776928
2019-06-18 07:14:28 +00:00
Seungha Yang
f9dc67c372 hls: m3u8: Parsing EXT-X-MAP tag to store initialization data
EXT-X-MAP tag informs media initialization data,
such as moov box in ISOBMFF case and PAT/PMT for MPEG TS stream.

https://bugzilla.gnome.org/show_bug.cgi?id=776928
2019-06-18 07:14:28 +00:00
Seungha Yang
b45dd51fb1 hlsdemux: Do not clear/advance fragment by finished header downloading
Header data must be forwarded to downstream, but if demux does not finish
to finding type (e.g., ts, mp4 and etc), this header data can be cleared
by _stream_clear_pending_data(). Moreover, although demux finish downloading
header data, still it has fragment date to be downloaded, fragment sequence
shouldn't be advanced yet at that moment.

https://bugzilla.gnome.org/show_bug.cgi?id=776928
2019-06-18 07:14:28 +00:00
Adam Duskett
43eaf5ac4a ext/hls/meson.build: fix dependency logic
Currently, if one was to set -Dhls-crypto to either libgcrypt or openssl
instead of auto, the following lines would fail because hls_crypto_dep is not
yet set:

if not hls_crypto_dep.found() and ['auto', 'libgcrypt'].contains(hls_crypto)
if not hls_crypto_dep.found() and ['auto', 'openssl'].contains(hls_crypto)

Instead, change "if not hls_crypto_dep.found()" to "if not have_hls_crypto"
which fixes the error.
2019-05-29 18:33:02 +00:00
Thibault Saunier
47a49f3381 docs: Build documentation with hotdoc 2019-05-13 17:00:00 -04:00
Sebastian Dröge
d45604d9eb hlssink2: Add property for disabling sending of force-keyunit events 2019-02-27 21:01:34 +00:00
Seungha Yang
2c81a50c2c hlssink2: Fix string leak
Need to free allocated string memory on _finalize()
2018-11-27 16:08:17 +09:00
Edward Hervey
4a24739a14 hls: Remove stray '\n' from debug statement 2018-10-22 09:59:24 +02:00
Nirbheek Chauhan
b55dfb5313 Add feature options for almost all plugins
The only plugins remaining are those that haven't been ported to Meson
yet, and msdk. Also, the tests are still automagic.

https://bugzilla.gnome.org/show_bug.cgi?id=795107
2018-07-27 19:04:38 +05:30
Xavier Claessens
83d0623293 Meson: Generate pc file for all plugins in bad
https://bugzilla.gnome.org/show_bug.cgi?id=794568
2018-04-25 11:08:09 +01:00
Sebastian Dröge
385a68b850 hlssink2: Use the new reset-muxer property on splitmuxsink
We don't want to reset the muxer, otherwise the continuity counter will
reset after each segment and some software gets confused. We want to
create a continuous stream.

https://bugzilla.gnome.org/show_bug.cgi?id=794816
2018-04-03 14:38:15 +03:00
Jun Xie
e9240762ed hlsdemux: fix memory leak while updating master playlist
new_master needs to be freed if current playlist is not a master playlist

https://bugzilla.gnome.org/show_bug.cgi?id=792146
2018-01-16 08:49:04 +01:00
Edward Hervey
c4b0bdb556 hlssink2: Remove useless if statement
message will always be present

CID #1409853
2018-01-03 15:15:25 +01:00
Hosang Lee
6a5bae5343 m3u8: Parse and use AVERAGE-BANDWIDTH attribute if available
The AVERAGE-BANDWIDTH attribute in the EXT-X-STREAM-INF tag represents
the average segment bit rate of the Variant Stream, while the BANDWIDTH
attribute represents the peak segment bit rate of the Variant Stream.
(https://tools.ietf.org/html/draft-pantos-http-live-streaming-23#section-4.3.4.2)
Using the average bit rate instead of the peak bit rate for variant switching
is more efficient and appropriate. Sometimes due to VBR encoding,
the BANDWIDTH may represent a value way above the average bit rate,
which could result to players not switching to that variant stream
 although network bandwidth is sufficiently available.

https://bugzilla.gnome.org/show_bug.cgi?id=790821
2017-12-06 15:02:40 -05:00
Edward Hervey
c92694e12a hls: Don't leak mutex 2017-11-25 13:10:11 +01:00
Jun Xie
0ef2a41d84 hlsdemux: Fix memory leak caused by double buffer map
https://bugzilla.gnome.org/show_bug.cgi?id=789999
2017-11-17 11:53:05 +02:00
Jan Alexander Steffens (heftig)
519ead2462 m3u8: Refine sequence update debug messages
Actually give some details about why it failed.

https://bugzilla.gnome.org/show_bug.cgi?id=788417
2017-10-19 15:47:04 +02:00
Jan Alexander Steffens (heftig)
7690a4a521 m3u8: Don't try to match URIs when we have media sequences
It is legal for a stream to reuse segments (marking discontinuities as
needed). Uplynk delivers such playlists for their placeholder loops.

Leave the URI scanning in place for playlists which have no
EXT-X-MEDIA-SEQUENCE tag. This should be harmless since the spec
requires these playlists to not be missing segments (RFC8216 6.2.2),
so we should be always matching on the first segment.

https://bugzilla.gnome.org/show_bug.cgi?id=788417
2017-10-19 15:47:04 +02:00
Jan Alexander Steffens (heftig)
025633b162 m3u8: Ignore empty playlists in check_media_seqnums
Let these error in the immediately following check in gst_m3u8_update.

https://bugzilla.gnome.org/show_bug.cgi?id=788417
2017-10-19 15:47:03 +02:00
Jan Alexander Steffens (heftig)
f80ad048e6 m3u8: Split gst_m3u8_update_check_consistent_media_seqnums
The function was basically one big if-else. Move the branch to the
one caller.

Currently, it's never called with previous_files == NULL. Assert that
this continues.

https://bugzilla.gnome.org/show_bug.cgi?id=788417
2017-10-19 15:47:03 +02:00
Jan Alexander Steffens (heftig)
234a8ecc50 m3u8: Simplify control flow for sequence update
Split the tail from the rest of the loop.

https://bugzilla.gnome.org/show_bug.cgi?id=788417
2017-10-19 15:47:02 +02:00
George Kiagiadakis
e796a7cb97 hlsdemux: fix compilation with OpenSSL 1.1.0
OpenSSL 1.1.0 no longer allows stack-allocated structures;
it hides the implementation behind typedefs

https://bugzilla.gnome.org/show_bug.cgi?id=787309
2017-09-05 15:54:48 +03:00
Nicolas Dufresne
4261692187 Remove plugin specific static build option
Static and dynamic plugins now have the same interface. The standard
--enable-static/--enable-shared toggle are sufficient.
2017-05-16 14:05:52 -04:00
Sebastian Dröge
9eda151348 hlssink2: New HLS sink element based on splitmuxsink
This embeds the muxer inside the sink and accepts elementary streams
while the old HLS sink required the muxer outside. Apart from that the
interface is the same as before.
Currently only mpegtsmux is supported, but support for other muxers is
just a matter of adding a property.

The advantage of the new sink is that it reduces complexity a lot and
properly handles pre-encoded streams with appropriately spaced
keyframes.

https://bugzilla.gnome.org/show_bug.cgi?id=781496
2017-05-12 12:03:10 +02:00
Ting-Wei Lan
b5abaabeae meson: hls: libm is required because m3u8.c uses math.h
https://bugzilla.gnome.org/show_bug.cgi?id=782119
2017-05-03 14:18:33 +01:00
Sebastian Dröge
bb8b27bee4 hlssink: Remove some unused struct fields 2017-04-19 12:36:46 +01:00
Thibault Saunier
78022a6e0c docs: Port all docstring to gtk-doc markdown 2017-04-12 12:57:57 -03:00
Seungha Yang
b8344ea997 m3u8: Fix parsing EXT-X-DISCONTINUITY
EXT-X-DISCONTINUITY tag should have no trailing ":" character

https://bugzilla.gnome.org/show_bug.cgi?id=780179
2017-03-17 12:13:40 +02:00
Seungha Yang
16dd0e693d m3u8: Release m3u8 lock if consistent checking failed
To fix deadlock during live m3u8 update

https://bugzilla.gnome.org/show_bug.cgi?id=780180
2017-03-17 12:13:40 +02: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
Seungha Yang
3c5eae63c0 hlsdemux: Try to find type at the end of a fragment
hlsdemux tries to find type if given buffer size is large enought to
find type (currently the threshold is 2KB), or EOS in some cases.
However, since there can be small byte fragments such as WebVTT,
demux should try to find type at the end of a fragment

https://bugzilla.gnome.org/show_bug.cgi?id=779011
2017-03-06 10:09:20 +02:00
Dongil Park
ffbe690656 hlsdemux: Fix checking adaptation_field_control field to parse pcr
The PCR_flag and PCR value is in adaptation_field, not in payload.
The MSB of adaptation_field_control is used as whether adaptation_
field is exist or not.

For the case(PCR in only adaptation_field without payload), we modify
checking condition about adaptation_field_control field.

https://bugzilla.gnome.org/show_bug.cgi?id=778731
2017-03-03 14:20:45 +11:00
Seungha Yang
5bd4bc8080 hls: Fix various leak on hlsdemux and m3u8
* default_variant should be freed, it holds ref.
* GstHLSMedia holds GstM3U8 ref.
* gst_m3u8_get_next_fragment() increases ref count.

https://bugzilla.gnome.org/show_bug.cgi?id=778073
2017-03-02 20:24:00 +02: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
Seungha Yang
b2e9891f8a hlsdemux: Implement adaptivedemux's _stream_seek()
_stream_seek() can be called by adaptivedemux when "restart download" condition.
It's mostly caused by track switching.

https://bugzilla.gnome.org/show_bug.cgi?id=776997
2017-03-02 19:25:48 +02:00
Seungha Yang
78b2169c32 hlsdemux: Simplify seeking code by using macro
Import an adaptivedemux's macro to minimize code.
Also, this patch considers KEY_UNIT and TRICKMODE_KEY_UNITS
as snap seek.

https://bugzilla.gnome.org/show_bug.cgi?id=776997
2017-03-02 19:25:48 +02:00
Seungha Yang
32c4850b33 hlsdemux: Early terminate seeking if we don't need to do
Some codes are imported from dashdemux

https://bugzilla.gnome.org/show_bug.cgi?id=776997
2017-03-02 19:25:48 +02:00