Commit graph

459 commits

Author SHA1 Message Date
Chris Bass
563ffc0d8f qtdemux: support timed-text subtitle tracks.
https://bugzilla.gnome.org/show_bug.cgi?id=752818
2015-09-26 00:51:42 +02:00
Sebastian Dröge
d7a0fd82c0 qtdemux: Accumulate segments for edit lists before activating the next segment
eceb2ccc73 broke segment seeks by always
accumulating segments manually when activating a segment. This is only
needed when handling edit lists, not when activating a segment because of a
seek. Do the accumulation when switching edit list segments instead.

This fixes segment seeks again, while keeping edit lists playback working.

https://bugzilla.gnome.org/show_bug.cgi?id=755471
2015-09-24 09:33:33 +02:00
Alex Ashley
5d99d0dfa0 qtdemux: fix offset calculation when parsing CENC aux info
Commit 7d7e54ce68 added support for
DASH common encryption, however commit
bb336840c0 that went onto master
shortly before the CENC commit caused the calculation of the CENC
aux info offset to be incorrect.

The base_offset was being added if present, but if the base_offset
is relative to the start of the moof, the offset was being added twice.
The correct approach is to calculate the offset from the start of the
moof and use that offset when parsing the CENC aux info.
2015-08-18 11:48:03 +01:00
Sebastian Dröge
e9aa4c7467 qtdemux: Use signed integer type to be able to check for negative subtraction results
CID 1315829
2015-08-16 13:04:02 +02:00
Thiago Santos
41a4b68390 qtdemux: only look for more samples in moofs in pull-mode
For playback of some fragmented formats with qtdemux it will
try to look for the next moof after finishing one but it is only
possible for pull-mode. For playback of streaming fragmented formats
such as DASH it should just not try to look for another moof but
instead wait for more data.

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

https://bugzilla.gnome.org/show_bug.cgi?id=752603
2015-08-15 11:06:02 -03:00
Thiago Santos
288b0bbb38 qtdemux: fix small typo in comment 2015-08-10 19:11:17 -03:00
Tim-Philipp Müller
604cc2a548 qtdemux: fix suboptimal queue iteration code 2015-08-10 12:45:50 +01:00
Tim-Philipp Müller
0fbf5f3d9e qtdemux: don't use glib 2.44-only API 2015-08-10 12:32:23 +01:00
Alex Ashley
7d7e54ce68 qtdemux: add support for ISOBMFF Common Encryption
This commit adds support for ISOBMFF Common Encryption (cenc), as
defined in ISO/IEC 23001-7. It uses a GstProtection event to
pass the contents of PSSH boxes to downstream decryptor elements
and attached GstProtectionMeta to each sample.

https://bugzilla.gnome.org/show_bug.cgi?id=705991
2015-08-10 12:32:17 +01:00
Thiago Santos
e0878d6325 qtdemux: store the moof-offset also for push mode
It will be used in some cases for getting the correct offsets
from trun atoms.

https://bugzilla.gnome.org/show_bug.cgi?id=752603
2015-08-05 18:12:45 -03:00
Thiago Santos
bb336840c0 qtdemux: handle default-base-is-moof flag
Handle the flag from the tfhd that signals the base offset to
start from the moof atom

https://bugzilla.gnome.org/show_bug.cgi?id=752603
2015-08-05 18:12:45 -03:00
Manasa Athreya
e6381ef285 qtdemux: fix 16-bit PCM audio advertised with 'raw ' fourcc
'NONE' and 'raw ' fourcc don't always contain U8 audio, it can
be more bits as well, in which case it's just like 'twos'.

https://bugzilla.gnome.org/show_bug.cgi?id=752613
2015-07-27 19:06:43 +01:00
Paul Hyunil
3740e69957 qtdemux: Support subtitle when track subtype is fourcc_subt
https://bugzilla.gnome.org/show_bug.cgi?id=752655
2015-07-21 12:24:15 +01:00
Thiago Santos
30b3aa3030 qtdemux: rework segment event handling for adaptive streaming
When a new time segment is received upstream is going to restart
with a new atom. Make the neededbytes and todrop variables
reflect that to avoid waiting too much or dropping the
initial bytes that contain the header.
2015-07-08 23:23:53 -03:00
Thiago Santos
38520a1e12 qtdemux: push data from adapter before starting new segment
The adapter might have data remaining from the previous segment,
push it all before clearing the adapter and starting a new segment.

