Commit graph

444 commits

Author SHA1 Message Date
Jimmy Ohn
84f436f122 qtdemux: Add the function to get channels and sample rate for AAC
Add aac_get_channels and sample_rate function to get these value for
AAC.

https://bugzilla.gnome.org/show_bug.cgi?id=749110
2016-03-24 14:28:09 +02:00
Thiago Santos
d8fb7a9c96 qtdemux: reset pending segment if we are already pushing one
When upstream is running in bytes in push-mode, qtdemux will
convert seeks from time to bytes and send it upstream. Upstream
element will perform a byte seek and send a byte segment to qtdemux
that will convert it to time and push it downstream.

There is, however, the pending_segment variable that stores a new
segment event to be pushed before the next data. When handling seeks
as mentioned above this variable was being ignored and, if it contained
some segment event, it would override the one resulting from the seek.
This would restore a previous segment and would cause the seek segment
to be discarded downstream.

This patch fixes this issue by unrefing any pending segment as the
seek from upstream should contain the latest one that should be
used, as requested by the application.

https://bugzilla.gnome.org/show_bug.cgi?id=763165
2016-03-07 15:26:13 -03:00
Thiago Santos
b46af7fda7 qtdemux: run gst-indent
Otherwise commits will fail with our indent check hook
2016-03-07 15:26:13 -03:00
Philippe Normand
9c47c0da59 qtdemux: cenc aux info parsing from mdat support in PULL mode
This is already supported for PUSH mode but was failing in PULL mode.
The aux info is sometimes stored in the mdat before the first sample,
so the loop task needs to pull data stored at that location and
perform the aux info cenc parsing.

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

https://bugzilla.gnome.org/show_bug.cgi?id=762516
2016-02-25 12:46:27 +02:00
Philippe Normand
67f3fc1748 qtdemux: prevent buffer flow if any stream failed to be exposed
In some cases the stream configuration can fail, for instance if the
stream is protected and no decryptor was found. For those situations
the demuxer shouldn't emit any data on the corresponding source pad of
the stream and bail out.

https://bugzilla.gnome.org/show_bug.cgi?id=762516
2016-02-25 12:46:27 +02:00
Philippe Normand
fb5d50cd07 qtdemux: don't push encrypted buffer without cenc metadata
When the cenc metadata is stored outside of the moof box and the
stream is exposed it is possible that the cenc metadata hasn't been
processed yet while the first buffer is being pushed. When this
happens the buffer can't possibly be decrypted downstream so don't
push it.

https://bugzilla.gnome.org/show_bug.cgi?id=762516
2016-02-25 12:46:27 +02:00
Philippe Normand
459ef195bb qtdemux: read saio aux_info_type as a FOURCC
https://bugzilla.gnome.org/show_bug.cgi?id=756897
2016-02-24 10:54:23 +02:00
Matej Knopp
f96c9eb6bc qtdemux: workaround for files with wrong color_table_id value
Instead of erroring out, just use the default color table.

