Bug 1384836 - rename MediaDecoderReaderWrapper to ReaderProxy. r=kaku
authorJW Wang <jwwang@mozilla.com>
Thu, 27 Jul 2017 14:49:57 +0800
changeset 422648 a9cb889906077ef445d3ef14dd0978f33228cc0b
parent 422647 c7f314bfb6f12775e54b75e0915a56bb8e77825e
child 422649 343e5952d6fe4480dfecdd6ab1758d6e5a025283
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskaku
bugs1384836
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 1384836 - rename MediaDecoderReaderWrapper to ReaderProxy. r=kaku MozReview-Commit-ID: 7WeNblTnTCG
dom/media/MediaDecoderReaderWrapper.cpp
dom/media/MediaDecoderReaderWrapper.h
dom/media/MediaDecoderStateMachine.cpp
dom/media/MediaDecoderStateMachine.h
dom/media/ReaderProxy.cpp
dom/media/ReaderProxy.h
dom/media/moz.build
--- a/dom/media/MediaDecoderStateMachine.cpp
+++ b/dom/media/MediaDecoderStateMachine.cpp
@@ -39,21 +39,21 @@
 #include "nsTArray.h"
 #include "nsDeque.h"
 #include "prenv.h"
 
 #include "AudioSegment.h"
 #include "DOMMediaStream.h"
 #include "ImageContainer.h"
 #include "MediaDecoder.h"
-#include "MediaDecoderReaderWrapper.h"
 #include "MediaDecoderStateMachine.h"
 #include "MediaShutdownManager.h"
 #include "MediaPrefs.h"
 #include "MediaTimer.h"
+#include "ReaderProxy.h"
 #include "TimeUnits.h"
 #include "VideoSegment.h"
 #include "VideoUtils.h"
 #include "gfxPrefs.h"
 
 namespace mozilla {
 
 using namespace mozilla::dom;
@@ -253,17 +253,17 @@ protected:
     Observable,
     Suppressed
   };
 
   using Master = MediaDecoderStateMachine;
   explicit StateObject(Master* aPtr) : mMaster(aPtr) { }
   TaskQueue* OwnerThread() const { return mMaster->mTaskQueue; }
   MediaResource* Resource() const { return mMaster->mResource; }
