Commit graph

316 commits

Author SHA1 Message Date
Jesper Larsen
8e4f966018 tsdemux: fix program-number functionality
Setting the program-number property does not affect which program
is actually being demuxed.

Moving the initialization of the program_number from
gst_ts_demux_reset to gst_ts_demux_init seems to fix this issue.

https://bugzilla.gnome.org/show_bug.cgi?id=690934
2013-07-22 09:53:46 +02:00
Edward Hervey
1b1b3a40d7 mpegtsdemux: Remember seek sequence number
* Avoids handling twice the same seek (can happen with playbin and files
  with subtitles)
* Set the sequence number of the segment event to the sequence number of
  the seek event that generated it (-1 for the initial one).
2013-07-15 11:20:40 +02:00
Arnaud Vrac
024aa47f64 tsdemux: implement seeking in push mode 2013-07-15 11:20:40 +02:00
Arnaud Vrac
388c28381f tsdemux: recalculate new segment after byte seek
The seeking start time is approximated from the seek offset in bytes
using the accumulated PCR observations, so on a VBR stream there might
be a big difference between the actual PCR and the estimated one after
the seek. This might result in a long wait to skip all out of segments
packets.

Instead we just recalculate the new segment to start at the first PTS
after the seek, so that playback starts immediatly.
2013-07-15 10:51:28 +02:00
Edward Hervey
8ca1751f00 mpegtsdemux: Avoid parsing section without enough data
This is actually a workaround (we'll be skipping the upcoming section)

This will only happen for sections where the beginning is located within
the last 8 bytes of a packet (which is the minimum we need to properly
identify any section beginning).

Later we should figure out a way to store those bytes and mark that
some analysis needs to happen. The probability of this happening is
too low for me to care right now and do that fix. There is a good chance
that section will eventually be repeated and won't end up on such border.
2013-07-09 12:25:11 +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
f58f13e874 mpegtsdemux: Fix multiple-SI detection/parsing
We had two issues with the previous code:
1) We were badly handling PUSI-flagged packets. We were discarding the
   initial data (if pointer != 0) whereas we should have been accumulating
   it with the previous data (if there was a continuity of course).
   => First series of information loss
2) We were not checking whether there were more sections after the end
   of one (i.e. when the following byte was not a stuff byte).

This fixes those two issues.

Fixes #677443

https://bugzilla.gnome.org/show_bug.cgi?id=677443
2013-07-07 08:29:37 +02:00
Edward Hervey
513417e0ff mpegtbase: Fix switch/case typo
Ended up trying to analyze PMT ... with a PAT :(
2013-07-07 07:21:46 +02:00
Edward Hervey
1c96c79b88 mpegtsdemux: Handle private section streams
Until now we simply ignored those streams (since we couldn't do anything
with it anyway). Now that we have the mpegts library and we offload the
section handling to the application side we can properly identify and
extract them.

By default it is disabled for tsparse and enabled for tsdemux, but there is
a property to change that.

This should open the way to properly handle all private section streams,
including:
* DSM-CC
* MHEG
* Carousel data
* Metadata streams (though I haven't seen any of those in the wild)
* ... And all other specs/protocols making use of those

Partially fixes #560631
2013-07-06 14:50:52 +02:00
Edward Hervey
a3b6b1a951 mpegtsdemux: Handle registration descriptor for programs and streams
* Allows us to simplify some code and prepare for future cleanups.
* Remove useless casts
* Add some FIXME regarding VC1
2013-07-06 10:59:54 +02:00
Edward Hervey
9da7551993 mpegtsbase: Remove no-longer needed code
Since we now send all sections to the packetizer, we no longer need to do
anymore in-depth checks for the validity of a section.

The choice boils down to:
1) Is it from a known PES pid ? If so pass it on (which might be just pushing
   downstream in the case of tsparse, or accumulating PES data for tsdemux)
2) Is it from a known SI pid ? If so pass it to the section packetizer
2013-07-05 17:25:17 +02:00
Edward Hervey
b7bba5658a mpegtsdemux: Fix compilation with debugging disabling
We previously weren't using that variable ...
2013-07-05 10:57:34 +02:00
Edward Hervey
7814ed196b mpegtsdemux: Switch to using GstMpegTsStreamType
We still have some other stream types which haven't been ported, but
we will do so once we have defined the enums in the mpegts library.