It can accumulate data if it had pushed and got not-linked, returning
immediately without processing all the data. Before starting a new
segment this data should be handled.
2015-07-08 23:23:53 -03:00
Thiago Santos
ee7ddf6c67 qtdemux: flush samples before adding more from moof
Avoids accumulating all samples from a fragmented stream that could
lead to a 'index-too-big' error once it goes over 50MB of data. It
could reach that before 2h of playback so it doesn't take that long.

As upstream elements are providing data in time format they should
be the ones that have more information about the full media index
and should be able to seek if possible.
2015-07-08 11:53:44 -03:00
Thiago Santos
6ee4b31c0e qtdemux: rename upstream_newsegment to upstream_format_is_time
upstream_newsegment isn't really clear on what it means, it is set
to TRUE when the upstream element sends a segment in TIME format, so
rename it to be more clear about it.

It is important to know this because it means that upstream has
a notion of time and qtdemux is likely being driven by an upstream
element that is reading from a higher level abstraction than a file,
such as a DASH, MSS or DLNA element.
2015-07-08 11:53:44 -03:00
Thiago Santos
5994b30257 qtdemux: fix leak by flushing previous sample info from trak
In fragmented streaming, multiple moov/moof will be parsed and their
previously stored samples array might leak when new values are parsed.
The parse_trak and callees won't free the previously stored values
before parsing the new ones.

In step-by-step, this is what happens:

1) initial moov is parsed, traks as well, streams are created. The
   trak doesn't contain samples because they are in the moof's trun
   boxes. n_samples is set to 0 while parsing the trak and the samples
   array is still NULL.
2) moofs are parsed, and their trun boxes will increase n_samples and
   create/extend the samples array
3) At some point a new moov might be sent (bitrate switching, for example)
   and parsing the trak will overwrite n_samples with the values from
   this trak. If the n_samples is set to 0 qtdemux will assume that
   the samples array is NULL and will leak it when a new one is
   created for the subsequent moofs.

This patch makes qtdemux properly free previous sample data before
creating new ones and adds an assert to catch future occurrences of
this issue when the code changes.
2015-07-08 11:53:44 -03:00
Thiago Santos
63f35eeb12 qtdemux: fix index size check and debug message
It is allocating samples_count + n_samples, not only n_samples
2015-07-08 11:53:44 -03:00
Stefan Sauer
12930c2f8c docs: fix "Symbol name not found at the start of the comment block"
Add symbols or change comment into a regular comment.
2015-07-07 17:12:02 +02:00
Thiago Santos
f40c1f8b09 qtdemux: avoid looping reading the 'moof' atom forever
It gets stuck if it only finds a moof and no mfra/mfro or moov
atoms. Skip the moof to continue the parsing to have it either
play or error out.

https://bugzilla.gnome.org/show_bug.cgi?id=745089
2015-07-06 11:00:20 -03:00
Gilbok Lee
0dcd76447a qtdemux: does not detect orientation
Most files don't contain the values for transposing the coordinates
back to the positive quadrant so qtdemux was ignoring the rotation
tag. To be able to properly handle those files qtdemux will also ignore
the transposing values to only detect the rotation using the values
abde from the transformation matrix:

[a b c]
[d e f]
[g h i]

https://bugzilla.gnome.org/show_bug.cgi?id=738681
2015-06-25 00:24:21 -03:00
Nicolas Dufresne
2359ee29e8 qtmux: Correctly calculate the elst media start
The media start has nothing to do with the shift we have applied
but with the value of the first PTS. This is defined as:

  Dt(0) = 0
  Ct(0) = Dt(0) + CTTS(0)

So the media start is always the first CTTS.

https://bugzilla.gnome.org/show_bug.cgi?id=751361
2015-06-23 22:34:36 -04:00
Thiago Santos
eceb2ccc73 qtdemux: accumulate previous edts entries into segment.base
Allows playing edts editted files with proper synchronization of
streams. This patch fixes the regression introduced by
bf95f93c01 that was added to fix
segment seeks handling.

Having the accumulated_base separated from the main segment.base
allows handling both segment seeks and edts editted files.

https://bugzilla.gnome.org/show_bug.cgi?id=751361
2015-06-23 22:34:36 -04:00
Thiago Santos
aef61c2251 qtdemux: improve some debug messages
Those messages are about the stream, use the pad as the
debug object to make it clear from the logs