https://bugzilla.gnome.org/show_bug.cgi?id=761637
2016-02-19 16:00:59 +00:00
Philippe Normand
52b16768a2 qtdemux: plug leaks in cenc aux info parsing 2016-02-19 10:30:46 +02:00
Alex Ashley
97f6f7c713 qtdemux: only transform protected caps once
Commit 7873bede31
(https://bugzilla.gnome.org/show_bug.cgi?id=760774) changed the
behaviour of qtdemux to call gst_qtdemux_configure_stream() for
every new moof.

When playing a protected stream, gst_qtdemux_configure_stream()
calls gst_qtdemux_configure_protected_caps(). The
gst_qtdemux_configure_protected_caps() function takes the original
media format, puts this in a field called "original-media-type"
and then changes the caps to "application/x-cenc".

The gst_qtdemux_configure_protected_caps() did not handle the case
of being called multiple times, causing it to incorrectly set the
caps. The second call was causing the caps to be set to:

    application/x-cenc, original-media-type"application/x-cenc"

This commit makes gst_qtdemux_configure_protected_caps() check that
the caps have already been transformed, so that it only gets
changed once.

    https://bugzilla.gnome.org/show_bug.cgi?id=761769
2016-02-17 17:04:25 +02:00
Seungha Yang
7873bede31 qtdemux: fix framerate calculation for fragmented format
qtdemux calculates framerate using duration and the number of sample.
In case of fragmented mp4 format, however, the number of sample can
be figure out after parsing every moof box. Because qtdemux does not
parse every moof in QTDEMUX_STATE_HEADER state, it will cause incorrect
framerate calculation.

This patch will triger gst_qtdemux_configure_stream() for every new moof.
Then, framerate will be calculated by using duration and n_samples of the moof.

https://bugzilla.gnome.org/show_bug.cgi?id=760774
2016-01-29 11:01:44 +01:00
Seungha Yang
0391a93a35 qtdemux: handling zero segment-duration edit list
Based on document ISO_IEC_14496-12, edit list box can have
segment duration as zero. It does not imply that media_start equals to
media_stop. But, it just indicates a sample which should be presented
at the first. This patch derives segment duration using media_time
and duration of file. And set derived duration to segment-duration.

https://bugzilla.gnome.org/show_bug.cgi?id=760781
2016-01-29 10:57:05 +01:00
Seungha Yang
d8bb6687ea qtdemux: expose streams with first moof for fragmented format
In case of push mode, qtdemux expose streams after got moov box.
We can not guarantee that a moov box has sample data such as sample duration
and the number of sample in stbl box for fragmented format case.
So, if a moov has no sample data, streams will not be exposed until get the first moof.

https://bugzilla.gnome.org/show_bug.cgi?id=760779
2016-01-29 10:53:39 +01:00
Víctor Manuel Jáquez Leal
e1834d1512 gst: Fix unintialized variable warnings
While cross-compiling with Linaro GCC 5.1-2015.08, it complained
about a couple unitialized variables.

This patch initializes them to zero.

https://bugzilla.gnome.org/show_bug.cgi?id=761094
2016-01-27 13:46:07 +01:00
Thiago Santos
0906d822ad qtdemux: drop flushes from our own offset seek
Prevents downstream from receiving flushes for a seek only in
upstream. Those seeks are only to start reading from the right
offset when skipping or returning to qt atoms.

https://bugzilla.gnome.org/show_bug.cgi?id=758928
2015-12-22 12:33:39 -03:00
Edward Hervey
d78d589627 qtdemux: Stop pushing data as soon as possible in push-mode
When working in push-mode, we attempt to push out everything currently
buffered in the adapter.

This has two pitfalls:
* We could stop earlier (the moment we get a non-ok or non-not-linked)
* We return the last combined flow return, which might be completely
  different from the previous combined flow return
2015-12-07 16:36:15 +01:00
Luis de Bethencourt
a400d504ca qtdemux: add support for Opus
Add support for demuxing Opus encapsulated in MP4 files, based on the
following spec: https://www.opus-codec.org/docs/opus_in_isobmff.html

https://bugzilla.gnome.org/show_bug.cgi?id=742643
2015-11-26 21:46:14 +00:00
Luis de Bethencourt
9d70682e73 qtdemux: use macro for codec_name
Use _codec() macro instead of duplicating code.
2015-11-25 22:48:36 +00:00
Thiago Santos
2dbc9f86fc qtdemux: restore the segment on case of soft reset
When seeking back to restore the mdat position a flush is pushed
through and it resets downstream segment information. Make sure
that after the flush (that does a soft reset) a segment will
be pushed again

Fixes regressions spotted at
https://ci.gstreamer.net/job/GStreamer-master-validate/2100/
2015-11-24 10:57:28 -03:00
Luis de Bethencourt
53f8f1abae qtdemux: unite duplicate FourCC
Unite in fourcc.h the FourCCs that are used twice or more in qtdemux
2015-11-20 11:05:51 +00:00
Luis de Bethencourt
ca6d71ef2a qtdemux: remove duplicate FourCC
Use the available FourCCs in fourcc.h instead of duplicating them.
2015-11-19 19:28:25 +00:00
Sebastian Dröge
cc119e6eb9 qtdemux: Replace tabs with spaces 2015-11-18 19:11:51 +02:00
Sebastian Dröge
b404b2239a qtdemux: Cast to signed integers to prevent unsigned compare between negative and positive numbers
This fixes seeking if the first entries in the samples table are negative. The
binary search would always fail on this as the array would not be sorted if
interpreting the negative numbers as huge positive numbers. This caused us to
always output buffers from the beginning after a seek instead of close to the
seek position.

Also add a case to the comparison function for equality.
2015-11-18 19:11:51 +02:00
Thiago Santos
8bcc733cec qtdemux: only send initial gaps for non-fragmented streams
It would be unusual to have the header segment with an 'edts' atom
indicating gaps at the beginning when handling fragmented streams.

The header usually doesn't contain any timestamping information, this
should come from the playlist/manifest and the segments with media
in those scenarios.

https://bugzilla.gnome.org/show_bug.cgi?id=758171
2015-11-17 09:42:07 -03:00
Thiago Santos
ef8cb05823 Revert "Revert "qtdemux: respect qt segments in push-mode for empty starts""
This reverts commit d842ff288a.

This was reverted by accident
2015-11-17 09:41:34 -03:00
Sebastian Dröge
d842ff288a Revert "qtdemux: respect qt segments in push-mode for empty starts"
This reverts commit 142d8e2d23.
2015-11-16 13:52:05 +02:00
Vineeth TM
0d4e3847f0 qtdemux: Fix string memory leak
The string got using g_strdup_printf will be allocated memory
and should be freed after use.

https://bugzilla.gnome.org/show_bug.cgi?id=758161
2015-11-16 10:22:16 +02:00
Thiago Santos
142d8e2d23 qtdemux: respect qt segments in push-mode for empty starts
In push-mode it is hard to support qt segments overall but it is
possible to support when the file isn't heavily edited but just contain
a segment to indicate a gap at the beginning. This also allows properly
timestamping data that has negative DTS in push-mode.

It is relevant to support those for 2 scenarios:

1) fragmented streaming
2) HTTP playback of 'regular' mp4

