Commit graph

57 commits

Author SHA1 Message Date
François Laignel 439717ab65 qtdemux: fix byte order for opus extension and version field type
The "Encapsulation of Opus in ISO Base Media File Format" [1] specifications,
§ 4.3.2 Opus Specific Box, indicates that data must be stored as big-endian.

[1] https://opus-codec.org/docs/opus_in_isobmff.html#4.3.2

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4875>
2023-06-19 14:31:55 +00:00
Xabier Rodriguez Calvar bdff780fe9 qtdemux: Fix critical message on cenc sample grouping parsing
Inside qtdemux_parse_sbgp there is already a check to ensure the fragment group
properties are not null but it is being hit in some examples and it is better to
directly avoid the critical.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4576>
2023-06-07 11:01:20 +00:00
Jan Alexander Steffens (heftig) 93699123b4 isomp4: Fix (E)AC-3 channel count handling
The muxer used a fixed value of 2 channels because the TR 102 366 spec
says they're to be ignored. However, the demuxer still trusted them,
resulting in bad caps.

Make the muxer fill in the correct channel count anyway (FFmpeg already
does) and make the demuxer ignore the value.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4739>
2023-06-02 19:07:58 +00:00
Sebastian Dröge d5a0cfc563 qtdemux: Add support for SpeedHQ video codec
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3982>
2023-05-19 07:16:03 +00:00
Mathieu Duponchelle 3d3d2ed447 Revert "qtdemux: fix conditions for end of segment in reverse playback"
This reverts commit 9deb3c27ac.

The test case that was described in the associated MR
(https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/262)
remains adequately fixed by a related MR that was merged later
(https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/275).

It introduced incorrect logic that broke edit lists as described in
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2549

Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/2549
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4560>
2023-05-11 16:45:37 +00:00
Xabier Rodriguez Calvar 021572de93 qtdemux: emit no-more-pads after pruning old pads
If we don't do that, clients can rely on this signal to see the final pad
topology but it won't be the real one as some of them will disappear after
emitting that signal. This can happen after injecting a different init segment.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4535>
2023-05-03 12:06:00 +00:00
Carlos Rafael Giani 0071c97128 qtdemux: Add audio clipping meta when playing gapless m4a content
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4200>
2023-05-03 08:47:55 +00:00
Xabier Rodriguez Calvar 66c15bc753 qtdemux: Fix segfault in cenc sample grouping
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4523>
2023-05-02 11:32:01 +02:00
Sebastian Szczepaniak 277a9f0cef qtdemux: Add support for cenc sample grouping
Co-authored-by: Xabier Rodriguez Calvar <calvaris@igalia.com>
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3551>
2023-04-26 18:51:56 +00:00
Edward Hervey 4c6f41a00a qtdemux: Fix av1C parsing
This is a regression introduced by
https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3882

The av1c codec configuration parsing would always fail due to an off-by-one
error, the content of an atom starting at offset 8 (i.e. the 9th byte) and not
9 (the 10th byte).

Also introduce a break in order to not get stray warnings

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4433>
2023-04-17 09:28:43 +02:00
Piotr Brzeziński 5beef42922 qtdemux: Fix seek adjustment with SNAP_AFTER flag
With GST_SEEK_FLAG_SNAP_AFTER present, the previous version would
adjust seek time based on the keyframe farthest away from desired_time.
This was incorrect, because we always want the *earliest* suitable keyframe
to seek to, not the last one.
With this fix, in case of the SNAP_AFTER, we now look for the closest keyframe
that can be found after desired_time. Behaviour for SNAP_BEFORE should remain
unchanged.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4183>
2023-03-22 13:05:53 +00:00
Enrique Ocaña González 735dac9d2f qtdemux: Fix crash on MSE-style flush
The flowcombiner and active_streams shouldn't be cleared in the
mse-bytestream variant, only in the mss-fragmented one. Otherwise the
soft reset leaves qtdemux in a state where it still believes that it has
streams, but they've been cleared. In that case, a null pointer
dereference happens and the app crashes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4199>
2023-03-17 15:33:49 +00:00
Tim-Philipp Müller 0fc568c6b1 gst-plugins-good: re-indent with GNU indent 2.2.12
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4182>
2023-03-17 03:18:54 +00:00
Alicia Boya García c1f4bd5a3f qtdemux: Add MSE-style flush
The abort() method of SourceBuffer in Media Source Extensions is
expected to flush the demuxer and discard the current fragment,
if any. The configuration of tracks, if any, should be preserved.

qtdemux has different behavior for flush events depending on the
context.

