Commit graph

251 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
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
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
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
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
Sebastian Dröge
046aad8c1b tsdemux: Set caps/tags in the GstStream object before pushing the stream-start event
Otherwise downstream will get a more or less empty GstStream although we
already know a lot about it at this point.
2017-01-24 23:11:08 +02:00
Sebastian Dröge
636cb4ce32 tsdemux: Don't leak pad name and template for Opus
It's set again (the same way) further below, overwriting the previously
allocated memory without freeing.

https://bugzilla.gnome.org/show_bug.cgi?id=777533
2017-01-20 14:34:10 +02:00
Sebastian Dröge
b0a6b5eac8 tsdemux: Post an error message on the bus if we activated a program without pads
Otherwise decodebin and applications are going to wait forever for pads
to appear, which is never going to happen.

Happens on this stream, which probably just need support for it added:
https://samples.mplayerhq.hu/3D/AVC_codec_in_m2ts_not_recognized/AVC_codec_not_recognized_right_video_sample.m2ts
2016-11-28 10:30:11 +02:00
Edward Hervey
6622e2dacf mpegtsdemux: Implement efficient program updates
If the parent bin can handle it, only add/remove the new/gone stream
instead of re-adding/re-moving everything

https://bugzilla.gnome.org/show_bug.cgi?id=772742
2016-10-12 15:07:46 +02:00
Edward Hervey
ee70f830a8 mpegtsdemux: Fix issues with GST_DISABLE_GST_DEBUG
Some variables were hidden or unused
2016-10-11 16:47:37 +02:00
Edward Hervey
bcc06d679a mpegtsdemux: Switch to using GstStream/GstStreamCollection
For each MpegTSBaseStream, we have a GstStream object which
subclasses can extend with information.

For each program a GstStreamCollection is created with all
GstStream from each stream.
2016-10-11 12:38:02 +02:00
Wonchul Lee
69b866326e tsdemux: Add conditions to identify ATSC EAC3
https://bugzilla.gnome.org/show_bug.cgi?id=770528
2016-10-03 15:14:54 -04:00
Wonchul Lee
35d147930d tsdemux: Support ATSC EAC3
EAC3 bit streams shall be identified with a stream_type value of 0x87 when
transmitted as PES streams conforming to ATSC-published standards. It is specified
in ATSC Standard A/52.

https://bugzilla.gnome.org/show_bug.cgi?id=770528
2016-09-01 17:56:41 -04:00
Edward Hervey
51c5ff45de tsdemux: Fix draining on wrong programs
When draining a program, we might send a newsegment event on the pads
that are going to be removed (and then the pending data).

In order to do that, calculate_and_push_newsegment() needs to know
what list of streams it should take into account (instead of blindly
using the current one).

All callers to calculate_and_push_newsegment() and push_pending_data()
can now specify the program on which to act (or NULL for the default
one).
2016-08-03 17:15:41 +02:00
Edward Hervey
e2b98a7721 tsdemux: Fix GAP synchronization without a valid PCR PID
For streams that don't have a valid PCR PID, we just use the latest
PTS from any given stream.

https://bugzilla.gnome.org/show_bug.cgi?id=608148
2016-08-03 17:15:41 +02:00
Arnaud Vrac
35a1720de1 mpegtsdemux: only wait for PCR when PCR pid is set
Streams without PCR make senses in HLS, where the playlist timestamps
can be used to seek or calculate the duration.

https://bugzilla.gnome.org/show_bug.cgi?id=608148
2016-08-03 17:15:40 +02:00
Michael Olbrich
48c5cc1b1b tsdemux: add support for LPCM with stream_type = 0x83
https://bugzilla.gnome.org/show_bug.cgi?id=765807
2016-07-25 13:38:29 +03:00
Jan Schmidt
e3f5ccb333 tsdemux: Change the pad naming scheme to include a generation ID
A simple fix for the problem of creating new pads with duplicate
names when switching program, easier than the alternative of
trying to work out which pads might persist and manage that.