https://bugzilla.gnome.org/show_bug.cgi?id=753484
2015-11-09 11:49:27 -03:00
Philippe Normand
9f0c22e891 qtdemux: support for cenc auxiliary info parsing outside of moof box
When the cenc aux info index is out of moof boundaries, keep track of
it and parse the beginning of the mdat box, before the first sample.

https://bugzilla.gnome.org/show_bug.cgi?id=755614
2015-11-04 15:29:10 +00:00
Reynaldo H. Verdejo Pinochet
82bffe3eef qtdemux: add support for FFV1 coded streams in mov
https://bugzilla.gnome.org/show_bug.cgi?id=752495
2015-10-15 10:38:34 -07:00
Guillaume Desmottes
360a6509c7 qtdemux: fix caps leak
If the QtDemuxStream are re-used they may already have caps which used
to be leaked.

Reproduced using the
validate.dash.playback.seek_forward.dash_exMPD_BIP_TC1 validate
scenario.

https://bugzilla.gnome.org/show_bug.cgi?id=756561
2015-10-14 14:42:19 +03:00
Vineeth TM
8283337e73 qtdemux: Fix taglist memory leak
Free the stream and its sub items instead of just the stream

https://bugzilla.gnome.org/show_bug.cgi?id=756544
2015-10-14 10:22:19 +03:00
Vineeth TM
b26ce7ba6d qtdemux: Fix memory leak for corrupted file
Free brands before overriding them.

https://bugzilla.gnome.org/show_bug.cgi?id=756226
2015-10-08 15:03:36 +01:00
Thiago Santos
df0a31b4ee qtdemux: handle empty segments in seeking adjust
If seeking targets an empty segment skip it as there is no media
offset to get from it. Instead look for the next one.

This doesn't make seeking in push-mode work if you seek to an
empty segment but at least won't get you to wrong offsets.

https://bugzilla.gnome.org/show_bug.cgi?id=753484
2015-10-02 19:23:43 +01:00
Manasa Athreya
e6a4c81af5 qtdemux: Check multi trex to find track id in mp4 mpeg-dash stream
If stream has more than one trex box which is not matched to actual
track id, it makes qtdemux crashed.

Author : Manasa Athreya (manasa.athreya@lge.com)

https://bugzilla.gnome.org/show_bug.cgi?id=754864
2015-10-02 17:38:57 +03:00
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
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
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
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
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
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
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
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
Tim-Philipp Müller
377c8405aa qtdemux: fix buffer leak on eos in push mode
Based on patch by Guillaume Desmottes.

scenario: validate.http.playback.seek_with_stop.raw_h264_1_mp4

https://bugzilla.gnome.org/show_bug.cgi?id=748617
2015-04-30 13:35:16 +01:00
Sebastian Dröge
178f0a4522 qtdemux: Check for sizes of the rdrf (redirect) atom before accessing the data and use g_strndup() instead of g_strdup()
Thanks to Ralph Giles for reporting this.
2015-04-29 19:41:29 +02:00
Vincent Penquerc'h
f02ad47998 qtdemux: fix tag list leaks on error paths 2015-04-16 13:10:22 +01:00
Vincent Penquerc'h
765faa306a qtdemux: fix tag list leak on unknown stream type 2015-04-16 13:10:21 +01:00
Hyunjun Ko
7fbd1b472f qtdemux: Update segment.start after key-unit seek
When doing key uint seek, qtdemux calls gst_qtdemux_adjust_seek
to get proper offset. And then this offset is set to
segment.position and segment.time in gst_qtdemux_perform_seek but
segment.start is not updated.

After that, application sends segment query,
qtdemux sets start and stop to query using gst_segment_to_stream_time. Due
to the wrong value in segment.start, the stop position is smaller than
it should.

https://bugzilla.gnome.org/show_bug.cgi?id=746822
2015-04-10 10:12:50 -03:00
Sebastian Dröge
bf95f93c01 qtdemux: Don't accumulate segment bases manually
gst_segment_do_seek() does that for us already, and doing it twice
will break non-flushing seeks in interesting ways. Leftover from 1.0
porting.