Also add some FIXMEs regarding items discovered during analysis
2013-07-04 08:45:32 +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
358a68e65b mpegdesc: Extend list of known descriptors
Add the various ATSC ones
2013-06-24 14:55:28 +02:00
Edward Hervey
26689fc437 mpegtsbase: Only warn for added streams when needed
We use add_stream(stream_type:-1) to ensure a programs' PCR Stream is
also taken into account. For most programs this will re-use an
existing ES stream.

So only warn that we are re-adding a stream if it was already present
AND it is not to ensure the PCR stream is taken into account.
2013-06-24 08:24:58 +02:00
Edward Hervey
f9b3b46ab5 mpegtspacketizer: Speed up section parsing
Only create subtables when needed. It was previously creating one every
single time ... to check if one was present.
And speed up code to detect whether a subtable was already present or not.

Overall makes section pushing 2 times faster.
2013-06-24 07:49:34 +02:00
Edward Hervey
15e3afc099 mpegdesc: Extend list of known descriptors
From ITU-T H222.0 (06/2012). Freely available from itu.int
2013-06-24 07:49:34 +02:00
Edward Hervey
9fd7f1c082 mpegtspacketizer: Speedup packet parsing
Avoid using bitshifting where not needed.

Speeds up packet parsing by 3% (this is *the* hotspot of mpeg-ts elements).
2013-06-24 07:49:34 +02:00
Edward Hervey
0592bcc3c9 mpegtspacketizer: Better detect already seen section
In some cases (NIT on highly-populated DVB-C operator for example), there
will be more than one section emitted for the same subtable and version
number.

In order not to lose those updates for the same version number, we checked
against the CRC of the previous section we parsed.

The problem is that, while it made sure we didn't lose any information, it
also meant that if the same section came back (same version, same CRC) later
on we would re-process it, re-parse it and re-emit it.

This version improves on that by keeping a list of previously observed CRC
for identical PID/subtable/version-number and will only process sections if
they really were never seen in the past (as opposed to just before).

On a 30s clip, this brings down the number of NIT section parsing from 4541
down to 663.

https://bugzilla.gnome.org/show_bug.cgi?id=614479
2013-06-23 09:06:15 +02:00
Edward Hervey
c0ce94dbf2 mpegtspacketizer: Speed up NIT parsing
Avoid duplicating the delivery structure, and instead give it to the
receiving container.
2013-06-19 19:31:12 +02:00
Edward Hervey
40bcf48b0c mpegtbase: simplify code
We don't need generic methods for push/flush since we know all the
subclass that we control
2013-06-19 12:29:47 +02:00
Edward Hervey
79e63e3daf mpegtsdemux: Fix for compiling without GST_DEBUG
Protect debug-only variables/usage, and in one case remove a useless
variable.
2013-06-19 12:29:46 +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
Arnaud Vrac
a5402d6eeb tsdemux: fix M2TS stream resync
Sync byte scan is incorrect for M2TS streams because the timestamp 4
bytes were not included in the flush size. This can result in an
infinite loop.

Rework the scan code to be clearer and work in all cases.
2013-06-12 08:01:24 +02:00
Arnaud Vrac
065d421d34 tsdemux: move some debug prints at the log level 2013-06-12 08:01:20 +02:00
Josep Torra
28a2902a7b tsdemux: fixes seeking in pull mode
Preserve the current segment and observations in pull mode seeks with
flushing.

https://bugzilla.gnome.org/show_bug.cgi?id=698050
2013-06-12 08:01:06 +02:00
Edward Hervey
0809770d26 mpegtspacketizer: Fix leak
Since we were manually setting GValue to the GValueArray, we also need
to specify how many were set, otherwise all values in the array will
be leaked.
2013-06-05 15:23:18 +02:00
Edward Hervey
877019ae00 mpegtspacketizer: Speedup TDT/TOT parsing
Use quarks where needed, makes it 2.5 times faster
2013-06-05 13:39:14 +02:00
Edward Hervey
824f08d1d8 mpegtspacketizer: Fix string leak
The description/text get copied in the structure.
2013-06-05 13:21:29 +02:00
Edward Hervey
f3bf40e2b0 mpegtspacketizer: Speed up descriptor parsing/packing
descriptors are stored as a GValueArray of GString. The downside is
that there is no way to "pass" ownership of a GValue to a GValueArray
which previously resulted in expensive copy/free of the (already expensive)
GString.

Here we estimate first the size of the GValueArray, then create it,
then directly use the GValue of that array.

Speeds up total SI parsing by ~30%
2013-06-05 12:49:09 +02:00
Edward Hervey
e6f0986b9e mpegtspacketizer: Use gst_value_list_append_and_take_value
Avoids doing the expensive copy of structures/arrays/...