This patch activates the intended behaviour only for streams of the
VARIANT_MSE_BYTESTREAM type, conformant to the ISO BMFF Bytestream
specification[1]. This flush behaviour is the same as the one
already in use for adaptivedemux sources.

[1] https://www.w3.org/TR/mse-byte-stream-format-isobmff/

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

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/4101>
2023-03-02 17:54:41 +00:00
Hosang Lee 88f16ebd2a qtdemux: compensate wrong data offset for MSS fragments
A data offset with an offset smaller than the moof length is wrong
in smooth streaming streams.

The samples will not be located and eventually playback will
error out. So compensate assuming data is in mdat following moof.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3840>
2023-02-16 00:43:57 +00:00
Vivia Nikolaidou 4e7a5ebb11 qtdemux: Handle moov atom length=0 case by reading until the end
Previously it would fail to demux the file by trying to read G_MAXUINT64
bytes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3934>
2023-02-11 02:20:39 +00:00
Vivia Nikolaidou 3a9acff978 qtdemux: Fix guint vs gsize type confusion
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3934>
2023-02-11 02:20:39 +00:00
Sebastian Dröge 8593a58916 qtdemux: Drop av1C version 0 parsing and implement version 1 parsing
The av1C box is optional so dropping parsing does not break anything
fundamentally, and there seems to be no historical record how version 0
even looks like while the comments and the parsing disagreed with each
other.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3882>
2023-02-09 14:04:06 +00:00
Enrique Ocaña González 92a4cfe20f qtdemux: Don't emit GstSegment correcting start time when in MSE mode
When using qtdemux in a pipeline that should only work as a pure demuxer (not
for actual playback), qtdemux shouldn't emit new GstSegments to correct
the start time (jump to the future) to ensure that the user experiences no
playback delay. By doing so, it's generating the wrong segments when an append
of data from the past happens. When that happens, downstream elements such as
parsers (eg: aacparse) may clip those buffers laying before the GstSegment and
create problems on the GStreamer client app (eg: WebKit).

Getting buffers clipped out because of the wrong GstSegments started becoming
a problen when this commit was introduced:

ab6e49e9cc audioparsers: add back segment clipping to parsers that have lost it

This clipping makes test DASH shaka 35 from MVT tests[1] to fail in
WebKitGTK/WPE (at least) and can potentially cause a number of other problems
in the WebKit Media Source Extensions (MSE) code.

Note that this new behaviour of not emitting new GstSegments only makes sense
when qtdemux is being used as a pure demuxer and not as part of a regular
pipeline. This is why the variant field has been added. When equal to
VARIANT_MSE_BYTESTREAM, it will make qtdemux behave differently in push mode,
taking decisions that meet the expectations for an MSE-like processing mode.
This kind of tweaks have been done in the past for MSS streams, for instance.
That code has been refactored to use VARIANT_MSS_FRAGMENTED now, instead of
its own dedicated boolean flag.

Co-authored by: Alicia Boya García <ntrrgc@gmail.com>

...who suggested to use "variant: mse-bytestream" in the caps to identify that
mode, as proposed in her unmerged patch:

https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/467

[1] https://github.com/rdkcentral/mvt

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3867>
2023-02-06 12:42:49 +00:00
Alicia Boya García 8a6023a38a qtdemux: Use safer clearing functions in dispose()
In theory, `dispose()` functions should be idempotent and should be
prepared not to crash or cause a double-free if an unref done from
inside caused a recursive call to `dispose()` of the same object.

https://developer.gnome.org/gobject/stable/howto-gobject-destruction.html

This patch modifies the `dispose()` method to honor these constraints.

Since the double `dispose()` call won't actually occur in qtdemux (there
is no cycle detection mechanism that could invoke it to work that way),
this is more of a code cleanup than a user-facing problem fix.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3822>
2023-01-28 00:32:57 +00:00
Sebastian Dröge 4c8141a0c3 isomp4: Add stream-format = (string) obu-stream to AV1 caps
Anything else is not allowed in MP4.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3740>
2023-01-19 12:10:40 +02:00
Jan Alexander Steffens (heftig) 211191564e qtdemux: Add basic support for AVC-Intra video
AVC-Intra is a range of H.264-compliant intra-only codecs from
Panasonic. The codes and descriptions have been taken from VLC.

The (encumbered) sample I have here produces byte-stream H.264,
including SPS and PPS and no `avcC` box.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3739>
2023-01-18 10:01:30 +00:00
Sebastian Dröge 066558cba1 qtdemux: Always use tfdt if available in BYTE segments
This reverts the decision from
  https://bugzilla.gnome.org/show_bug.cgi?id=754230
