Commit graph

109 commits

Author SHA1 Message Date
Sebastian Dröge 264d7dbd89 tsdemux: Drain remaining data on disconts 2014-03-29 10:33:45 +01:00
Sebastian Dröge d986d24d41 mpegtsbase: Flush if we receive a discont buffer 2014-03-29 10:33:45 +01:00
Sebastian Dröge 0cecb44813 mpegtsbase: Fix pull mode scanning for PCR on small files
If a file does not contain 5 PCRs until it is EOS, or does not
contain more than 655360 bytes the PCR scanning algorithm just
aborted.
2014-03-29 10:33:45 +01:00
Edward Hervey fc34d163d8 mpegtsbase: Uncomment PAT clearup in _reset
The PAT is related to the stream, we therefore want it cleared along
with anything stream related.

This commented section was from the (old) mpegtsparse and *might* have
been related to speeding up DVB start-up. But we have another plan for that.

Fixes https://bugzilla.gnome.org/show_bug.cgi?id=724716
2014-02-21 14:07:51 +01:00
Sebastian Dröge 9682e44db6 tsdemux: We do not support the SKIP seek flag but that is not a problem 2014-01-30 20:29:58 +01:00
Jesper Larsen 279bdef4ea tsdemux: Return descriptor in get_descriptor
https://bugzilla.gnome.org/show_bug.cgi?id=709180
2013-10-07 10:23:22 +02:00
Steve Maynard 17ed696faa mpegts: Add SCTE/EISS sections and table types
https://bugzilla.gnome.org/show_bug.cgi?id=708688
2013-09-28 13:15:44 +02:00
Edward Hervey 2762ead5ef mpegtsdemux: New PCR<=>Offset estimation code
This allows:
* Better duration estimation
* More accurate PCR location
* Overall more accurate running-time location and calculation

Location and values of PCR are recorded in groups (PCROffsetGroup)
with notable PCR/Offset observations in them (when bitrate changed
for example). PCR and offset are stored as 32bit values to
reduce memory usage (they are differences against that group's
first_{pcr|offset}.

Those groups each contain a global PCR offset (pcr_offset) which
indicates how far in the stream that group is.

Whenever new PCR values are observed, we store them in a sliding
window estimator (PCROffsetGroupCurrent).

When a reset/wrapover/gap is detected, we close the current group with
current values and start a new one (the pcr_offset of that new group
is also calculated).

When a notable change in bitrate is observed (+/- 10%), we record
new values in the current group. This is a compromise between
storing all PCR/offset observations and none, while at the same time
providing better information for running-time<=>offset calculation
in VBR streams.

Whenever a new non-contiguous group is start (due to seeking for example)
we re-evaluate the pcr_offset of each groups. This allows detecting as
quickly as possible PCR wrapover/reset.

When wanting to find the offset of a certain running-time, one can
iterate the groups by looking at the pcr_offset (which in essence *is*
the running-time of that group in the overall stream).
Once a group (or neighbouring groups if the running-time is between two
groups) is found, once can use the recorded values to find the most
accurate offset.

Right now this code is only used in pull-mode , but could also
be activated later on for any seekable stream, like live timeshift
with queue2.

Future improvements:
* some heuristics to "compress" the stored values in groups so as to keep
  the memory usage down while still keeping a decent amount of notable
  points.
* After a seek compare expected and obtained PCR/Offset and if the
  difference is too big, re-calculate position with newly observed
  values and seek to that more accurate position.

Note that this code will *not* provide keyframe-accurate seeking, but
will allow a much more accurate PCR/running-time/offset location on
any random stream.
For past (observed) values it will be as accurate as can be.
For future values it will be better than the current situation.
Finally the more you seek, the more accurate your positioning will be.
2013-09-28 13:15:43 +02:00
Thiago Santos efb27f19ec tsdemux: respect seqnums on seeks
Pass the seqnum to other events that are consequence of the
original seek event
2013-09-10 19:44:24 -03:00
Edward Hervey d6b55b8a66 mpegtsbase: Adapt for latest mpegts lib changes 2013-08-21 08:59:42 +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
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 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 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 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 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 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
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
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
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 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
Sebastian Dröge acacef9fbb mpegtsdemux: Fix various compiler warnings 2013-03-03 12:30:32 +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 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
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 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 b807753453 ext, gst: only activate in pull mode if upstream is seekable 2012-09-11 17:47:33 +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 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
Tim-Philipp Müller 489b102a43 gst_tag_list_free -> gst_tag_list_unref 2012-08-04 16:31:30 +01: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 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
Edward Hervey 8fd2d43d60 mpegtbase: Avoid copying GstStructure 2012-06-19 10:49:37 +01:00
Edward Hervey e2576f0e86 mpegtsdemux: Also parse TOT (Time Offset Section)
It's the same as TDT, except with descriptors at the end
2012-06-05 10:54:27 +02:00
Edward Hervey d9121c38ea mpegtsdemux: FIXME/Comment about issues/errors 2012-06-05 10:54:26 +02:00
Edward Hervey f0867c7247 mpegtspacketizer: Avoid alloc/free where possible
Helps for streams with a lot of sections, like EIT
2012-06-05 10:54:26 +02:00
Edward Hervey aab8c46f10 mpegtbase: Add more sections that don't have a CRC 2012-06-05 10:54:26 +02:00
Edward Hervey 25f6c78d79 mpegdefs: Add list of known table_id
Along with the specifications from which they come. Avoids having
to search for which spec a table_id belongs to
2012-06-05 10:54:26 +02:00