Commit graph

517 commits

Author SHA1 Message Date
yychao
c6ae415ca8 tsdemux: Parse Audio Preselection Descriptor
For Dolby AC4 audio experience, parsing PMTs/APD from transport stream layer for all available presentations.
Refer to ETSI EN 300 468 V1.16.1 (2019-05)

1. 6.4.1 Audio preselection descriptor
2. Table M.1: Mapping of codec specific values to the audio preselection descriptor

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1555>
2020-09-14 06:27:07 +00:00
yychao
5269777a97 tsdemux: Add new API for fetching extended descriptors
Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1555>
2020-09-14 06:27:07 +00:00
Mathieu Duponchelle
6baffc2931 docs: mark more types as plugin API 2020-06-23 12:10:17 -04:00
Jan Alexander Steffens (heftig)
23a2916afd mpegtsdemux: Deliver all packets to tsparse
34af8ed66a changed the code to use the
packetizer's packets instead of the incoming buffers, but mpegtsbase
didn't actually push all packets to the subclass. As a result, padding
(PID 0x1FFF) packets got lost.

Add a new boolean to toggle pushing unknown packets to mpegtsbase and
have mpegtsparse make use of it.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1300>
2020-05-28 16:41:30 +00:00
Jan Schmidt
3fdf25cc37 tsdemux: Handle old streams claiming to be HDMV with Opus
GStreamer 1.16 and earlier produced streams with HDMV registration id
but with Opus audio streams on the stream ID that AC-4 now uses. Make
sure those still play back by special casing the check for AC-4 in HDMV

Fixes https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/issues/1295

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1296>
2020-05-25 01:51:46 +10:00
Jan Alexander Steffens (heftig)
9b2ed3a3fc mpegtsdemux: Close a buffer leak and simplify input_done
tsparse leaked input buffers quite badly:

    GST_TRACERS=leaks GST_DEBUG=GST_TRACER:9 gst-launch-1.0 audiotestsrc num-buffers=3 ! avenc_aac ! mpegtsmux ! tsparse ! fakesink

The input_done vfunc was passed the input buffer, which it had to
consume. For this reason, the base class takes a reference on the buffer
if and only if input_done is not NULL.

Before 34af8ed66a, input_done was used in
tsparse to pass on the input buffer on the "src" pad. That commit
changed the code to packetize for that pad as well and removed the use
of input_done.

Afterwards, 0d2e908523 set input_done
again in order to handle automatic alignment of the output buffers to
the input buffers. However, it ignored the provided buffer and did not
even unref it, causing a leak.

Since no code makes use of the buffer provided with input_done, just
remove the argument in order to simplify things a bit.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1274>
2020-05-18 14:11:40 +00:00
Nicolas Dufresne
4a91a98ea1 mpegtsdemux: Don't pretend doing NAL alignment
Per specification in 2.14.2 "For PES packetization, no specific data
alignment constraints apply". So we should not advertise NAL
alignment.

This bug was introduced at the same moment the alignment field was introduced
10 years ago. The plan was that alignment=none (or no alignment field) was to
be used for mpegtsdemux, but no one noticed the error. The reason is that at
the same moment, everything dealing with H264 started defaulting to AU
alignment.

https://bugzilla.gnome.org/show_bug.cgi?id=606662#c22

This patch will have a side effect that a parser is now needed after the
tsdemux element. The following pipeline will not negotiate anymore as the
mpegtsmux element requires alignment={nal,au}.

  ... ! tsdemux ! mpegtsmux ! ...

As a side effect, anyone that forked from tsdemux should updated their code to
fix this bug.
2020-04-14 11:36:16 -04:00
Michael Olbrich
468408c6a6 mpegtspacketizer: be more tolerant when parsing the adaptation field
According to the specification, the adaptation field length must be 183 if
there is no payload data and < 183 if the packet contains an adaptation
field and payload data.

Unfortunately some payloaders always set the flag for payload data, even if
the adaptation field length is 183.

Don't return with an error in this case. Clear the payload data flag
instead and parse the adaptation field as usual. This avoids visual
artefacts for such streams.
2020-04-07 08:21:04 +00:00
Jan Schmidt
b9ebd885ff tsdemux: Send instant-rate-change event if requested in the SEEK event
Convert instant-rate-change seek events into a downstream
instant-rate-change event and skip any further local seek handling.
2020-04-02 11:26:46 +00:00
Seungha Yang
085f10340e tsdemux: Set mpegversion for AAC ADTS stream based on parsed ADTS header
Both 2 and 4 are supported version of AAC ADTS format stream.
So we need to set correct version to help negotiation
especially for non-autopluggable pipeline.
2020-03-23 10:57:26 +00:00
Edward Hervey
fa2916a159 mpegts: Add a property to ignore broken PCR streams
Some mpeg-ts (HLS, DVB, ...) streams out there have completely broken
PCR streams on which we can't reliably recover correct timestamps.