Speeds up parsing SI by about 50%
2013-06-05 12:48:05 +02:00
Edward Hervey
b378b7e9d6 mpegtspacketizer: Avoid copying GValueArray
Just give the GValueArray to the container GValue.
2013-06-05 11:27:05 +02:00
Michael Rubinstein
e6c8224609 mpegtsdemux: Free memory behind GString if we don't use it
https://bugzilla.gnome.org/show_bug.cgi?id=700903
2013-05-25 15:49:21 +02:00
Edward Hervey
ce441cbff7 mpegtsbase: Post an error message when EOS'ing without source pads
This ensures we don't "hang" when files can't be decoded, or contain
no valid streams.
2013-05-23 14:59:34 +02:00
Edward Hervey
7837cab44e tsdemux: Demote a warning to debug level
We will get it for virtually every first packets.
2013-05-23 14:59:34 +02:00
Edward Hervey
65ba9b4756 tsdemux: convert packet PTS/DTS as soon as possible
We let the mpegtspacketizer deal with pcr wraparound/resets.

https://bugzilla.gnome.org/show_bug.cgi?id=674536
2013-04-26 15:49:18 +02:00
Edward Hervey
05b51dfec0 mpegtsdemux: header cleanups/updates 2013-04-26 15:49:18 +02:00
Thiago Santos
d8b8809d57 tsdemux: Fix caps string leak 2013-04-24 12:28:17 +02:00
Greg Rutz
2306d51d9d tsdemux: Add support for Motorola DigiCipher II MPEG2 video
Since there is a conflict between the DCII stream type and BluRay
stream types, moved the processing of BluRay-specific stream types
to the beginning of the function.  Only if a BluRay stream type
IS NOT found do we proceed to check the rest of the stream type
identifiers

Previous code was also "sort-of" handling a similar conflict between
BluRay AC3 audio and standard AC3 audio.  Moved the special case BluRay
AC3 handling in the main switch statement to the new BluRay-specific
switch.

https://bugzilla.gnome.org/show_bug.cgi?id=697892
2013-04-18 09:30:58 +02:00
David Schleef
303a2eaec4 mpegtsdemux: check value before using as denominator 2013-04-15 17:05:30 -07:00
Sebastian Dröge
e51cd4fe2f gst: Add better support for static plugins 2013-04-15 15:59:22 +02:00
Sebastian Dröge
2713fd1058 tsdemux: Check the continuity counter for non-section packets too
And if we detect a discontinuity there (like... when losing packets
or having MPEGTS over raw UDP with out-of-order packets) we just
drop the corresponding packet.

A future version could try to implement a re-ordering algorithm based
on that, similar to what rtpjitterbuffer does.
2013-04-11 13:11:44 +02:00
Sebastian Dröge
4ca886c53b mpegtsbase: Call ::program_stopped after removing all streams
Subclasses want to access the program while removing the streams
and will currently crash because of dereferencing NULL in some cases.
2013-04-10 16:19:00 +02:00
Edward Hervey
98265d0b28 tsdemux: Add support for TrueHD audio 2013-04-07 18:41:38 +02:00
Edward Hervey
ca3146a2cd tsparse: Ensure segment events are forwarded
We skip them for tsdemux though (recreated later)

Fixes #690949
2013-03-30 13:54:37 +01:00
Douglas Bagnall
0c9db072ce tsdemux: remove unused current_program_number field
https://bugzilla.gnome.org/show_bug.cgi?id=690934
2013-03-24 20:58:28 +00:00
Sebastian Dröge
acacef9fbb mpegtsdemux: Fix various compiler warnings 2013-03-03 12:30:32 +01:00
Josep Torra
7fafbe2e22 tsdemux: expose VC1 streams with missing descriptor.
Fixes playback of VC1 streams when the descriptor is missing.
2013-02-05 23:07:12 +01:00
David Schleef
a19c0b5697 tsdemux: Add descriptors for SMPTE 302m audio 2013-02-04 18:07:17 -08:00
Matthias Hardt
0e3fdb1e16 tsdemux: extract ISO 639 language codes for subtitles into taglists
https://bugzilla.gnome.org/show_bug.cgi?id=680200
2012-12-28 23:32:55 +00:00
Josep Torra
3d012665f0 tsdemux: forward upstream time segments after flushes
Also reset segment info and drop the segment event when demuxer is
flushed.
Restore demuxer segment with the info stored in base when demuxer is
going to push data again if needed.
Drop code to recover the segment info from base in the initial program
becauses it's superseded by the new code.
2012-11-14 22:51:35 +01:00
Josep Torra
0b3e0ed080 tsdemux: reset the stream some more in the flushes
Now that we handle flushing in the FLUSH_STOP event we need to make
the streams ready if they were flushing.
2012-11-12 22:57:19 +01:00
Josep Torra
150376efe4 mpegtspacketizer: flush observations too
Flush the previous observations when the packetizer is flushed.
Also don't leak them in the dispose.
2012-11-12 22:57:19 +01:00
Josep Torra
1fc5fffe08 mpegtsbase: fix double unref of seek event 2012-11-12 22:57:19 +01:00
Josep Torra
cc40d49bed mpegtsbase: flush in FLUSH_STOP to avoid race conditions
Ensure the chain is not running before reset the state to avoid race
conditions and random corruptions downstream.
Also fixes segfaults in the packetizer due wrong available values that
causes gst_adapter_map to return a NULL pointer.
2012-11-12 22:57:19 +01:00
Josep Torra
996da425a9 Revert "tspacketizer: ensure that a null pointer isn't accessed"
This reverts commit 6efd611b8c.

