Bug 1325707: P4. Fix coding style of MediaDataDemuxers. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Mon, 06 Feb 2017 17:31:24 +0100
changeset 479518 405e2931b37f1cb138baedec70a28b8a2a4520c5
parent 479517 47a52003d8df3f15cc767be4e6d9298067f38aea
child 544705 4ee05e8af0ad7c154b912a9fb8f9679eaa43aa57
push id44276
push userbmo:jyavenard@mozilla.com
push dateMon, 06 Feb 2017 20:47:01 +0000
reviewersgerald
bugs1325707
milestone54.0a1
Bug 1325707: P4. Fix coding style of MediaDataDemuxers. r?gerald MozReview-Commit-ID: AV2lXwVZqLV
dom/media/ADTSDemuxer.cpp
dom/media/ADTSDemuxer.h
dom/media/MP3Demuxer.cpp
dom/media/MP3Demuxer.h
dom/media/flac/FlacDemuxer.cpp
dom/media/flac/FlacDemuxer.h
dom/media/fmp4/MP4Demuxer.cpp
dom/media/fmp4/MP4Demuxer.h
dom/media/mediasource/MediaSourceDecoder.cpp
dom/media/mediasource/MediaSourceDemuxer.h
dom/media/wave/WaveDemuxer.cpp
dom/media/wave/WaveDemuxer.h
--- a/dom/media/ADTSDemuxer.cpp
+++ b/dom/media/ADTSDemuxer.cpp
@@ -48,59 +48,63 @@ namespace adts {
 // M        13            frame length, this value must include 7 or 9 bytes of
 //                        header length: FrameLength =
 //                          (ProtectionAbsent == 1 ? 7 : 9) + size(AACFrame)
 // O        11            Buffer fullness
 // P        2             Number of AAC frames(RDBs) in ADTS frame minus 1, for
 //                        maximum compatibility always use 1 AAC frame per ADTS
 //                        frame
 // Q        16            CRC if protection absent is 0
-class FrameHeader {
+class FrameHeader
+{
 public:
   uint32_t mFrameLength;
   uint32_t mSampleRate;
   uint32_t mSamples;
   uint32_t mChannels;
   uint8_t  mObjectType;
   uint8_t  mSamplingIndex;
   uint8_t  mChannelConfig;
   uint8_t  mNumAACFrames;
   bool     mHaveCrc;
 
   // Returns whether aPtr matches a valid ADTS header sync marker
-  static bool MatchesSync(const uint8_t* aPtr) {
+  static bool MatchesSync(const uint8_t* aPtr)
+  {
     return aPtr[0] == 0xFF && (aPtr[1] & 0xF6) == 0xF0;
   }
 
   FrameHeader() { Reset(); }
 
   // Header size
   size_t HeaderSize() const { return (mHaveCrc) ? 9 : 7; }
 
   bool IsValid() const { return mFrameLength > 0; }
 
   // Resets the state to allow for a new parsing session.
   void Reset() { PodZero(this); }
 
   // Returns whether the byte creates a valid sequence up to this point.
-  bool Parse(const uint8_t* aPtr) {
+  bool Parse(const uint8_t* aPtr)
+  {
     const uint8_t* p = aPtr;
 
     if (!MatchesSync(p)) {
       return false;
     }
 
     // AAC has 1024 samples per frame per channel.
     mSamples = 1024;
 
     mHaveCrc = !(p[1] & 0x01);
     mObjectType = ((p[2] & 0xC0) >> 6) + 1;
     mSamplingIndex = (p[2] & 0x3C) >> 2;
     mChannelConfig = (p[2] & 0x01) << 2 | (p[3] & 0xC0) >> 6;
-    mFrameLength = (p[3] & 0x03) << 11 | (p[4] & 0xFF) << 3 | (p[5] & 0xE0) >> 5;
+    mFrameLength =
+      (p[3] & 0x03) << 11 | (p[4] & 0xFF) << 3 | (p[5] & 0xE0) >> 5;
     mNumAACFrames = (p[6] & 0x03) + 1;
 
     static const int32_t SAMPLE_RATES[16] = {
       96000, 88200, 64000, 48000,
       44100, 32000, 24000, 22050,
       16000, 12000, 11025,  8000,
       7350
     };
@@ -111,56 +115,56 @@ public:
 
     return true;
   }
 };
 
 
 // adts::Frame - Frame meta container used to parse and hold a frame
 // header and side info.
-class Frame {
+class Frame
+{
 public:
-  Frame() : mOffset(0), mHeader() {}
+  Frame() : mOffset(0), mHeader() { }
 
   int64_t Offset() const { return mOffset; }
-  size_t Length() const {
-    // TODO: If fields are zero'd when invalid, this check wouldn't be necessary.
+  size_t Length() const
+  {
+    // TODO: If fields are zero'd when invalid, this check wouldn't be
+    // necessary.
     if (!mHeader.IsValid()) {
       return 0;
     }
 
     return mHeader.mFrameLength;
   }
 
   // Returns the offset to the start of frame's raw data.
-  int64_t PayloadOffset() const {
-    return mOffset + mHeader.HeaderSize();
-  }
+  int64_t PayloadOffset() const { return mOffset + mHeader.HeaderSize(); }
 
   // Returns the length of the frame's raw data (excluding the header) in bytes.
-  size_t PayloadLength() const {
-    // TODO: If fields are zero'd when invalid, this check wouldn't be necessary.
+  size_t PayloadLength() const
+  {
+    // TODO: If fields are zero'd when invalid, this check wouldn't be
+    // necessary.
     if (!mHeader.IsValid()) {
       return 0;
     }
 
     return mHeader.mFrameLength - mHeader.HeaderSize();
   }
 
   // Returns the parsed frame header.
-  const FrameHeader& Header() const {
-    return mHeader;
-  }
+  const FrameHeader& Header() const { return mHeader; }
 
-  bool IsValid() const {
-    return mHeader.IsValid();
-  }
+  bool IsValid() const { return mHeader.IsValid(); }
 
   // Resets the frame header and data.
-  void Reset() {
+  void Reset()
+  {
     mHeader.Reset();
     mOffset = 0;
   }
 
   // Returns whether the valid
   bool Parse(int64_t aOffset, uint8_t* aStart, uint8_t* aEnd) {
     MOZ_ASSERT(aStart && aEnd);
 
@@ -182,45 +186,49 @@ private:
   // The offset to the start of the header.
   int64_t mOffset;
 
   // The currently parsed frame header.
   FrameHeader mHeader;
 };
 
 
-class FrameParser {
+class FrameParser
+{
 public:
 
   // Returns the currently parsed frame. Reset via Reset or EndFrameSession.
   const Frame& CurrentFrame() const { return mFrame; }
 
 
   // Returns the first parsed frame. Reset via Reset.
   const Frame& FirstFrame() const { return mFirstFrame; }
 
   // Resets the parser. Don't use between frames as first frame data is reset.
-  void Reset() {
+  void Reset()
+  {
     EndFrameSession();
     mFirstFrame.Reset();
   }
 
   // Clear the last parsed frame to allow for next frame parsing, i.e.:
   // - sets PrevFrame to CurrentFrame
   // - resets the CurrentFrame
   // - resets ID3Header if no valid header was parsed yet
-  void EndFrameSession() {
+  void EndFrameSession()
+  {
     mFrame.Reset();
   }
 
-  // Parses contents of given ByteReader for a valid frame header and returns true
-  // if one was found. After returning, the variable passed to 'aBytesToSkip' holds
-  // the amount of bytes to be skipped (if any) in order to jump across a large
-  // ID3v2 tag spanning multiple buffers.
-  bool Parse(int64_t aOffset, uint8_t* aStart, uint8_t* aEnd) {
+  // Parses contents of given ByteReader for a valid frame header and returns
+  // true if one was found. After returning, the variable passed to
+  // 'aBytesToSkip' holds the amount of bytes to be skipped (if any) in order to
+  // jump across a large ID3v2 tag spanning multiple buffers.
+  bool Parse(int64_t aOffset, uint8_t* aStart, uint8_t* aEnd)
+  {
     const bool found = mFrame.Parse(aOffset, aStart, aEnd);
 
     if (mFrame.Length() && !mFirstFrame.Length()) {
       mFirstFrame = mFrame;
     }
 
     return found;
   }
@@ -295,17 +303,18 @@ InitAudioSpecificConfig(const Frame& fra
 }
 
 } // namespace adts
 
 // ADTSDemuxer
 
 ADTSDemuxer::ADTSDemuxer(MediaResource* aSource)
   : mSource(aSource)
-{}
+{
+}
 
 bool
 ADTSDemuxer::InitInternal()
 {
   if (!mTrackDemuxer) {
     mTrackDemuxer = new ADTSTrackDemuxer(mSource);
   }
   return mTrackDemuxer->Init();
@@ -370,23 +379,21 @@ ADTSTrackDemuxer::ADTSTrackDemuxer(Media
   , mChannels(0)
 {
   Reset();
 }
 
 ADTSTrackDemuxer::~ADTSTrackDemuxer()
 {
   delete mParser;
-  mParser = nullptr;
 }
 
 bool
 ADTSTrackDemuxer::Init()
 {
-
   FastSeek(media::TimeUnit());
   // Read the first frame to fetch sample rate and other meta data.
   RefPtr<MediaRawData> frame(GetNextFrame(FindNextFrame(true)));
 
   ADTSLOG("Init StreamLength()=%" PRId64 " first-frame-found=%d",
           StreamLength(), !!frame);
 
   if (!frame) {
@@ -415,17 +422,18 @@ ADTSTrackDemuxer::Init()
   // wAudioProfileLevelIndication, which is passed mInfo->mProfile, is
   // a value from Table 1.12 -- audioProfileLevelIndication values, ISO/IEC 14496-3.
   mInfo->mProfile = ProfileLevelIndication(mParser->FirstFrame());
   // For AAC, mExtendedProfile contains the audioObjectType from Table
   // 1.3 -- Audio Profile definition, ISO/IEC 14496-3. Eg. 2 == AAC LC
   mInfo->mExtendedProfile = mParser->FirstFrame().Header().mObjectType;
   InitAudioSpecificConfig(mParser->FirstFrame(), mInfo->mCodecSpecificConfig);
 
-  ADTSLOG("Init mInfo={mRate=%u mChannels=%u mBitDepth=%u mDuration=%" PRId64 "}",
+  ADTSLOG("Init mInfo={mRate=%u mChannels=%u mBitDepth=%u mDuration=%" PRId64
+          "}",
           mInfo->mRate, mInfo->mChannels, mInfo->mBitDepth, mInfo->mDuration);
 
   return mSamplesPerSecond && mChannels;
 }
 
 UniquePtr<TrackInfo>
 ADTSTrackDemuxer::GetInfo() const
 {
@@ -505,40 +513,42 @@ ADTSTrackDemuxer::ScanUntil(const media:
 
   return Duration(mFrameIndex);
 }
 
 RefPtr<ADTSTrackDemuxer::SamplesPromise>
 ADTSTrackDemuxer::GetSamples(int32_t aNumSamples)
 {
   ADTSLOGV("GetSamples(%d) Begin mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
-          " mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d "
-          "mSamplesPerSecond=%d mChannels=%d",
-          aNumSamples, mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen,
-          mSamplesPerFrame, mSamplesPerSecond, mChannels);
+           " mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64
+           " mSamplesPerFrame=%d "
+           "mSamplesPerSecond=%d mChannels=%d",
+           aNumSamples, mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen,
+           mSamplesPerFrame, mSamplesPerSecond, mChannels);
 
   MOZ_ASSERT(aNumSamples);
 
   RefPtr<SamplesHolder> frames = new SamplesHolder();
 
   while (aNumSamples--) {
     RefPtr<MediaRawData> frame(GetNextFrame(FindNextFrame()));
     if (!frame)
       break;
 
     frames->mSamples.AppendElement(frame);
   }
 
   ADTSLOGV("GetSamples() End mSamples.Size()=%d aNumSamples=%d mOffset=%" PRIu64
-          " mNumParsedFrames=%" PRIu64 " mFrameIndex=%" PRId64
-          " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d mSamplesPerSecond=%d "
-          "mChannels=%d",
-          frames->mSamples.Length(), aNumSamples, mOffset, mNumParsedFrames,
-          mFrameIndex, mTotalFrameLen, mSamplesPerFrame, mSamplesPerSecond,
-          mChannels);
+           " mNumParsedFrames=%" PRIu64 " mFrameIndex=%" PRId64
+           " mTotalFrameLen=%" PRIu64
+           " mSamplesPerFrame=%d mSamplesPerSecond=%d "
+           "mChannels=%d",
+           frames->mSamples.Length(), aNumSamples, mOffset, mNumParsedFrames,
+           mFrameIndex, mTotalFrameLen, mSamplesPerFrame, mSamplesPerSecond,
+           mChannels);
 
   if (frames->mSamples.IsEmpty()) {
     return SamplesPromise::CreateAndReject(
       NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);
   }
 
   return SamplesPromise::CreateAndResolve(frames, __func__);
 }
@@ -550,17 +560,18 @@ ADTSTrackDemuxer::Reset()
   MOZ_ASSERT(mParser);
   if (mParser) {
     mParser->Reset();
   }
   FastSeek(media::TimeUnit());
 }
 
 RefPtr<ADTSTrackDemuxer::SkipAccessPointPromise>
-ADTSTrackDemuxer::SkipToNextRandomAccessPoint(const media::TimeUnit& aTimeThreshold)
+ADTSTrackDemuxer::SkipToNextRandomAccessPoint(
+  const media::TimeUnit &aTimeThreshold)
 {
   // Will not be called for audio-only resources.
   return SkipAccessPointPromise::CreateAndReject(
     SkipFailureHolder(NS_ERROR_DOM_MEDIA_DEMUXER_ERR, 0), __func__);
 }
 
 int64_t
 ADTSTrackDemuxer::GetResourceOffset() const
@@ -649,17 +660,18 @@ ADTSTrackDemuxer::FindNextFrame(bool fin
 
     const adts::Frame& currentFrame = mParser->CurrentFrame();
     foundFrame = mParser->Parse(frameHeaderOffset, buffer, buffer + read);
     if (findFirstFrame && foundFrame) {
       // Check for sync marker after the found frame, since it's
       // possible to find sync marker in AAC data. If sync marker
       // exists after the current frame then we've found a frame
       // header.
-      int64_t nextFrameHeaderOffset = currentFrame.Offset() + currentFrame.Length();
+      int64_t nextFrameHeaderOffset =
+        currentFrame.Offset() + currentFrame.Length();
       int32_t read = Read(buffer, nextFrameHeaderOffset, 2);
       if (read != 2 || !adts::FrameHeader::MatchesSync(buffer)) {
         frameHeaderOffset = currentFrame.Offset() + 1;
         mParser->Reset();
         foundFrame = false;
         continue;
       }
     }
@@ -747,46 +759,48 @@ ADTSTrackDemuxer::GetNextFrame(const adt
   frame->mDuration = Duration(1).ToMicroseconds();
   frame->mTimecode = frame->mTime;
   frame->mKeyframe = true;
 
   MOZ_ASSERT(frame->mTime >= 0);
   MOZ_ASSERT(frame->mDuration > 0);
 
   ADTSLOGV("GetNext() End mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
-          " mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64
-          " mSamplesPerFrame=%d mSamplesPerSecond=%d mChannels=%d",
-          mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen,
-          mSamplesPerFrame, mSamplesPerSecond, mChannels);
+           " mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64
+           " mSamplesPerFrame=%d mSamplesPerSecond=%d mChannels=%d",
+           mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen,
+           mSamplesPerFrame, mSamplesPerSecond, mChannels);
 
   return frame.forget();
 }
 
 int64_t
 ADTSTrackDemuxer::FrameIndexFromOffset(int64_t aOffset) const
 {
   int64_t frameIndex = 0;
 
   if (AverageFrameLength() > 0) {
-    frameIndex = (aOffset - mParser->FirstFrame().Offset()) / AverageFrameLength();
+    frameIndex =
+      (aOffset - mParser->FirstFrame().Offset()) / AverageFrameLength();
   }
 
   ADTSLOGV("FrameIndexFromOffset(%" PRId64 ") -> %" PRId64, aOffset, frameIndex);
   return std::max<int64_t>(0, frameIndex);
 }
 
 int64_t
 ADTSTrackDemuxer::FrameIndexFromTime(const media::TimeUnit& aTime) const
 {
   int64_t frameIndex = 0;
   if (mSamplesPerSecond > 0 && mSamplesPerFrame > 0) {
     frameIndex = aTime.ToSeconds() * mSamplesPerSecond / mSamplesPerFrame - 1;
   }
 
-  ADTSLOGV("FrameIndexFromOffset(%fs) -> %" PRId64, aTime.ToSeconds(), frameIndex);
+  ADTSLOGV("FrameIndexFromOffset(%fs) -> %" PRId64,
+           aTime.ToSeconds(), frameIndex);
   return std::max<int64_t>(0, frameIndex);
 }
 
 void
 ADTSTrackDemuxer::UpdateState(const adts::Frame& aFrame)
 {
   int32_t frameLength = aFrame.Length();
   // Prevent overflow.
@@ -811,17 +825,18 @@ ADTSTrackDemuxer::UpdateState(const adts
   ++mNumParsedFrames;
   ++mFrameIndex;
   MOZ_ASSERT(mFrameIndex > 0);
 }
 
 int32_t
 ADTSTrackDemuxer::Read(uint8_t* aBuffer, int64_t aOffset, int32_t aSize)
 {
-  ADTSLOGV("ADTSTrackDemuxer::Read(%p %" PRId64 " %d)", aBuffer, aOffset, aSize);
+  ADTSLOGV("ADTSTrackDemuxer::Read(%p %" PRId64 " %d)",
+           aBuffer, aOffset, aSize);
 
   const int64_t streamLen = StreamLength();
   if (mInfo && streamLen > 0) {
     // Prevent blocking reads after successful initialization.
     aSize = std::min<int64_t>(aSize, streamLen - aOffset);
   }
 
   uint32_t read = 0;
--- a/dom/media/ADTSDemuxer.h
+++ b/dom/media/ADTSDemuxer.h
@@ -17,35 +17,37 @@ namespace mozilla {
 
 namespace adts {
 class Frame;
 class FrameParser;
 }
 
 class ADTSTrackDemuxer;
 
-class ADTSDemuxer : public MediaDataDemuxer {
+class ADTSDemuxer : public MediaDataDemuxer
+{
 public:
   // MediaDataDemuxer interface.
   explicit ADTSDemuxer(MediaResource* aSource);
   RefPtr<InitPromise> Init() override;
   bool HasTrackType(TrackInfo::TrackType aType) const override;
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
-  already_AddRefed<MediaTrackDemuxer> GetTrackDemuxer(
-    TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
+  already_AddRefed<MediaTrackDemuxer>
+  GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
   bool IsSeekable() const override;
 
 private:
   bool InitInternal();
 
   RefPtr<MediaResource> mSource;
   RefPtr<ADTSTrackDemuxer> mTrackDemuxer;
 };
 
-class ADTSTrackDemuxer : public MediaTrackDemuxer {
+class ADTSTrackDemuxer : public MediaTrackDemuxer
+{
 public:
   explicit ADTSTrackDemuxer(MediaResource* aSource);
 
   // Initializes the track demuxer by reading the first frame for meta data.
   // Returns initialization success state.
   bool Init();
 
   // Returns the total stream length if known, -1 otherwise.
--- a/dom/media/MP3Demuxer.cpp
+++ b/dom/media/MP3Demuxer.cpp
@@ -32,73 +32,79 @@ using mozilla::media::TimeInterval;
 using mozilla::media::TimeIntervals;
 using mp4_demuxer::ByteReader;
 
 namespace mozilla {
 namespace mp3 {
 
 // MP3Demuxer
 
-MP3Demuxer::MP3Demuxer(MediaResource* aSource)
-  : mSource(aSource)
-{}
+MP3Demuxer::MP3Demuxer(MediaResource* aSource) : mSource(aSource) { }
 
 bool
-MP3Demuxer::InitInternal() {
+MP3Demuxer::InitInternal()
+{
   if (!mTrackDemuxer) {
     mTrackDemuxer = new MP3TrackDemuxer(mSource);
   }
   return mTrackDemuxer->Init();
 }
 
 RefPtr<MP3Demuxer::InitPromise>
-MP3Demuxer::Init() {
+MP3Demuxer::Init()
+{
   if (!InitInternal()) {
     MP3LOG("MP3Demuxer::Init() failure: waiting for data");
 
     return InitPromise::CreateAndReject(
       NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
   }
 
   MP3LOG("MP3Demuxer::Init() successful");
   return InitPromise::CreateAndResolve(NS_OK, __func__);
 }
 
 bool
-MP3Demuxer::HasTrackType(TrackInfo::TrackType aType) const {
+MP3Demuxer::HasTrackType(TrackInfo::TrackType aType) const
+{
   return aType == TrackInfo::kAudioTrack;
 }
 
 uint32_t
-MP3Demuxer::GetNumberTracks(TrackInfo::TrackType aType) const {
+MP3Demuxer::GetNumberTracks(TrackInfo::TrackType aType) const
+{
   return aType == TrackInfo::kAudioTrack ? 1u : 0u;
 }
 
 already_AddRefed<MediaTrackDemuxer>
-MP3Demuxer::GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber) {
+MP3Demuxer::GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber)
+{
   if (!mTrackDemuxer) {
     return nullptr;
   }
   return RefPtr<MP3TrackDemuxer>(mTrackDemuxer).forget();
 }
 
 bool
-MP3Demuxer::IsSeekable() const {
+MP3Demuxer::IsSeekable() const
+{
   return true;
 }
 
 void
-MP3Demuxer::NotifyDataArrived() {
+MP3Demuxer::NotifyDataArrived()
+{
   // TODO: bug 1169485.
   NS_WARNING("Unimplemented function NotifyDataArrived");
   MP3LOGV("NotifyDataArrived()");
 }
 
 void
-MP3Demuxer::NotifyDataRemoved() {
+MP3Demuxer::NotifyDataRemoved()
+{
   // TODO: bug 1169485.
   NS_WARNING("Unimplemented function NotifyDataRemoved");
   MP3LOGV("NotifyDataRemoved()");
 }
 
 
 // MP3TrackDemuxer
 
@@ -112,17 +118,18 @@ MP3TrackDemuxer::MP3TrackDemuxer(MediaRe
   , mSamplesPerFrame(0)
   , mSamplesPerSecond(0)
   , mChannels(0)
 {
   Reset();
 }
 
 bool
-MP3TrackDemuxer::Init() {
+MP3TrackDemuxer::Init()
+{
   Reset();
   FastSeek(TimeUnit());
   // Read the first frame to fetch sample rate and other meta data.
   RefPtr<MediaRawData> frame(GetNextFrame(FindFirstFrame()));
 
   MP3LOG("Init StreamLength()=%" PRId64 " first-frame-found=%d",
          StreamLength(), !!frame);
 
@@ -146,61 +153,69 @@ MP3TrackDemuxer::Init() {
   MP3LOG("Init mInfo={mRate=%d mChannels=%d mBitDepth=%d mDuration=%" PRId64 "}",
          mInfo->mRate, mInfo->mChannels, mInfo->mBitDepth,
          mInfo->mDuration);
 
   return mSamplesPerSecond && mChannels;
 }
 
 media::TimeUnit
-MP3TrackDemuxer::SeekPosition() const {
+MP3TrackDemuxer::SeekPosition() const
+{
   TimeUnit pos = Duration(mFrameIndex);
   if (Duration() > TimeUnit()) {
     pos = std::min(Duration(), pos);
   }
   return pos;
 }
 
 const FrameParser::Frame&
-MP3TrackDemuxer::LastFrame() const {
+MP3TrackDemuxer::LastFrame() const
+{
   return mParser.PrevFrame();
 }
 
 RefPtr<MediaRawData>
-MP3TrackDemuxer::DemuxSample() {
+MP3TrackDemuxer::DemuxSample()
+{
   return GetNextFrame(FindNextFrame());
 }
 
 const ID3Parser::ID3Header&
-MP3TrackDemuxer::ID3Header() const {
+MP3TrackDemuxer::ID3Header() const
+{
   return mParser.ID3Header();
 }
 
 const FrameParser::VBRHeader&
-MP3TrackDemuxer::VBRInfo() const {
+MP3TrackDemuxer::VBRInfo() const
+{
   return mParser.VBRInfo();
 }
 
 UniquePtr<TrackInfo>
-MP3TrackDemuxer::GetInfo() const {
+MP3TrackDemuxer::GetInfo() const
+{
   return mInfo->Clone();
 }
 
 RefPtr<MP3TrackDemuxer::SeekPromise>
-MP3TrackDemuxer::Seek(const TimeUnit& aTime) {
+MP3TrackDemuxer::Seek(const TimeUnit& aTime)
+{
   // Efficiently seek to the position.
   FastSeek(aTime);
   // Correct seek position by scanning the next frames.
   const TimeUnit seekTime = ScanUntil(aTime);
 
   return SeekPromise::CreateAndResolve(seekTime, __func__);
 }
 
 TimeUnit
-MP3TrackDemuxer::FastSeek(const TimeUnit& aTime) {
+MP3TrackDemuxer::FastSeek(const TimeUnit& aTime)
+{
   MP3LOG("FastSeek(%" PRId64 ") avgFrameLen=%f mNumParsedFrames=%" PRIu64
          " mFrameIndex=%" PRId64 " mOffset=%" PRIu64,
          aTime.ToMicroseconds(), AverageFrameLength(), mNumParsedFrames,
          mFrameIndex, mOffset);
 
   const auto& vbr = mParser.VBRInfo();
   if (!aTime.ToMicroseconds()) {
     // Quick seek to the beginning of the stream.
@@ -227,17 +242,18 @@ MP3TrackDemuxer::FastSeek(const TimeUnit
          " SL=%llu NumBytes=%u",
          vbr.IsTOCPresent(), AverageFrameLength(), mNumParsedFrames, mFrameIndex,
          mFirstFrameOffset, mOffset, StreamLength(), vbr.NumBytes().valueOr(0));
 
   return Duration(mFrameIndex);
 }
 
 TimeUnit
-MP3TrackDemuxer::ScanUntil(const TimeUnit& aTime) {
+MP3TrackDemuxer::ScanUntil(const TimeUnit& aTime)
+{
   MP3LOG("ScanUntil(%" PRId64 ") avgFrameLen=%f mNumParsedFrames=%" PRIu64
          " mFrameIndex=%" PRId64 " mOffset=%" PRIu64,
          aTime.ToMicroseconds(), AverageFrameLength(), mNumParsedFrames,
          mFrameIndex, mOffset);
 
   if (!aTime.ToMicroseconds()) {
     return FastSeek(aTime);
   }
@@ -262,20 +278,21 @@ MP3TrackDemuxer::ScanUntil(const TimeUni
   MP3LOG("ScanUntil End avgFrameLen=%f mNumParsedFrames=%" PRIu64
          " mFrameIndex=%" PRId64 " mOffset=%" PRIu64,
          AverageFrameLength(), mNumParsedFrames, mFrameIndex, mOffset);
 
   return SeekPosition();
 }
 
 RefPtr<MP3TrackDemuxer::SamplesPromise>
-MP3TrackDemuxer::GetSamples(int32_t aNumSamples) {
+MP3TrackDemuxer::GetSamples(int32_t aNumSamples)
+{
   MP3LOGV("GetSamples(%d) Begin mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
-          " mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64 " mSamplesPerFrame=%d "
-          "mSamplesPerSecond=%d mChannels=%d",
+          " mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64
+          " mSamplesPerFrame=%d mSamplesPerSecond=%d mChannels=%d",
           aNumSamples, mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen,
           mSamplesPerFrame, mSamplesPerSecond, mChannels);
 
   if (!aNumSamples) {
     return SamplesPromise::CreateAndReject(
         NS_ERROR_DOM_MEDIA_DEMUXER_ERR, __func__);
   }
 
@@ -301,37 +318,41 @@ MP3TrackDemuxer::GetSamples(int32_t aNum
   if (frames->mSamples.IsEmpty()) {
     return SamplesPromise::CreateAndReject(
         NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);
   }
   return SamplesPromise::CreateAndResolve(frames, __func__);
 }
 
 void
-MP3TrackDemuxer::Reset() {
+MP3TrackDemuxer::Reset()
+{
   MP3LOG("Reset()");
 
   FastSeek(TimeUnit());
   mParser.Reset();
 }
 
 RefPtr<MP3TrackDemuxer::SkipAccessPointPromise>
-MP3TrackDemuxer::SkipToNextRandomAccessPoint(const TimeUnit& aTimeThreshold) {
+MP3TrackDemuxer::SkipToNextRandomAccessPoint(const TimeUnit& aTimeThreshold)
+{
   // Will not be called for audio-only resources.
   return SkipAccessPointPromise::CreateAndReject(
     SkipFailureHolder(NS_ERROR_DOM_MEDIA_DEMUXER_ERR, 0), __func__);
 }
 
 int64_t
-MP3TrackDemuxer::GetResourceOffset() const {
+MP3TrackDemuxer::GetResourceOffset() const
+{
   return mOffset;
 }
 
 TimeIntervals
-MP3TrackDemuxer::GetBuffered() {
+MP3TrackDemuxer::GetBuffered()
+{
   AutoPinned<MediaResource> stream(mSource.GetResource());
   TimeIntervals buffered;
 
   if (Duration() > TimeUnit() && stream->IsDataCachedToEndOfResource(0)) {
     // Special case completely cached files. This also handles local files.
     buffered += TimeInterval(TimeUnit(), Duration());
     MP3LOGV("buffered = [[%" PRId64 ", %" PRId64 "]]",
             TimeUnit().ToMicroseconds(), Duration().ToMicroseconds());
@@ -352,22 +373,24 @@ MP3TrackDemuxer::GetBuffered() {
             start.ToMicroseconds(), end.ToMicroseconds());
     buffered += TimeInterval(start, end);
   }
 
   return buffered;
 }
 
 int64_t
-MP3TrackDemuxer::StreamLength() const {
+MP3TrackDemuxer::StreamLength() const
+{
   return mSource.GetLength();
 }
 
 TimeUnit
-MP3TrackDemuxer::Duration() const {
+MP3TrackDemuxer::Duration() const
+{
   if (!mNumParsedFrames) {
     return TimeUnit::FromMicroseconds(-1);
   }
 
   int64_t numFrames = 0;
   const auto numAudioFrames = mParser.VBRInfo().NumAudioFrames();
   if (mParser.VBRInfo().IsValid() && numAudioFrames.valueOr(0) + 1 > 1) {
     // VBR headers don't include the VBR header frame.
@@ -381,90 +404,97 @@ MP3TrackDemuxer::Duration() const {
     if (AverageFrameLength() > 0) {
       numFrames = (streamLen - mFirstFrameOffset) / AverageFrameLength();
     }
   }
   return Duration(numFrames);
 }
 
 TimeUnit
-MP3TrackDemuxer::Duration(int64_t aNumFrames) const {
+MP3TrackDemuxer::Duration(int64_t aNumFrames) const
+{
   if (!mSamplesPerSecond) {
     return TimeUnit::FromMicroseconds(-1);
   }
 
   const double usPerFrame = USECS_PER_S * mSamplesPerFrame / mSamplesPerSecond;
   return TimeUnit::FromMicroseconds(aNumFrames * usPerFrame);
 }
 
 MediaByteRange
-MP3TrackDemuxer::FindFirstFrame() {
+MP3TrackDemuxer::FindFirstFrame()
+{
   static const int MIN_SUCCESSIVE_FRAMES = 4;
 
   MediaByteRange candidateFrame = FindNextFrame();
   int numSuccFrames = candidateFrame.Length() > 0;
   MediaByteRange currentFrame = candidateFrame;
-  MP3LOGV("FindFirst() first candidate frame: mOffset=%" PRIu64 " Length()=%" PRIu64,
+  MP3LOGV("FindFirst() first candidate frame: mOffset=%" PRIu64
+          " Length()=%" PRIu64,
           candidateFrame.mStart, candidateFrame.Length());
 
   while (candidateFrame.Length() && numSuccFrames < MIN_SUCCESSIVE_FRAMES) {
     mParser.EndFrameSession();
     mOffset = currentFrame.mEnd;
     const MediaByteRange prevFrame = currentFrame;
 
     // FindNextFrame() here will only return frames consistent with our candidate frame.
     currentFrame = FindNextFrame();
     numSuccFrames += currentFrame.Length() > 0;
     // Multiple successive false positives, which wouldn't be caught by the consistency
     // checks alone, can be detected by wrong alignment (non-zero gap between frames).
     const int64_t frameSeparation = currentFrame.mStart - prevFrame.mEnd;
 
     if (!currentFrame.Length() || frameSeparation != 0) {
       MP3LOGV("FindFirst() not enough successive frames detected, "
-              "rejecting candidate frame: successiveFrames=%d, last Length()=%" PRIu64
-              ", last frameSeparation=%" PRId64, numSuccFrames, currentFrame.Length(),
-              frameSeparation);
+              "rejecting candidate frame: successiveFrames=%d, last "
+              "Length()=%" PRIu64 ", last frameSeparation=%" PRId64,
+              numSuccFrames, currentFrame.Length(), frameSeparation);
 
       mParser.ResetFrameData();
       mOffset = candidateFrame.mStart + 1;
       candidateFrame = FindNextFrame();
       numSuccFrames = candidateFrame.Length() > 0;
       currentFrame = candidateFrame;
-      MP3LOGV("FindFirst() new candidate frame: mOffset=%" PRIu64 " Length()=%" PRIu64,
+      MP3LOGV("FindFirst() new candidate frame: mOffset=%" PRIu64
+              " Length()=%" PRIu64,
               candidateFrame.mStart, candidateFrame.Length());
     }
   }
 
   if (numSuccFrames >= MIN_SUCCESSIVE_FRAMES) {
     MP3LOG("FindFirst() accepting candidate frame: "
             "successiveFrames=%d", numSuccFrames);
   } else {
     MP3LOG("FindFirst() no suitable first frame found");
   }
   return candidateFrame;
 }
 
 static bool
-VerifyFrameConsistency(
-    const FrameParser::Frame& aFrame1, const FrameParser::Frame& aFrame2) {
+VerifyFrameConsistency(const FrameParser::Frame &aFrame1,
+                       const FrameParser::Frame &aFrame2)
+{
   const auto& h1 = aFrame1.Header();
   const auto& h2 = aFrame2.Header();
 
-  return h1.IsValid() && h2.IsValid() &&
-         h1.Layer() == h2.Layer() &&
-         h1.SlotSize() == h2.SlotSize() &&
-         h1.SamplesPerFrame() == h2.SamplesPerFrame() &&
-         h1.Channels() == h2.Channels() &&
-         h1.SampleRate() == h2.SampleRate() &&
-         h1.RawVersion() == h2.RawVersion() &&
-         h1.RawProtection() == h2.RawProtection();
+  return h1.IsValid()
+         && h2.IsValid()
+         && h1.Layer() == h2.Layer()
+         && h1.SlotSize() == h2.SlotSize()
+         && h1.SamplesPerFrame() == h2.SamplesPerFrame()
+         && h1.Channels() == h2.Channels()
+         && h1.SampleRate() == h2.SampleRate()
+         && h1.RawVersion() == h2.RawVersion()
+         && h1.RawProtection() == h2.RawProtection();
 }
 
 MediaByteRange
-MP3TrackDemuxer::FindNextFrame() {
+MP3TrackDemuxer::FindNextFrame()
+{
   static const int BUFFER_SIZE = 64;
   static const int MAX_SKIPPED_BYTES = 1024 * BUFFER_SIZE;
 
   MP3LOGV("FindNext() Begin mOffset=%" PRIu64 " mNumParsedFrames=%" PRIu64
           " mFrameIndex=%" PRId64 " mTotalFrameLen=%" PRIu64
           " mSamplesPerFrame=%d mSamplesPerSecond=%d mChannels=%d",
           mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen,
           mSamplesPerFrame, mSamplesPerSecond, mChannels);
@@ -472,35 +502,37 @@ MP3TrackDemuxer::FindNextFrame() {
   uint8_t buffer[BUFFER_SIZE];
   int32_t read = 0;
 
   bool foundFrame = false;
   int64_t frameHeaderOffset = 0;
 
   // Check whether we've found a valid MPEG frame.
   while (!foundFrame) {
-    if ((!mParser.FirstFrame().Length() &&
-         mOffset - mParser.ID3Header().Size() > MAX_SKIPPED_BYTES) ||
-        (read = Read(buffer, mOffset, BUFFER_SIZE)) == 0) {
+    if ((!mParser.FirstFrame().Length()
+         && mOffset - mParser.ID3Header().Size() > MAX_SKIPPED_BYTES)
+        || (read = Read(buffer, mOffset, BUFFER_SIZE)) == 0) {
       MP3LOG("FindNext() EOS or exceeded MAX_SKIPPED_BYTES without a frame");
       // This is not a valid MPEG audio stream or we've reached EOS, give up.
       break;
     }
 
     ByteReader reader(buffer, read);
     uint32_t bytesToSkip = 0;
     foundFrame = mParser.Parse(&reader, &bytesToSkip);
-    frameHeaderOffset = mOffset + reader.Offset() - FrameParser::FrameHeader::SIZE;
+    frameHeaderOffset =
+      mOffset + reader.Offset() - FrameParser::FrameHeader::SIZE;
 
     // If we've found neither an MPEG frame header nor an ID3v2 tag,
     // the reader shouldn't have any bytes remaining.
     MOZ_ASSERT(foundFrame || bytesToSkip || !reader.Remaining());
 
-    if (foundFrame && mParser.FirstFrame().Length() &&
-        !VerifyFrameConsistency(mParser.FirstFrame(), mParser.CurrentFrame())) {
+    if (foundFrame && mParser.FirstFrame().Length()
+        && !VerifyFrameConsistency(mParser.FirstFrame(),
+                                   mParser.CurrentFrame())) {
       // We've likely hit a false-positive, ignore it and proceed with the
       // search for the next valid frame.
       foundFrame = false;
       mOffset = frameHeaderOffset + 1;
       mParser.EndFrameSession();
     } else {
       // Advance mOffset by the amount of bytes read and if necessary,
       // skip an ID3v2 tag which stretches beyond the current buffer.
@@ -522,17 +554,18 @@ MP3TrackDemuxer::FindNextFrame() {
           " mChannels=%d",
           mOffset, mNumParsedFrames, mFrameIndex, frameHeaderOffset,
           mTotalFrameLen, mSamplesPerFrame, mSamplesPerSecond, mChannels);
 
   return { frameHeaderOffset, frameHeaderOffset + mParser.CurrentFrame().Length() };
 }
 
 bool
-MP3TrackDemuxer::SkipNextFrame(const MediaByteRange& aRange) {
+MP3TrackDemuxer::SkipNextFrame(const MediaByteRange& aRange)
+{
   if (!mNumParsedFrames || !aRange.Length()) {
     // We can't skip the first frame, since it could contain VBR headers.
     RefPtr<MediaRawData> frame(GetNextFrame(aRange));
     return frame;
   }
 
   UpdateState(aRange);
 
@@ -541,33 +574,35 @@ MP3TrackDemuxer::SkipNextFrame(const Med
           " mSamplesPerFrame=%d mSamplesPerSecond=%d mChannels=%d",
           mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen,
           mSamplesPerFrame, mSamplesPerSecond, mChannels);
 
   return true;
 }
 
 already_AddRefed<MediaRawData>
-MP3TrackDemuxer::GetNextFrame(const MediaByteRange& aRange) {
+MP3TrackDemuxer::GetNextFrame(const MediaByteRange& aRange)
+{
   MP3LOG("GetNext() Begin({mStart=%" PRId64 " Length()=%" PRId64 "})",
          aRange.mStart, aRange.Length());
   if (!aRange.Length()) {
     return nullptr;
   }
 
   RefPtr<MediaRawData> frame = new MediaRawData();
   frame->mOffset = aRange.mStart;
 
   nsAutoPtr<MediaRawDataWriter> frameWriter(frame->CreateWriter());
   if (!frameWriter->SetSize(aRange.Length())) {
     MP3LOG("GetNext() Exit failed to allocated media buffer");
     return nullptr;
   }
 
-  const uint32_t read = Read(frameWriter->Data(), frame->mOffset, frame->Size());
+  const uint32_t read =
+    Read(frameWriter->Data(), frame->mOffset, frame->Size());
 
   if (read != aRange.Length()) {
     MP3LOG("GetNext() Exit read=%u frame->Size()=%u", read, frame->Size());
     return nullptr;
   }
 
   UpdateState(aRange);
 
@@ -591,61 +626,68 @@ MP3TrackDemuxer::GetNextFrame(const Medi
           " mSamplesPerFrame=%d mSamplesPerSecond=%d mChannels=%d",
           mOffset, mNumParsedFrames, mFrameIndex, mTotalFrameLen,
           mSamplesPerFrame, mSamplesPerSecond, mChannels);
 
   return frame.forget();
 }
 
 int64_t
-MP3TrackDemuxer::OffsetFromFrameIndex(int64_t aFrameIndex) const {
+MP3TrackDemuxer::OffsetFromFrameIndex(int64_t aFrameIndex) const
+{
   int64_t offset = 0;
   const auto& vbr = mParser.VBRInfo();
 
   if (vbr.IsComplete()) {
-    offset = mFirstFrameOffset + aFrameIndex * vbr.NumBytes().value() /
-             vbr.NumAudioFrames().value();
+    offset = mFirstFrameOffset
+             + aFrameIndex * vbr.NumBytes().value()
+               / vbr.NumAudioFrames().value();
   } else if (AverageFrameLength() > 0) {
     offset = mFirstFrameOffset + aFrameIndex * AverageFrameLength();
   }
 
   MP3LOGV("OffsetFromFrameIndex(%" PRId64 ") -> %" PRId64, aFrameIndex, offset);
   return std::max<int64_t>(mFirstFrameOffset, offset);
 }
 
 int64_t
-MP3TrackDemuxer::FrameIndexFromOffset(int64_t aOffset) const {
+MP3TrackDemuxer::FrameIndexFromOffset(int64_t aOffset) const
+{
   int64_t frameIndex = 0;
   const auto& vbr = mParser.VBRInfo();
 
   if (vbr.IsComplete()) {
-    frameIndex = static_cast<float>(aOffset - mFirstFrameOffset) /
-                 vbr.NumBytes().value() * vbr.NumAudioFrames().value();
+    frameIndex = static_cast<float>(aOffset - mFirstFrameOffset)
+                 / vbr.NumBytes().value()
+                 * vbr.NumAudioFrames().value();
     frameIndex = std::min<int64_t>(vbr.NumAudioFrames().value(), frameIndex);
   } else if (AverageFrameLength() > 0) {
     frameIndex = (aOffset - mFirstFrameOffset) / AverageFrameLength();
   }
 
   MP3LOGV("FrameIndexFromOffset(%" PRId64 ") -> %" PRId64, aOffset, frameIndex);
   return std::max<int64_t>(0, frameIndex);
 }
 
 int64_t
-MP3TrackDemuxer::FrameIndexFromTime(const media::TimeUnit& aTime) const {
+MP3TrackDemuxer::FrameIndexFromTime(const media::TimeUnit& aTime) const
+{
   int64_t frameIndex = 0;
   if (mSamplesPerSecond > 0 && mSamplesPerFrame > 0) {
     frameIndex = aTime.ToSeconds() * mSamplesPerSecond / mSamplesPerFrame - 1;
   }
 
-  MP3LOGV("FrameIndexFromOffset(%fs) -> %" PRId64, aTime.ToSeconds(), frameIndex);
+  MP3LOGV("FrameIndexFromOffset(%fs) -> %" PRId64, aTime.ToSeconds(),
+          frameIndex);
   return std::max<int64_t>(0, frameIndex);
 }
 
 void
-MP3TrackDemuxer::UpdateState(const MediaByteRange& aRange) {
+MP3TrackDemuxer::UpdateState(const MediaByteRange& aRange)
+{
   // Prevent overflow.
   if (mTotalFrameLen + aRange.Length() < mTotalFrameLen) {
     // These variables have a linear dependency and are only used to derive the
     // average frame length.
     mTotalFrameLen /= 2;
     mNumParsedFrames /= 2;
   }
 
@@ -664,17 +706,18 @@ MP3TrackDemuxer::UpdateState(const Media
   ++mFrameIndex;
   MOZ_ASSERT(mFrameIndex > 0);
 
   // Prepare the parser for the next frame parsing session.
   mParser.EndFrameSession();
 }
 
 int32_t
-MP3TrackDemuxer::Read(uint8_t* aBuffer, int64_t aOffset, int32_t aSize) {
+MP3TrackDemuxer::Read(uint8_t* aBuffer, int64_t aOffset, int32_t aSize)
+{
   MP3LOGV("MP3TrackDemuxer::Read(%p %" PRId64 " %d)", aBuffer, aOffset, aSize);
 
   const int64_t streamLen = StreamLength();
   if (mInfo && streamLen > 0) {
     // Prevent blocking reads after successful initialization.
     aSize = std::min<int64_t>(aSize, streamLen - aOffset);
   }
 
@@ -682,24 +725,25 @@ MP3TrackDemuxer::Read(uint8_t* aBuffer, 
   MP3LOGV("MP3TrackDemuxer::Read        -> ReadAt(%d)", aSize);
   const nsresult rv = mSource.ReadAt(aOffset, reinterpret_cast<char*>(aBuffer),
                                      static_cast<uint32_t>(aSize), &read);
   NS_ENSURE_SUCCESS(rv, 0);
   return static_cast<int32_t>(read);
 }
 
 double
-MP3TrackDemuxer::AverageFrameLength() const {
+MP3TrackDemuxer::AverageFrameLength() const
+{
   if (mNumParsedFrames) {
     return static_cast<double>(mTotalFrameLen) / mNumParsedFrames;
   }
   const auto& vbr = mParser.VBRInfo();
   if (vbr.IsComplete() && vbr.NumAudioFrames().value() + 1) {
-    return static_cast<double>(vbr.NumBytes().value()) /
-           (vbr.NumAudioFrames().value() + 1);
+    return static_cast<double>(vbr.NumBytes().value())
+           / (vbr.NumAudioFrames().value() + 1);
   }
   return 0.0;
 }
 
 // FrameParser
 
 namespace frame_header {
 // FrameHeader mRaw byte offsets.
@@ -709,91 +753,102 @@ static const int BITRATE_SAMPLERATE_PADD
 static const int CHANNELMODE_MODEEXT_COPY_ORIG_EMPH = 3;
 } // namespace frame_header
 
 FrameParser::FrameParser()
 {
 }
 
 void
-FrameParser::Reset() {
+FrameParser::Reset()
+{
   mID3Parser.Reset();
   mFrame.Reset();
 }
 
 void
-FrameParser::ResetFrameData() {
+FrameParser::ResetFrameData()
+{
   mFrame.Reset();
   mFirstFrame.Reset();
   mPrevFrame.Reset();
 }
 
 void
-FrameParser::EndFrameSession() {
+FrameParser::EndFrameSession()
+{
   if (!mID3Parser.Header().IsValid()) {
     // Reset ID3 tags only if we have not parsed a valid ID3 header yet.
     mID3Parser.Reset();
   }
   mPrevFrame = mFrame;
   mFrame.Reset();
 }
 
 const FrameParser::Frame&
-FrameParser::CurrentFrame() const {
+FrameParser::CurrentFrame() const
+{
   return mFrame;
 }
 
 const FrameParser::Frame&
-FrameParser::PrevFrame() const {
+FrameParser::PrevFrame() const
+{
   return mPrevFrame;
 }
 
 const FrameParser::Frame&
-FrameParser::FirstFrame() const {
+FrameParser::FirstFrame() const
+{
   return mFirstFrame;
 }
 
 const ID3Parser::ID3Header&
-FrameParser::ID3Header() const {
+FrameParser::ID3Header() const
+{
   return mID3Parser.Header();
 }
 
 const FrameParser::VBRHeader&
-FrameParser::VBRInfo() const {
+FrameParser::VBRInfo() const
+{
   return mVBRHeader;
 }
 
 bool
-FrameParser::Parse(ByteReader* aReader, uint32_t* aBytesToSkip) {
+FrameParser::Parse(ByteReader* aReader, uint32_t* aBytesToSkip)
+{
   MOZ_ASSERT(aReader && aBytesToSkip);
   *aBytesToSkip = 0;
 
   if (!mID3Parser.Header().Size() && !mFirstFrame.Length()) {
     // No MP3 frames have been parsed yet, look for ID3v2 headers at file begin.
     // ID3v1 tags may only be at file end.
     // TODO: should we try to read ID3 tags at end of file/mid-stream, too?
     const size_t prevReaderOffset = aReader->Offset();
     const uint32_t tagSize = mID3Parser.Parse(aReader);
     if (tagSize) {
       // ID3 tag found, skip past it.
       const uint32_t skipSize = tagSize - ID3Parser::ID3Header::SIZE;
 
       if (skipSize > aReader->Remaining()) {
-        // Skipping across the ID3v2 tag would take us past the end of the buffer, therefore we
-        // return immediately and let the calling function handle skipping the rest of the tag.
+        // Skipping across the ID3v2 tag would take us past the end of the
+        // buffer, therefore we return immediately and let the calling function
+        // handle skipping the rest of the tag.
         MP3LOGV("ID3v2 tag detected, size=%d,"
                 " needing to skip %d bytes past the current buffer",
                 tagSize, skipSize - aReader->Remaining());
         *aBytesToSkip = skipSize - aReader->Remaining();
         return false;
       }
       MP3LOGV("ID3v2 tag detected, size=%d", tagSize);
       aReader->Read(skipSize);
     } else {
-      // No ID3v2 tag found, rewinding reader in order to search for a MPEG frame header.
+      // No ID3v2 tag found, rewinding reader in order to search for a MPEG
+      // frame header.
       aReader->Seek(prevReaderOffset);
     }
   }
 
   while (aReader->CanRead8() && !mFrame.ParseNext(aReader->ReadU8())) { }
 
   if (mFrame.Length()) {
     // MP3 frame found.
@@ -809,108 +864,123 @@ FrameParser::Parse(ByteReader* aReader, 
 // FrameParser::Header
 
 FrameParser::FrameHeader::FrameHeader()
 {
   Reset();
 }
 
 uint8_t
-FrameParser::FrameHeader::Sync1() const {
+FrameParser::FrameHeader::Sync1() const
+{
   return mRaw[frame_header::SYNC1];
 }
 
 uint8_t
-FrameParser::FrameHeader::Sync2() const {
+FrameParser::FrameHeader::Sync2() const
+{
   return 0x7 & mRaw[frame_header::SYNC2_VERSION_LAYER_PROTECTION] >> 5;
 }
 
 uint8_t
-FrameParser::FrameHeader::RawVersion() const {
+FrameParser::FrameHeader::RawVersion() const
+{
   return 0x3 & mRaw[frame_header::SYNC2_VERSION_LAYER_PROTECTION] >> 3;
 }
 
 uint8_t
-FrameParser::FrameHeader::RawLayer() const {
+FrameParser::FrameHeader::RawLayer() const
+{
   return 0x3 & mRaw[frame_header::SYNC2_VERSION_LAYER_PROTECTION] >> 1;
 }
 
 uint8_t
-FrameParser::FrameHeader::RawProtection() const {
+FrameParser::FrameHeader::RawProtection() const
+{
   return 0x1 & mRaw[frame_header::SYNC2_VERSION_LAYER_PROTECTION] >> 6;
 }
 
 uint8_t
-FrameParser::FrameHeader::RawBitrate() const {
+FrameParser::FrameHeader::RawBitrate() const
+{
   return 0xF & mRaw[frame_header::BITRATE_SAMPLERATE_PADDING_PRIVATE] >> 4;
 }
 
 uint8_t
-FrameParser::FrameHeader::RawSampleRate() const {
+FrameParser::FrameHeader::RawSampleRate() const
+{
   return 0x3 & mRaw[frame_header::BITRATE_SAMPLERATE_PADDING_PRIVATE] >> 2;
 }
 
 uint8_t
-FrameParser::FrameHeader::Padding() const {
+FrameParser::FrameHeader::Padding() const
+{
   return 0x1 & mRaw[frame_header::BITRATE_SAMPLERATE_PADDING_PRIVATE] >> 1;
 }
 
 uint8_t
-FrameParser::FrameHeader::Private() const {
+FrameParser::FrameHeader::Private() const
+{
   return 0x1 & mRaw[frame_header::BITRATE_SAMPLERATE_PADDING_PRIVATE];
 }
 
 uint8_t
-FrameParser::FrameHeader::RawChannelMode() const {
+FrameParser::FrameHeader::RawChannelMode() const
+{
   return 0x3 & mRaw[frame_header::CHANNELMODE_MODEEXT_COPY_ORIG_EMPH] >> 6;
 }
 
 int32_t
-FrameParser::FrameHeader::Layer() const {
+FrameParser::FrameHeader::Layer() const
+{
   static const uint8_t LAYERS[4] = { 0, 3, 2, 1 };
 
   return LAYERS[RawLayer()];
 }
 
 int32_t
-FrameParser::FrameHeader::SampleRate() const {
+FrameParser::FrameHeader::SampleRate() const
+{
   // Sample rates - use [version][srate]
   static const uint16_t SAMPLE_RATE[4][4] = {
     { 11025, 12000,  8000, 0 }, // MPEG 2.5
     {     0,     0,     0, 0 }, // Reserved
     { 22050, 24000, 16000, 0 }, // MPEG 2
     { 44100, 48000, 32000, 0 }  // MPEG 1
   };
 
   return SAMPLE_RATE[RawVersion()][RawSampleRate()];
 }
 
 int32_t
-FrameParser::FrameHeader::Channels() const {
+FrameParser::FrameHeader::Channels() const
+{
   // 3 is single channel (mono), any other value is some variant of dual
   // channel.
   return RawChannelMode() == 3 ? 1 : 2;
 }
 
 int32_t
-FrameParser::FrameHeader::SamplesPerFrame() const {
+FrameParser::FrameHeader::SamplesPerFrame() const
+{
   // Samples per frame - use [version][layer]
   static const uint16_t FRAME_SAMPLE[4][4] = {
     // Layer     3     2     1       Version
     {      0,  576, 1152,  384 }, // 2.5
     {      0,    0,    0,    0 }, // Reserved
     {      0,  576, 1152,  384 }, // 2
     {      0, 1152, 1152,  384 }  // 1
   };
 
   return FRAME_SAMPLE[RawVersion()][RawLayer()];
 }
 
 int32_t
-FrameParser::FrameHeader::Bitrate() const {
+FrameParser::FrameHeader::Bitrate() const
+{
   // Bitrates - use [version][layer][bitrate]
   static const uint16_t BITRATE[4][4][16] = {
     { // Version 2.5
       { 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 0 }, // Reserved
       { 0,   8,  16,  24,  32,  40,  48,  56,  64,  80,  96, 112, 128, 144, 160, 0 }, // Layer 3
       { 0,   8,  16,  24,  32,  40,  48,  56,  64,  80,  96, 112, 128, 144, 160, 0 }, // Layer 2
       { 0,  32,  48,  56,  64,  80,  96, 112, 128, 144, 160, 176, 192, 224, 256, 0 }  // Layer 1
     },
@@ -933,36 +1003,39 @@ FrameParser::FrameHeader::Bitrate() cons
       { 0,  32,  64,  96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0 }, // Layer 1
     }
   };
 
   return 1000 * BITRATE[RawVersion()][RawLayer()][RawBitrate()];
 }
 
 int32_t
-FrameParser::FrameHeader::SlotSize() const {
+FrameParser::FrameHeader::SlotSize() const
+{
   // Slot size (MPEG unit of measurement) - use [layer]
   static const uint8_t SLOT_SIZE[4] = { 0, 1, 1, 4 }; // Rsvd, 3, 2, 1
 
   return SLOT_SIZE[RawLayer()];
 }
 
 bool
-FrameParser::FrameHeader::ParseNext(uint8_t c) {
+FrameParser::FrameHeader::ParseNext(uint8_t c)
+{
   if (!Update(c)) {
     Reset();
     if (!Update(c)) {
       Reset();
     }
   }
   return IsValid();
 }
 
 bool
-FrameParser::FrameHeader::IsValid(int aPos) const {
+FrameParser::FrameHeader::IsValid(int aPos) const
+{
   if (aPos >= SIZE) {
     return true;
   }
   if (aPos == frame_header::SYNC1) {
     return Sync1() == 0xFF;
   }
   if (aPos == frame_header::SYNC2_VERSION_LAYER_PROTECTION) {
     return Sync2() == 7 &&
@@ -972,27 +1045,30 @@ FrameParser::FrameHeader::IsValid(int aP
   if (aPos == frame_header::BITRATE_SAMPLERATE_PADDING_PRIVATE) {
     return RawBitrate() != 0xF && RawBitrate() != 0 &&
            RawSampleRate() != 3;
   }
   return true;
 }
 
 bool
-FrameParser::FrameHeader::IsValid() const {
+FrameParser::FrameHeader::IsValid() const
+{
   return mPos >= SIZE;
 }
 
 void
-FrameParser::FrameHeader::Reset() {
+FrameParser::FrameHeader::Reset()
+{
   mPos = 0;
 }
 
 bool
-FrameParser::FrameHeader::Update(uint8_t c) {
+FrameParser::FrameHeader::Update(uint8_t c)
+{
   if (mPos < SIZE) {
     mRaw[mPos] = c;
   }
   return IsValid(mPos++);
 }
 
 // FrameParser::VBRHeader
 
@@ -1002,82 +1078,93 @@ static const uint32_t TOC_SIZE = 100;
 } // namespace vbr_header
 
 FrameParser::VBRHeader::VBRHeader()
   : mType(NONE)
 {
 }
 
 FrameParser::VBRHeader::VBRHeaderType
-FrameParser::VBRHeader::Type() const {
+FrameParser::VBRHeader::Type() const
+{
   return mType;
 }
 
 const Maybe<uint32_t>&
-FrameParser::VBRHeader::NumAudioFrames() const {
+FrameParser::VBRHeader::NumAudioFrames() const
+{
   return mNumAudioFrames;
 }
 
 const Maybe<uint32_t>&
-FrameParser::VBRHeader::NumBytes() const {
+FrameParser::VBRHeader::NumBytes() const
+{
   return mNumBytes;
 }
 
 const Maybe<uint32_t>&
-FrameParser::VBRHeader::Scale() const {
+FrameParser::VBRHeader::Scale() const
+{
   return mScale;
 }
 
 bool
-FrameParser::VBRHeader::IsTOCPresent() const {
+FrameParser::VBRHeader::IsTOCPresent() const
+{
   return mTOC.size() == vbr_header::TOC_SIZE;
 }
 
 bool
-FrameParser::VBRHeader::IsValid() const {
+FrameParser::VBRHeader::IsValid() const
+{
   return mType != NONE;
 }
 
 bool
-FrameParser::VBRHeader::IsComplete() const {
-  return IsValid() &&
-         mNumAudioFrames.valueOr(0) > 0 &&
-         mNumBytes.valueOr(0) > 0 &&
+FrameParser::VBRHeader::IsComplete() const
+{
+  return IsValid()
+         && mNumAudioFrames.valueOr(0) > 0
+         && mNumBytes.valueOr(0) > 0
          // We don't care about the scale for any computations here.
-         // mScale < 101 &&
-         true;
+         // && mScale < 101
+         && true;
 }
 
 int64_t
-FrameParser::VBRHeader::Offset(float aDurationFac) const {
+FrameParser::VBRHeader::Offset(float aDurationFac) const
+{
   if (!IsTOCPresent()) {
     return -1;
   }
 
   // Constrain the duration percentage to [0, 99].
-  const float durationPer = 100.0f * std::min(0.99f, std::max(0.0f, aDurationFac));
+  const float durationPer =
+    100.0f * std::min(0.99f, std::max(0.0f, aDurationFac));
   const size_t fullPer = durationPer;
   const float rest = durationPer - fullPer;
 
   MOZ_ASSERT(fullPer < mTOC.size());
   int64_t offset = mTOC.at(fullPer);
 
   if (rest > 0.0 && fullPer + 1 < mTOC.size()) {
     offset += rest * (mTOC.at(fullPer + 1) - offset);
   }
 
   return offset;
 }
 
 bool
-FrameParser::VBRHeader::ParseXing(ByteReader* aReader) {
+FrameParser::VBRHeader::ParseXing(ByteReader* aReader)
+{
   static const uint32_t XING_TAG = BigEndian::readUint32("Xing");
   static const uint32_t INFO_TAG = BigEndian::readUint32("Info");
 
-  enum Flags {
+  enum Flags
+  {
     NUM_FRAMES = 0x01,
     NUM_BYTES = 0x02,
     TOC = 0x04,
     VBR_SCALE = 0x08
   };
 
   MOZ_ASSERT(aReader);
   const size_t prevReaderOffset = aReader->Offset();
@@ -1119,25 +1206,27 @@ FrameParser::VBRHeader::ParseXing(ByteRe
     mScale = Some(aReader->ReadU32());
   }
 
   aReader->Seek(prevReaderOffset);
   return mType == XING;
 }
 
 bool
-FrameParser::VBRHeader::ParseVBRI(ByteReader* aReader) {
+FrameParser::VBRHeader::ParseVBRI(ByteReader* aReader)
+{
   static const uint32_t TAG = BigEndian::readUint32("VBRI");
   static const uint32_t OFFSET = 32 + FrameParser::FrameHeader::SIZE;
   static const uint32_t FRAME_COUNT_OFFSET = OFFSET + 14;
   static const uint32_t MIN_FRAME_SIZE = OFFSET + 26;
 
   MOZ_ASSERT(aReader);
-  // ParseVBRI assumes that the ByteReader offset points to the beginning of a frame,
-  // therefore as a simple check, we look for the presence of a frame sync at that position.
+  // ParseVBRI assumes that the ByteReader offset points to the beginning of a
+  // frame, therefore as a simple check, we look for the presence of a frame
+  // sync at that position.
   MOZ_ASSERT((aReader->PeekU16() & 0xFFE0) == 0xFFE0);
   const size_t prevReaderOffset = aReader->Offset();
 
   // VBRI have a fixed relative position, so let's check for it there.
   if (aReader->Remaining() > MIN_FRAME_SIZE) {
     aReader->Seek(prevReaderOffset + OFFSET);
     if (aReader->ReadU32() == TAG) {
       aReader->Seek(prevReaderOffset + FRAME_COUNT_OFFSET);
@@ -1147,59 +1236,65 @@ FrameParser::VBRHeader::ParseVBRI(ByteRe
       return true;
     }
   }
   aReader->Seek(prevReaderOffset);
   return false;
 }
 
 bool
-FrameParser::VBRHeader::Parse(ByteReader* aReader) {
+FrameParser::VBRHeader::Parse(ByteReader* aReader)
+{
   const bool rv = ParseVBRI(aReader) || ParseXing(aReader);
   if (rv) {
     MP3LOG("VBRHeader::Parse found valid VBR/CBR header: type=%s"
            " NumAudioFrames=%u NumBytes=%u Scale=%u TOC-size=%u",
            vbr_header::TYPE_STR[Type()], NumAudioFrames().valueOr(0),
            NumBytes().valueOr(0), Scale().valueOr(0), mTOC.size());
   }
   return rv;
 }
 
 // FrameParser::Frame
 
 void
-FrameParser::Frame::Reset() {
+FrameParser::Frame::Reset()
+{
   mHeader.Reset();
 }
 
 int32_t
-FrameParser::Frame::Length() const {
+FrameParser::Frame::Length() const
+{
   if (!mHeader.IsValid() || !mHeader.SampleRate()) {
     return 0;
   }
 
   const float bitsPerSample = mHeader.SamplesPerFrame() / 8.0f;
-  const int32_t frameLen = bitsPerSample * mHeader.Bitrate() /
-                           mHeader.SampleRate() +
-                           mHeader.Padding() * mHeader.SlotSize();
+  const int32_t frameLen = bitsPerSample * mHeader.Bitrate()
+                           / mHeader.SampleRate()
+                           + mHeader.Padding() * mHeader.SlotSize();
   return frameLen;
 }
 
 bool
-FrameParser::Frame::ParseNext(uint8_t c) {
+FrameParser::Frame::ParseNext(uint8_t c)
+{
   return mHeader.ParseNext(c);
 }
 
 const FrameParser::FrameHeader&
-FrameParser::Frame::Header() const {
+FrameParser::Frame::Header() const
+{
   return mHeader;
 }
 
 bool
-FrameParser::ParseVBRHeader(ByteReader* aReader) {
+FrameParser::ParseVBRHeader(ByteReader* aReader)
+{
   return mVBRHeader.Parse(aReader);
 }
 
 // ID3Parser
 
 // Constants
 namespace id3_header {
 static const int ID_LEN = 3;
@@ -1214,126 +1309,139 @@ static const int SIZE_END = FLAGS_END + 
 
 static const uint8_t ID[ID_LEN] = {'I', 'D', '3'};
 
 static const uint8_t MIN_MAJOR_VER = 2;
 static const uint8_t MAX_MAJOR_VER = 4;
 } // namespace id3_header
 
 uint32_t
-ID3Parser::Parse(ByteReader* aReader) {
+ID3Parser::Parse(ByteReader* aReader)
+{
   MOZ_ASSERT(aReader);
 
   while (aReader->CanRead8() && !mHeader.ParseNext(aReader->ReadU8())) { }
 
   if (mHeader.IsValid()) {
     // Header found, return total tag size.
     return ID3Header::SIZE + Header().Size() + Header().FooterSize();
   }
   return 0;
 }
 
 void
-ID3Parser::Reset() {
+ID3Parser::Reset()
+{
   mHeader.Reset();
 }
 
 const ID3Parser::ID3Header&
-ID3Parser::Header() const {
+ID3Parser::Header() const
+{
   return mHeader;
 }
 
 // ID3Parser::Header
 
 ID3Parser::ID3Header::ID3Header()
 {
   Reset();
 }
 
 void
-ID3Parser::ID3Header::Reset() {
+ID3Parser::ID3Header::Reset()
+{
   mSize = 0;
   mPos = 0;
 }
 
 uint8_t
-ID3Parser::ID3Header::MajorVersion() const {
+ID3Parser::ID3Header::MajorVersion() const
+{
   return mRaw[id3_header::ID_END];
 }
 
 uint8_t
-ID3Parser::ID3Header::MinorVersion() const {
+ID3Parser::ID3Header::MinorVersion() const
+{
   return mRaw[id3_header::ID_END + 1];
 }
 
 uint8_t
-ID3Parser::ID3Header::Flags() const {
+ID3Parser::ID3Header::Flags() const
+{
   return mRaw[id3_header::FLAGS_END - id3_header::FLAGS_LEN];
 }
 
 uint32_t
-ID3Parser::ID3Header::Size() const {
+ID3Parser::ID3Header::Size() const
+{
   if (!IsValid()) {
     return 0;
   }
   return mSize;
 }
 
 uint8_t
-ID3Parser::ID3Header::FooterSize() const {
+ID3Parser::ID3Header::FooterSize() const
+{
   if (Flags() & (1 << 4)) {
     return SIZE;
   }
   return 0;
 }
 
 bool
-ID3Parser::ID3Header::ParseNext(uint8_t c) {
+ID3Parser::ID3Header::ParseNext(uint8_t c)
+{
   if (!Update(c)) {
     Reset();
     if (!Update(c)) {
       Reset();
     }
   }
   return IsValid();
 }
 
 bool
-ID3Parser::ID3Header::IsValid(int aPos) const {
+ID3Parser::ID3Header::IsValid(int aPos) const
+{
   if (aPos >= SIZE) {
     return true;
   }
   const uint8_t c = mRaw[aPos];
   switch (aPos) {
     case 0: case 1: case 2:
       // Expecting "ID3".
       return id3_header::ID[aPos] == c;
     case 3:
-      return MajorVersion() >= id3_header::MIN_MAJOR_VER &&
-             MajorVersion() <= id3_header::MAX_MAJOR_VER;
+      return MajorVersion() >= id3_header::MIN_MAJOR_VER
+             && MajorVersion() <= id3_header::MAX_MAJOR_VER;
     case 4:
       return MinorVersion() < 0xFF;
     case 5:
       // Validate flags for supported versions, see bug 949036.
       return ((0xFF >> MajorVersion()) & c) == 0;
     case 6: case 7: case 8: case 9:
       return c < 0x80;
   }
   return true;
 }
 
 bool
-ID3Parser::ID3Header::IsValid() const {
+ID3Parser::ID3Header::IsValid() const
+{
   return mPos >= SIZE;
 }
 
 bool
-ID3Parser::ID3Header::Update(uint8_t c) {
-  if (mPos >= id3_header::SIZE_END - id3_header::SIZE_LEN &&
-      mPos < id3_header::SIZE_END) {
+ID3Parser::ID3Header::Update(uint8_t c)
+{
+  if (mPos >= id3_header::SIZE_END - id3_header::SIZE_LEN
+      && mPos < id3_header::SIZE_END) {
     mSize <<= 7;
     mSize |= c;
   }
   if (mPos < SIZE) {
     mRaw[mPos] = c;
   }
   return IsValid(mPos++);
 }
--- a/dom/media/MP3Demuxer.h
+++ b/dom/media/MP3Demuxer.h
@@ -12,17 +12,18 @@
 #include "mp4_demuxer/ByteReader.h"
 #include <vector>
 
 namespace mozilla {
 namespace mp3 {
 
 class MP3TrackDemuxer;
 
-class MP3Demuxer : public MediaDataDemuxer {
+class MP3Demuxer : public MediaDataDemuxer
+{
 public:
   // MediaDataDemuxer interface.
   explicit MP3Demuxer(MediaResource* aSource);
   RefPtr<InitPromise> Init() override;
   bool HasTrackType(TrackInfo::TrackType aType) const override;
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
   already_AddRefed<MediaTrackDemuxer> GetTrackDemuxer(
       TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
@@ -37,20 +38,22 @@ private:
   RefPtr<MediaResource> mSource;
   RefPtr<MP3TrackDemuxer> mTrackDemuxer;
 };
 
 // ID3 header parser state machine used by FrameParser.
 // The header contains the following format (one byte per term):
 // 'I' 'D' '3' MajorVersion MinorVersion Flags Size1 Size2 Size3 Size4
 // For more details see http://id3.org/id3v2.3.0.
-class ID3Parser {
+class ID3Parser
+{
 public:
   // Holds the ID3 header and its parsing state.
-  class ID3Header {
+  class ID3Header
+  {
   public:
     // The header size is static, see class comment.
     static const int SIZE = 10;
 
     // Constructor.
     ID3Header();
 
     // Resets the state to allow for a new parsing session.
@@ -125,20 +128,22 @@ private:
 //   P          - Padding bit (0->not padded, 1->padded by 1 slot size)
 //   R          - Private bit (ignored)
 //   MM         - Channel mode (0->stereo, 1->joint stereo, 2->dual channel,
 //                3->single channel)
 //   EE         - Mode extension for joint stereo (ignored)
 //   T          - Copyright (0->disabled, 1->enabled)
 //   O          - Original (0->copy, 1->original)
 //   HH         - Emphasis (0->none, 1->50/15 ms, 2->reserved, 3->CCIT J.17)
-class FrameParser {
+class FrameParser
+{
 public:
   // Holds the frame header and its parsing state.
-  class FrameHeader {
+  class FrameHeader
+  {
   public:
     // The header size is static, see class comments.
     static const int SIZE = 4;
 
     // Constructor.
     FrameHeader();
 
     // Raw field access, see class comments for details.
@@ -195,20 +200,22 @@ public:
 
     // The current byte position in the parsed sequence. Reset via Reset and
     // incremented via Update.
     int mPos;
   };
 
   // VBR frames may contain Xing or VBRI headers for additional info, we use
   // this class to parse them and access this info.
-  class VBRHeader {
+  class VBRHeader
+  {
   public:
     // Synchronize with vbr_header TYPE_STR on change.
-    enum VBRHeaderType {
+    enum VBRHeaderType
+    {
       NONE = 0,
       XING,
       VBRI
     };
 
     // Constructor.
     VBRHeader();
 
@@ -226,27 +233,28 @@ public:
     const Maybe<uint32_t>& Scale() const;
 
     // Returns true iff Xing/Info TOC (table of contents) is present.
     bool IsTOCPresent() const;
 
     // Returns whether the header is valid (type XING or VBRI).
     bool IsValid() const;
 
-    // Returns whether the header is valid and contains reasonable non-zero field values.
+    // Returns whether the header is valid and contains reasonable non-zero
+    // field values.
     bool IsComplete() const;
 
     // Returns the byte offset for the given duration percentage as a factor
     // (0: begin, 1.0: end).
     int64_t Offset(float aDurationFac) const;
 
     // Parses contents of given ByteReader for a valid VBR header.
-    // The offset of the passed ByteReader needs to point to an MPEG frame begin,
-    // as a VBRI-style header is searched at a fixed offset relative to frame begin.
-    // Returns whether a valid VBR header was found in the range.
+    // The offset of the passed ByteReader needs to point to an MPEG frame
+    // begin, as a VBRI-style header is searched at a fixed offset relative to
+    // frame begin. Returns whether a valid VBR header was found in the range.
     bool Parse(mp4_demuxer::ByteReader* aReader);
 
   private:
     // Parses contents of given ByteReader for a valid Xing header.
     // The initial ByteReader offset will be preserved.
     // Returns whether a valid Xing header was found in the range.
     bool ParseXing(mp4_demuxer::ByteReader* aReader);
 
@@ -269,17 +277,18 @@ public:
     // The TOC table mapping duration percentage to byte offset.
     std::vector<int64_t> mTOC;
 
     // The detected VBR header type.
     VBRHeaderType mType;
   };
 
   // Frame meta container used to parse and hold a frame header and side info.
-  class Frame {
+  class Frame
+  {
   public:
     // Returns the length of the frame excluding the header in bytes.
     int32_t Length() const;
 
     // Returns the parsed frame header.
     const FrameHeader& Header() const;
 
     // Resets the frame header and data.
@@ -320,26 +329,26 @@ public:
   void ResetFrameData();
 
   // Clear the last parsed frame to allow for next frame parsing, i.e.:
   // - sets PrevFrame to CurrentFrame
   // - resets the CurrentFrame
   // - resets ID3Header if no valid header was parsed yet
   void EndFrameSession();
 
-  // Parses contents of given ByteReader for a valid frame header and returns true
-  // if one was found. After returning, the variable passed to 'aBytesToSkip' holds
-  // the amount of bytes to be skipped (if any) in order to jump across a large
-  // ID3v2 tag spanning multiple buffers.
+  // Parses contents of given ByteReader for a valid frame header and returns
+  // true if one was found. After returning, the variable passed to
+  // 'aBytesToSkip' holds the amount of bytes to be skipped (if any) in order to
+  // jump across a large ID3v2 tag spanning multiple buffers.
   bool Parse(mp4_demuxer::ByteReader* aReader, uint32_t* aBytesToSkip);
 
   // Parses contents of given ByteReader for a valid VBR header.
   // The offset of the passed ByteReader needs to point to an MPEG frame begin,
-  // as a VBRI-style header is searched at a fixed offset relative to frame begin.
-  // Returns whether a valid VBR header was found.
+  // as a VBRI-style header is searched at a fixed offset relative to frame
+  // begin. Returns whether a valid VBR header was found.
   bool ParseVBRHeader(mp4_demuxer::ByteReader* aReader);
 
 private:
   // ID3 header parser.
   ID3Parser mID3Parser;
 
   // VBR header parser.
   VBRHeader mVBRHeader;
@@ -348,17 +357,18 @@ private:
   // previously parsed frame for debugging and the currently parsed frame.
   Frame mFirstFrame;
   Frame mFrame;
   Frame mPrevFrame;
 };
 
 // The MP3 demuxer used to extract MPEG frames and side information out of
 // MPEG streams.
-class MP3TrackDemuxer : public MediaTrackDemuxer {
+class MP3TrackDemuxer : public MediaTrackDemuxer
+{
 public:
   // Constructor, expecting a valid media resource.
   explicit MP3TrackDemuxer(MediaResource* aSource);
 
   // Initializes the track demuxer by reading the first frame for meta data.
   // Returns initialization success state.
   bool Init();
 
@@ -381,18 +391,18 @@ public:
   const ID3Parser::ID3Header& ID3Header() const;
   const FrameParser::VBRHeader& VBRInfo() const;
 
   // MediaTrackDemuxer interface.
   UniquePtr<TrackInfo> GetInfo() const override;
   RefPtr<SeekPromise> Seek(const media::TimeUnit& aTime) override;
   RefPtr<SamplesPromise> GetSamples(int32_t aNumSamples = 1) override;
   void Reset() override;
-  RefPtr<SkipAccessPointPromise> SkipToNextRandomAccessPoint(
-    const media::TimeUnit& aTimeThreshold) override;
+  RefPtr<SkipAccessPointPromise>
+  SkipToNextRandomAccessPoint(const media::TimeUnit &aTimeThreshold) override;
   int64_t GetResourceOffset() const override;
   media::TimeIntervals GetBuffered() override;
 
 private:
   // Destructor.
   ~MP3TrackDemuxer() {}
 
   // Fast approximate seeking to given time.
--- a/dom/media/flac/FlacDemuxer.cpp
+++ b/dom/media/flac/FlacDemuxer.cpp
@@ -36,17 +36,18 @@ namespace flac {
 #define FLAC_MAX_CHANNELS           8
 #define FLAC_MIN_BLOCKSIZE         16
 #define FLAC_MAX_BLOCKSIZE      65535
 #define FLAC_MIN_FRAME_SIZE        11
 #define FLAC_MAX_FRAME_HEADER_SIZE 16
 #define FLAC_MAX_FRAME_SIZE (FLAC_MAX_FRAME_HEADER_SIZE \
                              +FLAC_MAX_BLOCKSIZE*FLAC_MAX_CHANNELS*3)
 
-class FrameHeader {
+class FrameHeader
+{
 public:
   const AudioInfo& Info() const { return mInfo; }
 
   uint32_t Size() const { return mSize; }
 
   bool IsValid() const { return mValid; }
 
   // Return the index (in samples) from the beginning of the track.
@@ -154,17 +155,18 @@ public:
       mInfo.mMimeType = "audio/flac";
     }
 
     return mValid;
   }
 
 private:
   friend class Frame;
-  enum {
+  enum
+  {
     FLAC_CHMODE_INDEPENDENT = 0,
     FLAC_CHMODE_LEFT_SIDE,
     FLAC_CHMODE_RIGHT_SIDE,
     FLAC_CHMODE_MID_SIDE,
   };
   AudioInfo mInfo;
   // Index in samples from start;
   int64_t mIndex = 0;
@@ -175,17 +177,18 @@ private:
 
   static const int FlacSampleRateTable[16];
   static const int32_t FlacBlocksizeTable[16];
   static const uint8_t FlacSampleSizeTable[8];
   static const uint8_t CRC8Table[256];
 };
 
 const int FrameHeader::FlacSampleRateTable[16] =
-{ 0,
+{
+  0,
   88200, 176400, 192000,
   8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000,
   0, 0, 0, 0
 };
 
 const int32_t FrameHeader::FlacBlocksizeTable[16] =
 {
   0     , 192   , 576<<0, 576<<1, 576<<2, 576<<3,      0,      0,
@@ -227,17 +230,18 @@ const uint8_t FrameHeader::CRC8Table[256
   0xAE, 0xA9, 0xA0, 0xA7, 0xB2, 0xB5, 0xBC, 0xBB,
   0x96, 0x91, 0x98, 0x9F, 0x8A, 0x8D, 0x84, 0x83,
   0xDE, 0xD9, 0xD0, 0xD7, 0xC2, 0xC5, 0xCC, 0xCB,
   0xE6, 0xE1, 0xE8, 0xEF, 0xFA, 0xFD, 0xF4, 0xF3
 };
 
 // flac::Frame - Frame meta container used to parse and hold a frame
 // header and side info.
-class Frame {
+class Frame
+{
 public:
 
   // The FLAC signature is made of 14 bits set to 1; however the 15th bit is
   // mandatorily set to 0, so we need to find either of 0xfffc or 0xfffd 2-bytes
   // signature. We first use a bitmask to see if 0xfc or 0xfd is present. And if
   // so we check for the whole signature.
   // aData must be pointing to a buffer at least
   // aLength + FLAC_MAX_FRAME_HEADER_SIZE bytes.
@@ -379,17 +383,18 @@ private:
   uint32_t mDuration = 0;
   bool mEOS = false;
 
   // The currently parsed frame header.
   FrameHeader mHeader;
 
 };
 
-class FrameParser {
+class FrameParser
+{
 public:
 
   // Returns the currently parsed frame. Reset via EndFrameSession.
   const Frame& CurrentFrame() const { return mFrame; }
 
   // Returns the first parsed frame.
   const Frame& FirstFrame() const { return mFirstFrame; }
 
@@ -560,17 +565,18 @@ private:
 };
 
 } // namespace flac
 
 // FlacDemuxer
 
 FlacDemuxer::FlacDemuxer(MediaResource* aSource)
   : mSource(aSource)
-{}
+{
+}
 
 bool
 FlacDemuxer::InitInternal()
 {
   if (!mTrackDemuxer) {
     mTrackDemuxer = new FlacTrackDemuxer(mSource);
   }
   return mTrackDemuxer->Init();
@@ -633,17 +639,18 @@ FlacTrackDemuxer::~FlacTrackDemuxer()
 
 bool
 FlacTrackDemuxer::Init()
 {
   static const int BUFFER_SIZE = 4096;
 
   // First check if we have a valid Flac start.
   char buffer[BUFFER_SIZE];
-  const uint8_t* ubuffer = reinterpret_cast<uint8_t*>(buffer); // only needed due to type constraints of ReadAt.
+  const uint8_t *ubuffer = // only needed due to type constraints of ReadAt.
+    reinterpret_cast<uint8_t *>(buffer);
   int64_t offset = 0;
 
   do {
     uint32_t read = 0;
     nsresult ret = mSource.ReadAt(offset, buffer, BUFFER_SIZE, &read);
     if (NS_FAILED(ret) || read < BUFFER_SIZE) {
       // Assume that if we can't read that many bytes while parsing the header,
       // that something is wrong.
@@ -757,17 +764,18 @@ FlacTrackDemuxer::FastSeek(const TimeUni
   // We look for the seek position using a bisection search, starting where the
   // estimated position might be using the average frame length.
   // Typically, with flac such approximation is typically useless.
 
   // Estimate where the position might be.
   int64_t pivot =
     aTime.ToSeconds() * AverageFrameLength() + mParser->FirstFrame().Offset();
 
-  // Time in seconds where we can stop seeking and will continue using ScanUntil.
+  // Time in seconds where we can stop seeking and will continue using
+  // ScanUntil.
   static const int GAP_THRESHOLD = 5;
   int64_t first = mParser->FirstFrame().Offset();
   int64_t last = mSource.GetLength();
   Maybe<int64_t> lastFoundOffset;
   uint32_t iterations = 0;
   TimeUnit timeSeekedTo;
 
   do {
--- a/dom/media/flac/FlacDemuxer.h
+++ b/dom/media/flac/FlacDemuxer.h
@@ -14,17 +14,18 @@ namespace mozilla {
 
 namespace flac {
 class Frame;
 class FrameParser;
 }
 class FlacTrackDemuxer;
 
 
-class FlacDemuxer : public MediaDataDemuxer {
+class FlacDemuxer : public MediaDataDemuxer
+{
 public:
   // MediaDataDemuxer interface.
   explicit FlacDemuxer(MediaResource* aSource);
   RefPtr<InitPromise> Init() override;
   bool HasTrackType(TrackInfo::TrackType aType) const override;
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
   already_AddRefed<MediaTrackDemuxer> GetTrackDemuxer(
     TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
@@ -35,17 +36,18 @@ public:
 
 private:
   bool InitInternal();
 
   RefPtr<MediaResource> mSource;
   RefPtr<FlacTrackDemuxer> mTrackDemuxer;
 };
 
-class FlacTrackDemuxer : public MediaTrackDemuxer {
+class FlacTrackDemuxer : public MediaTrackDemuxer
+{
 public:
   explicit FlacTrackDemuxer(MediaResource* aSource);
 
   // Initializes the track demuxer by reading the first frame for meta data.
   // Returns initialization success state.
   bool Init();
 
   // MediaTrackDemuxer interface.
@@ -66,17 +68,18 @@ private:
 
   // Returns the estimated stream duration, or a 0-duration if unknown.
   media::TimeUnit Duration() const;
   media::TimeUnit TimeAtEnd();
 
   // Fast approximate seeking to given time.
   media::TimeUnit FastSeek(const media::TimeUnit& aTime);
 
-  // Seeks by scanning the stream up to the given time for more accurate results.
+  // Seeks by scanning the stream up to the given time for more accurate
+  // results.
   media::TimeUnit ScanUntil(const media::TimeUnit& aTime);
 
   // Finds the next valid frame and return it.
   const flac::Frame& FindNextFrame();
 
   // Returns the next ADTS frame, if available.
   already_AddRefed<MediaRawData> GetNextFrame(const flac::Frame& aFrame);
 
--- a/dom/media/fmp4/MP4Demuxer.cpp
+++ b/dom/media/fmp4/MP4Demuxer.cpp
@@ -4,32 +4,32 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include <algorithm>
 #include <limits>
 #include <stdint.h>
 
 #include "MP4Demuxer.h"
+
+// Used for telemetry
+#include "mozilla/Telemetry.h"
+#include "mp4_demuxer/AnnexB.h"
+#include "mp4_demuxer/H264.h"
 #include "mp4_demuxer/MoofParser.h"
 #include "mp4_demuxer/MP4Metadata.h"
 #include "mp4_demuxer/ResourceStream.h"
 #include "mp4_demuxer/BufferStream.h"
 #include "mp4_demuxer/Index.h"
+#include "nsAutoPtr.h"
 #include "nsPrintfCString.h"
 
-// Used for telemetry
-#include "mozilla/Telemetry.h"
-#include "mp4_demuxer/AnnexB.h"
-#include "mp4_demuxer/H264.h"
-
-#include "nsAutoPtr.h"
-
 extern mozilla::LazyLogModule gMediaDemuxerLog;
-mozilla::LogModule* GetDemuxerLog() {
+mozilla::LogModule* GetDemuxerLog()
+{
   return gMediaDemuxerLog;
 }
 
 #define LOG(arg, ...) MOZ_LOG(gMediaDemuxerLog, mozilla::LogLevel::Debug, ("MP4Demuxer(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
 
 namespace mozilla {
 
 class MP4TrackDemuxer : public MediaTrackDemuxer
@@ -77,34 +77,35 @@ private:
 
 
 // Returns true if no SPS was found and search for it should continue.
 bool
 AccumulateSPSTelemetry(const MediaByteBuffer* aExtradata)
 {
   mp4_demuxer::SPSData spsdata;
   if (mp4_demuxer::H264::DecodeSPSFromExtraData(aExtradata, spsdata)) {
-    uint8_t constraints = (spsdata.constraint_set0_flag ? (1 << 0) : 0) |
-                          (spsdata.constraint_set1_flag ? (1 << 1) : 0) |
-                          (spsdata.constraint_set2_flag ? (1 << 2) : 0) |
-                          (spsdata.constraint_set3_flag ? (1 << 3) : 0) |
-                          (spsdata.constraint_set4_flag ? (1 << 4) : 0) |
-                          (spsdata.constraint_set5_flag ? (1 << 5) : 0);
+    uint8_t constraints = (spsdata.constraint_set0_flag ? (1 << 0) : 0)
+                          | (spsdata.constraint_set1_flag ? (1 << 1) : 0)
+                          | (spsdata.constraint_set2_flag ? (1 << 2) : 0)
+                          | (spsdata.constraint_set3_flag ? (1 << 3) : 0)
+                          | (spsdata.constraint_set4_flag ? (1 << 4) : 0)
+                          | (spsdata.constraint_set5_flag ? (1 << 5) : 0);
     Telemetry::Accumulate(Telemetry::VIDEO_DECODED_H264_SPS_CONSTRAINT_SET_FLAG,
                           constraints);
 
     // Collect profile_idc values up to 244, otherwise 0 for unknown.
     Telemetry::Accumulate(Telemetry::VIDEO_DECODED_H264_SPS_PROFILE,
                           spsdata.profile_idc <= 244 ? spsdata.profile_idc : 0);
 
     // Make sure level_idc represents a value between levels 1 and 5.2,
     // otherwise collect 0 for unknown level.
     Telemetry::Accumulate(Telemetry::VIDEO_DECODED_H264_SPS_LEVEL,
-                          (spsdata.level_idc >= 10 && spsdata.level_idc <= 52) ?
-                          spsdata.level_idc : 0);
+                          (spsdata.level_idc >= 10 && spsdata.level_idc <= 52)
+                          ? spsdata.level_idc
+                          : 0);
 
     // max_num_ref_frames should be between 0 and 16, anything larger will
     // be treated as invalid.
     Telemetry::Accumulate(Telemetry::VIDEO_H264_SPS_MAX_NUM_REF_FRAMES,
                           std::min(spsdata.max_num_ref_frames, 17u));
 
     return false;
   }
@@ -121,33 +122,36 @@ MP4Demuxer::MP4Demuxer(MediaResource* aR
 
 RefPtr<MP4Demuxer::InitPromise>
 MP4Demuxer::Init()
 {
   AutoPinned<mp4_demuxer::ResourceStream> stream(mStream);
 
   // Check that we have enough data to read the metadata.
   if (!mp4_demuxer::MP4Metadata::HasCompleteMetadata(stream)) {
-    return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_DEMUXER_ERR, __func__);
+    return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
+                                        __func__);
   }
 
   mInitData = mp4_demuxer::MP4Metadata::Metadata(stream);
   if (!mInitData) {
     // OOM
-    return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_DEMUXER_ERR, __func__);
+    return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
+                                        __func__);
   }
 
   RefPtr<mp4_demuxer::BufferStream> bufferstream =
     new mp4_demuxer::BufferStream(mInitData);
 
   mMetadata = MakeUnique<mp4_demuxer::MP4Metadata>(bufferstream);
 
-  if (!mMetadata->GetNumberTracks(mozilla::TrackInfo::kAudioTrack) &&
-      !mMetadata->GetNumberTracks(mozilla::TrackInfo::kVideoTrack)) {
-    return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_DEMUXER_ERR, __func__);
+  if (!mMetadata->GetNumberTracks(mozilla::TrackInfo::kAudioTrack)
+      && !mMetadata->GetNumberTracks(mozilla::TrackInfo::kVideoTrack)) {
+    return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
+                                        __func__);
   }
 
   return InitPromise::CreateAndResolve(NS_OK, __func__);
 }
 
 bool
 MP4Demuxer::HasTrackType(TrackInfo::TrackType aType) const
 {
@@ -238,26 +242,26 @@ MP4TrackDemuxer::MP4TrackDemuxer(MP4Demu
                                   mInfo->IsAudio()))
   , mIterator(MakeUnique<mp4_demuxer::SampleIterator>(mIndex))
   , mNeedReIndex(true)
 {
   EnsureUpToDateIndex(); // Force update of index
 
   VideoInfo* videoInfo = mInfo->GetAsVideoInfo();
   // Collect telemetry from h264 AVCC SPS.
-  if (videoInfo &&
-      (mInfo->mMimeType.EqualsLiteral("video/mp4") ||
-       mInfo->mMimeType.EqualsLiteral("video/avc"))) {
+  if (videoInfo
+      && (mInfo->mMimeType.EqualsLiteral("video/mp4")
+          || mInfo->mMimeType.EqualsLiteral("video/avc"))) {
     mIsH264 = true;
     RefPtr<MediaByteBuffer> extraData = videoInfo->mExtraData;
     mNeedSPSForTelemetry = AccumulateSPSTelemetry(extraData);
     mp4_demuxer::SPSData spsdata;
-    if (mp4_demuxer::H264::DecodeSPSFromExtraData(extraData, spsdata) &&
-        spsdata.pic_width > 0 && spsdata.pic_height > 0 &&
-        mp4_demuxer::H264::EnsureSPSIsSane(spsdata)) {
+    if (mp4_demuxer::H264::DecodeSPSFromExtraData(extraData, spsdata)
+        && spsdata.pic_width > 0 && spsdata.pic_height > 0
+        && mp4_demuxer::H264::EnsureSPSIsSane(spsdata)) {
       videoInfo->mImage.width = spsdata.pic_width;
       videoInfo->mImage.height = spsdata.pic_height;
       videoInfo->mDisplay.width = spsdata.display_width;
       videoInfo->mDisplay.height = spsdata.display_height;
     }
   } else {
     // No SPS to be found.
     mNeedSPSForTelemetry = false;
@@ -294,31 +298,33 @@ MP4TrackDemuxer::Seek(const media::TimeU
 
   mIterator->Seek(seekTime);
 
   // Check what time we actually seeked to.
   RefPtr<MediaRawData> sample;
   do {
     sample = GetNextSample();
     if (!sample) {
-      return SeekPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);
+      return SeekPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_END_OF_STREAM,
+                                          __func__);
     }
     if (!sample->Size()) {
       // This sample can't be decoded, continue searching.
       continue;
     }
     if (sample->mKeyframe) {
       mQueuedSample = sample;
       seekTime = mQueuedSample->mTime;
     }
   } while (!mQueuedSample);
 
   SetNextKeyFrameTime();
 
-  return SeekPromise::CreateAndResolve(media::TimeUnit::FromMicroseconds(seekTime), __func__);
+  return SeekPromise::CreateAndResolve(
+    media::TimeUnit::FromMicroseconds(seekTime), __func__);
 }
 
 already_AddRefed<MediaRawData>
 MP4TrackDemuxer::GetNextSample()
 {
   RefPtr<MediaRawData> sample = mIterator->GetNext();
   if (!sample) {
     return nullptr;
@@ -329,30 +335,30 @@ MP4TrackDemuxer::GetNextSample()
       mp4_demuxer::H264::FrameType type =
         mp4_demuxer::H264::GetFrameType(sample);
       switch (type) {
         case mp4_demuxer::H264::FrameType::I_FRAME: MOZ_FALLTHROUGH;
         case mp4_demuxer::H264::FrameType::OTHER:
         {
           bool keyframe = type == mp4_demuxer::H264::FrameType::I_FRAME;
           if (sample->mKeyframe != keyframe) {
-            NS_WARNING(nsPrintfCString("Frame incorrectly marked as %skeyframe @ pts:%lld dur:%u dts:%lld",
-                                       keyframe ? "" : "non-",
-                                       sample->mTime,
-                                       sample->mDuration,
-                                       sample->mTimecode).get());
+            NS_WARNING(nsPrintfCString("Frame incorrectly marked as %skeyframe "
+                                       "@ pts:%lld dur:%u dts:%lld",
+                                       keyframe ? "" : "non-", sample->mTime,
+                                       sample->mDuration, sample->mTimecode)
+                         .get());
             sample->mKeyframe = keyframe;
           }
           break;
         }
         case mp4_demuxer::H264::FrameType::INVALID:
-          NS_WARNING(nsPrintfCString("Invalid H264 frame @ pts:%lld dur:%u dts:%lld",
-                                     sample->mTime,
-                                     sample->mDuration,
-                                     sample->mTimecode).get());
+          NS_WARNING(
+            nsPrintfCString("Invalid H264 frame @ pts:%lld dur:%u dts:%lld",
+                            sample->mTime, sample->mDuration, sample->mTimecode)
+              .get());
           // We could reject the sample now, however demuxer errors are fatal.
           // So we keep the invalid frame, relying on the H264 decoder to
           // handle the error later.
           // TODO: make demuxer errors non-fatal.
           break;
       }
     }
   }
@@ -372,17 +378,18 @@ MP4TrackDemuxer::GetNextSample()
 }
 
 RefPtr<MP4TrackDemuxer::SamplesPromise>
 MP4TrackDemuxer::GetSamples(int32_t aNumSamples)
 {
   EnsureUpToDateIndex();
   RefPtr<SamplesHolder> samples = new SamplesHolder;
   if (!aNumSamples) {
-    return SamplesPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_DEMUXER_ERR, __func__);
+    return SamplesPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_DEMUXER_ERR,
+                                           __func__);
   }
 
   if (mQueuedSample) {
     MOZ_ASSERT(mQueuedSample->mKeyframe,
                "mQueuedSample must be a keyframe");
     samples->mSamples.AppendElement(mQueuedSample);
     mQueuedSample = nullptr;
     aNumSamples--;
@@ -392,29 +399,31 @@ MP4TrackDemuxer::GetSamples(int32_t aNum
     if (!sample->Size()) {
       continue;
     }
     samples->mSamples.AppendElement(sample);
     aNumSamples--;
   }
 
   if (samples->mSamples.IsEmpty()) {
-    return SamplesPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);
+    return SamplesPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_END_OF_STREAM,
+                                           __func__);
   } else {
     for (const auto& sample : samples->mSamples) {
       // Collect telemetry from h264 Annex B SPS.
       if (mNeedSPSForTelemetry && mp4_demuxer::AnnexB::HasSPS(sample)) {
         RefPtr<MediaByteBuffer> extradata =
         mp4_demuxer::AnnexB::ExtractExtraData(sample);
         mNeedSPSForTelemetry = AccumulateSPSTelemetry(extradata);
       }
     }
 
-    if (mNextKeyframeTime.isNothing() ||
-        samples->mSamples.LastElement()->mTime >= mNextKeyframeTime.value().ToMicroseconds()) {
+    if (mNextKeyframeTime.isNothing()
+        || samples->mSamples.LastElement()->mTime
+           >= mNextKeyframeTime.value().ToMicroseconds()) {
       SetNextKeyFrameTime();
     }
     return SamplesPromise::CreateAndResolve(samples, __func__);
   }
 }
 
 void
 MP4TrackDemuxer::SetNextKeyFrameTime()
@@ -445,17 +454,18 @@ MP4TrackDemuxer::GetNextRandomAccessPoin
       media::TimeUnit::FromMicroseconds(std::numeric_limits<int64_t>::max());
   } else {
     *aTime = mNextKeyframeTime.value();
   }
   return NS_OK;
 }
 
 RefPtr<MP4TrackDemuxer::SkipAccessPointPromise>
-MP4TrackDemuxer::SkipToNextRandomAccessPoint(const media::TimeUnit& aTimeThreshold)
+MP4TrackDemuxer::SkipToNextRandomAccessPoint(
+  const media::TimeUnit &aTimeThreshold)
 {
   mQueuedSample = nullptr;
   // Loop until we reach the next keyframe after the threshold.
   uint32_t parsed = 0;
   bool found = false;
   RefPtr<MediaRawData> sample;
   while (!found && (sample = GetNextSample())) {
     parsed++;
--- a/dom/media/fmp4/MP4Demuxer.h
+++ b/dom/media/fmp4/MP4Demuxer.h
@@ -28,18 +28,18 @@ public:
   explicit MP4Demuxer(MediaResource* aResource);
 
   RefPtr<InitPromise> Init() override;
 
   bool HasTrackType(TrackInfo::TrackType aType) const override;
 
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
 
-  already_AddRefed<MediaTrackDemuxer> GetTrackDemuxer(TrackInfo::TrackType aType,
-                                                      uint32_t aTrackNumber) override;
+  already_AddRefed<MediaTrackDemuxer>
+  GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
 
   bool IsSeekable() const override;
 
   UniquePtr<EncryptionInfo> GetCrypto() override;
 
   void NotifyDataArrived() override;
 
   void NotifyDataRemoved() override;
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -264,18 +264,18 @@ MediaSourceDecoder::GetDuration()
   return ExplicitDuration();
 }
 
 MediaDecoderOwner::NextFrameStatus
 MediaSourceDecoder::NextFrameBufferedStatus()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
-  if (!mMediaSource ||
-      mMediaSource->ReadyState() == dom::MediaSourceReadyState::Closed) {
+  if (!mMediaSource
+      || mMediaSource->ReadyState() == dom::MediaSourceReadyState::Closed) {
     return MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE;
   }
 
   // Next frame hasn't been decoded yet.
   // Use the buffered range to consider if we have the next frame available.
   TimeUnit currentPosition = TimeUnit::FromMicroseconds(CurrentPosition());
   TimeIntervals buffered = GetBuffered();
   buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ / 2);
@@ -299,17 +299,18 @@ MediaSourceDecoder::CanPlayThrough()
 
   if (IsNaN(mMediaSource->Duration())) {
     // Don't have any data yet.
     return false;
   }
   TimeUnit duration = TimeUnit::FromSeconds(mMediaSource->Duration());
   TimeUnit currentPosition = TimeUnit::FromMicroseconds(CurrentPosition());
   if (duration.IsInfinite()) {
-    // We can't make an informed decision and just assume that it's a live stream
+    // We can't make an informed decision and just assume that it's a live
+    // stream
     return true;
   } else if (duration <= currentPosition) {
     return true;
   }
   // If we have data up to the mediasource's duration or 30s ahead, we can
   // assume that we can play without interruption.
   TimeIntervals buffered = GetBuffered();
   buffered.SetFuzz(MediaSourceDemuxer::EOS_FUZZ / 2);
--- a/dom/media/mediasource/MediaSourceDemuxer.h
+++ b/dom/media/mediasource/MediaSourceDemuxer.h
@@ -30,18 +30,18 @@ public:
   explicit MediaSourceDemuxer(AbstractThread* aAbstractMainThread);
 
   RefPtr<InitPromise> Init() override;
 
   bool HasTrackType(TrackInfo::TrackType aType) const override;
 
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
 
-  already_AddRefed<MediaTrackDemuxer> GetTrackDemuxer(TrackInfo::TrackType aType,
-                                                              uint32_t aTrackNumber) override;
+  already_AddRefed<MediaTrackDemuxer>
+  GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
 
   bool IsSeekable() const override;
 
   UniquePtr<EncryptionInfo> GetCrypto() override;
 
   bool ShouldComputeStartTime() const override { return false; }
 
   void NotifyDataArrived() override;
@@ -100,32 +100,34 @@ public:
   RefPtr<SeekPromise> Seek(const media::TimeUnit& aTime) override;
 
   RefPtr<SamplesPromise> GetSamples(int32_t aNumSamples = 1) override;
 
   void Reset() override;
 
   nsresult GetNextRandomAccessPoint(media::TimeUnit* aTime) override;
 
-  RefPtr<SkipAccessPointPromise> SkipToNextRandomAccessPoint(const media::TimeUnit& aTimeThreshold) override;
+  RefPtr<SkipAccessPointPromise>
+  SkipToNextRandomAccessPoint(const media::TimeUnit &aTimeThreshold) override;
 
   media::TimeIntervals GetBuffered() override;
 
   void BreakCycles() override;
 
   bool GetSamplesMayBlock() const override
   {
     return false;
   }
 
 private:
   RefPtr<SeekPromise> DoSeek(const media::TimeUnit& aTime);
   RefPtr<SamplesPromise> DoGetSamples(int32_t aNumSamples);
-  RefPtr<SkipAccessPointPromise> DoSkipToNextRandomAccessPoint(const media::TimeUnit& aTimeThreadshold);
-  already_AddRefed<MediaRawData> GetSample(MediaResult& aError);
+  RefPtr<SkipAccessPointPromise>
+  DoSkipToNextRandomAccessPoint(const media::TimeUnit &aTimeThreadshold);
+  already_AddRefed<MediaRawData> GetSample(MediaResult &aError);
   // Return the timestamp of the next keyframe after mLastSampleIndex.
   media::TimeUnit GetNextRandomAccessPoint();
 
   RefPtr<MediaSourceDemuxer> mParent;
   RefPtr<TrackBuffersManager> mManager;
   TrackInfo::TrackType mType;
   // Monitor protecting members below accessed from multiple threads.
   Monitor mMonitor;
--- a/dom/media/wave/WaveDemuxer.cpp
+++ b/dom/media/wave/WaveDemuxer.cpp
@@ -192,17 +192,18 @@ WAVTrackDemuxer::HeaderParserInit()
 
 bool
 WAVTrackDemuxer::FmtChunkParserInit()
 {
   RefPtr<MediaRawData> fmtChunk = GetFileHeader(FindFmtChunk());
   if (!fmtChunk) {
     return false;
   }
-  ByteReader fmtReader(fmtChunk->Data(), mHeaderParser.GiveHeader().ChunkSize());
+  ByteReader fmtReader(fmtChunk->Data(),
+                       mHeaderParser.GiveHeader().ChunkSize());
   mFmtParser.Parse(fmtReader);
   return true;
 }
 
 bool
 WAVTrackDemuxer::ListChunkParserInit(uint32_t aChunkSize)
 {
   uint32_t bytesRead = 0;
@@ -255,26 +256,30 @@ WAVTrackDemuxer::ListChunkParserInit(uin
 
     if (!IsUTF8(val)) {
       mHeaderParser.Reset();
       continue;
     }
 
     switch (id) {
       case 0x49415254:                // IART
-        mInfo->mTags.AppendElement(MetadataTag(NS_LITERAL_CSTRING("artist"), val));
+        mInfo->mTags.AppendElement(
+          MetadataTag(NS_LITERAL_CSTRING("artist"), val));
         break;
       case 0x49434d54:                // ICMT
-        mInfo->mTags.AppendElement(MetadataTag(NS_LITERAL_CSTRING("comments"), val));
+        mInfo->mTags.AppendElement(
+          MetadataTag(NS_LITERAL_CSTRING("comments"), val));
         break;
       case 0x49474e52:                // IGNR
-        mInfo->mTags.AppendElement(MetadataTag(NS_LITERAL_CSTRING("genre"), val));
+        mInfo->mTags.AppendElement(
+          MetadataTag(NS_LITERAL_CSTRING("genre"), val));
         break;
       case 0x494e414d:                // INAM
-        mInfo->mTags.AppendElement(MetadataTag(NS_LITERAL_CSTRING("name"), val));
+        mInfo->mTags.AppendElement(
+          MetadataTag(NS_LITERAL_CSTRING("name"), val));
         break;
     }
 
     mHeaderParser.Reset();
   }
   return true;
 }
 
@@ -352,17 +357,17 @@ WAVTrackDemuxer::GetSamples(int32_t aNum
     if (!datachunk) {
       break;
     }
     datachunks->mSamples.AppendElement(datachunk);
   }
 
   if (datachunks->mSamples.IsEmpty()) {
     return SamplesPromise::CreateAndReject(
-        NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);
+      NS_ERROR_DOM_MEDIA_END_OF_STREAM, __func__);
   }
 
   return SamplesPromise::CreateAndResolve(datachunks, __func__);
 }
 
 void
 WAVTrackDemuxer::Reset()
 {
@@ -425,19 +430,18 @@ WAVTrackDemuxer::Duration() const
 }
 
 TimeUnit
 WAVTrackDemuxer::Duration(int64_t aNumDataChunks) const
 {
   if (!mSamplesPerSecond || !mSamplesPerChunk) {
     return TimeUnit();
   }
-  const double usPerDataChunk = USECS_PER_S *
-                                static_cast<double>(mSamplesPerChunk) /
-                                mSamplesPerSecond;
+  const double usPerDataChunk =
+    USECS_PER_S * static_cast<double>(mSamplesPerChunk) / mSamplesPerSecond;
   return TimeUnit::FromMicroseconds(aNumDataChunks * usPerDataChunk);
 }
 
 TimeUnit
 WAVTrackDemuxer::DurationFromBytes(uint32_t aNumBytes) const
 {
   if (!mSamplesPerSecond || !mChannels || !mSampleFormat) {
     return TimeUnit();
@@ -511,19 +515,18 @@ WAVTrackDemuxer::GetNextChunk(const Medi
   RefPtr<MediaRawData> datachunk = new MediaRawData();
   datachunk->mOffset = aRange.mStart;
 
   nsAutoPtr<MediaRawDataWriter> chunkWriter(datachunk->CreateWriter());
   if (!chunkWriter->SetSize(aRange.Length())) {
     return nullptr;
   }
 
-  const uint32_t read = Read(chunkWriter->Data(),
-                             datachunk->mOffset,
-                             datachunk->Size());
+  const uint32_t read =
+    Read(chunkWriter->Data(), datachunk->mOffset, datachunk->Size());
 
   if (read != aRange.Length()) {
     return nullptr;
   }
 
   UpdateState(aRange);
   ++mNumParsedChunks;
   ++mChunkIndex;
@@ -556,19 +559,18 @@ WAVTrackDemuxer::GetFileHeader(const Med
   RefPtr<MediaRawData> fileHeader = new MediaRawData();
   fileHeader->mOffset = aRange.mStart;
 
   nsAutoPtr<MediaRawDataWriter> headerWriter(fileHeader->CreateWriter());
   if (!headerWriter->SetSize(aRange.Length())) {
     return nullptr;
   }
 
-  const uint32_t read = Read(headerWriter->Data(),
-                             fileHeader->mOffset,
-                             fileHeader->Size());
+  const uint32_t read =
+    Read(headerWriter->Data(), fileHeader->mOffset, fileHeader->Size());
 
   if (read != aRange.Length()) {
     return nullptr;
   }
 
   UpdateState(aRange);
 
   return fileHeader.forget();
@@ -752,25 +754,29 @@ bool
 HeaderParser::ChunkHeader::IsValid() const
 {
   return mPos >= CHUNK_HEAD_SIZE;
 }
 
 uint32_t
 HeaderParser::ChunkHeader::ChunkName() const
 {
-  return ((mRaw[0] << 24) | (mRaw[1] << 16) |
-          (mRaw[2] << 8 ) | (mRaw[3]));
+  return ((mRaw[0] << 24)
+          | (mRaw[1] << 16)
+          | (mRaw[2] << 8 )
+          | (mRaw[3]));
 }
 
 uint32_t
 HeaderParser::ChunkHeader::ChunkSize() const
 {
-  return ((mRaw[7] << 24) | (mRaw[6] << 16) |
-          (mRaw[5] << 8 ) | (mRaw[4]));
+  return ((mRaw[7] << 24)
+          | (mRaw[6] << 16)
+          | (mRaw[5] << 8 )
+          | (mRaw[4]));
 }
 
 void
 HeaderParser::ChunkHeader::Update(uint8_t c)
 {
   if (mPos < CHUNK_HEAD_SIZE) {
     mRaw[mPos++] = c;
   }
@@ -826,18 +832,20 @@ uint16_t
 FormatParser::FormatChunk::Channels() const
 {
   return (mRaw[3] << 8) | (mRaw[2]);
 }
 
 uint32_t
 FormatParser::FormatChunk::SampleRate() const
 {
-  return (mRaw[7] << 24) | (mRaw[6] << 16) |
-         (mRaw[5] << 8 ) | (mRaw[4]);
+  return (mRaw[7] << 24)
+         | (mRaw[6] << 16)
+         | (mRaw[5] << 8)
+         | (mRaw[4]);
 }
 
 uint16_t
 FormatParser::FormatChunk::FrameSize() const
 {
   return (mRaw[13] << 8) | (mRaw[12]);
 }
 
@@ -852,18 +860,18 @@ FormatParser::FormatChunk::ParseNext(uin
 {
   Update(c);
   return IsValid();
 }
 
 bool
 FormatParser::FormatChunk::IsValid() const
 {
-  return (FrameSize() == SampleRate() * Channels() / 8) &&
-         (mPos >= FMT_CHUNK_MIN_SIZE);
+  return (FrameSize() == SampleRate() * Channels() / 8)
+         && (mPos >= FMT_CHUNK_MIN_SIZE);
 }
 
 void
 FormatParser::FormatChunk::Update(uint8_t c)
 {
   if (mPos < FMT_CHUNK_MIN_SIZE) {
     mRaw[mPos++] = c;
   }
--- a/dom/media/wave/WaveDemuxer.h
+++ b/dom/media/wave/WaveDemuxer.h
@@ -25,47 +25,50 @@ static const uint8_t WAVE[4] = {'W', 'A'
 
 static const uint16_t RIFF_CHUNK_SIZE = 12;
 static const uint16_t CHUNK_HEAD_SIZE = 8;
 static const uint16_t FMT_CHUNK_MIN_SIZE = 16;
 static const uint16_t DATA_CHUNK_SIZE = 768;
 
 class WAVTrackDemuxer;
 
-class WAVDemuxer : public MediaDataDemuxer {
+class WAVDemuxer : public MediaDataDemuxer
+{
 public:
   // MediaDataDemuxer interface.
   explicit WAVDemuxer(MediaResource* aSource);
   RefPtr<InitPromise> Init() override;
   bool HasTrackType(TrackInfo::TrackType aType) const override;
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
   already_AddRefed<MediaTrackDemuxer> GetTrackDemuxer(
-      TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
+    TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
   bool IsSeekable() const override;
 
 private:
   // Synchronous Initialization.
   bool InitInternal();
 
   MediaResourceIndex mSource;
   RefPtr<WAVTrackDemuxer> mTrackDemuxer;
 };
 
-class RIFFParser {
+class RIFFParser
+{
 private:
   class RIFFHeader;
 public:
   const RIFFHeader& RiffHeader() const;
 
   uint32_t Parse(ByteReader& aReader);
 
   void Reset();
 
 private:
-  class RIFFHeader {
+  class RIFFHeader
+  {
   public:
     RIFFHeader();
     void Reset();
 
     bool IsValid() const;
     bool IsValid(int aPos) const;
 
     bool ParseNext(uint8_t c);
@@ -76,28 +79,30 @@ private:
     uint8_t mRaw[RIFF_CHUNK_SIZE];
 
     int mPos;
   };
 
   RIFFHeader mRiffHeader;
 };
 
-class HeaderParser {
+class HeaderParser
+{
 private:
   class ChunkHeader;
 public:
   const ChunkHeader& GiveHeader() const;
 
   uint32_t Parse(ByteReader& aReader);
 
   void Reset();
 
 private:
-  class ChunkHeader {
+  class ChunkHeader
+  {
   public:
     ChunkHeader();
     void Reset();
 
     bool IsValid() const;
 
     uint32_t ChunkName() const;
     uint32_t ChunkSize() const;
@@ -110,28 +115,30 @@ private:
     uint8_t mRaw[CHUNK_HEAD_SIZE];
 
     int mPos;
   };
 
   ChunkHeader mHeader;
 };
 
-class FormatParser {
+class FormatParser
+{
 private:
   class FormatChunk;
 public:
   const FormatChunk& FmtChunk() const;
 
   uint32_t Parse(ByteReader& aReader);
 
   void Reset();
 
 private:
-  class FormatChunk {
+  class FormatChunk
+  {
   public:
     FormatChunk();
     void Reset();
 
     uint16_t WaveFormat() const;
     uint16_t Channels() const;
     uint32_t SampleRate() const;
     uint16_t FrameSize() const;
@@ -146,38 +153,41 @@ private:
     uint8_t mRaw[FMT_CHUNK_MIN_SIZE];
 
     int mPos;
   };
 
   FormatChunk mFmtChunk;
 };
 
-class DataParser {
+class DataParser
+{
 private:
   class DataChunk;
 public:
   DataParser();
 
   const DataChunk& CurrentChunk() const;
 
   void Reset();
 
 private:
-  class DataChunk {
+  class DataChunk
+  {
   public:
     void Reset();
   private:
     int mPos; // To Check Alignment
   };
 
   DataChunk mChunk;
 };
 
-class WAVTrackDemuxer : public MediaTrackDemuxer {
+class WAVTrackDemuxer : public MediaTrackDemuxer
+{
 public:
   explicit WAVTrackDemuxer(MediaResourceIndex aSource);
 
   bool Init();
 
   int64_t StreamLength() const;
 
   media::TimeUnit Duration() const;
@@ -194,17 +204,17 @@ public:
   RefPtr<SamplesPromise> GetSamples(int32_t aNumSamples) override;
   void Reset() override;
   RefPtr<SkipAccessPointPromise> SkipToNextRandomAccessPoint(
     const media::TimeUnit& aTimeThreshold) override;
   int64_t GetResourceOffset() const override;
   media::TimeIntervals GetBuffered() override;
 
 private:
-  ~WAVTrackDemuxer() {}
+  ~WAVTrackDemuxer() { }
 
   media::TimeUnit FastSeek(const media::TimeUnit& aTime);
   media::TimeUnit ScanUntil(const media::TimeUnit& aTime);
 
   MediaByteRange FindNextChunk();
 
   MediaByteRange FindChunkHeader();
   MediaByteRange FindRIFFHeader();