https://bugzilla.gnome.org/show_bug.cgi?id=751361
2015-06-23 22:34:35 -04:00
Thiago Santos
1ec9a86e72 qtmux: store last_dts of the first buffer
Buffers need not to start at running-time 0 so the last_dts needs
to be the value of the first buffer's dts as it is used to compute
the duration of the buffers. If it was left at 0 the first buffer
would have a larger duration when it shouldn't

https://bugzilla.gnome.org/show_bug.cgi?id=751361
2015-06-23 22:34:35 -04:00
Jan Schmidt
b7cbfe1fa1 qtdemux: Move multiview caps calculations, add half-aspect heuristics
Move the multiview caps calculations to the configure_stream()
function, so the rest of the video info is available, and
use the gst_video_multiview_guess_half_aspect() function to
determine if the half-aspect flag should be set on frame-packed
video.
2015-06-23 11:58:41 +10:00
Nicolas Dufresne
dd72267a8d qtdemux: Add cslg support
The cslg atom provide information about the DTS shift. This is
needed in recent version of ctts atom where the offset can be
negative. When cslg is missing, we parse the CTTS table as proposed
in the spec to calculate these values.

In this implementation, we only need to know the shift. As GStreamer
cannot transport negative timestamps, we shift the timestamps forward
using that value and adapt the segment to compensate. This patch also
removes bogus offset of ctts_soffset, this offset shall be included
in the edit list.

https://bugzilla.gnome.org/show_bug.cgi?id=751103
2015-06-22 17:51:49 -04:00
Nicolas Dufresne
7b8615d4fc qtmux: Use PTS to figure-out presence of gaps
We need to look at the presentation timestamp in order to conclude if
there is a gap at the start of a stream.

https://bugzilla.gnome.org/show_bug.cgi?id=751242
2015-06-22 17:45:30 -04:00
Nicolas Dufresne
feda525591 qtmux: Set edit list to compensate DTS shift
We shift DTS forward to avoid negative timestamps which cannot be
represented with version 0 of the CTTS table. To stick with that
version (backward compatibility), the spec recommend using an
edit list entry to move back the presentation time to where it
should be.

https://bugzilla.gnome.org/show_bug.cgi?id=751242
2015-06-22 17:45:30 -04:00
Nicolas Dufresne
d6e1e744a7 cslg: Add Composition Shift Least Greatest Atom
This simply add fourcc and dump function for the cslg Atom.

https://bugzilla.gnome.org/show_bug.cgi?id=751103
2015-06-17 15:21:16 -04:00
Nicolas Dufresne
8a406c9c38 ctts_dump: Fix signess issues
It didn't bug, but use correct signess in traces. The number of
entries is unsigned while the offset can be signed according to
recent spec.

https://bugzilla.gnome.org/show_bug.cgi?id=751103
2015-06-17 15:21:16 -04:00
Nicolas Dufresne
135e516730 qtdemux: Adjust segment according to ctts offset
In presence of a CTTS, the segment start/stop must be offset so
the segment start/stop include the PTS. This is needed since the
PTS cannot be negative in this format. This fixes issues where the
running time of the first buffer isn't at the start.

https://bugzilla.gnome.org/show_bug.cgi?id=740575
2015-06-12 17:18:24 -04:00
Nicolas Dufresne
12181efddc qtmux: Handle DTS with negative running time
As QT works with duration, simply bring back first DTS to 0 and shift
forward the PTS of the same amount.

https://bugzilla.gnome.org/show_bug.cgi?id=740575
2015-06-12 17:18:24 -04:00
Thiago Santos
03f1a2ea67 atoms: remove custom gst_buffer_new function in favor of core version
Remove a custom specialized version of gst_buffer_new_wrapped by
using gst_buffer_new_wrapped_full inside a macro to simplify
parameters and give it a more meaningful name.
It is only used to create temporary buffers to have its data copied.
2015-06-11 01:11:31 -03:00
Thiago Santos
1596972674 atoms: simplify free form data atoms creation
Avoid creating an intermediary buffer or memory area just
to copy into an atom's data area.
2015-06-11 01:11:31 -03:00
Thiago Santos
ab18f5035c qtmux: add AC-3 muxing support
Adds AC-3 muxing support. It is defined for mp4 and 3gp formats.

