Bug 1316211. P13 - replace use of MediaDecoderReader with MediaFormatReader. r=gerald
authorJW Wang <jwwang@mozilla.com>
Wed, 19 Jul 2017 17:01:32 +0800
changeset 418812 1a089f2a645bc03c979256a73e84416f97aae08d
parent 418811 a56cdce8ca54d7f54ed06d343d954949e8285070
child 418813 44cec0ee85fa5aa25ba2e3d69fd058ac60cba030
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1316211
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1316211. P13 - replace use of MediaDecoderReader with MediaFormatReader. r=gerald We will remove MediaDecoderReader in the future. MozReview-Commit-ID: BaCRXleKK5a
dom/media/DecoderTraits.cpp
dom/media/DecoderTraits.h
dom/media/MediaDecoder.cpp
dom/media/MediaDecoder.h
dom/media/MediaDecoderReaderWrapper.cpp
dom/media/MediaDecoderReaderWrapper.h
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
dom/media/MediaFormatReader.h
dom/media/fmp4/MP4Decoder.cpp
dom/media/mediasource/MediaSourceDecoder.cpp
dom/media/webaudio/MediaBufferDecoder.cpp
dom/media/webm/WebMDecoder.cpp
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -285,22 +285,22 @@ already_AddRefed<ChannelMediaDecoder>
 DecoderTraits::CreateDecoder(MediaDecoderInit& aInit,
                              DecoderDoctorDiagnostics* aDiagnostics)
 {
   MOZ_ASSERT(NS_IsMainThread());
   return InstantiateDecoder(aInit, aDiagnostics);
 }
 
 /* static */