Also copy over segment offset and applied_rate, just in case.
2015-04-06 20:17:52 -07:00
Thiago Santos
aeb4d32363 qtdemux: stbl_index is valid from 0 onwards
It indicates the last sample parsed, not the next one to parse.
As it starts in -1, any value from 0 onwards means that it has
some valid data.
2015-04-06 19:29:03 -03:00
Jan Schmidt
ffa5fce094 qtdemux: Guard against 64-bit overflow
For large-file atoms, guard against overflow in the size field,
which could make us jump backward in the file and cause
infinite loops.
2015-04-03 23:07:07 +11:00
Mark Nauwelaerts
71b0b8d943 qtdemux: resurrect some flow return handling
https://bugzilla.gnome.org/show_bug.cgi?id=744572
2015-03-29 13:58:56 +02:00
Matej Knopp
f75e443a7a qtdemux: fix key unit seek
Unlike many other seek flags, the KEY_UNIT seek
flag is not copied over into the GstSegment,
since it's only relevant for the seek itself,
so we need to pass it explicitly to the seek
handler here.

https://bugzilla.gnome.org/show_bug.cgi?id=745339
2015-03-01 13:06:55 +00:00
Thibault Saunier
fa0870658d qtdemux: All segment resulting from a seek should have the same seqnum
https://bugzilla.gnome.org/show_bug.cgi?id=744983
2015-02-23 20:05:20 +01:00
Thiago Santos
84b7cf6795 qtmux: remove not needed condition
gst_buffer_replace can handle NULL inputs by itself
2015-02-18 10:36:06 -03:00
Thiago Santos
a12e41c106 qtdemux: prefer the tfdt timestamp over the buffer's that is less accurate
The tfdt should be more accurate as the buffer timestamp is provided
by the fragmented format manifest and it might just be an approximation.
2015-02-18 09:57:48 -03:00
Edward Hervey
6798dc7912 isomp4: Redefine gst_isoff_ symbols to gst_isoff_qt_
We need different symbol names, because these symbols are also present
in the fragmented plugin ... which will cause conflicts when doing
static linking
2015-02-17 12:31:06 +01:00
Thiago Santos
afa5481c50 qtdemux: do not use sparse streams in push-based seeking
Using the sparse streams can make the push-based seeking return
too far in the stream. It also can lead to issues as the
sparse streams will be ignored when restarting playback and,
 if the sparse stream is the one that has the earliest sample,
it will confuse qtdemux's offsets as one stream will have
an earlier offset than the demuxer's one which might lead to
early EOS.

https://bugzilla.gnome.org/show_bug.cgi?id=742661
2015-02-14 11:36:11 -03:00
Philippe Normand
3a9b0188cd qtdemux: Initial 'sidx' atom parsing support
Parse the 'sidx' atom and update the total duration according to the
parser result. The isoff parser code is imported from
gst-plugins-bad's dashdemux and a gst_isoff_sidx_parser_add_data()
function was factored out of the gst_isoff_sidx_parser_add_buffer()
function.

https://bugzilla.gnome.org/show_bug.cgi?id=743578
2015-02-12 14:23:21 -03:00
Jan Schmidt
a3059bec1f qtdemux: Simple implementation of GST_SEGMENT_FLAG_TRICKMODE_KEY_UNITS
When the trickmode key-units flag is set on the segment, simply skip
any sample on a video stream that isn't a keyframe
2015-02-04 21:58:31 +11:00
Thiago Santos
75dee31b0d qtdemux: parse stream tags
Keep global and stream tags separately and parse the udta node
that can be found under the trak atom. The udta will contain
stream specific tags and will be pushed as such

https://bugzilla.gnome.org/show_bug.cgi?id=692473
2015-02-02 14:05:51 -03:00
Thiago Santos
9a9d4eccea qtdemux: simplify segment.base math
Remove a fix for heavily edited files added for fixing
https://bugzilla.gnome.org/show_bug.cgi?id=345830 to work
with seeks and proper gaps playback. The fix was replaced
for a more general solution that bases on using previous
segment's duration, just like it works for media segments
playback.

https://bugzilla.gnome.org/show_bug.cgi?id=743518
2015-01-28 15:20:58 -03:00
Thiago Santos
2586a219f6 qtdemux: Fix data dropping for fragmented streams
For fragmented streams with extra data at the end of the mdat
qtdemux was not dropping those bytes and would try to use
that extra data as the beginning of a new atom, causing the
stream to fail.

https://bugzilla.gnome.org/show_bug.cgi?id=743407
2015-01-27 08:54:19 -03:00
Sebastian Dröge
d5aab81a77 Constify some static arrays everywhere 2015-01-21 09:55:53 +01:00
Vincent Penquerc'h
d854cfff9d qtdemux: fix deadlock seeking in files without seek entries
A mutex unlock was missing.

https://bugzilla.gnome.org/show_bug.cgi?id=739975
2015-01-19 17:49:54 +00:00
Sebastian Dröge
b7134435ee qtdemux: v210 is v210, not UYVY and yuv2 is YUY2, not I420
Also add a few other raw video formats we support: v308, v216
and add comments for a few others we don't support yet.