One extra feature that was added was the ability to add extension
atoms after set_caps as the AC-3 extension atom needs some data
that has to be extracted from the stream itself and is not
present on caps.
2015-06-11 01:11:31 -03:00
Thiago Santos
674e0cc2df qtmux: remove unused type MP4S 2015-06-11 01:11:31 -03:00
Thiago Santos
f83fd7a88f qtmux: remove duplicate attribute value set
It is also set a few lines below
2015-06-11 01:11:18 -03:00
Jan Schmidt
fff76157d8 qtdemux: Add basic support for MPEG-A stereoscopic video
The MPEG-A format provides an extension to the ISO base media
file format to store stereoscopic content encoded with different
codecs like H.264 and MPEG-4:2. The stereo video media information(svmi)
atom declares the presence and storage method for the video.

Stereo video information for MPEG-A can also be supplied through
the 'stvi' atom (ref: ISO/IEC_14496-12, ISO/IEC_23000-11), which
is not implemented in this patch.

Also missing is support for stereo video encoded as separate video tracks
for now.

Based on a patch by Sreerenj Balachandran <sreerenj.balachandran@intel.com>

https://bugzilla.gnome.org/show_bug.cgi?id=611157
2015-06-11 12:11:42 +10:00
Vineeth TM
720ff75c72 qtdemux: fix reverse playback
When performing seek, segment->start is being updated with desired_offset,
but in case of reverse playback segment->start should be 0 and
segment->stop should be updated with desired offset.

https://bugzilla.gnome.org/show_bug.cgi?id=750675
2015-06-10 10:41:13 +02:00
Jan Schmidt
23d610140d isomp4: fsync after sending updates in robust mode
Use the new GstBuffer SYNC_AFTER flag to trigger an fsync
after updating the moov or mdat atom, and after updating the free
atom to make it visible.
2015-06-08 14:49:11 +10:00
Jan Schmidt
3e17cd8acb isomp4: Only set moov header into streamheader at EOS
Only update the moov header into the caps if it's the finalised
moov at EOS time. Avoids posting a bogus moov at startup and
repeated updates in robust-recording mode
2015-06-08 14:49:11 +10:00
Jan Schmidt
1d058c7d8a isomp4: Implement robust muxing using ping-pong strategy
Implement a robust recording mode, where the output
file is always in a playable state, seeking and rewriting
the moov header at a configurable interval. Rewriting
moov is done using reserved space at the start of
the file, and a ping-pong strategy where the moov
is replaced atomically so it's never invalid.

Track when tags have actually changed, and don't write them into
the moov unless they've changed. Clear any existing tags when
re-writing them, so we can do progressive moov updating in robust
recording mode.

Write placeholder mdat as a free atom plus a 32-bit mdat
with '0' size, which means "rest of the file" in the spec.

Re-write it later to a full 64-bit extended size atom if needed.
2015-06-08 14:49:11 +10:00
Jan Schmidt
3d7b343525 isomp4: Update edit list when re-writing moov
Correctly update any edit lists each time the moov is recalculated,
updating existing table entries if they already exist instead of just
adding new ones.
2015-06-08 14:16:36 +10:00
Jan Schmidt
0c1bcc629d isomp4: Remove an extra bracket in a comment. 2015-06-08 14:16:36 +10:00
Thiago Santos
d03b9513f1 qtdemux: remove fixme from 2006
It has been verified by use over time.
2015-05-25 08:47:47 -03:00
Thiago Santos
fc0a184592 qtdemux: fix reverse playback of fragmented media
qtdemux creates a samples array and gets the timestamps for buffers by
accumulating their durations. When doing reverse playback of fragments,
accumulating samples will lead to wrong timestamps as the timestamps
should go decreasing from fragment to fragment and the accumulation
will produce wrong results.

In this case, when receiving a discont for fragmented reverse playback,
the previous samples information should be flushed before new data
is processed.
2015-05-25 08:46:18 -03:00
Stefan Sauer
426eb3e300 qtdemux: avoid wrong warnings on unknown node types
Add 'name' and 'mean' fourccs, as we handle them. Right now each use would
trigger a warning.
2015-05-15 14:56:07 +02:00
Paul Hyunil
3792e9ca9b qtdemux: fix example pipeline in docs
The gst-launch script for example launch line to test qtdemux is
missing a queue before the decodebins, otherwise the gst-launch-1.0
command won't work.

https://bugzilla.gnome.org/show_bug.cgi?id=749054
2015-05-08 11:06:31 +01:00