Also this extra check won't be needed if it's fixed the race by moving
flush actions to FLUSH_STOP.
2012-11-10 19:52:46 +01:00
Josep Torra
80dd130fb0 Revert "tsbase: add a guard with an atomic boolean when flushing"
This reverts commit e14e310f71.

Would be better move the packetizer flushing to FLUSH_STOP and avoid
the race that way. Without introducing a memory barrier that could
have impact in the performance.
2012-11-10 19:46:40 +01:00
Josep Torra
e14e310f71 tsbase: add a guard with an atomic boolean when flushing 2012-11-10 00:08:35 +01:00
Josep Torra
6efd611b8c tspacketizer: ensure that a null pointer isn't accessed
Mitigates segfault due race condition in FLUSH_START handling and
mpegts_base_chain.
2012-11-09 22:17:11 +01:00
Edward Hervey
651203de07 mpegts: Only use timestamp-based PCR/PTS estimation when needed
When dealing with non-time based push-mode streams, we need to revert
to using the offset-based PCR/PTS estimation logic of packetizer.

This solves uses cases such as:
 pushfile:// ! tsdemux
 src ! queue ! tsdemux

https://bugzilla.gnome.org/show_bug.cgi?id=687178
2012-11-09 12:15:24 +01: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
Sebastian Pölsterl
43938bbf54 tsdemux: Fix name of CAT GstStructure
The structure previously was assigned the name "pat".

https://bugzilla.gnome.org/show_bug.cgi?id=686948
2012-10-29 13:16:46 +01:00
Tim-Philipp Müller
465374f3c8 tsdemux: fix program packet sequence counter parsing in PES header 2012-10-19 01:05:44 +01:00
Tim-Philipp Müller
10c881b107 tsdemux: fix some inconsequential PES header parsing issues
additional_copy_info: need to get rid of the highest
bit, not the lowest one

program_packet_sequence_counter: also need to get rid
of the highest bit instead of multiplying with a random
value

original_stuff_length: want to AND 0x3f to extract the
lowest 6 bits, not multiply by it.