For those, provide a property that will ignore the program PCR stream
(by faking that it's not present (0x1fff)).
2020-03-11 16:28:03 +00:00
Dong Il Park
691b066ec6 tsdemux: Add format_identifier for AC4 codec
According to following spec document, add format_identifier for AC4 in tsdemux.

ETSI TS 103 190-2 V1.2.1 : Annex D : AC-4 in MPEG-2 transport stream
2020-03-10 16:32:59 +09:00
yychao
adc3d12741 tsdemux: Add support for AC4
According to following two specs, add support for AC4 in tsdemux.

1. ETSI TS 103 190-2 V1.2.1 (2018-02) : Annex D (normative): AC-4 in MPEG-2 transport streams
2. ETSI EN 300 468 V1.16.1 (2019-08) : Annex D (normative):Service information implementation of AC-3, EnhancedAC-3, and AC-4 audio in DVB systems
2020-03-09 21:54:09 +00:00
Vivia Nikolaidou
3df3c3c5f6 tsparse: Add split-on-rai property
If set, buffers sized smaller than the alignment will be sent so that
RAI packets are at the start of a new buffer.

Fixes: #1190
2020-02-11 10:56:54 +00:00
Vivia Nikolaidou
8d522bf3e6 mpegtsparse: Moved dispose function into finalize
dispose can be called several times and would double-free the flow
combiner in that case.
2020-01-29 20:39:44 +00:00
Vivia Nikolaidou
0d2e908523 mpegtsparse: Added alignment property
alignment works like in mpegtsmux, joining several MpegTS packets into
one buffer. Default value of 0 joins as many as possible for each
incoming buffer, to optimise CPU usage.
2020-01-29 20:39:44 +00:00
Vivia Nikolaidou
2f946274d5 mpegtsparse: Set delta unit flag on non-random-access buffers
If they don't have the random access flag set, they cannot be decoded
independently.
2020-01-29 20:39:44 +00:00
Vivia Nikolaidou
34af8ed66a mpegtsparse: Packetize output on default srcpad
Align buffer boundaries with mpeg-ts packets, instead of keeping
whatever packetization we have from the source (network, file reading).
2020-01-29 20:39:44 +00:00
Vivia Nikolaidou
e44cbfb1da mpegtsparse: Factor common code into mpegts_packet_to_buffer
The same code was used twice for turning an MpegTSPacketizerPacket into
a GstBuffer.
2020-01-29 20:39:44 +00:00
Vivia Nikolaidou
68f69d419b mpegtspacketizer: Fix typo in flag name 2020-01-29 20:39:44 +00:00
Mark Nauwelaerts
42b60627fa mpegtsdemux: resurrect actual and efficient seeking of all kinds
... by seeking to target offset determined by new seek segment,
rather than that of the previous segment.  The latter would typically
seek back to start for a non-accurate seek, and lead to a lot
of skipping in case of an accurate seek.
2019-12-31 10:44:35 +01:00
Vivia Nikolaidou
413c6ec57b tsdemux: Always issue a DTS even when it's equal to PTS
Currently tsdemux timestamps only the PTS, and only issues the DTS if
it's different. In that case, parsers tend to estimate the next DTS
based on the previous DTS and the duration, which can accumulate
rounding errors.
2019-11-14 12:16:04 +00:00
Edward Hervey
60cec38591 tsdemux: Handle continuity mismatch in more cases
Packets of a given PID are meant to have sequential continuity counters
(modulo 16). If there are not sequential, this is the sign of a broken
stream, which we then consider as a discontinuity.

But if that new packet is a frame start (PUSI is true), then we can resume
from that packet without any damage.
2019-11-07 09:17:25 +00:00
Aaron Boxer
6d3429af34 documentation: fixed a heap o' typos 2019-11-05 09:11:25 -05:00
Edward Hervey
6a9108884c mpegts: Add support for SCTE-35 sections
Not all commands are supported, but the most common ones are.
Both parsing and packetizing is supported
2019-10-31 12:31:27 +00:00
Edward Hervey
878edacc05 mpegtspacketizer: Fix off-by-one error
This went un-noticed for 6 years :( The issue is that for short
sections (without subtables and CRC), we would always fail when
checking whether we had enough data or not and then default to the
long section checking.

Use the long section checking would then cause interesting side-effects
for short sections (such as believing they were already seen and therefore
would be dropped/ignored).
2019-10-31 12:31:27 +00:00
Tim-Philipp Müller
f218ec2794 Remove autotools build system 2019-10-14 13:54:27 +01:00
Olivier Crête
963dda3482 tsdemux: Make latency configurable
Allows for "low latency" mpeg-ts mode which is not standard, but somewhat common.
For this to work the sender has to put timestamps at a higher frequency than the spec requires.
2019-08-27 12:09:57 -04:00
Jan Schmidt
eaf918df03 tsdemux: Limit the maximum PES payload size
PES packets with size 0 are unbounded, and
could therefore overflow the 32-bit size
accumulator.

Add a 32MB limit, which is larger than
any PES packet should ever get. If one does,
then output a 32MB chunk and continue.
2019-08-21 18:07:02 +00:00
Aaron Boxer
a427b36f79 tsdemux: do not error if buffer size is invalid due to DISCONT
Don't signal a pipeline error when processing incomplete
j2pk PES packets that are too small. That can happen normally
during a DISCONT and shouldn't shut down the whole pipeline
2019-08-16 10:26:04 -04:00
Mathieu Duponchelle
bc4c221be3 tsdemux: always take the seek segment stop into account
Even if an accurate seek was not requested, we should still
respect the seek stop.
2019-08-07 16:39:21 +10:00
Jan Schmidt
b4a298c80e tsdemux: Use gst_segment_do_seek()
Remove some custom and incomplete seek calculation
logic in favour of gst_segment_do_seek(), and
short-circuit any actual seeking or recalculation
if the position didn't change and just send an updated
segment directly.

This removes the custom seeking logic in favour of
using standard core seek handling.
2019-08-07 16:39:21 +10:00
Jan Schmidt
b7c4785a22 mpegtsdemux: Keep the position increasing.
Don't keep the segment position jumping back and forth
based on stream DTS/PTS, only increase the position
if the new value is larger than the old.
2019-08-07 16:39:21 +10:00
Jan Schmidt
32d650491c mpegts: Re-work segment tracking
Add an output segment into the base class for sub-classes
to use for their output segment, in a place where the base
class can see it.
2019-08-07 16:39:21 +10:00
Thibault Saunier
47a49f3381 docs: Build documentation with hotdoc 2019-05-13 17:00:00 -04:00
Jan Schmidt
b7f95d64f8 tsdemux: Skew correction should use the upstream DTS
The MPEG-TS packetiser should use the upstream DTS for
skew correction when running in that mode, as the DTS
carries the upstream arrival time. The PTS (if it's
set at all) is less useful, and can be invalid.
2019-02-13 22:15:53 +11:00
Matthew Waters
aa3d7de98b tsdemux: implement preliminary support for the bitrate query
Return the size / total duration as a ballpark estimate.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/60
2018-11-07 15:09:21 +00: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
Nicolas Dufresne
c052ae511a tsdemux: Don't set invalid seqnum on segment event
https://bugzilla.gnome.org/show_bug.cgi?id=796623
2018-06-19 06:56:48 +02:00
Edward Hervey
4ae9a9dc91 tsdemux: Don't query duration if program isn't active 2018-06-12 11:14:51 +02:00
Edward Hervey
e1133bbbfe mpegtsdemux: Fix SEGMENT seqnum propagation
* If the seek was handled upstream, use that SEGMENT seqnum
* Use the proper invalid default value
2018-06-06 07:51:19 +02:00
Aurélien Zanelli
89a85732d4 tsdemux: ignore sparse stream when checking for initial timestamp
Unless we only have sparse streams. In this case we will consider them.
It fixes a bug happening when first observed timestamp comes from a
sparse stream and other streams don't have a valid timestamp, yet. Thus
leading the timestamp from sparse stream to be the start of the
following segment. In this case, if the timestamp is really bigger than
non-sparse stream (audio/video), it will lead the pipeline to clip
samples from the non-parse stream.

https://bugzilla.gnome.org/show_bug.cgi?id=744469
2018-05-04 22:59:26 +10:00
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
Edward Hervey
52d0ef2665 tsdemux: Make jp2k handling more robust and efficient
* Avoid copying the pending data and instead create a buffer directly from
  that data with the appropriate offset.
* Locate the jp2k magic to determine the exact location of the (first) frame
  data instead of assuming that the header is of an expected size

https://bugzilla.gnome.org/show_bug.cgi?id=786111
2017-09-01 10:49:36 +02:00
Edward Hervey
c393f0d768 tsdemux: Handle quirk in jp2k es header handling
The jp2k specification (ITU-T T.800) specifies that the 'brat' box
has two fields and the second one (AUF2) can be set to 0 for progressive
streams.

The problem is that the mpeg-ts specification (ITU-T H.222.0 06/2012)
says that the AUF2 field is only present if the stream is interlaced

In order to cope with both situation, accept those next 32bit if the
stream is marked as progressive and those bits contain 0

https://bugzilla.gnome.org/show_bug.cgi?id=786111
2017-09-01 10:49:36 +02:00
Edward Hervey
62d6f5c78a tsdemux: Properly error out on jp2k parsing errors
Avoids crashes later on where we assume buffer exists
2017-08-29 10:37:11 +02:00
Mark Nauwelaerts
d949de49f3 mpegtsdemux: remove obsolete function declaration 2017-08-09 19:33:08 +02:00
Aaron Boxer
bbbdc2cd7e tsmux/tsdemux: Add support for JPEG2000
Based on patches by Milos Seleceni.

https://bugzilla.gnome.org/show_bug.cgi?id=753323
2017-07-21 09:33:31 +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
Edward Hervey
fcf87ef2bf mpegtsdemux: Fix wrong usage of '<<' operator
Detected by GCC 7.

Add comments for clarity

https://bugzilla.gnome.org/show_bug.cgi?id=779333
2017-02-28 09:27:41 +01:00