Commit graph

901 commits

Author SHA1 Message Date
Edward Hervey
8e1c224fbc good: Avoid usage of deprecated API
GTimeval and related functions are now deprecated in glib.
Replacement APIs have been present since 2.26
2019-10-16 07:46:58 +00:00
Tim-Philipp Müller
c9a47c0c8d Remove autotools build system 2019-10-14 11:04:18 +01:00
Aaron Boxer
46989dca96 documentation: fix a number of typos 2019-10-05 22:38:11 +00:00
Thibault Saunier
a55576d1fd qtdemux: Specify REDIRECT information in error message
There are in the wild (mp4) streams that basically contain no tracks
but do have a redirect info[0], in which case, we won't be able
to expose any pad (there are no tracks) so we can't post anything but
an error on the bus, as:

- it can't send EOS downstream, it has no pad,
- posting an EOS message will be useless as PAUSED state can't be
  reached and there is no sink in the pipeline meaning GstBin will
  simply ignore it

The approach here is to to add details to the ERROR message with a
`redirect-location` field which elements like playbin handle and use right
away.

[0]: http://movietrailers.apple.com/movies/paramount/terminator-dark-fate/terminator-dark-fate-trailer-2_480p.mov
2019-09-30 12:15:43 -03:00
Matthew Waters
5ffd733317 build: fix werror build with newer gcc
In file included from ../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gst.h:55,
                 from ../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/tag/tag.h:25,
                 from ../gst/isomp4/qtdemux.c:56:
In function ‘qtdemux_inspect_transformation_matrix’,
    inlined from ‘qtdemux_parse_trak’ at ../gst/isomp4/qtdemux.c:10676:5,
    inlined from ‘qtdemux_parse_tree’ at ../gst/isomp4/qtdemux.c:14210:5:
../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gstinfo.h:645:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=]
  645 |     gst_debug_log ((cat), (level), __FILE__, GST_FUNCTION, __LINE__, \
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  646 |         (GObject *) (object), __VA_ARGS__);    \
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../../../dist/linux_x86_64/include/gstreamer-1.0/gst/gstinfo.h:1062:35: note: in expansion of macro ‘GST_CAT_LEVEL_LOG’
 1062 | #define GST_DEBUG_OBJECT(obj,...) GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, GST_LEVEL_DEBUG,   obj,  __VA_ARGS__)
      |                                   ^~~~~~~~~~~~~~~~~