-MediaDecoderReader*
+MediaFormatReader*
 DecoderTraits::CreateReader(const MediaContainerType& aType,
                             MediaDecoderReaderInit& aInit)
 {
   MOZ_ASSERT(NS_IsMainThread());
-  MediaDecoderReader* decoderReader = nullptr;
+  MediaFormatReader* decoderReader = nullptr;
 
   if (!aInit.mDecoder) {
     return decoderReader;
   }
 
   MediaResource* resource = aInit.mResource;
 
 #ifdef MOZ_FMP4
--- a/dom/media/DecoderTraits.h
+++ b/dom/media/DecoderTraits.h
@@ -16,17 +16,17 @@ namespace mozilla {
 
 class AbstractMediaDecoder;
 class ChannelMediaDecoder;
 class DecoderDoctorDiagnostics;
 class MediaContainerType;
 struct MediaDecoderInit;
 struct MediaDecoderReaderInit;
 class MediaDecoderOwner;
-class MediaDecoderReader;
+class MediaFormatReader;
 class MediaResource;
 
 enum CanPlayStatus {
   CANPLAY_NO,
   CANPLAY_MAYBE,
   CANPLAY_YES
 };
 
@@ -46,18 +46,18 @@ public:
   // Create a decoder for the given aType. Returns null if we
   // were unable to create the decoder.
   static already_AddRefed<ChannelMediaDecoder> CreateDecoder(
     MediaDecoderInit& aInit,
     DecoderDoctorDiagnostics* aDiagnostics);
 
   // Create a reader for thew given MIME type aType. Returns null
   // if we were unable to create the reader.
-  static MediaDecoderReader* CreateReader(const MediaContainerType& aType,
-                                          MediaDecoderReaderInit& aInit);
+  static MediaFormatReader* CreateReader(const MediaContainerType& aType,
+                                         MediaDecoderReaderInit& aInit);
 
   // Returns true if MIME type aType is supported in video documents,
   // or false otherwise. Not all platforms support all MIME types, and
   // vice versa.
   static bool IsSupportedInVideoDocument(const nsACString& aType);
 
   // Convenience function that returns false if MOZ_FMP4 is not defined,
   // otherwise defers to MP4Decoder::IsSupportedType().
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -5,16 +5,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "MediaDecoder.h"
 
 #include "AudioChannelService.h"
 #include "ImageContainer.h"
 #include "Layers.h"
 #include "MediaDecoderStateMachine.h"
+#include "MediaFormatReader.h"
 #include "MediaResource.h"
 #include "MediaShutdownManager.h"
 #include "VideoFrameContainer.h"
 #include "VideoUtils.h"
 #include "mozilla/AbstractThread.h"
 #include "mozilla/FloatingPoint.h"
 #include "mozilla/MathAlgorithms.h"
 #include "mozilla/Preferences.h"
@@ -1069,19 +1070,19 @@ MediaDecoder::GetCompositor()
 
 void
 MediaDecoder::NotifyCompositor()
 {
   RefPtr<KnowsCompositor> knowsCompositor = GetCompositor();
   if (knowsCompositor) {
     nsCOMPtr<nsIRunnable> r =
       NewRunnableMethod<already_AddRefed<KnowsCompositor>&&>(
-        "MediaDecoderReader::UpdateCompositor",
+        "MediaFormatReader::UpdateCompositor",
         mReader,
-        &MediaDecoderReader::UpdateCompositor,
+        &MediaFormatReader::UpdateCompositor,
         knowsCompositor.forget());
     mReader->OwnerThread()->Dispatch(r.forget(),
                                      AbstractThread::DontAssertDispatchSuccess);
   }
 }
 
 void
 MediaDecoder::SetElementVisibility(bool aIsDocumentVisible,
@@ -1380,19 +1381,19 @@ void MediaDecoder::AddSizeOfResources(Re
 }
 
 void
 MediaDecoder::NotifyDataArrivedInternal()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
   mReader->OwnerThread()->Dispatch(
-    NewRunnableMethod("MediaDecoderReader::NotifyDataArrived",
+    NewRunnableMethod("MediaFormatReader::NotifyDataArrived",
                       mReader.get(),
-                      &MediaDecoderReader::NotifyDataArrived));
+                      &MediaFormatReader::NotifyDataArrived));
 }
 
 void
 MediaDecoder::NotifyDataArrived()
 {
   NotifyDataArrivedInternal();
   DownloadProgressed();
 }
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -32,17 +32,17 @@
 #include "nsITimer.h"
 
 class nsIPrincipal;
 
 namespace mozilla {
 
 class AbstractThread;
 class VideoFrameContainer;
-class MediaDecoderReader;
+class MediaFormatReader;
 class MediaDecoderStateMachine;
 
 enum class MediaEventType : int8_t;
 enum class Visibility : uint8_t;
 
 // GetCurrentTime is defined in winbase.h as zero argument macro forwarding to
 // GetTickCount() and conflicts with MediaDecoder::GetCurrentTime implementation.
 #ifdef GetCurrentTime
@@ -509,17 +509,17 @@ protected:
 
   /******
    * The following member variables can be accessed from any thread.
    ******/
 
   // Media data resource.
   RefPtr<MediaResource> mResource;
 
-  RefPtr<MediaDecoderReader> mReader;
+  RefPtr<MediaFormatReader> mReader;
 
   // Amount of buffered data ahead of current time required to consider that
   // the next frame is available.
   // An arbitrary value of 250ms is used.
   static constexpr auto DEFAULT_NEXT_FRAME_AVAILABLE_BUFFERED =
     media::TimeUnit::FromMicroseconds(250000);
 
 private:
--- a/dom/media/MediaDecoderReaderWrapper.cpp
+++ b/dom/media/MediaDecoderReaderWrapper.cpp
@@ -1,21 +1,23 @@
 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * 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 "mozilla/MozPromise.h"
 #include "MediaDecoderReaderWrapper.h"
+#include "MediaFormatReader.h"
 
 namespace mozilla {
 
-MediaDecoderReaderWrapper::MediaDecoderReaderWrapper(AbstractThread* aOwnerThread,
-                                                     MediaDecoderReader* aReader)
+MediaDecoderReaderWrapper::MediaDecoderReaderWrapper(
+  AbstractThread* aOwnerThread,
+  MediaFormatReader* aReader)
   : mOwnerThread(aOwnerThread)
   , mReader(aReader)
   , mWatchManager(this, aReader->OwnerThread())
   , mDuration(aReader->OwnerThread(),
               NullableTimeUnit(),
               "MediaDecoderReaderWrapper::mDuration (Mirror)")
 {
   // Must support either heuristic buffering or WaitForData().
@@ -34,106 +36,121 @@ MediaDecoderReaderWrapper::StartTime() c
   return mStartTime.ref();
 }
 
 RefPtr<MediaDecoderReaderWrapper::MetadataPromise>
 MediaDecoderReaderWrapper::ReadMetadata()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(!mShutdown);
-  return InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
-                     &MediaDecoderReader::AsyncReadMetadata)
-         ->Then(mOwnerThread, __func__, this,
-                &MediaDecoderReaderWrapper::OnMetadataRead,
-                &MediaDecoderReaderWrapper::OnMetadataNotRead);
+  return InvokeAsync(mReader->OwnerThread(),
+                     mReader.get(),
+                     __func__,
+                     &MediaFormatReader::AsyncReadMetadata)
+    ->Then(mOwnerThread,
+           __func__,
+           this,
+           &MediaDecoderReaderWrapper::OnMetadataRead,
+           &MediaDecoderReaderWrapper::OnMetadataNotRead);
 }
 
 RefPtr<MediaDecoderReaderWrapper::AudioDataPromise>
 MediaDecoderReaderWrapper::RequestAudioData()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(!mShutdown);
 
   int64_t startTime = StartTime().ToMicroseconds();
-  return InvokeAsync(mReader->OwnerThread(), mReader.get(),
-                     __func__, &MediaDecoderReader::RequestAudioData)
-    ->Then(mOwnerThread, __func__,
-           [startTime] (RefPtr<AudioData> aAudio) {
+  return InvokeAsync(mReader->OwnerThread(),
+                     mReader.get(),
+                     __func__,
+                     &MediaFormatReader::RequestAudioData)
+    ->Then(mOwnerThread,
+           __func__,
+           [startTime](RefPtr<AudioData> aAudio) {
              aAudio->AdjustForStartTime(startTime);
              return AudioDataPromise::CreateAndResolve(aAudio.forget(), __func__);
            },
-           [] (const MediaResult& aError) {
+           [](const MediaResult& aError) {
              return AudioDataPromise::CreateAndReject(aError, __func__);
            });
 }
 
 RefPtr<MediaDecoderReaderWrapper::VideoDataPromise>
 MediaDecoderReaderWrapper::RequestVideoData(const media::TimeUnit& aTimeThreshold)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(!mShutdown);
 
   const auto threshold = aTimeThreshold > media::TimeUnit::Zero()
                          ? aTimeThreshold + StartTime()
                          : aTimeThreshold;
 
   int64_t startTime = StartTime().ToMicroseconds();
-  return InvokeAsync(
-    mReader->OwnerThread(), mReader.get(), __func__,
-    &MediaDecoderReader::RequestVideoData, threshold)
-  ->Then(mOwnerThread, __func__,
-         [startTime] (RefPtr<VideoData> aVideo) {
-           aVideo->AdjustForStartTime(startTime);
-           return VideoDataPromise::CreateAndResolve(aVideo.forget(), __func__);
-         },
-         [] (const MediaResult& aError) {
-           return VideoDataPromise::CreateAndReject(aError, __func__);
-         });
+  return InvokeAsync(mReader->OwnerThread(),
+                     mReader.get(),
+                     __func__,
+                     &MediaFormatReader::RequestVideoData,
+                     threshold)
+    ->Then(mOwnerThread,
+           __func__,
+           [startTime](RefPtr<VideoData> aVideo) {
+             aVideo->AdjustForStartTime(startTime);
+             return VideoDataPromise::CreateAndResolve(aVideo.forget(),
+                                                       __func__);
+           },
+           [](const MediaResult& aError) {
+             return VideoDataPromise::CreateAndReject(aError, __func__);
+           });
 }
 
 RefPtr<MediaDecoderReader::SeekPromise>
 MediaDecoderReaderWrapper::Seek(const SeekTarget& aTarget)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   SeekTarget adjustedTarget = aTarget;
   adjustedTarget.SetTime(adjustedTarget.GetTime() + StartTime());
-  return InvokeAsync(
-           mReader->OwnerThread(), mReader.get(), __func__,
-           &MediaDecoderReader::Seek,
-           Move(adjustedTarget));
+  return InvokeAsync(mReader->OwnerThread(),
+                     mReader.get(),
+                     __func__,
+                     &MediaFormatReader::Seek,
+                     Move(adjustedTarget));
 }
 
 RefPtr<MediaDecoderReaderWrapper::WaitForDataPromise>
 MediaDecoderReaderWrapper::WaitForData(MediaData::Type aType)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(mReader->IsWaitForDataSupported());
-  return InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
-                     &MediaDecoderReader::WaitForData, aType);
+  return InvokeAsync(mReader->OwnerThread(),
+                     mReader.get(),
+                     __func__,
+                     &MediaFormatReader::WaitForData,
+                     aType);
 }
 
 void
 MediaDecoderReaderWrapper::ReleaseResources()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   nsCOMPtr<nsIRunnable> r =
