This adds 2 checks to deal with overflow related issues when parsing webms.
- Detect uint64 overflows when calculating buffered ranges. This is unlikely,
but appears like something that could conceptually happen given the data types
involved. This isn't strictly needed to fix the bug, but figured I'd guard
against it while I'm in the code.
- Detect issues from uint64 -> int64 conversion when calculating TimeUnits in
the WebM parser. This is needed to fix the bug, as while we do some checks
that start <= end, we were not guarding against this following TimeUnit
conversion. My understanding is we should never encounter negative TimeUnits
for the code in question, so the added check bails if any negative values are
encountered.
Differential Revision: https://phabricator.services.mozilla.com/D105506
This replaces the instances where Length was being called on an interval set
to determine if it was empty or not empty. IsEmpty makes the intention in these
cases more immediately obvious, and avoids the need to think about ints as
bools in cases like `if(!mySet.Length())`.
Depends on D46638
Differential Revision: https://phabricator.services.mozilla.com/D46639
--HG--
extra : moz-landing-system : lando
We should always append sample by using `AppendSample()` to assert whether a sample is valid, so making `mSamples` private can prevent a direct usage of the nsTarry's `AppendElement()`.
Also provide a method to return non-const mSamples which is only used for the move semantics.
Differential Revision: https://phabricator.services.mozilla.com/D38427
--HG--
extra : moz-landing-system : lando
Return demux error when we get a invalid sample. For mp4 demuxer, we use `MOZ_DIAGNOSTIC_ASSERT` instead because we are pretty sure that it won't happen.
Differential Revision: https://phabricator.services.mozilla.com/D38553
--HG--
extra : moz-landing-system : lando
We don't want to have a sample with invalid time, duration, end time or end timecode, so add a diagnostic assertion to check. And will handle invalid sample for demuxers in next patch.
Differential Revision: https://phabricator.services.mozilla.com/D38426
--HG--
extra : moz-landing-system : lando
The mp4 demuxer already does this, so have the WebM case follow suit. This
avoids asserts with creating 0 size shmems in the case where the demuxer is
being used with the remote data decoder.
Differential Revision: https://phabricator.services.mozilla.com/D25846
--HG--
extra : moz-landing-system : lando
The mp4 demuxer already does this, so have the WebM case follow suit. This
avoids asserts with creating 0 size shmems in the case where the demuxer is
being used with the remote data decoder.
Differential Revision: https://phabricator.services.mozilla.com/D25846
--HG--
extra : moz-landing-system : lando
WebM specify that timestamp must be monotonically increasing. Unfortunately, this is not always the case.
WebM doesn't have a concept of frame duration, the duration is calculated as being the delta between the next frame's time and the current one. So non-monotonically increasing timestamps would have caused negative duration.
Differential Revision: https://phabricator.services.mozilla.com/D21687
--HG--
extra : moz-landing-system : lando
We're able to hit this assertion in the wild due to bad muxers. As such, replace
the assert with a log. If a sample has a time stamp > the segment duration, use
that instead of the duration for calculating our next time stamp. Use an
explicit int64_t type in the signature for our next time stamp calculation
as the logging explicitly expects an int64_t (makes it harder to change the
types involved and footgunning by having a wrong formatter in the logs).
Differential Revision: https://phabricator.services.mozilla.com/D21717
--HG--
extra : moz-landing-system : lando
Explicitly store the crypto scheme being used on our crypto structs to let us
differentiate between cenc and cbcs data. In doing so remove mMode and replace
mValid with IsEncrypted() for the following reasons:
- Different modes within the existing schemes are not currently utilized by the
spec: the scheme implies mode. Having a mode and a scheme could lead to confusion
between the two. We can return mMode if ever needed by the spec --
possibly if the isProtected flag which we were tracking with mMode, is
ever changed to be more than a bool in the spec.
- mValid was typically used to check if these structs contained valid crypto
data or not. With only one scheme this was often shorthand for 'IsEncrypted',
but with multiple schemes what is considered valid data for one may not be for
another. Do away with this and just explicitly have an 'IsEncrypted'.
Differential Revision: https://phabricator.services.mozilla.com/D15874
--HG--
extra : moz-landing-system : lando
Explicitly store the crypto scheme being used on our crypto structs to let us
differentiate between cenc and cbcs data. In doing so remove mMode and replace
mValid with IsEncrypted() for the following reasons:
- Different modes within the existing schemes are not currently utilized by the
spec of implementation. Having a mode and a scheme could lead to confusion
between the two. We can return mMode if ever needed by the spec.
- mValid was typically used to check if these structs contained valid crypto
data or not. With only one scheme this was often shorthand for 'IsEncrypted',
but with multiple schemes what is considered valid data for one may not be for
another. Do away with this and just explicitly have an 'IsEncrypted'.
Differential Revision: https://phabricator.services.mozilla.com/D15874
--HG--
extra : moz-landing-system : lando
The VideoSink shares the AudioSink's own EndedPromise to notify its user that it has ended. As such, the MozPromise used must be non-exclusive.
Using the GenericPromise for such purpose only hid that requirement.
We also remove the MediaSink from the media namespace, and clarify the naming of some arguments and class members to accurately describe what they do.
Differential Revision: https://phabricator.services.mozilla.com/D14024
--HG--
extra : moz-landing-system : lando
When reading samples from plain file resource, if we can't get the duration from sample, that means it's the last sample. Therefore, the next timestamp should be the track's duration.
Differential Revision: https://phabricator.services.mozilla.com/D6217
--HG--
extra : moz-landing-system : lando
As audio track sample and video track sample are both using the same code pattern, we can eliminate
redundant codes.
Differential Revision: https://phabricator.services.mozilla.com/D6216
--HG--
extra : moz-landing-system : lando
WebMs with encrypted tracks may have unencrypted samples in these tracks.
Previously we would populate some of the crypto metadata on these samples. This
data was correct, but it was potentially misleading to include crypto metadata on
clear samples.
This changeset alters the behaviour so that we do not populate any such data for
unencrypted packets. This should not alter existing behaviour, notably the
Widevine CDM version 9 should continue to work. However, this change makes our
samples easier to feed to version 10 of the CDM. Without this change, we would
need to do extra conversion steps to appease the new CDM.
Differential Revision: https://phabricator.services.mozilla.com/D6183
--HG--
extra : moz-landing-system : lando
This was done automatically replacing:
s/mozilla::Move/std::move/
s/ Move(/ std::move(/
s/(Move(/(std::move(/
Removing the 'using mozilla::Move;' lines.
And then with a few manual fixups, see the bug for the split series..
MozReview-Commit-ID: Jxze3adipUh
Returning UniquePtr is nicer than returning raw pointers, and has the
nice side effect of forcing us to clean up the uses of nsAutoPtr that
were hanging about.
Mostly-mechanical replacement of MOZ_LOG with DDMOZ_LOG, usually just removing
the class name and `this` pointer (as they are already implicitly recorded).
Some files needed a bit more work when logging was done from helper classes or
static functions.
MozReview-Commit-ID: IeJJmzYqWMQ
--HG--
extra : rebase_source : 94200838dcdaf6c3bda9de30042ce2d307237eef
Mostly-mechanical additions:
- Log constructions&destructions, usually by just inheriting from
DecoderDoctorLifeLogger, otherwise with explicit log commands (for internal
classes for which DecoderDoctorTraits can't be specialized),
- Log links between most objects, e.g.: Media element -> decoder -> state
machine -> reader -> demuxer -> resource, etc.
And logging some important properties and events (JS events, duration change,
frames being decoded, etc.)
More will be added later on, from just converting MOZ_LOGs, and as needed.
MozReview-Commit-ID: KgNhHSz35t0
--HG--
extra : rebase_source : dd7206e350e32671adc6f3b9e54ebf777251de2c
The only actual code use in MediaSourceDemuxer can trivially be folded into
its caller GetNumberTracks in the same class.
MozReview-Commit-ID: E6zh98zmJwJ
--HG--
extra : rebase_source : 9358dc37523d6cd7c1a4d5ec62a790db6a092063
When we seek in a webm containing an alpha channel, the first frame of a cluster may not be a keyframe for both channels. So seek backward until we find one.
We limit such operation on video with an alpha channel to prevent potential regression (even though thoses files would technically be invalid)
MozReview-Commit-ID: 14ETazkQ0AG
--HG--
extra : rebase_source : 8e106a382605c23769da5a8da5b88d107833cc6e
We want both the normal and alpha channels to be keyframe.
MozReview-Commit-ID: 9hHo7v97R3s
--HG--
extra : rebase_source : c531b8947b96760ad03e4dc75e6431706ebaa5a5
The codec mimetype is now shown in the media devtools. May as well make it readable.
MozReview-Commit-ID: 6rccDiTR24m
--HG--
extra : rebase_source : 7b8d1da8f05d0c46d5fd57b5e604ec3aed36a5f2
The codec mimetype is now shown in the media devtools. May as well make it readable.
MozReview-Commit-ID: 6rccDiTR24m
--HG--
extra : rebase_source : 7b8d1da8f05d0c46d5fd57b5e604ec3aed36a5f2
The nsRect.h and nsSize.h headers typedef nsIntRect to gfx::IntRect etc, so the
rect/size objects we use will be the same, just under a different name.
However the old headers #include a bunch of things we don't use, so we if we
use the gfx objects directly we end up with a smaller include graph.
MozReview-Commit-ID: 7S4OSqBJK9m
--HG--
extra : rebase_source : 7cc48507356ce754e8395af957fa68a28711e00a