None of these fields are actually used though, so these
should not have caused any issues.
2012-10-19 01:05:34 +01:00
Raimo Järvi
9640669689 tsdemux: Fix parsing P-STD_buffer in PES header
https://bugzilla.gnome.org/show_bug.cgi?id=686294
2012-10-19 00:29:40 +01:00
Andoni Morales Alastruey
f768dfd925 tsdemux: fix potential crash dereferencing NULL program pointer
https://bugzilla.gnome.org/show_bug.cgi?id=686358
2012-10-18 17:54:41 +01:00
Tim-Philipp Müller
32ba17cd0f Use gst_element_class_set_static_metadata()
where possible. Avoids some string copies. Also re-indent
some stuff. Also some indent fixes here and there.
2012-10-17 17:46:34 +01:00
Sebastian Dröge
e5eceaaa73 mpegtsdemux: First push EOS, then destroy all programs
And also properly remove the program from the subclass
2012-10-12 15:38:44 +02:00
Mark Nauwelaerts
578861abea replace gst_element_class_set_details_simple with gst_element_class_set_metadata 2012-09-14 17:27:49 +02:00
Mark Nauwelaerts
b807753453 ext, gst: only activate in pull mode if upstream is seekable 2012-09-11 17:47:33 +02:00
Tim-Philipp Müller
2483c82bd7 video/x-dvd-subpicture -> subpicture/x-dvd 2012-08-20 23:37:00 +01:00
Edward Hervey
105737db54 mpegtspacketizer: Fix flushing/sync handling
There was a stray adapter_flush() now that we used a temporary buffer
2012-08-14 19:07:58 +02:00
Edward Hervey
121aa3ad13 mpegtspacketizer: Better detect PCR resets
Assume that any differences in PCR greater than 15s means there is
a reset in the stream.
2012-08-14 19:07:51 +02:00
Edward Hervey
3153965658 mpegtspacketizer: Remove/demote some debugging 2012-08-14 19:07:39 +02:00
Edward Hervey
9abedc97ff tsdemux: Always use current PTS/DTS
This avoids setting old PTS and/or DTS
2012-08-14 19:07:33 +02:00
Edward Hervey
e25c2e8e74 mpegtspacketizer: Remove unneeded memset(0) 2012-08-14 19:07:28 +02:00
Edward Hervey
8b80114101 mpegts: Use G_GNUC_INTERNAL 2012-08-14 19:07:24 +02:00
Edward Hervey
4d4d2f6eb0 mpegtspacketizer: Use gst_structure_*_take_value where applicable
Saves copying/freeing data
2012-08-14 19:06:16 +02:00
Edward Hervey
5de6fd1ff8 mpegtspacketizer: Cache the GIConv
Avoids having to constantly open/free them (which will end up being
very often with EIT/NIT).
2012-08-14 19:06:11 +02:00
Edward Hervey
e3c0bbe5f6 mpegtbase: reset element in READY=>PAUSED
Ensures all subclass reset vmethods are called
2012-08-14 19:06:04 +02:00
Edward Hervey
b1295aef14 mpegtspacketizer: Use more Quarks 2012-08-14 19:05:58 +02:00
Edward Hervey
d54624aa49 tsdemux: Remove useless code
PCR/OPCR is meant to be handled by the packetizer
2012-08-14 19:05:52 +02:00
Edward Hervey
4f55cc12ae tsdemux: Calculate pcr/time/offset separately per program
Avoids quite a few issues with multi-program streams
2012-08-14 19:05:48 +02:00
Edward Hervey
a8d1e88bda tsparse: Push out buffer on main source pad 2012-08-14 19:05:44 +02:00
Edward Hervey
558beab1b4 mpegtbase: vmethod to notify when we're done processing input
This can be used to notify subclasses no more data is expected this
round.
tsparse will use it to push whole buffers (without copy) on the main
source pad.
It could also be used later to decide whether to push pending data
in order to reduce latency.
2012-08-14 19:05:37 +02:00
Sebastian Dröge
bdc46898de gst: Add stream-id to stream-start events 2012-08-06 14:05:08 +02:00
Tim-Philipp Müller
489b102a43 gst_tag_list_free -> gst_tag_list_unref 2012-08-04 16:31:30 +01:00
Sebastian Dröge
afd50a79f4 tag: Update for taglist/tag event API changes 2012-07-28 00:32:58 +02:00
Mark Nauwelaerts
76aedf5641 tsdemux: more correctly determine expected PES packet payload size
... particularly considering that packet_length == 0 is possible.
2012-07-12 10:17:57 +02:00
Mark Nauwelaerts
006fe188e7 tsdemux: correctly determine expected PES packet payload size
Avoids consistently failing to detect that a packet is complete, which
would then only be pushed upon the start of a next packet, which leads
to quite a delay in case of a sparse (subtitle) stream.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=666674
2012-07-11 20:43:46 +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
ada9990092 mpegtbase: Add more known default SI PIDs 2012-06-29 09:59:13 +02:00
Edward Hervey
b5967d2323 tsdemux: Fix AAC LATM caps 2012-06-29 09:23:32 +02:00
Tony Houghton
a996d2f01a Correct satellite delivery descriptor parsing.
Original code to parse satellite delivery descriptors to generate
"satellite" structures appeared to be copy & pasted from cable's code
without amending for satellite.

Also added 8PSK to dvbsrc's enum for modulation.

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

Conflicts:

	gst/mpegdemux/gstmpegdesc.h
	gst/mpegdemux/mpegtspacketizer.c
2012-06-21 11:37:21 +01: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
Edward Hervey
a8dd05742a mpegtbase: Always send EOS
subclass will take care of handling it more if needed
2012-06-21 11:25:17 +01:00
Wim Taymans
dbed726057 update for task api change 2012-06-20 10:40:42 +02:00