Bug 1316211. P15 - remove MDR from the base class of MFR. r=gerald
authorJW Wang <jwwang@mozilla.com>
Wed, 19 Jul 2017 22:18:37 +0800
changeset 418814 e7032affc21d55147373d0b1fc166dda98497502
parent 418813 44cec0ee85fa5aa25ba2e3d69fd058ac60cba030
child 418815 29999b34e728334b5b83f5b5a0909c03bdc168ee
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. P15 - remove MDR from the base class of MFR. r=gerald MozReview-Commit-ID: Jf5pCxkhexg
dom/media/ADTSDecoder.cpp
dom/media/DecoderTraits.cpp
dom/media/DecoderTraits.h
dom/media/MediaDecoderReader.cpp
dom/media/MediaDecoderReader.h
dom/media/MediaFormatReader.cpp
dom/media/MediaFormatReader.h
dom/media/flac/FlacDecoder.cpp
dom/media/fmp4/MP4Decoder.cpp
dom/media/hls/HLSDecoder.cpp
dom/media/mediasource/MediaSourceDecoder.cpp
dom/media/mp3/MP3Decoder.cpp
dom/media/ogg/OggDecoder.cpp
dom/media/wave/WaveDecoder.cpp
dom/media/webaudio/MediaBufferDecoder.cpp
dom/media/webm/WebMDecoder.cpp
--- a/dom/media/ADTSDecoder.cpp
+++ b/dom/media/ADTSDecoder.cpp
@@ -20,17 +20,17 @@ ADTSDecoder::Clone(MediaDecoderInit& aIn
     return nullptr;
 
   return new ADTSDecoder(aInit);
 }
 
 MediaDecoderStateMachine*
 ADTSDecoder::CreateStateMachine()
 {
-  MediaDecoderReaderInit init(this);
+  MediaFormatReaderInit init(this);
   init.mCrashHelper = GetOwner()->CreateGMPCrashHelper();
   mReader = new MediaFormatReader(init, new ADTSDemuxer(mResource));
   return new MediaDecoderStateMachine(this, mReader);
 }
 
 /* static */ bool
 ADTSDecoder::IsEnabled()
 {
--- a/dom/media/DecoderTraits.cpp
+++ b/dom/media/DecoderTraits.cpp
@@ -287,17 +287,17 @@ DecoderTraits::CreateDecoder(MediaDecode
 {
   MOZ_ASSERT(NS_IsMainThread());
   return InstantiateDecoder(aInit, aDiagnostics);
 }
 
 /* static */
 MediaFormatReader*
 DecoderTraits::CreateReader(const MediaContainerType& aType,
-                            MediaDecoderReaderInit& aInit)
+                            MediaFormatReaderInit& aInit)
 {
   MOZ_ASSERT(NS_IsMainThread());
   MediaFormatReader* decoderReader = nullptr;
 
   if (!aInit.mDecoder) {
     return decoderReader;
   }
 
--- a/dom/media/DecoderTraits.h
+++ b/dom/media/DecoderTraits.h
@@ -14,17 +14,17 @@ class nsACString;
 
 namespace mozilla {
 
 class AbstractMediaDecoder;
 class ChannelMediaDecoder;
 class DecoderDoctorDiagnostics;
 class MediaContainerType;
 struct MediaDecoderInit;
-struct MediaDecoderReaderInit;
+struct MediaFormatReaderInit;
 class MediaDecoderOwner;
 class MediaFormatReader;
 class MediaResource;
 
 enum CanPlayStatus {
   CANPLAY_NO,
   CANPLAY_MAYBE,
   CANPLAY_YES
@@ -47,17 +47,17 @@ public:
   // 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 MediaFormatReader* CreateReader(const MediaContainerType& aType,
-                                         MediaDecoderReaderInit& aInit);
+                                         MediaFormatReaderInit& 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/MediaDecoderReader.cpp
+++ b/dom/media/MediaDecoderReader.cpp
@@ -32,17 +32,17 @@ extern LazyLogModule gMediaDecoderLog;
 #undef FMT
 #undef DECODER_LOG
 #undef DECODER_WARN
 
 #define FMT(x, ...) "Decoder=%p " x, mDecoder, ##__VA_ARGS__
 #define DECODER_LOG(...) MOZ_LOG(gMediaDecoderLog, LogLevel::Debug,   (FMT(__VA_ARGS__)))
 #define DECODER_WARN(...) NS_WARNING(nsPrintfCString(FMT(__VA_ARGS__)).get())
 
-MediaDecoderReader::MediaDecoderReader(MediaDecoderReaderInit& aInit)
+MediaDecoderReader::MediaDecoderReader()
 {
   MOZ_COUNT_CTOR(MediaDecoderReader);
   MOZ_ASSERT(NS_IsMainThread());
 }
 
 MediaDecoderReader::~MediaDecoderReader()
 {
   MOZ_COUNT_DTOR(MediaDecoderReader);
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -24,44 +24,30 @@
 namespace mozilla {
 
 class CDMProxy;
 class GMPCrashHelper;
 class MediaDecoderReader;
 class TaskQueue;
 class VideoFrameContainer;
 
-struct MOZ_STACK_CLASS MediaDecoderReaderInit
-{
-  AbstractMediaDecoder* const mDecoder;
-  MediaResource* mResource = nullptr;
-  VideoFrameContainer* mVideoFrameContainer = nullptr;
-  already_AddRefed<layers::KnowsCompositor> mKnowsCompositor;
-  already_AddRefed<GMPCrashHelper> mCrashHelper;
-
-  explicit MediaDecoderReaderInit(AbstractMediaDecoder* aDecoder)
-    : mDecoder(aDecoder)
-  {
-  }
-};
-
 // Encapsulates the decoding and reading of media data. Reading can either
 // synchronous and done on the calling "decode" thread, or asynchronous and
 // performed on a background thread, with the result being returned by
 // callback.
 // Unless otherwise specified, methods and fields of this class can only
 // be accessed on the decode task queue.
 class MediaDecoderReader
 {
 public:
   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReader)
 
   // The caller must ensure that Shutdown() is called before aDecoder is
   // destroyed.
-  explicit MediaDecoderReader(MediaDecoderReaderInit& aInit);
+  MediaDecoderReader();
 
 protected:
   virtual ~MediaDecoderReader();
 };
 
 } // namespace mozilla
 
 #endif
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1088,20 +1088,19 @@ MediaFormatReader::DemuxerProxy::NotifyD
     }
     if (data->mVideoDemuxer) {
       data->mVideoDemuxer->UpdateBuffered();
     }
     return NotifyDataArrivedPromise::CreateAndResolve(true, __func__);
   });
 }
 
