Commit graph

39 commits

Author SHA1 Message Date
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
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
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
Jan Schmidt 60810cd057 tsparse: Convert PCR values immediately
Doing lazy conversion of PCR values doesn't work right
when a PCR discont is encountered. Instead, convert PCR
values to the continuous timestamp domain as soon as we
encounter them and store that instead.
2017-02-27 23:48:49 +11:00
Vineeth TM 8cdfb13658 bad: use new gst_element_class_add_static_pad_template()
https://bugzilla.gnome.org/show_bug.cgi?id=763081
2016-03-24 14:56:51 +02:00
Edward Hervey ab31900b64 tsparse: Fix per-program-pad pushing
This fixes a couple of issues regarding the output of (request)
per-program pads output:

We would never push out PAT sections (ok, that was one reallly stupid
mistake. I guess nobody ever uses this feature ...).

In the case where the PMT section of a program was bigger than one
packet, we would only end up pushing the last packet of that PMT. Which
obviously results in the resulting stream never containing the proper
(complete) PMT.

The problem was that the program is only started (in the base class)
after the PMT section is completely parsed. When dealing with single-program
pads, tsparse only wants to push the PMT corresponding to the requested
program (and not the other ones). tsparse did that check by looking
at the streams of the program...
... but that program doesn't exist for the first packets of the initial
PMT.

The fix is to use the base class program information (if it parsed the
PAT it already has some information, like the PMT PID for a given program)
if the program hasn't started yet.
2016-02-19 18:12:59 +01:00
Edward Hervey 00a1879d65 tsparse: Use GstFlowCombiner
In addition to the fact that it's a sane thing to do for multi-source
pad elements, it also avoids the situation where just using a request
pad (and not the main static pad) would result in the processing
stopping.
2016-02-19 18:04:23 +01:00
Tim-Philipp Müller edab4deb3a glshader, tsdemux: simplify code
Jus use _delete_link() instead of _remove_link() + _free1()
2015-11-06 13:00:55 +00:00
Vincent Penquerc'h 68f57d20b9 tsparse: fix timestamps not updating after a PMT change
The PCRs stay locked onto the same PID as before the change,
but the relevant PID has no reason to be the same after it.

https://bugzilla.gnome.org/show_bug.cgi?id=745102
2015-04-09 15:44:20 +01:00
Jan Schmidt 068cba5df6 tsparse: Handle backward and discont timestamps better.
Assume that small backward PCR jumps are just from upstream packet
mis-ordering and don't reset timestamp tracking state - assuming that
things will be OK again shortly.

Make the threshold for detecting discont between sequential buffers
configurable and match the smoothing-latency setting on tsparse
to better cope with data bursts.
2014-10-29 23:02:50 +11:00
Jan Schmidt a49ce685d1 tsparse: Implement timestamp/retimestamping of output buffers
When the set-timestamps property is set, use PCRs on the provided
(or autodetected) pcr-pid to apply (or replace) timestamps on the
output buffers, using piece-wise linear interpolation.

This allows tsparse to be used to stream an arbitrary mpeg-ts file,
or to smooth jittery reception timestamps from a network stream.

The reported latency is increased to match the smoothing latency if
necessary.
2014-10-29 23:02:50 +11:00
Edward Hervey 22dfd9aef3 mpegts: Unify API : GstMpegts / gst_mpegts_ / GST_*_MPEGTS_
It was previously a mix and match of both variants, introducing just too much
confusion.

The prefix are from now on:
* GstMpegts for structures and type names (and not GstMpegTs)
* gst_mpegts_ for functions (and not gst_mpeg_ts_)
* GST_MPEGTS_ for enums/flags (and not GST_MPEG_TS_)
* GST_TYPE_MPEGTS_ for types (and not GST_TYPE_MPEG_TS_)