https://developer.apple.com/library/mac/technotes/tn2162/
2015-01-13 19:05:40 +01:00
Thiago Santos
3e0be85840 qtdemux: fix stream time conversion
Use the right macro to convert to the correct scale or the
segment information will be wrong

https://bugzilla.gnome.org/show_bug.cgi?id=742572
2015-01-09 11:40:40 -03:00
Edward Hervey
6b69ef24a1 qtdemux: Fix debug statement
It was using the non-increasing offset variable, which made that statement
not so useful :)
2014-12-12 11:06:17 +01:00
Edward Hervey
d1ae39d6d6 qtdemux: Add macros for the various timescale conversions
This helps make the code more readable and avoid future bad usage of
scaling function argument order.
2014-12-12 11:03:15 +01:00
Jan Schmidt
de8d00348e qtdemux: Copy flags of the overall segment to output segments
Preserve the segment flags of the overall demux segment on the output
segments for each pad.
2014-12-12 00:56:49 +11:00
Edward Hervey
9a903c994f qtdemux: Fix rounding errors in duration update
Make sure we store updated segment stop/duration with the same
granularity as the duration timescale.

And add more debug
2014-12-10 17:39:17 +01:00
Edward Hervey
b40cfcfffb qtdemux: Update duration when we get more information
When dealing with fragmented files, we will get more accurate duration
information via the mfra and moof atoms.

In order for playback to not stop at the initial duration (from the
moov atom), we need to check and update the various duration variables
when we find more information.

Fixes playback of fragmented files in pull mode
2014-12-10 16:55:44 +01:00
Edward Hervey
799609583e qtdemux: Remove variable assignments never read
As detected by clang/scan-build
2014-12-10 15:09:25 +01:00
Edward Hervey
7828f73516 qtdemux: Use GstClockTime for nanosecond-based time variables/fields
Avoids confusion with timescaled-based variables and bytes (offset)
variables.
And use GST_CLOCK_TIME_NONE where applicable
2014-12-10 15:09:25 +01:00
Jan Schmidt
f4ca3c255a qtdemux: More fixes for reverse playback
When seeking or finding the previous keyframe, do
comparisons against targets and segments using composition time
to correctly decide which sample times match.
2014-12-04 22:53:07 +11:00
Jan Schmidt
b3d1ab5267 qtdemux: Handle seeks past EOS as a seek to the end
Fix reverse playback of every frame by making seeks past/to EOS
find the last segment and start there.
2014-12-03 13:23:35 +11:00
Thiago Santos
148da6210a qtdemux: don't use GST_CLOCK_TIME_NONE in non GstClockTime variables
Use -1 instead as those are gint64/guint64 variables and not GstClockTime
2014-12-02 00:46:35 -03:00
Tim-Philipp Müller
d65c3bbe7e qtdemux: implement seeking in fragmented mp4 files in pull mode based on the mfra table 2014-11-30 15:33:13 +00:00
Tim-Philipp Müller
77f37a6b22 qtdemux: use track fragment decoding time (tfdt) in parse_trun() for interpolation
As fallback if we don't have any existing samples
as reference point yet.

Based on patch by David Corvoysier <david.corvoysier@orange.com>
2014-11-30 15:33:13 +00:00
Tim-Philipp Müller
e24f903b13 qtdemux: parse mfra random access box for fragmented mp4 files
If it's present, and we operate in pull mode.
2014-11-30 15:33:13 +00:00
Tim-Philipp Müller
8a0f4e74e4 qtdemux: stop parsing headers for fragmented mp4s at the first moof
Currently during header parsing, we scan through the entire file
and skip every moof+mdat chunk for fragmented mp4s, which makes
start-up incredibly slow. Instead, just stop at the first moof
chunk when have a moov, and start exposing the streams, so we
can go and start handling the moofs for real.
2014-11-30 15:30:04 +00:00
Edward Hervey
5b5e9f320f isomp4: Check presence of mfhd in moof
The 'mfhd' atom is mandatory in 'moof'. We can later on check whether
the fragment number properly increases
2014-11-26 16:36:39 +01:00
Jan Schmidt
61bbd2d226 qtdemux: Handle empty segments when seeking in reverse play.
Empty segments in an edit list have a media_start time of -1,
as they don't actually play any media. Allow for that when
aligning to the reference stream in reverse play.
2014-11-27 00:17:03 +11:00
Sanjay NM
26a1344f37 Miscellaneous minor cleanups
Fix redundant variables and assignments,
and unreachable breaks.

