Commit graph

806 commits

Author SHA1 Message Date
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