-    NewRunnableMethod("MediaDecoderReader::ReleaseResources",
+    NewRunnableMethod("MediaFormatReader::ReleaseResources",
                       mReader,
-                      &MediaDecoderReader::ReleaseResources);
+                      &MediaFormatReader::ReleaseResources);
   mReader->OwnerThread()->Dispatch(r.forget());
 }
 
 void
 MediaDecoderReaderWrapper::ResetDecode(TrackSet aTracks)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   nsCOMPtr<nsIRunnable> r =
-    NewRunnableMethod<TrackSet>("MediaDecoderReader::ResetDecode",
+    NewRunnableMethod<TrackSet>("MediaFormatReader::ResetDecode",
                                 mReader,
-                                &MediaDecoderReader::ResetDecode,
+                                &MediaFormatReader::ResetDecode,
                                 aTracks);
   mReader->OwnerThread()->Dispatch(r.forget());
 }
 
 RefPtr<ShutdownPromise>
 MediaDecoderReaderWrapper::Shutdown()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
@@ -167,19 +184,19 @@ MediaDecoderReaderWrapper::OnMetadataNot
   return MetadataPromise::CreateAndReject(aError, __func__);
 }
 
 void
 MediaDecoderReaderWrapper::SetVideoBlankDecode(bool aIsBlankDecode)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   nsCOMPtr<nsIRunnable> r =