The rationale for chosing that is:
* the namespace is shorter/direct (it's mpegts, not mpeg_ts nor mpeg-ts)
* the namespace is one word under Gst
* it's shorter (yah)
2014-06-25 14:50:05 +02:00
Sebastian Dröge d7c7f54734 mpegtsparse: Queue buffers until we have enough to know the caps
https://bugzilla.gnome.org/show_bug.cgi?id=708222
2013-09-27 16:10:54 +02:00
Sebastian Dröge 2a1877909f tsparse: Add support for group-id in the stream-start event 2013-07-23 10:33:31 +02:00
Edward Hervey 2fb7b87140 mpegtsdemux: Avoid vmethod calls
Depending on usage, tsparse and tsdemux might not need to be called
when new section/pes-data is available.
2013-07-09 12:25:11 +02:00
Edward Hervey 61b30175b3 mpegtsdemux: Remove unneeded variables
* packet.origts is no longer used since the PCR refactoring done ages ago
* known_packet_size is a duplicate of packet_size != 0
* caps was never used outside of the packetizer
2013-07-09 12:25:11 +02:00
Edward Hervey 1f2bb15618 mpegtsdemux: GstMpegTS => GstMpegTs 2013-07-03 14:00:58 +02:00
Edward Hervey 92edd82c86 mpegtsdemux: Switch to MPEG-TS SI library
* Only mpeg-ts section packetization remains.
* Improve code to detect duplicated sections as early as possible
* Add FIXME for various issues that need fixing (but are not regressions)

https://bugzilla.gnome.org/show_bug.cgi?id=702724
2013-07-03 09:17:25 +02:00
Edward Hervey e66d543f00 tsparse: Ensure initial events are sent in the right order
First send stream-start, then caps, then segment.

The segment we push is from upstream in push-mode. If we work in pull-mode
then we initialize the base segment to BYTES.

https://bugzilla.gnome.org/show_bug.cgi?id=702422
2013-06-19 07:40:28 +02:00
Tim-Philipp Müller 9e1b75fda3 Fix FSF address
https://bugzilla.gnome.org/show_bug.cgi?id=687520
2012-11-04 00:09:59 +00:00
Edward Hervey a8d1e88bda tsparse: Push out buffer on main source pad 2012-08-14 19:05:44 +02:00
Sebastian Dröge bdc46898de gst: Add stream-id to stream-start events 2012-08-06 14:05:08 +02:00
Edward Hervey d3271381ee mpegtsbase: Move known PSI PIDs to where they belong
This avoids tsdemux parsing data is doesn't really care about

Conflicts:

	gst/mpegtsdemux/mpegtsparse.c
2012-06-29 10:02:30 +02:00
Edward Hervey b8f32811ca tsparse: Rework handling and cleanups
tspad always has a static source pad which output everything received
(not functional yet).

Program pads are now request pads.

Remove all cruft that should have been removed from the switch over
to mpegtsbase.

Conflicts:

	gst/mpegtsdemux/mpegtsparse.c
2012-06-21 11:34:28 +01:00
Wim Taymans b98ec32380 update for tag event change 2012-06-06 13:02:40 +02:00
Edward Hervey 7fdf1cb0c8 tsparse: Adapt to new packetizer API 2012-05-22 17:43:38 +02:00
Gil Pedersen fcd8155d87 mpegtsdemux: port to 0.11
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=674397
2012-04-20 11:25:31 +02:00
Gil Pedersen 095a17ad03 mpegtsdemux: fix memory leaks
Fixes https://bugzilla.gnome.org/show_bug.cgi?id=674393
2012-04-20 11:25:31 +02:00
Sebastian Dröge a1c291ebb6 mpegtsdemux: Revert to 0.10 state as this is unmergeable, also put it into the non-ported plugins again 2012-03-29 17:55:09 +02:00
Wim Taymans 6d92ecac75 add parent to query function 2011-11-16 17:30:38 +01:00
Wim Taymans c8adc4f8c8 make request pads take _%u 2011-11-04 12:22:37 +01:00
Wim Taymans ac27b5bcc8 tag: update for tag API removal 2011-11-02 12:10:03 +01:00
Edward Hervey 6abe2134bf tsdemux/tsparse: Port to 0.11
This is a naive port that somewhat works but is inefficient.
I need to rethink how to make the best out of GstMemory/GstBuffer
2011-10-12 18:06:16 +02:00
Janne Grunau 22ecf13e42 mpegtsdemux: add MPEG TS demuxer rewrite from Edward Hervey
with contributions from Miquel Angel Farre Guiu and Zaheer Abbas Merali
2011-02-17 17:56:59 +01:00