https://bugzilla.gnome.org/show_bug.cgi?id=736875
https://bugzilla.gnome.org/show_bug.cgi?id=736876
https://bugzilla.gnome.org/show_bug.cgi?id=736879
https://bugzilla.gnome.org/show_bug.cgi?id=736880
https://bugzilla.gnome.org/show_bug.cgi?id=736881
https://bugzilla.gnome.org/show_bug.cgi?id=736888
https://bugzilla.gnome.org/show_bug.cgi?id=736890
https://bugzilla.gnome.org/show_bug.cgi?id=736892
https://bugzilla.gnome.org/show_bug.cgi?id=736893
https://bugzilla.gnome.org/show_bug.cgi?id=736894
2014-09-24 00:45:31 +01:00
Matej Knopp
8a4931726d qtdemux: Handle mp4a without ESDS atom
https://bugzilla.gnome.org/show_bug.cgi?id=736986
2014-09-22 13:04:52 -03:00
Tim-Philipp Müller
884f81ba28 qtdemux: mark jpeg and png as parsed so avdec_mjpeg can be used too
https://bugzilla.gnome.org/show_bug.cgi?id=735971
2014-09-03 23:08:16 +01:00
Jan Schmidt
9375e90203 qtdemux: Silence some warnings for normal file contents 2014-09-03 23:47:49 +10:00
Thiago Santos
fa103ca5ad qtdemux: avoid crashing on dash streams
DASH/fragmented moov might have no samples as those are carried
in moof fragments. Avoid crashing or failing the stream because
of that.
2014-08-18 14:05:52 -03:00
Jan Schmidt
ca068865c3 qtdemux: Improve framerate calculation/guessing
Change the way the output framerate is calculated
to ignore the first sample (which is sometimes truncated
in my testing) and use the new gst_video_guess_framerate()
function to recognise common standard framerates better.

Remove the code that was sorting the first 20 sample
durations and then ignoring the result.
2014-08-15 01:12:20 +10:00
George Kiagiadakis
9dd48c503c qtdemux: forward DISCONT from upstream to the output streams
This makes sense in DASH reverse playback, where the upstream dashdemux
will download DASH segments in reverse order, but push their buffers
forward to qtdemux and mark each segment start as DISCONT. This needs
to be forwarded downstream to the parser/decoder, otherwise it won't work.

https://bugzilla.gnome.org/show_bug.cgi?id=734443
2014-08-11 10:28:14 +02:00
Tim-Philipp Müller
e8321af983 qtdemux: improve debug logging of fourccs
If we can't show ASCII, at least show them
in big endian order.
2014-08-09 20:50:01 +01:00
Tim-Philipp Müller
f41d03cd4d qtdemux: add support for 'wma ' mapping as found in some ismv files
e.g. To_The_Limit_720_2962.ismv
2014-08-09 20:49:53 +01:00
Tim-Philipp Müller
6183f83190 qtdemux: add support for 'vc-1' mapping as found in some ismv files
e.g. To_The_Limit_720_2962.ismv
2014-08-09 20:49:49 +01:00
Jan Schmidt
d9e1aa4959 isomp4/qtmux: Write correct file duration when gaps exist.
When writing out a trak with an edit list, make sure the
overall file duration is also updated to reflect the
lengthening of the stream.

Add some more debug to qtdemux to warn about streams that
are longer than the file and get truncated.
2014-08-08 04:01:19 +10:00
Tim-Philipp Müller
5122410f11 qtdemux: fix language code parsing for 3-letter codes starting with 'a'
And handle special value for 'unspecified' explicitly.

https://developer.apple.com/library/mac/documentation/QuickTime/QTFF/QTFFChap4/qtff4.html
2014-07-21 18:21:50 +01:00
Jan Schmidt
8da6ee0312 isomp4: Add object type id and fourcc for DTS/DTS-HD
Enables playback for files with DTS audio tracks.
Also add an extra AC-3 variant fourcc from Nero
2014-06-26 19:57:41 +10:00
Thiago Santos
9fda7b107f qtdemux: avoid looping indefinitely in broken svq3 files
Abort if an atom with size 0 is read from within the svq3 stsd
atoms

https://bugzilla.gnome.org/show_bug.cgi?id=726512
2014-06-10 15:33:33 -03:00
Thiago Santos
c25d94b7ef qtdemux: upstream handles seek if fragmented and on time segment
Otherwise we can reject seeks on local files that contain fragmented-like
atoms like 'mvex'. Also improve a message log

https://bugzilla.gnome.org/show_bug.cgi?id=730722
2014-05-30 15:01:50 -03:00
Thiago Santos
2b454bf87f qtdemux: remove last flow return from stream struct
It is already stored on GstPad on core

https://bugzilla.gnome.org/show_bug.cgi?id=709224
2014-05-26 19:51:12 -03:00
Thiago Santos
4b0ce7dc30 qtdemux: use GstFlowCombiner
Removes the common code to combining flow returns to let it be
handled by core gstutils' GstFlowCombiner