where it was decided that we rather play safe and only use the `tfdt` if
it is "significantly different" to the sum of sample durations.

As the specification says

    If the time expressed in the track fragment decode time (‘tfdt’) box
    exceeds the sum of the durations of the samples in the preceding
    movie and movie fragments, then the duration of the last sample
    preceding this track fragment is extended such that the sum now
    equals the time given in this box.

we have to use the `tfdt` in general to allow for it to signal gaps in
the stream.

A muxer producing fragments might not yet know the full duration of the
last sample of a previous fragment if the next fragment starts with a
gap, and knowing the actual start of the next fragment would potentially
require to violate latency requirements.

Additionally, the existence of `tfdt` allows to avoid accumulating
rounding errors from summing up the durations.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3586>
2022-12-17 19:26:19 +02:00
Xabier Rodriguez Calvar 87ae60176b qtdemux: Clear protection events when we get new ones
If we keep the old events they can be end up being passed to the app, that could
discard the protection information because it has been seen before.

Drive by improvement: use g_queue_clear_full instead of foreach+clear for
protection events.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3547>
2022-12-14 11:01:23 +01:00
Jacek Skiba 61c17c5665 qtdemux: exit when protection caps are not defined during PIFF parsing
Reproduction testcase (uses PlayReady):
https://developers.canal-plus.com/rx-player/upc/?appTileLocation=[object%20Object]

In test streams we are using PIFF box, but caps did not had
present GST_PROTECTION_SYSTEM_ID_CAPS_FIELD. In consequence, invalid
system_id was returned which caused SIGSEGV crash.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3535>
2022-12-07 18:35:37 +00:00
Justin Chadwell fd96fc23c5 qtdemux: use unsigned int types to store result of QT_UINT32
In a few cases throughout qtdemux, the results of QT_UINT32 were being
stored in a signed integer, which could cause subtle bugs in the case of
an integer overflow, even allowing the the result to equal a negative
number!

This patch prevents this by simply storing the results of this function
call properly in an unsigned integer type. Additionally, we fix up the
length checking with stsd parsing to prevent cases of child atoms
exceeding their parent atom sizes.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3344>
2022-11-06 12:00:31 +00:00
Edward Hervey 6ffae88a9f qtdemux: Fix cenc-related leaks
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3319>
2022-11-04 17:59:21 +00:00
Edward Hervey f2a1769236 qtdemux: Don't stop task when resetting
This is a regression that was introduced in
cca2f555d1 (yes, 9 years ago).

The only place where a demuxer streaming thread should be stopped is when the
sinkpad is deactivated from pull mode (i.e. PAUSED->READY).

Attempting to stop the task in this function would cause this to happen when a
FLUSH_STOP or STREAM_START event is received... which can cause deadlocks.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3109>
2022-10-03 14:41:18 +02:00
Tim-Philipp Müller 02a8f9973b qtdemux: guard against timestamp calculation overflow in gap event loop
Could possibly cause an endless loop.

Fixes #1400.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3084>
2022-09-27 13:07:15 +00:00
Mathieu Duponchelle 8756f523d1 playback: add onvif metadata caps to raw caps
+ remove encoding from x-onvif-metadata caps output by qtdemux

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2889>
2022-08-24 12:21:18 +03:00
Jan Schmidt c2fa0b50ce qtdemux: Avoid crash on reconfiguring.
When reconfiguring a stream that never created
an output pad, don't access a NULL GstPad pointer.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2869>
2022-08-16 19:01:28 +00:00
Sebastian Dröge a3037eb453 qtdemux: Set parsed=true on ONVIF Timed Metadata caps
Inside MP4 the metadata must be properly parsed into frames and in
order.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2897>
2022-08-16 18:11:53 +00:00
Sebastian Dröge b0533d1ea0 qtdemux: Add reference timestamp meta with UTC times based on the ONVIF Export File Format CorrectStartTime box to outgoing buffers
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2525>
2022-08-12 16:13:50 +00:00
Edward Hervey 63dcee34fb qtdemux: Don't use invalid values from failed trex parsing
If parsing the fragment default values (`trex` atom) failed, don't try to
compute a bogus sample_description_id value.

Fixes #1369

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2860>
2022-08-11 08:50:34 +02:00
Sebastian Dröge 14d306da6d qtdemux: Fix integer overflows in zlib decompression code
Various variables were of smaller types than needed and there were no
checks for any overflows when doing additions on the sizes. This is all
checked now.