-  MediaDecoderReaderWrapper* Reader() const { return mMaster->mReader; }
+  ReaderProxy* Reader() const { return mMaster->mReader; }
   const MediaInfo& Info() const { return mMaster->Info(); }
   bool IsExpectingMoreData() const
   {
     // We are expecting more data if either the resource states so, or if we
     // have a waiting promise pending (such as with non-MSE EME).
     return Resource()->IsExpectingMoreData()
            || mMaster->IsWaitingAudioData()
            || mMaster->IsWaitingVideoData();
@@ -995,17 +995,17 @@ public:
     return SeekingState::Enter(Move(aSeekJob), aVisibility);
   }
 
   void Exit() override
   {
     // Disconnect MediaDecoder.
     mSeekJob.RejectIfExists(__func__);
 
-    // Disconnect MediaDecoderReaderWrapper.
+    // Disconnect ReaderProxy.
     mSeekRequest.DisconnectIfExists();
 
     mWaitRequest.DisconnectIfExists();
   }
 
   void HandleAudioDecoded(AudioData* aAudio) override
   {
     MOZ_ASSERT(!mDoneAudioSeeking || !mDoneVideoSeeking,
@@ -2715,17 +2715,17 @@ MediaDecoderStateMachine::MediaDecoderSt
   mTaskQueue(new TaskQueue(
     GetMediaThreadPool(MediaThreadType::PLAYBACK),
     "MDSM::mTaskQueue", /* aSupportsTailDispatch = */ true)),
   mWatchManager(this, mTaskQueue),
   mDispatchedStateMachine(false),
   mDelayedScheduler(mTaskQueue),
   mCurrentFrameID(0),
   INIT_WATCHABLE(mObservedDuration, TimeUnit()),
-  mReader(new MediaDecoderReaderWrapper(mTaskQueue, aReader)),
+  mReader(new ReaderProxy(mTaskQueue, aReader)),
   mPlaybackRate(1.0),
   mAmpleAudioThreshold(detail::AMPLE_AUDIO_THRESHOLD),
   mAudioCaptured(false),
   mMinimizePreroll(aDecoder->GetMinimizePreroll()),
   mSentFirstFrameLoadedEvent(false),
   mVideoDecodeSuspended(false),
   mVideoDecodeSuspendTimer(mTaskQueue),
   mOutputStreamManager(new OutputStreamManager()),
--- a/dom/media/MediaDecoderStateMachine.h
+++ b/dom/media/MediaDecoderStateMachine.h
@@ -103,18 +103,18 @@ namespace mozilla {
 
 namespace media {
 class MediaSink;
 }
 
 class AbstractThread;
 class AudioSegment;
 class DecodedStream;
-class MediaDecoderReaderWrapper;
 class OutputStreamManager;
+class ReaderProxy;
 class TaskQueue;
 
 extern LazyLogModule gMediaDecoderLog;
 
 enum class MediaEventType : int8_t
 {
   PlaybackStarted,
   PlaybackStopped,
@@ -543,17 +543,17 @@ private:
   }
 
   // Media Fragment end time.
   media::TimeUnit mFragmentEndTime = media::TimeUnit::Invalid();
 
   // The media sink resource.  Used on the state machine thread.
   RefPtr<media::MediaSink> mMediaSink;
 
-  const RefPtr<MediaDecoderReaderWrapper> mReader;
+  const RefPtr<ReaderProxy> mReader;
 
   // The end time of the last audio frame that's been pushed onto the media sink
   // in microseconds. This will approximately be the end time
   // of the audio stream, unless another frame is pushed to the hardware.
   media::TimeUnit AudioEndTime() const;
 
   // The end time of the last rendered video frame that's been sent to
   // compositor.
rename from dom/media/MediaDecoderReaderWrapper.cpp
rename to dom/media/ReaderProxy.cpp
--- a/dom/media/MediaDecoderReaderWrapper.cpp
+++ b/dom/media/ReaderProxy.cpp
@@ -1,64 +1,64 @@
 /* -*- 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"
+#include "ReaderProxy.h"
+#include "TimeUnits.h"
 
 namespace mozilla {
 
-MediaDecoderReaderWrapper::MediaDecoderReaderWrapper(
-  AbstractThread* aOwnerThread,
-  MediaFormatReader* aReader)
+ReaderProxy::ReaderProxy(AbstractThread* aOwnerThread,
+                         MediaFormatReader* aReader)
   : mOwnerThread(aOwnerThread)
   , mReader(aReader)
   , mWatchManager(this, aReader->OwnerThread())
   , mDuration(aReader->OwnerThread(),
-              NullableTimeUnit(),
-              "MediaDecoderReaderWrapper::mDuration (Mirror)")
+              media::NullableTimeUnit(),
+              "ReaderProxy::mDuration (Mirror)")
 {
   // Must support either heuristic buffering or WaitForData().
   MOZ_ASSERT(mReader->UseBufferingHeuristics() ||
              mReader->IsWaitForDataSupported());
 }
 
-MediaDecoderReaderWrapper::~MediaDecoderReaderWrapper()
+ReaderProxy::~ReaderProxy()
 {}
 
 media::TimeUnit
-MediaDecoderReaderWrapper::StartTime() const
+ReaderProxy::StartTime() const
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(!mShutdown);
   return mStartTime.ref();
 }
 
-RefPtr<MediaDecoderReaderWrapper::MetadataPromise>
-MediaDecoderReaderWrapper::ReadMetadata()
+RefPtr<ReaderProxy::MetadataPromise>
+ReaderProxy::ReadMetadata()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(!mShutdown);
   return InvokeAsync(mReader->OwnerThread(),
                      mReader.get(),
                      __func__,
                      &MediaFormatReader::AsyncReadMetadata)
     ->Then(mOwnerThread,
            __func__,
            this,
-           &MediaDecoderReaderWrapper::OnMetadataRead,
-           &MediaDecoderReaderWrapper::OnMetadataNotRead);
+           &ReaderProxy::OnMetadataRead,
+           &ReaderProxy::OnMetadataNotRead);
 }
 
-RefPtr<MediaDecoderReaderWrapper::AudioDataPromise>
-MediaDecoderReaderWrapper::RequestAudioData()
+RefPtr<ReaderProxy::AudioDataPromise>
+ReaderProxy::RequestAudioData()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(!mShutdown);
 
   int64_t startTime = StartTime().ToMicroseconds();
   return InvokeAsync(mReader->OwnerThread(),
                      mReader.get(),
                      __func__,
@@ -69,18 +69,18 @@ MediaDecoderReaderWrapper::RequestAudioD
              aAudio->AdjustForStartTime(startTime);
              return AudioDataPromise::CreateAndResolve(aAudio.forget(), __func__);
            },
            [](const MediaResult& aError) {
              return AudioDataPromise::CreateAndReject(aError, __func__);
            });
 }
 
-RefPtr<MediaDecoderReaderWrapper::VideoDataPromise>
-MediaDecoderReaderWrapper::RequestVideoData(const media::TimeUnit& aTimeThreshold)
+RefPtr<ReaderProxy::VideoDataPromise>
+ReaderProxy::RequestVideoData(const media::TimeUnit& aTimeThreshold)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(!mShutdown);
 
   const auto threshold = aTimeThreshold > media::TimeUnit::Zero()
                          ? aTimeThreshold + StartTime()
                          : aTimeThreshold;
 
@@ -97,127 +97,125 @@ MediaDecoderReaderWrapper::RequestVideoD
              return VideoDataPromise::CreateAndResolve(aVideo.forget(),
                                                        __func__);
            },
            [](const MediaResult& aError) {
              return VideoDataPromise::CreateAndReject(aError, __func__);
            });
 }
 
-RefPtr<MediaDecoderReaderWrapper::SeekPromise>
-MediaDecoderReaderWrapper::Seek(const SeekTarget& aTarget)
+RefPtr<ReaderProxy::SeekPromise>
+ReaderProxy::Seek(const SeekTarget& aTarget)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   SeekTarget adjustedTarget = aTarget;
   adjustedTarget.SetTime(adjustedTarget.GetTime() + StartTime());
   return InvokeAsync(mReader->OwnerThread(),
                      mReader.get(),
                      __func__,
                      &MediaFormatReader::Seek,
                      Move(adjustedTarget));
 }
 
-RefPtr<MediaDecoderReaderWrapper::WaitForDataPromise>
-MediaDecoderReaderWrapper::WaitForData(MediaData::Type aType)
+RefPtr<ReaderProxy::WaitForDataPromise>
+ReaderProxy::WaitForData(MediaData::Type aType)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   MOZ_ASSERT(mReader->IsWaitForDataSupported());
   return InvokeAsync(mReader->OwnerThread(),
                      mReader.get(),
                      __func__,
                      &MediaFormatReader::WaitForData,
                      aType);
 }
 
 void
-MediaDecoderReaderWrapper::ReleaseResources()
+ReaderProxy::ReleaseResources()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   nsCOMPtr<nsIRunnable> r =
     NewRunnableMethod("MediaFormatReader::ReleaseResources",
                       mReader,
                       &MediaFormatReader::ReleaseResources);
   mReader->OwnerThread()->Dispatch(r.forget());
 }
 
 void
-MediaDecoderReaderWrapper::ResetDecode(TrackSet aTracks)
+ReaderProxy::ResetDecode(TrackSet aTracks)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   nsCOMPtr<nsIRunnable> r =
     NewRunnableMethod<TrackSet>("MediaFormatReader::ResetDecode",
                                 mReader,
                                 &MediaFormatReader::ResetDecode,
                                 aTracks);
   mReader->OwnerThread()->Dispatch(r.forget());
 }
 
 RefPtr<ShutdownPromise>
-MediaDecoderReaderWrapper::Shutdown()
+ReaderProxy::Shutdown()
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   mShutdown = true;
-  RefPtr<MediaDecoderReaderWrapper> self = this;
+  RefPtr<ReaderProxy> self = this;
   return InvokeAsync(mReader->OwnerThread(), __func__, [self]() {
     self->mDuration.DisconnectIfConnected();
     self->mWatchManager.Shutdown();
     return self->mReader->Shutdown();
   });
 }
 
-RefPtr<MediaDecoderReaderWrapper::MetadataPromise>
-MediaDecoderReaderWrapper::OnMetadataRead(MetadataHolder&& aMetadata)
+RefPtr<ReaderProxy::MetadataPromise>
+ReaderProxy::OnMetadataRead(MetadataHolder&& aMetadata)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   if (mShutdown) {
     return MetadataPromise::CreateAndReject(
       NS_ERROR_DOM_MEDIA_ABORT_ERR, __func__);
   }
 
   if (mStartTime.isNothing()) {
     mStartTime.emplace(aMetadata.mInfo->mStartTime);
   }
   return MetadataPromise::CreateAndResolve(Move(aMetadata), __func__);
 }
 
-RefPtr<MediaDecoderReaderWrapper::MetadataPromise>
-MediaDecoderReaderWrapper::OnMetadataNotRead(const MediaResult& aError)
+RefPtr<ReaderProxy::MetadataPromise>
+ReaderProxy::OnMetadataNotRead(const MediaResult& aError)
 {
   return MetadataPromise::CreateAndReject(aError, __func__);
 }
 
 void
-MediaDecoderReaderWrapper::SetVideoBlankDecode(bool aIsBlankDecode)
+ReaderProxy::SetVideoBlankDecode(bool aIsBlankDecode)
 {
   MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
   nsCOMPtr<nsIRunnable> r =
     NewRunnableMethod<bool>("MediaFormatReader::SetVideoNullDecode",
                             mReader,
                             &MediaFormatReader::SetVideoNullDecode,
                             aIsBlankDecode);
   mReader->OwnerThread()->Dispatch(r.forget());
 }
 
 void
-MediaDecoderReaderWrapper::UpdateDuration()
+ReaderProxy::UpdateDuration()
 {
   MOZ_ASSERT(mReader->OwnerThread()->IsCurrentThreadIn());
   mReader->UpdateDuration(mDuration.Ref().ref());
 }
 
 void
-MediaDecoderReaderWrapper::SetCanonicalDuration(
+ReaderProxy::SetCanonicalDuration(
   AbstractCanonical<media::NullableTimeUnit>* aCanonical)
 {
   using DurationT = AbstractCanonical<media::NullableTimeUnit>;
-  RefPtr<MediaDecoderReaderWrapper> self = this;
+  RefPtr<ReaderProxy> self = this;
   RefPtr<DurationT> canonical = aCanonical;
   nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
-    "MediaDecoderReaderWrapper::SetCanonicalDuration",
-    [this, self, canonical]() {
+    "ReaderProxy::SetCanonicalDuration", [this, self, canonical]() {
       mDuration.Connect(canonical);
-      mWatchManager.Watch(mDuration,
-                          &MediaDecoderReaderWrapper::UpdateDuration);
+      mWatchManager.Watch(mDuration, &ReaderProxy::UpdateDuration);
     });
   mReader->OwnerThread()->Dispatch(r.forget());
 }
 
 } // namespace mozilla
rename from dom/media/MediaDecoderReaderWrapper.h
rename to dom/media/ReaderProxy.h
--- a/dom/media/MediaDecoderReaderWrapper.h
+++ b/dom/media/ReaderProxy.h
@@ -1,16 +1,16 @@
 /* -*- 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/. */
 
-#ifndef MediaDecoderReaderWrapper_h_
-#define MediaDecoderReaderWrapper_h_
+#ifndef ReaderProxy_h_
+#define ReaderProxy_h_
 
 #include "mozilla/AbstractThread.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/Variant.h"
 #include "nsISupportsImpl.h"
 
 #include "MediaEventSource.h"
 #include "MediaFormatReader.h"
@@ -18,28 +18,28 @@
 namespace mozilla {
 
 /**
  * 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 {
+class ReaderProxy
+{
   using MetadataPromise = MediaFormatReader::MetadataPromise;
   using AudioDataPromise = MediaFormatReader::AudioDataPromise;
   using VideoDataPromise = MediaFormatReader::VideoDataPromise;
   using SeekPromise = MediaFormatReader::SeekPromise;
   using WaitForDataPromise = MediaFormatReader::WaitForDataPromise;
   using TrackSet = MediaFormatReader::TrackSet;
-  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(MediaDecoderReaderWrapper);
+  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(ReaderProxy);
 
 public:
-  MediaDecoderReaderWrapper(AbstractThread* aOwnerThread,
-                            MediaFormatReader* aReader);
+  ReaderProxy(AbstractThread* aOwnerThread, MediaFormatReader* aReader);
 
   media::TimeUnit StartTime() const;
   RefPtr<MetadataPromise> ReadMetadata();
 
   RefPtr<AudioDataPromise> RequestAudioData();
 
   RefPtr<VideoDataPromise>
   RequestVideoData(const media::TimeUnit& aTimeThreshold);
@@ -80,29 +80,29 @@ public:
   void SetCDMProxy(CDMProxy* aProxy) { mReader->SetCDMProxy(aProxy); }
 
   void SetVideoBlankDecode(bool aIsBlankDecode);
 
   void SetCanonicalDuration(
     AbstractCanonical<media::NullableTimeUnit>* aCanonical);
 
 private:
-  ~MediaDecoderReaderWrapper();
+  ~ReaderProxy();
   RefPtr<MetadataPromise> OnMetadataRead(MetadataHolder&& aMetadata);
   RefPtr<MetadataPromise> OnMetadataNotRead(const MediaResult& aError);
   void UpdateDuration();
 
   const RefPtr<AbstractThread> mOwnerThread;
   const RefPtr<MediaFormatReader> mReader;
 
   bool mShutdown = false;
   Maybe<media::TimeUnit> mStartTime;
 
   // State-watching manager.
-  WatchManager<MediaDecoderReaderWrapper> mWatchManager;
+  WatchManager<ReaderProxy> mWatchManager;
 
   // Duration, mirrored from the state machine task queue.
   Mirror<media::NullableTimeUnit> mDuration;
 };
 
 } // namespace mozilla
 
-#endif // MediaDecoderReaderWrapper_h_
+#endif // ReaderProxy_h_
--- a/dom/media/moz.build
+++ b/dom/media/moz.build
@@ -218,17 +218,16 @@ UNIFIED_SOURCES += [
     'FileBlockCache.cpp',
     'GetUserMediaRequest.cpp',
     'GraphDriver.cpp',
     'Latency.cpp',
     'MediaCache.cpp',
     'MediaContainerType.cpp',
     'MediaData.cpp',
     'MediaDecoder.cpp',
-    'MediaDecoderReaderWrapper.cpp',
     'MediaDecoderStateMachine.cpp',
     'MediaDeviceInfo.cpp',
     'MediaDevices.cpp',
     'MediaFormatReader.cpp',
     'MediaInfo.cpp',
     'MediaManager.cpp',
     'MediaMIMETypes.cpp',
     'MediaPrefs.cpp',
@@ -240,16 +239,17 @@ UNIFIED_SOURCES += [
     'MediaStreamListener.cpp',
     'MediaStreamTrack.cpp',
     'MediaStreamVideoSink.cpp',
     'MediaTimer.cpp',
     'MediaTrack.cpp',
     'MediaTrackList.cpp',
     'MemoryBlockCache.cpp',
     'QueueObject.cpp',
+    'ReaderProxy.cpp',
     'SeekJob.cpp',
     'StreamTracks.cpp',
     'TextTrack.cpp',
     'TextTrackCue.cpp',
     'TextTrackCueList.cpp',
     'TextTrackList.cpp',
     'TextTrackRegion.cpp',
     'TrackUnionStream.cpp',