https://bugzilla.gnome.org/show_bug.cgi?id=709224
2014-05-26 15:30:12 -03:00
Thiago Santos
d423b9f63e qtdemux: parse tkhd transformation matrix and add tags if appropriate
Handle the transformation matrix cases where there are only simple rotations
(90, 180 or 270 degrees) and use a tag for those cases. This is a common scenario
when recording with mobile devices

https://bugzilla.gnome.org/show_bug.cgi?id=679522
2014-05-24 15:38:54 -04:00
Thiago Santos
f0b99d96a9 qtdemux: add tag mappings for _swr, _mak and _mod tags
swr -> Application name
mak -> device manufacturer
mod -> device model
2014-05-23 03:15:42 -03:00
Edward Hervey
420661bd95 qtdemux: Fix leak of palette_data in error cases
CID #1212151
2014-05-12 16:56:35 +02:00
Eric Trousset
bd51aa7aa8 qtdemux: don't respond to a position query in BYTE format with a TIME position
https://bugzilla.gnome.org/show_bug.cgi?id=729553
2014-05-09 16:12:45 +01:00
Vincent Penquerc'h
b692539b55 qtdemux: guard against invalid frame size to avoid division by 0
Coverity 1139690
2014-05-02 09:49:32 +01:00
Vincent Penquerc'h
436c8c11a0 qtdemux: trivial typo fix 2014-05-02 09:49:17 +01:00
Luis de Bethencourt
5dc2e6bef1 qtdemux: check return from qt_demux_video_caps
Now qtdemux_video_caps() can return NULL. We need to check this return before
using it's value.

https://bugzilla.gnome.org/show_bug.cgi?id=728987
2014-04-26 20:51:36 -04:00
Tim-Philipp Müller
c9597298f9 docs: remove outdated and pointless 'Last reviewed' lines from docs
They are very confusing for people, and more often than not
also just not very accurate. Seeing 'last reviewed: 2005' in
your docs is not very confidence-inspiring. Let's just remove
those comments.
2014-04-26 23:35:17 +01:00
Luis de Bethencourt
c073a6c779 qtdemux: initialize caps pointer to null
Make sure the caps pointer returns initialized when using it in
qtdemux_parse_tree ().

https://bugzilla.gnome.org/show_bug.cgi?id=728987
2014-04-25 18:23:23 -04:00
Vincent Penquerc'h
595a9cb5c5 isomp4: fix incorrect masking for multiple tags
Coverity 206058
2014-04-16 17:44:50 +01:00
Jimmy Ohn
ecf188e6cd qtdemux: replace duplicated variable when parsing trex atom
https://bugzilla.gnome.org/show_bug.cgi?id=727878
2014-04-10 09:03:02 +02:00
Sebastian Dröge
d47806320d qtdemux: Properly return stream flags when parsing trex atom
https://bugzilla.gnome.org/show_bug.cgi?id=727867
2014-04-09 08:58:48 +02:00
Thiago Santos
7f1d51ba90 qtdemux: handle tags in mac encoding
Check the charset from (C)*** tags and set the charset
to convert from MAC encoding if suitable.

https://bugzilla.gnome.org/show_bug.cgi?id=723166
2014-02-13 12:37:03 -03:00
Thiago Santos
52fc078310 qtdemux: remove elst_offset variables
They are not used anymore
2014-01-15 15:33:45 -03:00
Thiago Santos
5fe1b3eb28 qtdemux: remember reverse playback when verifying the segment end
Check if the rate is positive or negative to correctly compare the current
position with the segment to make reverse playback work
2014-01-15 15:33:45 -03:00
Thiago Santos
90a5565229 qtdemux: do not ignore empty segments
Make sure empty segments are used and pushed with a gap event
to represent its data (or lack of it)

Each QtSegment is mapped into a GstSegment with the corresponding
media range. For empty QtSegments a gap event is pushed instead
of GstBuffers and it advances to the next QtSegment.

To make this work with seeks, need to keep track of the starting
'base' to make sure it remains consistently increasing when
pushing new segment events.
For example: if a seek makes qtdemux start from 5s, the first
segment will have a base=0. When the next segment is activated,
its base time will be QtSegment.time - qtdemux.segment_base so
that it doesn't include the first 5s that weren't played and
shouldn't be accounted on the running time

This purposedly will remove the fix made for
https://bugzilla.gnome.org/show_bug.cgi?id=700264, at this
point it was decided to respect the gaps, even if they cause
a delay on playback, because that's the way the file was crafted.

https://bugzilla.gnome.org/show_bug.cgi?id=345830
2014-01-15 15:33:45 -03:00
Thiago Santos
c1cd2f81f9 qtdemux: improve mss_mode/fragmented special handling
Make it clear what should be handled purely by mss mode:
1) Expose the streams on the first moof as there are no moov atoms
2) Properly cleanup streams on flushes

Add a note about the meaning of upstream_newsegment and mss_mode
for future reference.