See https://bugzilla.gnome.org/show_bug.cgi?id=758454
2016-06-06 13:05:34 +03:00
Tim-Philipp Müller
5ec337f8ae tsdemux: add video/x-h265 to template caps 2016-03-12 15:44:54 +00:00
Jan Schmidt
6de7f0c0fa mpegts: Don't leave freed programs in the hash table
When the sub-class claims a program for later freeing, make
sure it's not left in the hash table, or it can cause crashes on shutdown.

Make sure tsdemux frees any program it has kept around at shutdown
if it wasn't freed already.

https://bugzilla.gnome.org/show_bug.cgi?id=763503
2016-03-12 03:32:32 +11:00
Edward Hervey
215c9eb71a tsdemux: Don't reset/recalculate segments with accurate seeks
When dealing with accurate seeks, we must send out a segment which
is exactly what is requested.

https://bugzilla.gnome.org/show_bug.cgi?id=763262
2016-03-08 15:13:40 +01:00
Edward Hervey
a21c2618c5 tsdemux: Expose DVB Subpicture as subpictures
For some reason we were considering them as private data.
2015-12-02 14:15:04 +01:00
Edward Hervey
531117b7df tsdemux: Push GAP events *after* deactivating old programs
The order in which program switch must happen is:
1) drain all data on old pads (but don't push EOS)
2) add new pads (but don't push any data on them)
3) Push EOS and remove old pads
4) Start pushing data on new pads

There was one caveat in this implementation, which is that when
we activate a sparse pad (step 2) we would push a GAP event. The problem
is that, while being an event, it is actually *data*.

We therefore need to make sure pushing those GAP event is done at the step
we start pushing data.

https://bugzilla.gnome.org/show_bug.cgi?id=750402
2015-12-02 14:15:04 +01:00
Edward Hervey
7336294635 tsdemux: Make sure old streams are drained before switching
Before we add any streams, make sure we drain all streams. This ensures
there's consistency that only "new" data will be pushed on buffers once
the new pads are added

https://bugzilla.gnome.org/show_bug.cgi?id=750402
2015-12-02 14:15:04 +01:00
Edward Hervey
14e6d2d427 mpegtsdemux: Allow deactivation of programs to be delayed
When changing programs, the order of events needs to be the following:
* add pads from new program
* send EOS on old pads
* remove old pads
* emit 'no-more-pads'

Previously tsdemux was not doing that, and was first deactivating and
removing old pads before adding new ones.

We fix this by allowing subclasses of mpegtsbase to be able to handle
themselves the deactivation of programs. In this case tsdemux will
properly deactivate it once it has activated the new program.

https://bugzilla.gnome.org/show_bug.cgi?id=750402
2015-12-02 14:15:04 +01:00
Reynaldo H. Verdejo Pinochet
86ec812429 Remove unnecessary NULL checks before g_free()
g_free() is NULL-safe
2015-11-18 16:05:42 -08:00
Luis de Bethencourt
fc23467152 tsdemux: remove memory leak
The values of channel_mapping are copied by gst_codec_utils_opus_create_caps ()
but it doesn't free or take ownership of the g_new0 allocated memory. This
needs to be freed before going out of scope.

CID 1338692
2015-11-12 12:08:15 +00:00
Nicolas Huet
21a025c2a1 tsdemux: fix pending buffers leak when flushing
https://bugzilla.gnome.org/show_bug.cgi?id=757895
2015-11-11 15:35:54 +01:00
Etienne Peron
a336181ef5 tsdemux: Fix pad leak when the pad is never exposed
If tsdemux never receives data for a stream, the corresponding pad will never
be added and stream->active will remain FALSE. When the stream is removed, the
pad will not be unreffed and will be leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=757873
2015-11-11 15:32:30 +01:00