In addition the size of the decompressed data is limited to 200MB now as
any larger sizes are likely pathological and we can avoid out of memory
situations in many cases like this.

Also fix a bug where the available output size on the next iteration in
the zlib decompression code was provided too large and could
potentially lead to out of bound writes.

Thanks to Adam Doupe for analyzing and reporting the issue.

CVE: tbd

https://gstreamer.freedesktop.org/security/sa-2022-0003.html

Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1225

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2610>
2022-06-15 17:50:55 +00:00
Sebastian Dröge 7273024ae5 qtdemux: Add support for ONVIF XML Timed MetaData
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2453>
2022-05-20 13:01:44 +00:00
Sebastian Dröge 04f6258863 qtdemux: Parse styp box for informational purposes
And include some more details in the debug logs for the ftyp box too.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2453>
2022-05-20 13:01:44 +00:00
Sebastian Dröge 1223324246 qtdemux: Don't use tfdt for parsing subsequent trun boxes
The timestamp in the tfdt refers to the first trun box and if there are
multiple trun boxes then the distance between the first timestamps will
grow.

At some point this distance reaches a threshold and triggers the
resetting of the first sample's timestamp of this trun box to be reset
to the tfdt.

This threshold is implemented for files where there is a jump in the
timeline between fragments and where this can be detected via a jump
between the end timestamp of the previous fragment and the tfdt of the
next. This behaviour is preserved.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2409>
2022-05-13 04:19:36 +00:00
Xavier Claessens b99ecc78ca Replace gst-i18n-*.h with gi18n-lib.h
GLib guarantees libintl is always present, using proxy-libintl as
last resort. There is no need to mock gettex API any more.

This fix static build on Windows because G_INTL_STATIC_COMPILATION must
be defined before including libintl.h, and glib does it for us as part
as including glib.h.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2028>
2022-04-19 18:01:06 +00:00
Havard Graff 71891e5647 qtdemux: fix leak of channel_mapping
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2179>
2022-04-14 19:41:36 +09:00
Edward Hervey 568b918971 qtdemux: Propagate stick events downstream when creating pads
If upstream provided a stream collection event before any pads were created,
make sure it's propagated downstream when pads are created.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1891>
2022-03-09 16:09:31 +00:00
Nicolas Dufresne f6c070fbff isomp4: Fix AV1 default alignment
ISOMP4 store TU (temporal units) worth of AV1. Expose this in the
caps to reduce overhead in the parser, and in the muxer to avoid
storing frames split in the wrong way.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1837>
2022-03-04 21:58:15 +00:00
Seungha Yang 53ed876002 qtdemux: Do not send unnecessary GAP events
Each stream may have its own segment timeline
(i.g., different segment.start or segment.base)
depending on edit-list and composition-to-decode atom.

Make sure whether time position of a stream has been actually
far behind than that of current target stream.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1352>
2022-02-17 19:39:53 +00:00
Sebastian Dröge efb2b6d478 qtdemux: Log cslg_shift that was determined
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1294>
2021-11-12 17:51:04 +00:00
Sebastian Dröge 12e918428a qtdemux: Use a composition time offset of 0 for "no decode samples" for the time being
This needs codec-specific handling, but using 0 instead of G_MININT32 at
least gives somewhat reasonable behaviour.

See https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/883

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1294>
2021-11-12 17:51:03 +00:00
Sebastian Dröge ad412d257b qtdemux: Always check ctts for unreasonably large offsets
If this happens then ignore the whole ctts. Previously we only did this
if the PTS/DTS shift was determined from the ctts instead of the cslg.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1294>
2021-11-12 17:51:03 +00:00
Sebastian Dröge a33e30cfc4 qtdemux: Only adjust segment.stop by cslg_shift if stop is not -1
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1294>
2021-11-12 17:51:03 +00:00
Sebastian Dröge bb5a5ae8a8 qtdemux: Handle negative composition offsets in the trun box the same way as for non-fragmented streams
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1294>
2021-11-12 17:51:03 +00:00
Sebastian Dröge 767e8bf668 qtdemux: Parse ctts version
Negative composition time offsets are only allowed with version 1 of the
box, however we parse it as a signed value also for version 0 boxes as
unfortunately there are such files out there and it's unlikely to have
(valid) huge composition offsets.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1294>
2021-11-12 17:51:03 +00:00
Sebastian Dröge 284dd5443f qtdemux: Add support for version 1 cslg boxes
They use 64 bit fields instead of 32 bit.

Also parse offset as a signed integer (in both versions) and clamp it to
a positive value as negative values don't really interest us here.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1294>
2021-11-12 17:51:03 +00:00