Make all other special fragment handling shared for both dash
and mss streams.
2013-12-27 12:04:49 -03:00
Thiago Santos
a82f3418fd qtdemux: drain the adapter before pushing EOS
In a fragmented scenario, qtdemux is operating in push mode
and it gets a fragmented buffer. While processing its data
downstream gets unlinked (or a input-selector changes its
active pad and returns not-linked). Qtdemux stops processing
this fragment and returns not-linked upstream, leaving the
remaining data in its adapter.

When it gets an EOS it should make sure that all the data it
had received is pushed before pushing EOS.
2013-12-27 12:00:27 -03:00
Thiago Santos
1fd094d96b qtdemux: improve fragment-start tracking
Some buffers can have multiple moov atoms inside and the strategy
of using the gst_adapter_prev_pts timestamp to get the base timestamp
for the media of the fragment would fail as it would reuse the same
base timestamp for all moofs in the buffer instead of accumulating
the durations for all of them.

Heres a better explanation of the issue:
qtdemux receives a buffer where PTS(buf) = X
buf -> moofA | moofB | moofC

The problem was that PTS(buf) was used as the base timestamp for
all 3 moofs, causing all buffers to be X based. In this case we want
only moofA to be X based as it is what the PTS on buf means, and the
other moofB and moofC just use the accumulated timestamp from the
previous moofs durations.

To solve this, this patch uses gst_adapter_prev_pts distance
result, this allows qtdemux to calculate if it should use the
resulting pts or just accumulate the samples as it can identify
if the moofs belong to the same upstream buffer or not.

https://bugzilla.gnome.org/show_bug.cgi?id=719783
2013-12-04 10:36:38 -03:00
Thiago Santos
079dde49ed qtdemux: Use the timestamp of the moof as the base fragment start
In SmoothStreaming fragmented scenario, the timestamps are calculated
starting from the fragment buffer timestamp. When there is a not-linked
return from downstream, qtdemux will return upstream and will keep the
non-pushed data into its adapter.

On a new fragment buffer pushed to qtdemux, the new buffer timestamp
would overwrite the previous one that should be used on the still
to be pushed buffers. Because of this, this patch will also
update the fragment_start timestamp from the adapter last pts
to make sure the moof and timestamps are in sync and will result
in correct timestamps for all fragments.
2013-11-29 17:28:48 -03:00
Thiago Santos
45c16599ff qtdemux: avoid re-reading the same moov and entering into loop
In the scenario of "mdat | moov (with fragmented artifacts)" qtdemux
could read the moov again after the mdat because it was considering the
media as a fragmented one.

To avoid this loop this patch makes it store
the last processed moov_offset to avoid parsing it again.
And it also checks if there are any samples to play before
resturning to the mdat, so that it knows there is new data to be played.

https://bugzilla.gnome.org/show_bug.cgi?id=691570
2013-11-29 17:28:48 -03:00
Thiago Santos
fcc78aa3bd qtdemux: do not free streams if they were not created locally
When parsing a trak only free streams on failures if those streams
were created locally. They could have been created from a previous
fragment, in this case we they have valid info from the other fragment.
Including pads.

https://bugzilla.gnome.org/show_bug.cgi?id=691570
2013-11-29 17:28:48 -03:00
Tim-Philipp Müller
4278ab18ff qtdemux: fix compilation with gst debuging disabled
qtdemux.c:9452:1: error: label at end of compound statement
2013-11-29 09:21:52 +00:00
Jan Schmidt
b3b89dfec1 qtdemux: Add HydrogenAudio ReplayGain tags
Identical to the itunes (tm) version, but labelled with
org.hydrogenaudio.replaygain as the producer.
2013-11-28 22:36:44 +11:00
Jan Schmidt
fdfc6a2a86 qtdemux: Discard 2 byte subpicture packets
As for text subtitles and as suggested in #712643, throw
away the 2 byte terminator packets that some encoders insert.

This will make things better when remuxing and causes generation
of gap events.
2013-11-25 12:24:22 +11:00
Thibault Saunier
a45d470236 qtdemux: Use GstVideoInfo helper to create caps for raw video
This way we do not miss mandatory fields in caps.
At the same time use the gst_pb_utils_get_codec_description
helper to get codec description.

https://bugzilla.gnome.org/show_bug.cgi?id=712335
2013-11-22 18:52:54 -03:00
Jan Schmidt
81e2c8130a isomp4: Handle mp4s subpicture streams better.
Clean up the handling of mp4s streams. Use the generic esds
descriptor function to extract the palette, instead of hard coding
a wrong magic offset.

Add some more size safety checks when parsing ES descriptors, and
replace magic numbers with the descriptive constants that are already
defined.

Enhance dump output for stsd atoms.

Streams from both bug 712643 and historic bug 568278 now both work
correctly.

Fixes: #712643
2013-11-21 02:28:27 +11:00