-    NewRunnableMethod<bool>("MediaDecoderReader::SetVideoNullDecode",
+    NewRunnableMethod<bool>("MediaFormatReader::SetVideoNullDecode",
                             mReader,
-                            &MediaDecoderReader::SetVideoNullDecode,
+                            &MediaFormatReader::SetVideoNullDecode,
                             aIsBlankDecode);
   mReader->OwnerThread()->Dispatch(r.forget());
 }
 
 void
 MediaDecoderReaderWrapper::UpdateDuration()
 {
   MOZ_ASSERT(mReader->OwnerThread()->IsCurrentThreadIn());
--- a/dom/media/MediaDecoderReaderWrapper.h
+++ b/dom/media/MediaDecoderReaderWrapper.h
@@ -13,33 +13,33 @@
 #include "nsISupportsImpl.h"
 
 #include "MediaDecoderReader.h"
 #include "MediaEventSource.h"
 
 namespace mozilla {
 
 /**
- * A wrapper around MediaDecoderReader to offset the timestamps of Audio/Video
+ * A wrapper around MediaFormatReader to offset the timestamps of Audio/Video
  * samples by the start time to ensure MDSM can always assume zero start time.
  * It also adjusts the seek target passed to Seek() to ensure correct seek time
  * is passed to the underlying reader.
  */
 class MediaDecoderReaderWrapper {
   typedef MediaDecoderReader::MetadataPromise MetadataPromise;
   typedef MediaDecoderReader::AudioDataPromise AudioDataPromise;
   typedef MediaDecoderReader::VideoDataPromise VideoDataPromise;
   typedef MediaDecoderReader::SeekPromise SeekPromise;
   typedef MediaDecoderReader::WaitForDataPromise WaitForDataPromise;
   typedef MediaDecoderReader::TrackSet TrackSet;
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReaderWrapper);
 
 public:
   MediaDecoderReaderWrapper(AbstractThread* aOwnerThread,
-                            MediaDecoderReader* aReader);
+                            MediaFormatReader* aReader);
 
   media::TimeUnit StartTime() const;
   RefPtr<MetadataPromise> ReadMetadata();
 
   RefPtr<AudioDataPromise> RequestAudioData();
 
   RefPtr<VideoDataPromise>
   RequestVideoData(const media::TimeUnit& aTimeThreshold);
@@ -86,17 +86,17 @@ public:
 
 private:
   ~MediaDecoderReaderWrapper();
   RefPtr<MetadataPromise> OnMetadataRead(MetadataHolder&& aMetadata);
   RefPtr<MetadataPromise> OnMetadataNotRead(const MediaResult& aError);
   void UpdateDuration();
 
   const RefPtr<AbstractThread> mOwnerThread;
-  const RefPtr<MediaDecoderReader> mReader;
+  const RefPtr<MediaFormatReader> mReader;
 
   bool mShutdown = false;
   Maybe<media::TimeUnit> mStartTime;
 
   // State-watching manager.
   WatchManager<MediaDecoderReaderWrapper> mWatchManager;
 
   // Duration, mirrored from the state machine task queue.
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -2703,17 +2703,17 @@ ShutdownState::Enter()
 #define INIT_WATCHABLE(name, val) \
   name(val, "MediaDecoderStateMachine::" #name)
 #define INIT_MIRROR(name, val) \
   name(mTaskQueue, val, "MediaDecoderStateMachine::" #name " (Mirror)")
 #define INIT_CANONICAL(name, val) \
   name(mTaskQueue, val, "MediaDecoderStateMachine::" #name " (Canonical)")
 
 MediaDecoderStateMachine::MediaDecoderStateMachine(MediaDecoder* aDecoder,
-                                                   MediaDecoderReader* aReader) :
+                                                   MediaFormatReader* aReader) :
   mDecoderID(aDecoder),
   mAbstractMainThread(aDecoder->AbstractMainThread()),
   mFrameStats(&aDecoder->GetFrameStatistics()),
   mVideoFrameContainer(aDecoder->GetVideoFrameContainer()),
   mAudioChannel(aDecoder->GetAudioChannel()),
   mTaskQueue(new TaskQueue(
     GetMediaThreadPool(MediaThreadType::PLAYBACK),
     "MDSM::mTaskQueue", /* aSupportsTailDispatch = */ true)),
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -149,18 +149,17 @@ class MediaDecoderStateMachine
 {
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderStateMachine)
 
   using TrackSet = MediaDecoderReader::TrackSet;
 
 public:
   typedef MediaDecoderOwner::NextFrameStatus NextFrameStatus;
   typedef mozilla::layers::ImageContainer::FrameID FrameID;
-  MediaDecoderStateMachine(MediaDecoder* aDecoder,
-                           MediaDecoderReader* aReader);
+  MediaDecoderStateMachine(MediaDecoder* aDecoder, MediaFormatReader* aReader);
 
   nsresult Init(MediaDecoder* aDecoder);
 
   // Enumeration for the valid decoding states
   enum State
   {
     DECODER_STATE_DECODING_METADATA,
     DECODER_STATE_WAIT_FOR_CDM,
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -42,18 +42,19 @@ public:
   RefPtr<AudioDataPromise> RequestAudioData() override;
 
   RefPtr<MetadataPromise> AsyncReadMetadata() override;
 
   void ReadUpdatedMetadata(MediaInfo* aInfo) override;
 
   RefPtr<SeekPromise> Seek(const SeekTarget& aTarget) override;
 
+  void NotifyDataArrived() override;
+
 protected:
-  void NotifyDataArrived() override;
   void UpdateBuffered() override;
 
 public:
   // For Media Resource Management
   void ReleaseResources() override;
 
   nsresult ResetDecode(TrackSet aTracks) override;
 
--- a/dom/media/fmp4/MP4Decoder.cpp
+++ b/dom/media/fmp4/MP4Decoder.cpp
@@ -286,16 +286,14 @@ MP4Decoder::IsVideoAccelerated(layers::K
            });
 
   return promise.forget();
 }
 
 void
 MP4Decoder::GetMozDebugReaderData(nsACString& aString)
 {
-  // This is definitely a MediaFormatReader. See CreateStateMachine() above.
-  auto reader = static_cast<MediaFormatReader*>(mReader.get());
-  if (reader) {
-    reader->GetMozDebugReaderData(aString);
+  if (mReader) {
+    mReader->GetMozDebugReaderData(aString);
   }
 }
 
 } // namespace mozilla
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -244,19 +244,17 @@ MediaSourceDecoder::SetMediaSourceDurati
     SetExplicitDuration(PositiveInfinity<double>());
   }
 }
 
 void
 MediaSourceDecoder::GetMozDebugReaderData(nsACString& aString)
 {
   if (mReader && mDemuxer) {
-    // This is definitely a MediaFormatReader. See CreateStateMachine() above.
-    auto reader = static_cast<MediaFormatReader*>(mReader.get());
-    reader->GetMozDebugReaderData(aString);
+    mReader->GetMozDebugReaderData(aString);
     mDemuxer->GetMozDebugReaderData(aString);
   }
 }
 
 double
 MediaSourceDecoder::GetDuration()
 {
   MOZ_ASSERT(NS_IsMainThread());
--- a/dom/media/webaudio/MediaBufferDecoder.cpp
+++ b/dom/media/webaudio/MediaBufferDecoder.cpp
@@ -9,17 +9,17 @@
 #include "mozilla/dom/AudioContextBinding.h"
 #include "mozilla/dom/BaseAudioContextBinding.h"
 #include "mozilla/dom/DOMException.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/AbstractThread.h"
 #include <speex/speex_resampler.h>
 #include "nsXPCOMCIDInternal.h"
 #include "nsComponentManagerUtils.h"
-#include "MediaDecoderReader.h"
+#include "MediaFormatReader.h"
 #include "BufferMediaResource.h"
 #include "DecoderTraits.h"
 #include "AudioContext.h"
 #include "AudioBuffer.h"
 #include "MediaContainerType.h"
 #include "nsContentUtils.h"
 #include "nsIScriptObjectPrincipal.h"
 #include "nsIScriptError.h"
@@ -92,17 +92,21 @@ public:
     , mFirstFrameDecoded(false)
   {
     MOZ_ASSERT(aBuffer);
     MOZ_ASSERT(NS_IsMainThread());
   }
 
   NS_IMETHOD Run();
   bool CreateReader();
-  MediaDecoderReader* Reader() { MOZ_ASSERT(mDecoderReader); return mDecoderReader; }
+  MediaFormatReader* Reader()
+  {
+    MOZ_ASSERT(mDecoderReader);
+    return mDecoderReader;
+  }
 
 private:
   void ReportFailureOnMainThread(WebAudioDecodeJob::ErrorCode aErrorCode) {
     if (NS_IsMainThread()) {
       Cleanup();
       mDecodeJob.OnFailure(aErrorCode);
     } else {
       // Take extra care to cleanup on the main thread
@@ -123,31 +127,31 @@ private:
   void SampleNotDecoded(const MediaResult& aError);
   void FinishDecode();
   void AllocateBuffer();
   void CallbackTheResult();
 
   void Cleanup()
   {
     MOZ_ASSERT(NS_IsMainThread());
-    // MediaDecoderReader expects that BufferDecoder is alive.
-    // Destruct MediaDecoderReader first.
+    // MediaFormatReader expects that BufferDecoder is alive.
+    // Destruct MediaFormatReader first.
     mDecoderReader = nullptr;
     mBufferDecoder = nullptr;
     JS_free(nullptr, mBuffer);
   }
 
 private:
   MediaContainerType mContainerType;
   uint8_t* mBuffer;
   uint32_t mLength;
   WebAudioDecodeJob& mDecodeJob;
   PhaseEnum mPhase;
   RefPtr<BufferDecoder> mBufferDecoder;
-  RefPtr<MediaDecoderReader> mDecoderReader;
+  RefPtr<MediaFormatReader> mDecoderReader;
   MediaInfo mMediaInfo;
   MediaQueue<AudioData> mAudioQueue;
   RefPtr<AbstractThread> mMainThread;
   bool mFirstFrameDecoded;
 };
 
 NS_IMETHODIMP
 MediaDecodeTask::Run()
--- a/dom/media/webm/WebMDecoder.cpp
+++ b/dom/media/webm/WebMDecoder.cpp
@@ -66,17 +66,15 @@ WebMDecoder::IsSupportedType(const Media
     return false;
   }
   return true;
 }
 
 void
 WebMDecoder::GetMozDebugReaderData(nsACString& aString)
 {
-  // This is definitely a MediaFormatReader. See CreateStateMachine() above.
-  auto reader = static_cast<MediaFormatReader*>(mReader.get());
-  if (reader) {
-    reader->GetMozDebugReaderData(aString);
+  if (mReader) {
+    mReader->GetMozDebugReaderData(aString);
   }
 }
 
 } // namespace mozilla