tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 94598ef5f31b9a9e3b9e61322640a98ae7742745
parent 441e74873808697f149524edae8d361d625fc364
Author: Karl Tomlinson <karlt+@karlt.net>
Date:   Wed, 10 Dec 2025 20:57:02 +0000

Bug 2004858 Declare ParseTraf() parameter aTrex as const r=ArnaudBienner,media-playback-reviewers,chunmin

Differential Revision: https://phabricator.services.mozilla.com/D275550

Diffstat:
Mdom/media/mp4/Box.cpp | 2+-
Mdom/media/mp4/Box.h | 4++--
Mdom/media/mp4/MoofParser.cpp | 10+++++-----
Mdom/media/mp4/MoofParser.h | 17+++++++++--------
4 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/dom/media/mp4/Box.cpp b/dom/media/mp4/Box.cpp @@ -195,7 +195,7 @@ bool Box::Read(nsTArray<uint8_t>* aDest, const MediaByteRange& aRange) const { return true; } -ByteSlice Box::ReadAsSlice() { +ByteSlice Box::ReadAsSlice() const { if (!mContext || mRange.IsEmpty()) { return ByteSlice{nullptr, 0}; } diff --git a/dom/media/mp4/Box.h b/dom/media/mp4/Box.h @@ -69,7 +69,7 @@ class Box { // Returns a slice, pointing to the data of this box. The lifetime of // the memory this slice points to matches the box's context's lifetime. - ByteSlice ReadAsSlice(); + ByteSlice ReadAsSlice() const; private: bool Contains(MediaByteRange aRange) const; @@ -89,7 +89,7 @@ class Box { // Ensure that the BoxReader doesn't outlive the BoxContext! class MOZ_RAII BoxReader { public: - explicit BoxReader(Box& aBox) + explicit BoxReader(const Box& aBox) : mData(aBox.ReadAsSlice()), mReader(mData.mBytes, mData.mSize) {} BufferReader* operator->() { return &mReader; } diff --git a/dom/media/mp4/MoofParser.cpp b/dom/media/mp4/MoofParser.cpp @@ -429,7 +429,7 @@ class CtsComparator { } }; -Moof::Moof(Box& aBox, const TrackParseMode& aTrackParseMode, Trex& aTrex, +Moof::Moof(Box& aBox, const TrackParseMode& aTrackParseMode, const Trex& aTrex, const Mvhd& aMvhd, const Mdhd& aMdhd, const Edts& aEdts, const Sinf& aSinf, const bool aIsAudio, uint64_t* aDecodeTime, nsTArray<TrackEndCts>& aTracksEndCts) @@ -726,7 +726,7 @@ const CencSampleEncryptionInfoEntry* Moof::GetSampleEncryptionEntry( } void Moof::ParseTraf(Box& aBox, const TrackParseMode& aTrackParseMode, - Trex& aTrex, const Mvhd& aMvhd, const Mdhd& aMdhd, + const Trex& aTrex, const Mvhd& aMvhd, const Mdhd& aMdhd, const Edts& aEdts, const Sinf& aSinf, const bool aIsAudio, uint64_t* aDecodeTime) { LOG_DEBUG( @@ -1077,7 +1077,7 @@ Result<Ok, nsresult> Mvhd::Parse(Box& aBox) { Mdhd::Mdhd(Box& aBox) : Mvhd(aBox) {} -Trex::Trex(Box& aBox) +Trex::Trex(const Box& aBox) : mFlags(0), mTrackId(0), mDefaultSampleDescriptionIndex(0), @@ -1090,7 +1090,7 @@ Trex::Trex(Box& aBox) } } -Result<Ok, nsresult> Trex::Parse(Box& aBox) { +Result<Ok, nsresult> Trex::Parse(const Box& aBox) { BoxReader reader(aBox); mFlags = MOZ_TRY(reader->ReadU32()); @@ -1103,7 +1103,7 @@ Result<Ok, nsresult> Trex::Parse(Box& aBox) { return Ok(); } -Tfhd::Tfhd(Box& aBox, Trex& aTrex) : Trex(aTrex), mBaseDataOffset(0) { +Tfhd::Tfhd(Box& aBox, const Trex& aTrex) : Trex(aTrex), mBaseDataOffset(0) { mValid = Parse(aBox).isOk(); if (!mValid) { LOG_WARN(Tfhd, "Parse failed"); diff --git a/dom/media/mp4/MoofParser.h b/dom/media/mp4/MoofParser.h @@ -81,7 +81,7 @@ class Trex : public Atom { mDefaultSampleSize(0), mDefaultSampleFlags(0) {} - explicit Trex(Box& aBox); + explicit Trex(const Box& aBox); uint32_t mFlags; uint32_t mTrackId; @@ -91,15 +91,15 @@ class Trex : public Atom { uint32_t mDefaultSampleFlags; protected: - Result<Ok, nsresult> Parse(Box& aBox); + Result<Ok, nsresult> Parse(const Box& aBox); }; class Tfhd : public Trex { public: - explicit Tfhd(Trex& aTrex) : Trex(aTrex), mBaseDataOffset(0) { + explicit Tfhd(const Trex& aTrex) : Trex(aTrex), mBaseDataOffset(0) { mValid = aTrex.IsValid(); } - Tfhd(Box& aBox, Trex& aTrex); + Tfhd(Box& aBox, const Trex& aTrex); uint64_t mBaseDataOffset; @@ -246,7 +246,7 @@ using TrackParseMode = Variant<ParseAllTracks, uint32_t>; class Moof final : public Atom { public: - Moof(Box& aBox, const TrackParseMode& aTrackParseMode, Trex& aTrex, + Moof(Box& aBox, const TrackParseMode& aTrackParseMode, const Trex& aTrex, const Mvhd& aMvhd, const Mdhd& aMdhd, const Edts& aEdts, const Sinf& aSinf, const bool aIsAudio, uint64_t* aDecodeTime, nsTArray<TrackEndCts>& aTracksEndCts); @@ -282,9 +282,10 @@ class Moof final : public Atom { private: // aDecodeTime is updated to the end of the parsed TRAF on return. - void ParseTraf(Box& aBox, const TrackParseMode& aTrackParseMode, Trex& aTrex, - const Mvhd& aMvhd, const Mdhd& aMdhd, const Edts& aEdts, - const Sinf& aSinf, const bool aIsAudio, uint64_t* aDecodeTime); + void ParseTraf(Box& aBox, const TrackParseMode& aTrackParseMode, + const Trex& aTrex, const Mvhd& aMvhd, const Mdhd& aMdhd, + const Edts& aEdts, const Sinf& aSinf, const bool aIsAudio, + uint64_t* aDecodeTime); // aDecodeTime is updated to the end of the parsed TRUN on return. Result<Ok, nsresult> ParseTrun(Box& aBox, const Mvhd& aMvhd, const Mdhd& aMdhd, const Edts& aEdts,