../gst/isomp4/qtdemux.c:10294:5: note: in expansion of macro ‘GST_DEBUG_OBJECT’
10294 |     GST_DEBUG_OBJECT (qtdemux, "Transformation matrix rotation %s",
      |     ^~~~~~~~~~~~~~~~
../gst/isomp4/qtdemux.c: In function ‘qtdemux_parse_tree’:
../gst/isomp4/qtdemux.c:10294:64: note: format string is defined here
10294 |     GST_DEBUG_OBJECT (qtdemux, "Transformation matrix rotation %s",
      |                                                                ^~
2019-09-23 18:46:16 +10:00
Sebastian Dröge
d7738da285 qtmux: Use the new helper functions for mapping the colr atom values to colorimetry 2019-09-18 18:32:02 +03:00
Sebastian Dröge
5d4a46aa63 qtdemux: Use the new helper functions for mapping the colr atom values to colorimetry 2019-09-18 18:29:27 +03:00
Seungha Yang
2ef74f2c81 qtmux: Fix incompatible type warning with MSVC
gstqtmux.c(5582): warning C4133: 'function':
  incompatible types - from 'GstVideoMultiviewFlags *' to 'guint *'
2019-09-02 15:07:17 +00:00
Mathieu Duponchelle
3429ddde38 docstrings: port ulinks to markdown links 2019-08-23 18:56:01 +02:00
luke.lin
d6ae59c32d qtdemux: enlarge the maximal atom size
For 8K content, frame size is over 25MB, and cause the negotiation failure.
Enlarge the limitation of QTDEMUX_MAX_ATOM_SIZE to 32MB.
2019-08-07 02:46:20 +00:00
Seungha Yang
4146dc905d qtdemux: Use empty-array safe way to cleanup GPtrArray
Fix assertion fail
GLib-CRITICAL **: g_ptr_array_remove_range: assertion 'index_ < rarray->len' failed
2019-08-02 12:32:59 +09:00
Mathieu Duponchelle
4830bbe6ca qtdemux: fix reverse playback EOS conditions
In reverse playback, we don't want to rely on the position of the current
keyframe to decide a stream is EOS: the last GOP we push will start with
a keyframe, which position is likely to be outside of the segment.

Instead, let the normal seek_to_previous_keyframe mechanism do its job,
it works just fine.
2019-07-26 02:42:11 +00:00
Mathieu Duponchelle
104f459258 qtdemux: fix key unit seek corner case
If a key unit seek is performed with a time position that matches
the offset of a keyframe, but not its actual PTS, we need to
adjust the segment nevertheless.

For example consider the following case:

* stream starts with a keyframe at 0 nanosecond, lasting 40 milliseconds
* user does a key unit seek at 20 milliseconds
* we don't adjust the segment as the time position is "over" a keyframe
* we push a segment that starts at 20 milliseconds
* we push a buffer with PTS == 0
* an element downstream (eg rtponviftimestamp) tries to calculate the
  stream time of the buffer, fails to do so and drops it
2019-07-26 01:50:47 +00:00
Mathieu Duponchelle
5fde140e6e qtdemux: implement support for trickmode interval
When the seek event contains a (newly-added) trickmode interval,
and TRICKMODE_KEY_UNITS was requested, only let through keyframes
separated with the required interval
2019-07-18 17:54:43 +02:00
Mathieu Duponchelle
9deb3c27ac qtdemux: fix conditions for end of segment in reverse playback
The time_position field of the stream is offset by the media_start
of its QtDemuxSegment compared to the start of the GstSegment of
the demuxer, take it into account when making comparisons.
2019-07-09 21:21:20 +00:00
Mart Raudsepp
ade531183f qtdemux: Provide a 30 frames lead-in for MP3
mpegaudioparse suggests MP3 needs 10 or 30 frames of lead-in (depending on
mpegaudioversion, which we don't know here), thus provide at least 30 frames
lead-in for such cases as a followup to commit cbfa4531ee.
2019-07-02 20:50:21 +00:00
Mathieu Duponchelle
f4f11530c2 qtdemux: do_seek can never be called with a NULL event 2019-07-02 13:39:55 +02:00
Mathieu Duponchelle
83704e32e6 qtdemux: only adjust segment time when adjusting segment start
We ended up setting segment.time to segment.position when doing
reverse playback, which is obviously wrong.
2019-07-02 13:39:55 +02:00
Mart Raudsepp
cbfa4531ee qtdemux: Provide a 2 frames lead-in for audio decoders
AAC and various other audio codecs need a couple frames of lead-in to
decode it properly. The parser elements like aacparse take care of it
via gst_base_parse_set_frame_rate, but when inside a container, the
demuxer is doing the seek segment handling and never gives lead-in
data downstream.
Handle this similar to going back to a keyframe with video, in the
same place. Without a lead-in, the start of the segment is silence,
when it shouldn't, which becomes especially evident in NLE use cases.
2019-06-05 23:13:33 +03:00
Mart Raudsepp
9b348e755c qtdemux: remove indent exception and reindent
As the indent disabling isn't playing along for a following fix,
remove the indent disabling and reindent in a way that doesn't
look too stupid.
2019-06-05 23:11:13 +03:00
Sebastian Dröge
2bed2687bb qtmux: Use size of first closed caption buffer in prefill mode
It must be accurate for all samples to work in Final Cut properly, so
the best we can do is to assume that all samples are the same as the
first. Bigger samples are truncated, smaller samples are padded.
2019-06-03 12:46:34 +03:00
Mathieu Duponchelle
d704790519 doc: fix element section documentations
Element sections were not rendered anymore after the hotdoc
port, fixing this revealed a few incorrect links.
2019-05-25 16:57:31 +02:00
Thibault Saunier
af01988534 doc: Port documentation to hotdoc 2019-05-13 11:34:56 -04:00
Thibault Saunier
232e3682ea Mark some properties as DOC_SHOW_DEFAULT 2019-05-13 10:24:40 -04:00
Thibault Saunier
0a6a62aa76 docs: Port all docstring to gtk-doc markdown 2019-05-13 10:24:40 -04:00
Seungha Yang
63bb1e3a4d qtdemux: Don't pass zero to denominator for framerate
Need to respect return of gst_video_guess_framerate() to ensure
non-zero denominator.

This patch is to fix below error with an abnormal (but has valid frame) file.
(gst-play-1.0:17940): GStreamer-CRITICAL **: passed '0' as denominator for `GstFraction'
2019-03-19 12:35:08 +09:00
Charlie Turner
39d32b2394 qtdemux: Find mp4a esds atoms in protected streams sample description tables.
This problem was found in Test. 2 of the YouTube 2018 EME
tests[1]. The code was accidentally not finding an mp4a's esds atom in
the sample description table when the stream was encrypted. It assumed
that if the stream is protected, then only an enca atom will be found
here. What happens with YouTube is they often provide protected
content with a few seconds of clear content, and then switch to the
encrypted stream.

The failure case here was an incorrect codec_data field being sent
into aacparse. The advertisement of stereo audio @ 44.1kHz for the
mp4a (unprotected) stream was incorrect. As usual, the esds contained
the real values here which were mono at 22050 Hz.

Here's what the MP4 tree looks like for these types of files,
demonstrating why the code was making a wrong assumption (or maybe
YouTube is being unusual),

[ftyp] size=8+16
...
[moov] size=8+1571
...
  [trak] size=8+559
...
          [stsd] size=12+234
            entry-count = 2
            [enca] size=8+147
              channel_count = 2
              sample_size = 16
              sample_rate = 44100
              [esds] size=12+27
                ...
            ...
            [mp4a] size=8+67
              channel_count = 2
              sample_size = 16
              sample_rate = 44100
              [esds] size=12+27
                ...

In addition to fixing this, the checks for esds atoms in mp4a and mp4v
have been made symmetrical. While I haven't seen a test case for video
with the same problem, it seemed better to make the same checks. This
also fixes a crash reported from another user[2], they also noted the
asymmetry with mp4v and mp4a.

[1] https://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2018.html?test_type=encryptedmedia-test
[2] https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/issues/398
2019-03-15 12:41:33 +00:00
Vivia Nikolaidou
92272b5e5c qtmux: Only write timecode trak for video
Recent changes in ccextractor were attaching timecode meta to the closed
caption track. We shouldn't write timecode information for the closed
caption trak.
2019-02-08 14:13:46 +02:00
Edward Hervey
f5f1de54d2 qtdemux: Remove trailing '\n' in debug 2019-02-05 11:01:21 +01:00
Sebastian Dröge
ec931601a6 qtdemux: Split CEA608 buffers correctly so that each output buffer represents a single frame 2019-01-02 10:29:46 +00:00
Sebastian Dröge
aa65ea85f9 qtdemux: Refactor buffer pushing into its own function 2019-01-02 10:29:46 +00:00
Sebastian Dröge
d471be4f3a qtdemux: Extract CEA608 framerate from the (first) video stream
EA608 closed caption tracks are a bit special in that each sample
can contain CCs for multiple frames, and CCs can be omitted and have to
be inferred from the duration of the sample then.

As such we take the framerate from the (first) video track here for
CEA608 as there must be one CC byte pair for every video frame
according to the spec.

For CEA708 all is fine and there is one sample per frame.
2019-01-02 10:29:46 +00:00
Philippe Normand
ce96d6dcd4 qtdemux: Offset correction for track language code parsing
The duration field being a uint64, is stored in 8 bytes, not 4. So the offset of
the following field, language code, needs to be updated accordingly so that the
parsed language code is not garbage.
2018-12-22 20:05:34 +01:00
Sebastian Dröge
4f7ef56c53 isomp4: Replace GST_VIDEO_CAPTION_TYPE_CEA608_IN_CEA708_RAW with CEA608_S334_1A
For the demuxer we have to select line offset 0 for the time being as
this information is not passed over MOV.
2018-12-15 21:31:20 +00:00
Sebastian Dröge
c50be8f146 qtdemux: Put framerate into the closedcaption caps if it can be calculated from the stream
Using the same calculation used for video streams.
2018-12-06 16:05:50 +00:00
Sebastian Dröge
830e7dc14b qtmux: Set timescale of closedcaption tracks to the one of the main video track 2018-12-06 16:05:50 +00:00
Alicia Boya García
38b553dda7 qtdemux: set need_segment after a second moov
stream.segment should be updated with the values of the current edit
list, also when a new `moov` is received. Unfortunately this was not
being the case because of an early return.

As a consequence of this bugs, no end of movie clipping was being
performed on the new moov and no segment event was being emitted.

When performing stream switching (e.g. in MSE) the new moov may have a
different edit list. This is often the case when switching between
baseline H.264 (which lacks B-frames) and more demanding profiles. For
this reason it's important to emit a new segment in order to be able
to get matching stream times.
2018-11-30 20:44:57 +00:00
Alicia Boya García
26cc201c8a qtdemux: Initialize QtDemuxStream.segment in its constructor
This patch moves the initialization of QtDemuxStream.segment from
gst_qtdemux_add_stream() to _create_stream(). This ensures the segment
is always initialized when the stream is created.

Otherwise the segment format is left as GST_FORMAT_UNDEFINED in the case
were a track is reparsed and qtdemux_reuse_and_configure_stream() is
called instead of gst_qtdemux_add_stream(). (See
qtdemux_expose_streams() in the non streams-aware case.)
2018-11-30 20:44:57 +00:00
Matthew Waters
8a7074f748 isomp4: add preliminary support for the bitrate query
Return the upstream size over the duration as a first estimate.

https://gitlab.freedesktop.org/gstreamer/gst-plugins-base/issues/60
2018-11-07 15:07:18 +00:00
Seungha Yang
5d542030db qtdemux: Ignore corrupted CTTS box
If ctts (CompositionOffsetBox) has larger sample_offset
(offset between PTS and DTS) than (2 * duration) of the stream,
assume the ctts box to be corrupted and ignore the box.

https://bugzilla.gnome.org/show_bug.cgi?id=797262
2018-11-01 16:03:12 +02:00
Alicia Boya García
5fcb7f715a qtmux: round to nearest when computing mehd and tkhd duration
This fixes a bug where in some files mehd.fragment_duration is one unit
less than the actual duration of the fragmented movie, as explained below:

mehd.fragment_duration is computed by scaling the end timestamp of
the last frame of the movie in (in nanoseconds) by the movie timescale.

In some situations, the end timestamp is innacurate due to lossy conversion to
fixed point required by GstBuffer upstream.

Take for instance a movie with 3 frames at exactly 3 fps.

$ gst-launch-1.0 -v videotestsrc num-buffers=3 \
  ! video/x-raw, framerate="(fraction)3/1" \
  ! x264enc \
  ! fakesink silent=false

dts: 999:59:59.333333334,  pts: 1000:00:00.000000000, duration: 0:00:00.333333333
dts: 999:59:59.666666667,  pts: 1000:00:00.666666666, duration: 0:00:00.333333334
dts: 1000:00:00.000000000, pts: 1000:00:00.333333333, duration: 0:00:00.333333333

The end timestamp is calculated by qtmux in this way:

end timestamp = last frame DTS + last frame DUR - first frame DTS =
  = 1000:00:00.000000000 + 0:00:00.333333333 - 999:59:59.333333334 =
  = 0:00:00.999999999

qtmux needs to round this timestamp to the declared movie timescale, which can
ameliorate this distortion, but it's important that round-neareast is used;
otherwise it would backfire badly.

Take for example a movie with a timescale of 30 units/s.

0.999999999 s * 30 units/s = 29.999999970 units

A round-floor (as it was done before this patch) would set fragment_duration to
29 units, amplifying the original distorsion from 1 nanosecond up to 33
milliseconds less than the correct value. The greatest distortion would occur
in the case where timescale = framerate, where an entire frame duration would
be subtracted.

Also, rounding is added to tkhd duration computation too, which
potentially has the same problem.

https://bugzilla.gnome.org/show_bug.cgi?id=793959
2018-10-27 13:12:56 +01:00
Sebastian Dröge
01a2119ad0 qtmux: Add property for providing a threshold after which we create an edit list for gaps at the start
https://bugzilla.gnome.org/show_bug.cgi?id=797290
2018-10-22 12:29:23 +01:00
Sebastian Dröge
324f8c7f3c qtmux: Correctly set tkhd width/height to the display size
It was previously set to the display aspect ratio, e.g. 4x3, 16x9, etc.
but should be set to the display size.

This is a regression from e655d47dfc
(1.5.1) and was correct before that.

https://bugzilla.gnome.org/show_bug.cgi?id=797318
2018-10-22 12:23:05 +01:00
Seungha Yang
7bce030be3 qtdemux: Fix build with GLib versions < 2.54
g_ptr_array_find_with_equal_func was introduced in glib 2.54
which is a higher version than our minimum required one.

https://bugzilla.gnome.org/show_bug.cgi?id=797239
2018-10-20 12:38:32 +01:00
Seungha Yang
05bd25ea35 qtdemux: Don't switch active streams and old streams ...
... before the old streams is not exposed yet for MSS stream.

In case of DASH, newly configured streams will be exposed
whenever demux got moov without delay.
Meanwhile, since there is no moov box in MSS stream,
the caps will act like moov. Then, there is delay for exposing new pads
until demux got the first moof.

So, following scenario is possible only for MSS but not for DASH,
STREAM-START -> CAPS -> (configure stream but NOT EXPOSED YET)
-> STREAM-START-> CAPS (configure stream again).

In above scenario, we can reuse old stream without any stream reconfigure.

https://bugzilla.gnome.org/show_bug.cgi?id=797239
2018-10-19 14:44:43 +02:00
Seungha Yang
b2876ad8a4 qtdemux: Use GPtrArray to store QtDemuxStream structure
GPtrArray has less overhead than linked list and the length also
can be auto updated by using it.

https://bugzilla.gnome.org/show_bug.cgi?id=797239
2018-10-19 14:44:43 +02:00
Seungha Yang
1600323119 qtdemux: Make QtDemuxStream refcounted structure
This a prework for porting GPtrArray.
Refcounting will help the use of g_ptr_array_new_with_free_func()
with QtDemuxStream structure

https://bugzilla.gnome.org/show_bug.cgi?id=797239
2018-10-19 14:44:43 +02:00
Seungha Yang
72123e3da3 qtdemux: Make function foreach method friendly
https://bugzilla.gnome.org/show_bug.cgi?id=797239
2018-10-19 14:44:43 +02:00
Olivier Crête
20d5f92b28 qtdemux: Only set width/height in caps if they're non-0
If they are not valid, then let a downstream parser complete them.

https://bugzilla.gnome.org/show_bug.cgi?id=796878
2018-10-19 14:19:27 +02:00
Philippe Normand
56669205eb qtdemux: Avoid warning when reporting about decryptors
https://bugzilla.gnome.org/show_bug.cgi?id=796652
2018-10-17 15:51:32 +01:00
Vivia Nikolaidou
09904e59df qtmux: Allow up to 1% of frame rate for lateness
https://bugzilla.gnome.org/show_bug.cgi?id=797290
2018-10-16 16:05:46 +03:00
Philippe Normand
babf4210f0 qtdemux: PIFF track encryption box support
The PIFF track encryption box is a UUID box containing the default encryption
values that should be used for PIFF sample encryption.

https://bugzilla.gnome.org/show_bug.cgi?id=796647
2018-09-25 09:53:31 +01:00
Alicia Boya García
bc0ea0dbbb qtdemux: turn impossible condition into an assert
qtdemux_update_streams() is only ever called after checking
`qtdemux->streams_aware` is TRUE. There is no need to check for that
condition again.

`qtdemux->streams_aware` is only modified when the demuxer is
hard-resetted, which is mutually exclusive with demuxing, so it cannot
be modified during the call.

https://bugzilla.gnome.org/show_bug.cgi?id=797191
2018-09-24 08:33:02 +01:00
Sebastian Dröge
c6e07a6eee qtmux: Set Closed Caption track width/height to that of the first video track
Otherwise software like Premiere or Final Cut Pro won't like our files.

https://bugzilla.gnome.org/show_bug.cgi?id=797111
2018-09-20 11:35:31 +03:00
Sebastian Dröge
54a5b3f845 qtmux: Initialize caption track language code to 0 instead of "und"
Without this, Final Cut considers it "non-standard" and 0 (english) is a
good default for closed captions.

https://bugzilla.gnome.org/show_bug.cgi?id=797111
2018-09-18 17:32:46 +03:00
Vivia Nikolaidou
94f8603411 qtmux: Allow up to 1 trak timescale unit of lateness in prefill mode
For 59.94 FPS, it's common to set 60000 as timescale. For that
timescale, if the audio is late by as little as 0:00:00.000016666
(definitely less than one audio sample), lateness gets rounded to 1.
Added a safeguard that allows lateness up to 1 sample with the specific
trak's timescale, to make sure that values less than e.g. one audio
sample won't break the prefill mode. What will happen in this case is
that the audio will get squeezed back to the video's timestamp, which in
practice means that the audio will be 0.000016666 seconds early (with
the patch).

https://bugzilla.gnome.org/show_bug.cgi?id=797133
2018-09-13 13:51:18 +03:00
Sebastian Dröge
d9b52d1f5e qtmux: Use existing helper function to create "und" language code 2018-09-06 20:07:57 +03:00
Alicia Boya García
794dcfbfee qtdemux: Keep sample data from the current fragment only (push mode)
This patch clears the sample table whenever the demuxing of a new
fragment begins. This avoids increasing memory usage for long videos.
This behavior was already present when upstream_format_is_time; this
patch extends it to all push mode operation (e.g. Media Source
Extensions).

https://bugzilla.gnome.org/show_bug.cgi?id=796899
2018-09-03 12:38:17 -03:00
Mathieu Duponchelle
bfcddb7125 mp4 robust muxing: improve documentation and logging 2018-08-16 19:43:50 +02:00
Sebastian Dröge
5e4f215bfb qtdemux: Handle closed captions as subtitle streams 2018-08-02 16:13:26 +03:00
Sebastian Dröge
7a354d0507 qtmux: The sample size we have to reserve is 256+8 bytes for the header for CDP packets 2018-08-02 13:40:09 +03:00
Sebastian Dröge
8a3075fbae qtmux: Properly allocate 256 bytes per CDP packet in prefill mode
Instead of allowing 256 but only pre-allocating 100.
2018-08-02 12:27:45 +03:00
Sebastian Dröge
bbfd76e94e Revert "qtmux: Allow for CDP packets up to 320 bytes"
This reverts commit 5eed1d49bd.

255 is actually the maximum, there's a bug if more is arriving.
2018-08-02 12:27:17 +03:00
Sebastian Dröge
5eed1d49bd qtmux: Allow for CDP packets up to 320 bytes
Apparently they can be bigger than 256 bytes sometimes.
2018-08-01 16:51:11 +03:00
Sebastian Dröge
7679412b69 qtdemux: Don't assert in prefill mode if a track has no samples at all
Just write it with a duration of 0, no samples, etc.
2018-07-31 12:47:47 +03:00
Sebastian Dröge
6ce2a5f7bf qtdemux: Don't assert if a file does not have any active streams
** (gst-play-1.0:9113): CRITICAL **: 12:31:54.360: qtdemux_is_streams_update: assertion 'qtdemux->active_streams != NULL' failed
2018-07-31 12:33:54 +03:00
Sebastian Dröge
e58dceec3a qtmux: Reserve 256 bytes for CDP packets in pre-fill mode
92 is sometimes too small and compared to the wasted space for other
codecs 256 bytes is small (and should be the maximum CDP packet size)
2018-07-30 13:35:02 +03:00
Olivier Crête
6c478453a8 qtmux: Implement muxing of AV1 into MP4 files
According to
https://aomediacodec.github.io/av1-isobmff/
2018-07-26 14:14:53 -04:00
Olivier Crête
e07ce9afb4 qtdemux: Recognize more AV1 atoms 2018-07-26 14:14:53 -04:00
Olivier Crête
43ee4055c3 qtdemux: Extract AV1 codec_data and put it in the caps
Also extract the presentation-delay and put it in the caps.
2018-07-26 14:14:53 -04:00
Olivier Crête
b6e8c6323e qtdemux: Add initial support for AV1 demuxing
Following the spec at
https://aomediacodec.github.io/av1-isobmff/
2018-07-26 14:14:53 -04:00
Edward Hervey
9be72b585d qtdemux: Store and propagate SEGMENT sequence numbers
* When receiving a segment in TIME, use that seqnum
* Only reset the stored sequence number when doing HARD reset
  (and not when we get a FLUSH event from upstream)
2018-07-06 15:21:33 +02:00
Alicia Boya García
025a430d08 qtdemux: rework segment event pushing, again
This patch aims at fixing the recent regressions in the adaptive test
suite.

All segment pushing in push mode is now done with
gst_qtdemux_check_send_pending_segment(), which is idempotent and
handles both edit lists cases and cases where the upstream TIME segments
have to be sent directly.

Fragmented files that start with a non-zero tfdt are also taken into
account, but their handling has been vastly simplified: now they are
handled as implicit default seeks so there is no need to extend the
GstSegment formulas as was being done before.

qtdemux->segment.duration is no longer modified when
upstream_format_is_time, respecting in this way the durations provided
by dashdemux and fixing bugs in reverse playback tests where mangled
durations appeared in the emitted segments.

https://bugzilla.gnome.org/show_bug.cgi?id=752603
2018-06-29 09:19:31 -04:00
Alicia Boya García
2c394304b7 qtdemux: Don't send EOS during upstream reverse playback
Upstream driving elements such as dashdemux often do reverse playback by
feeding qtdemux with the fragments containing the requested playback
range in reverse order.

But the requested playback range stop may be somewhere in the
middle of a fragment. In that case, a naive pts >= segment.stop
condition may declare end of segment prematurely when demuxing this
first fragment.

This used not to happen because there were places in moov parsing where
segment.stop was overwritten to GST_CLOCK_TIME_NONE even if
upstream_format_is_time -- resulting in this case in a segment with rate
< 0 and stop == -1 and hence not triggering the EOS check, but that was
likely an accident.

This patch modifies the EOS check to take this case into account, not
sending EOS when upstream_format_is_time if rate < 0.

This fixes adaptive.dash.playback.seek_end_live.DASHIF_livestream_testpic_2s

https://bugzilla.gnome.org/show_bug.cgi?id=752603
2018-06-29 09:19:31 -04:00
Thibault Saunier
1840159d0b qtdemux: Do not set INVALID seqnum on events 2018-06-06 11:44:33 -04:00
Seungha Yang
6b29a4507e qtdemux: Forward upstream time-format segment without mapping
Sample table based segment event (genereted by qtdemux) could break
presentation timeline. For example, qtdemux should not modify upstream
time format segment (e.g., adaptivedemux use case)

https://bugzilla.gnome.org/show_bug.cgi?id=796480
2018-06-06 10:54:55 -04:00
Thibault Saunier
0fbde2a079 qtdemux: Clarify field name about stream-encryption-system
This field is actually only informatory and the user can potentially
choose something else. EME tests in WebKit testsuite actually doesn't
take it into and force another encryption system to be used, and expects
to be given the occasion to do so.

This basically also reverts 3e063703b3.
2018-05-28 16:52:10 -04:00
Thiago Santos
ae7b531902 qtdemux: mark segment as sent after pushing when moov is received
Otherwise we would try to send it a second time if the same moov is
received or in any other situation that might trigger segment sending.

https://bugzilla.gnome.org/show_bug.cgi?id=752603
2018-05-28 11:26:36 -07:00
Thiago Santos
364a921d3f qtdemux: do not update segment.stop is it is not a valid time
Otherwise it overflows and starts having a meaningful and wrong value.

https://bugzilla.gnome.org/show_bug.cgi?id=752603
2018-05-25 08:34:29 -07:00
Thiago Santos
9c514f9c7c qtdemux: offset edts segments by the min timestamp of the stream
Otherwise if the stream is starting at timestamp=X it would wait
'X' to start playing.

https://bugzilla.gnome.org/show_bug.cgi?id=752603
2018-05-25 08:34:29 -07:00
Thiago Santos
bfd0e0225e qtdemux: rework segment event pushing
Instead of always keeping a safe segment (start=0) event from the beginning,
delay the creation of this event to when we really know the timestamp of the
first sample. This is important to properly start fragmented streams that
we might join in the middle or to play isolated fragment files that might
have an advanced tfdt.

https://bugzilla.gnome.org/show_bug.cgi?id=752603
2018-05-25 08:34:29 -07:00
Thibault Saunier
43a540b1cd qtdemux: Do not unref a NULL stream_tags
stream->stream_tags is reset to NULL once we expose the stream and
these have been consumed, we need to check that when cleaning up
the stream.
2018-05-25 10:54:54 +02:00
Thibault Saunier
3e063703b3 qtdemux: Do not run the preferred decryptor context query if no decryptor avalaible
Ultimately this avoids a segfault as the code expect a non NULL array
here.
2018-05-25 10:53:16 +02:00
Alicia Boya García
c2a0da8096 qtdemux: Allow edit lists on fragmented files on push mode
Fragmented files often use elst.duration=0 which before
ee78825eae was wrongly interpreted as
having no frames.

Since that issue has now been fixed, there is no reason to disable edit
lists in fragmented files. This commit enables them, therefore producing
correct stream time for files containing edit lists.

https://bugzilla.gnome.org/show_bug.cgi?id=793058
2018-05-24 15:53:48 +02:00
Alicia Boya García
5388d6e6a2 qtdemux: fix computation of first_duration for fragmented files in push mode
Since ca068865c3 the duration of the first
frame is not used for estimating the frame rate.

For this purpose, stream->first_duration was initialized with the
duration of the first frame. In fragmented files, this was previously
done by peeking the first moof, but that can only be done in pull mode.

Fortunately, we don't really need to do that, at least with the current
design: When we are estimating the frame rate we already have the
sample table, regardless of the scheduling mode and whether the file is
fragmented or not, so we can obtain first_duration there much more
reliably.

This fixes frame rate estimation for fragmented files in push mode.

https://bugzilla.gnome.org/show_bug.cgi?id=796384
2018-05-24 15:53:48 +02:00
Alicia Boya García
d35f893715 qtdemux: Don't send gaps bigger than 1 second (now in push mode too)
This applies the same workaround to gaps that is being used in pull
mode.

https://bugzilla.gnome.org/show_bug.cgi?id=778426
2018-05-24 11:09:53 +02:00
Seungha Yang
f61c2bc301 qtdemux: Properly handle edit list in push mode
If there are empty segments in edit list, demux should
adjust "accumulated_base" to apply it into running time.

https://bugzilla.gnome.org/show_bug.cgi?id=778426
2018-05-24 11:09:53 +02:00
Alicia Boya García
ee78825eae qtdemux: fix buggy duration in edits with duration=0 in fragmented files without a mehd
https://bugzilla.gnome.org/show_bug.cgi?id=794858
2018-05-23 14:25:56 +02:00
Seungha Yang
c69ccf60d8 qtdemux: Clarify variable name
As defined by spec, use "empty edit". It's more straightforward.

https://bugzilla.gnome.org/show_bug.cgi?id=778426
2018-05-22 11:29:44 +02:00
Xabier Rodriguez Calvar
ee4b45da24 qtdemux: add context for a preferred protection
qtdemux selected the first system corresponding to a working GStreamer
decryptor. With this change, before selecting that decryptor, qtdemux
will check if it has context (a preferred decryptor id) and if not, it
will request it.

The request includes track-id, available key system ids for the
available decryptors and even the events so that the init data is
accessible.

[eocanha@igalia.com: select the preferred protection system even if not available]

Test "4. ClearKeyVideo" in YouTube leanback EME conformance tests 2016 for
H.264[1] uses a media file[2] with cenc encryption which embeds 'pssh' boxes
with the init data for the Playready and Widevine encryption systems, but not
for the ClearKey encryption system (as defined by the EMEv0.1b spec[3] and with
the encryption system id defined in [4]).

Instead, the ClearKey encryption system is manually selected by the web page
code (even if not originally detected by qtdemux) and the proper decryption key
is dispatched to the decryptor, which can then decrypt the video successfully.

[1] http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2016.html?test_type=encryptedmedia-test&webm=false
[2] http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/media/car_cenc-20120827-86.mp4
[3] https://dvcs.w3.org/hg/html-media/raw-file/eme-v0.1b/encrypted-media/encrypted-media.html#simple-decryption-clear-key
[4] https://www.w3.org/Bugs/Public/show_bug.cgi?id=24027#c2

https://bugzilla.gnome.org/show_bug.cgi?id=770107
2018-05-21 17:36:17 +02:00
Enrique Ocaña González
844423ff99 qtdemux: also push buffers without encryption info instead of dropping them
Test "17. PlayReadyH264Video" in YouTube leanback EME conformance tests 2016
for H.264[1] uses a media file[2] with cenc encryption whose first two 'moof'
boxes have no encryption information (no 'saiz' and 'saio' boxes).

Those boxes are actually not encrypted and the current qtdemux implementation
was just dropping them, breaking the test use case.

This patch detects those kind of situations and just lets the unencrypted
buffers pass. Of course, this needs some collaboration by the decryptors,
which should also do the same and not to try to decrypt those clear buffers.

[1] http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/2016.html?test_type=encryptedmedia-test&webm=false
[2] http://yt-dash-mse-test.commondatastorage.googleapis.com/unit-tests/media/oops_cenc-20121114-142.mp4

https://bugzilla.gnome.org/show_bug.cgi?id=770107
2018-05-21 17:36:17 +02:00
Alicia Boya García
c097289725 qtdemux_parse_segments: remove superfluous variable
https://bugzilla.gnome.org/show_bug.cgi?id=793751
2018-05-18 11:29:47 -04:00
Sebastian Dröge
6e7b0d6061 qtmux: Print expected/actual values in debug log on mismatch in prefill mode
This helps debugging a lot.
2018-05-14 21:06:55 +03:00
Edward Hervey
4253c51c5f qtdemux: Initialize riff library
Avoids debugging message issues. Also just use the main riff header
2018-05-10 13:59:36 +02:00
Seungha Yang
7651036530 qtdemux: Protect _expose_streams() from flush event
Flush during stream change can break autoplugging or the
flush event could be dropped.

https://bugzilla.gnome.org/show_bug.cgi?id=684790
2018-05-10 08:09:20 +02:00
Seungha Yang
d72a7c038c qtdemux: Try to expose whenever got new moov or new stream-start
Whenever got new moov or new stream-start,
demux will try to expose new pad by following rule.

Comparing stream-id in the current moov with previous one, then
* If matched stream-id is found from previous one,
  reuse existing pad (most common case)
* Otherwise, expose new pad with new stream-start
* No more used stream will be freed

https://bugzilla.gnome.org/show_bug.cgi?id=684790
2018-05-10 08:09:20 +02:00
Seungha Yang
0bd3459053 qtdemux: Remove duplication of initializing member variables
Most initialization of variables in gst_qtdemux_init() are duplicated in
gst_qtdemux_reset() function.

https://bugzilla.gnome.org/show_bug.cgi?id=684790
2018-05-10 08:09:20 +02:00
Seungha Yang
553607756b qtdemux: Create stream whenever got new moov
Whenever demux got moov, demux will create new stream. Only exception is
duplicated track-id in a moov box. In that case the first stream
will be accepted. This patch is pre-work for rework of moov handling.

https://bugzilla.gnome.org/show_bug.cgi?id=684790
2018-05-10 08:09:20 +02:00
Seungha Yang
96a6aab6a1 qtdemux: Store stream-id to manage streams
In order to figure out stream change such as
track-id change or stream-id change, demux will store
 stream-id per QtDemuxStream structure.

https://bugzilla.gnome.org/show_bug.cgi?id=684790
2018-05-10 08:09:20 +02:00
Seungha Yang
b5245be1b1 qtdemux: Use GList to manage QtDemuxStream
* Move to GList from static array
* Logging track-id instead of array index. It's more meaningful.

https://bugzilla.gnome.org/show_bug.cgi?id=684790
2018-05-10 08:09:20 +02:00