-MediaFormatReader::MediaFormatReader(MediaDecoderReaderInit& aInit,
+MediaFormatReader::MediaFormatReader(MediaFormatReaderInit& aInit,
                                      MediaDataDemuxer* aDemuxer)
-  : MediaDecoderReader(aInit)
-  , mTaskQueue(new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK),
+  : mTaskQueue(new TaskQueue(GetMediaThreadPool(MediaThreadType::PLAYBACK),
                              "MediaFormatReader::mTaskQueue",
                              /* aSupportsTailDispatch = */ true))
   , mAudio(this, MediaData::AUDIO_DATA, MediaPrefs::MaxAudioDecodeError())
   , mVideo(this, MediaData::VIDEO_DATA, MediaPrefs::MaxVideoDecodeError())
   , mDemuxer(new DemuxerProxy(aDemuxer))
   , mDemuxerInitDone(false)
   , mPendingNotifyDataArrived(false)
   , mLastReportedNumDecodedFrames(0)
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -9,24 +9,25 @@
 
 #include "mozilla/Atomics.h"
 #include "mozilla/Maybe.h"
 #include "mozilla/TaskQueue.h"
 #include "mozilla/Mutex.h"
 
 #include "MediaEventSource.h"
 #include "MediaDataDemuxer.h"
-#include "MediaDecoderReader.h"
 #include "MediaPrefs.h"
 #include "nsAutoPtr.h"
 #include "PDMFactory.h"
 
 namespace mozilla {
 
 class CDMProxy;
+class GMPCrashHelper;
+class VideoFrameContainer;
 
 struct WaitForDataRejectValue
 {
   enum Reason
   {
     SHUTDOWN,
     CANCELED
   };
@@ -62,22 +63,38 @@ struct SeekRejectValue
 };
 
 struct MetadataHolder
 {
   UniquePtr<MediaInfo> mInfo;
   UniquePtr<MetadataTags> mTags;
 };
 
-class MediaFormatReader final : public MediaDecoderReader
+struct MOZ_STACK_CLASS MediaFormatReaderInit
+{
+  AbstractMediaDecoder* const mDecoder;
+  MediaResource* mResource = nullptr;
+  VideoFrameContainer* mVideoFrameContainer = nullptr;
+  already_AddRefed<layers::KnowsCompositor> mKnowsCompositor;
+  already_AddRefed<GMPCrashHelper> mCrashHelper;
+
+  explicit MediaFormatReaderInit(AbstractMediaDecoder* aDecoder)
+    : mDecoder(aDecoder)
+  {
+  }
+};
+
+class MediaFormatReader final
 {
   static const bool IsExclusive = true;
   typedef TrackInfo::TrackType TrackType;
   typedef MozPromise<bool, MediaResult, IsExclusive> NotifyDataArrivedPromise;
 
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaFormatReader)
+
 public:
   using TrackSet = EnumSet<TrackInfo::TrackType>;
   using MetadataPromise = MozPromise<MetadataHolder, MediaResult, IsExclusive>;
 
   template<typename Type>
   using DataPromise = MozPromise<RefPtr<Type>, MediaResult, IsExclusive>;
   using AudioDataPromise = DataPromise<AudioData>;
   using VideoDataPromise = DataPromise<VideoData>;
@@ -86,19 +103,17 @@ public:
 
   // Note that, conceptually, WaitForData makes sense in a non-exclusive sense.
   // But in the current architecture it's only ever used exclusively (by MDSM),
   // so we mark it that way to verify our assumptions. If you have a use-case
   // for multiple WaitForData consumers, feel free to flip the exclusivity here.
   using WaitForDataPromise =
     MozPromise<MediaData::Type, WaitForDataRejectValue, IsExclusive>;
 
-  MediaFormatReader(MediaDecoderReaderInit& aInit, MediaDataDemuxer* aDemuxer);
-
-  virtual ~MediaFormatReader();
+  MediaFormatReader(MediaFormatReaderInit& aInit, MediaDataDemuxer* aDemuxer);
 
   // Initializes the reader, returns NS_OK on success, or NS_ERROR_FAILURE
   // on failure.
   nsresult Init();
 
   size_t SizeOfVideoQueueInFrames();
   size_t SizeOfAudioQueueInFrames();
 
@@ -233,16 +248,18 @@ public:
     return mOnEncrypted;
   }
 
   MediaEventSource<void>& OnWaitingForKey() { return mOnWaitingForKey; }
 
   MediaEventSource<MediaResult>& OnDecodeWarning() { return mOnDecodeWarning; }
 
 private:
+  ~MediaFormatReader();
+
   bool HasVideo() const { return mVideo.mTrackDemuxer; }
   bool HasAudio() const { return mAudio.mTrackDemuxer; }
 
   bool IsWaitingOnCDMResource();
 
   bool InitDemuxer();
   // Notify the track demuxers that new data has been received.
   void NotifyTrackDemuxers();
--- a/dom/media/flac/FlacDecoder.cpp
+++ b/dom/media/flac/FlacDecoder.cpp
@@ -21,17 +21,17 @@ FlacDecoder::Clone(MediaDecoderInit& aIn
   }
 
   return new FlacDecoder(aInit);
 }
 
 MediaDecoderStateMachine*
 FlacDecoder::CreateStateMachine()
 {
-  MediaDecoderReaderInit init(this);
+  MediaFormatReaderInit init(this);
   init.mCrashHelper = GetOwner()->CreateGMPCrashHelper();
   mReader = new MediaFormatReader(init, new FlacDemuxer(mResource));
   return new MediaDecoderStateMachine(this, mReader);
 }
 
 /* static */ bool
 FlacDecoder::IsEnabled()
 {
--- a/dom/media/fmp4/MP4Decoder.cpp
+++ b/dom/media/fmp4/MP4Decoder.cpp
@@ -27,17 +27,17 @@ namespace mozilla {
 
 MP4Decoder::MP4Decoder(MediaDecoderInit& aInit)
   : ChannelMediaDecoder(aInit)
 {
 }
 
 MediaDecoderStateMachine* MP4Decoder::CreateStateMachine()
 {
-  MediaDecoderReaderInit init(this);
+  MediaFormatReaderInit init(this);
   init.mVideoFrameContainer = GetVideoFrameContainer();
   init.mKnowsCompositor = GetCompositor();
   init.mCrashHelper = GetOwner()->CreateGMPCrashHelper();
   mReader = new MediaFormatReader(init, new MP4Demuxer(mResource));
   return new MediaDecoderStateMachine(this, mReader);
 }
 
 static bool
--- a/dom/media/hls/HLSDecoder.cpp
+++ b/dom/media/hls/HLSDecoder.cpp
@@ -23,17 +23,17 @@ MediaDecoderStateMachine*
 HLSDecoder::CreateStateMachine()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
   MediaResource* resource = GetResource();
   MOZ_ASSERT(resource);
   auto resourceWrapper = static_cast<HLSResource*>(resource)->GetResourceWrapper();
   MOZ_ASSERT(resourceWrapper);
-  MediaDecoderReaderInit init(this);
+  MediaFormatReaderInit init(this);
   init.mVideoFrameContainer = GetVideoFrameContainer();
   init.mKnowsCompositor = GetCompositor();
   init.mCrashHelper = GetOwner()->CreateGMPCrashHelper();
   mReader =
     new MediaFormatReader(init, new HLSDemuxer(resourceWrapper->GetPlayerId()));
 
   return new MediaDecoderStateMachine(this, mReader);
 }
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -34,17 +34,17 @@ MediaSourceDecoder::MediaSourceDecoder(M
   mExplicitDuration.Set(Some(UnspecifiedNaN<double>()));
 }
 
 MediaDecoderStateMachine*
 MediaSourceDecoder::CreateStateMachine()
 {
   MOZ_ASSERT(NS_IsMainThread());
   mDemuxer = new MediaSourceDemuxer(AbstractMainThread());
-  MediaDecoderReaderInit init(this);
+  MediaFormatReaderInit init(this);
   init.mVideoFrameContainer = GetVideoFrameContainer();
   init.mKnowsCompositor = GetCompositor();
   init.mCrashHelper = GetOwner()->CreateGMPCrashHelper();
   mReader = new MediaFormatReader(init, mDemuxer);
   return new MediaDecoderStateMachine(this, mReader);
 }
 
 nsresult
--- a/dom/media/mp3/MP3Decoder.cpp
+++ b/dom/media/mp3/MP3Decoder.cpp
@@ -21,17 +21,17 @@ MP3Decoder::Clone(MediaDecoderInit& aIni
   if (!IsEnabled()) {
     return nullptr;
   }
   return new MP3Decoder(aInit);
 }
 
 MediaDecoderStateMachine*
 MP3Decoder::CreateStateMachine() {
-  MediaDecoderReaderInit init(this);
+  MediaFormatReaderInit init(this);
   init.mCrashHelper = GetOwner()->CreateGMPCrashHelper();
   mReader = new MediaFormatReader(init, new MP3Demuxer(mResource));
   return new MediaDecoderStateMachine(this, mReader);
 }
 
 /* static */
 bool
 MP3Decoder::IsEnabled() {
--- a/dom/media/ogg/OggDecoder.cpp
+++ b/dom/media/ogg/OggDecoder.cpp
@@ -11,17 +11,17 @@
 #include "OggDemuxer.h"
 #include "OggDecoder.h"
 
 namespace mozilla {
 
 MediaDecoderStateMachine* OggDecoder::CreateStateMachine()
 {
   RefPtr<OggDemuxer> demuxer = new OggDemuxer(mResource);
-  MediaDecoderReaderInit init(this);
+  MediaFormatReaderInit init(this);
   init.mVideoFrameContainer = GetVideoFrameContainer();
   init.mKnowsCompositor = GetCompositor();
   init.mCrashHelper = GetOwner()->CreateGMPCrashHelper();
   mReader = new MediaFormatReader(init, demuxer);
   demuxer->SetChainingEvents(&mReader->TimedMetadataProducer(),
                              &mReader->MediaNotSeekableProducer());
   return new MediaDecoderStateMachine(this, mReader);
 }
--- a/dom/media/wave/WaveDecoder.cpp
+++ b/dom/media/wave/WaveDecoder.cpp
@@ -17,17 +17,17 @@ ChannelMediaDecoder*
 WaveDecoder::Clone(MediaDecoderInit& aInit)
 {
   return new WaveDecoder(aInit);
 }
 
 MediaDecoderStateMachine*
 WaveDecoder::CreateStateMachine()
 {
-  MediaDecoderReaderInit init(this);
+  MediaFormatReaderInit init(this);
   init.mCrashHelper = GetOwner()->CreateGMPCrashHelper();
   mReader = new MediaFormatReader(init, new WAVDemuxer(mResource));
   return new MediaDecoderStateMachine(this, mReader);
 }
 
 /* static */ bool
 WaveDecoder::IsSupportedType(const MediaContainerType& aContainerType)
 {
--- a/dom/media/webaudio/MediaBufferDecoder.cpp
+++ b/dom/media/webaudio/MediaBufferDecoder.cpp
@@ -192,17 +192,17 @@ MediaDecodeTask::CreateReader()
   MOZ_ASSERT(!mBufferDecoder);
   mMainThread =
     mDecodeJob.mContext->GetOwnerGlobal()->AbstractMainThreadFor(TaskCategory::Other);
   mBufferDecoder = new BufferDecoder(resource, mMainThread);
 
   // If you change this list to add support for new decoders, please consider
   // updating HTMLMediaElement::CreateDecoder as well.
 
-  MediaDecoderReaderInit init(mBufferDecoder);
+  MediaFormatReaderInit init(mBufferDecoder);
   init.mResource = resource;
   mDecoderReader = DecoderTraits::CreateReader(mContainerType, init);
 
   if (!mDecoderReader) {
     return false;
   }
 
   nsresult rv = mDecoderReader->Init();
--- a/dom/media/webm/WebMDecoder.cpp
+++ b/dom/media/webm/WebMDecoder.cpp
@@ -13,17 +13,17 @@
 #include "WebMDemuxer.h"
 #include "WebMDecoder.h"
 #include "VideoUtils.h"
 
 namespace mozilla {
 
 MediaDecoderStateMachine* WebMDecoder::CreateStateMachine()
 {
-  MediaDecoderReaderInit init(this);
+  MediaFormatReaderInit init(this);
   init.mVideoFrameContainer = GetVideoFrameContainer();
   init.mKnowsCompositor = GetCompositor();
   init.mCrashHelper = GetOwner()->CreateGMPCrashHelper();
   mReader = new MediaFormatReader(init, new WebMDemuxer(mResource));
   return new MediaDecoderStateMachine(this, mReader);
 }
 
 /* static */