Bug 1393386. P2 - remove MediaDecoder::GetResource(). draft
authorJW Wang <jwwang@mozilla.com>
Thu, 24 Aug 2017 18:10:31 +0800
changeset 654639 b3d51ee17d672c3baff64ea404979263f5f2a709
parent 654638 babf4f70bfe57e315c484209b43d553e4273b2f7
child 654641 704ac308b4c696a1581969aadc9d73d766d75a11
push id76625
push userjwwang@mozilla.com
push dateTue, 29 Aug 2017 02:36:30 +0000
bugs1393386
milestone57.0a1
Bug 1393386. P2 - remove MediaDecoder::GetResource(). MozReview-Commit-ID: 7OfkJthwfoM
dom/media/ChannelMediaDecoder.cpp
dom/media/ChannelMediaDecoder.h
dom/media/MediaDecoder.h
dom/media/hls/HLSDecoder.cpp
dom/media/hls/HLSDecoder.h
dom/media/mediasource/MediaSourceDecoder.cpp
dom/media/mediasource/MediaSourceDecoder.h
--- a/dom/media/ChannelMediaDecoder.cpp
+++ b/dom/media/ChannelMediaDecoder.cpp
@@ -187,22 +187,16 @@ ChannelMediaDecoder::Clone(MediaDecoderI
   nsresult rv = decoder->Load(mResource);
   if (NS_FAILED(rv)) {
     decoder->Shutdown();
     return nullptr;
   }
   return decoder.forget();
 }
 
-MediaResource*
-ChannelMediaDecoder::GetResource() const
-{
-  return mResource;
-}
-
 MediaDecoderStateMachine* ChannelMediaDecoder::CreateStateMachine()
 {
   MOZ_ASSERT(NS_IsMainThread());
   MediaFormatReaderInit init;
   init.mVideoFrameContainer = GetVideoFrameContainer();
   init.mKnowsCompositor = GetCompositor();
   init.mCrashHelper = GetOwner()->CreateGMPCrashHelper();
   init.mFrameStats = mFrameStats;
--- a/dom/media/ChannelMediaDecoder.h
+++ b/dom/media/ChannelMediaDecoder.h
@@ -81,17 +81,16 @@ public:
   void AddSizeOfResources(ResourceSizes* aSizes) override;
   already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override;
   bool IsTransportSeekable() override;
   void SetLoadInBackground(bool aLoadInBackground) override;
   void Suspend() override;
   void Resume() override;
 
 private:
-  MediaResource* GetResource() const override final;
   void PinForSeek() override;
   void UnpinForSeek() override;
 
   // Create a new state machine to run this decoder.
   MediaDecoderStateMachine* CreateStateMachine();
 
   nsresult OpenResource(nsIStreamListener** aStreamListener);
   nsresult Load(BaseMediaResource* aOriginal);
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -476,25 +476,16 @@ protected:
 
   // 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:
-  // Get the current MediaResource being used.
-  // Note: The MediaResource is refcounted, but it outlives the MediaDecoder,
-  // so it's OK to use the reference returned by this function without
-  // refcounting, *unless* you need to store and use the reference after the
-  // MediaDecoder has been destroyed. You might need to do this if you're
-  // wrapping the MediaResource in some kind of byte stream interface to be
-  // passed to a platform decoder.
-  virtual MediaResource* GetResource() const = 0;
-
   // Ensures our media resource has been pinned.
   virtual void PinForSeek() = 0;
 
   // Ensures our media resource has been unpinned.
   virtual void UnpinForSeek() = 0;
 
   nsCString GetDebugInfo();
 
--- a/dom/media/hls/HLSDecoder.cpp
+++ b/dom/media/hls/HLSDecoder.cpp
@@ -14,22 +14,16 @@
 #include "MediaDecoderStateMachine.h"
 #include "MediaFormatReader.h"
 #include "MediaPrefs.h"
 #include "MediaShutdownManager.h"
 #include "nsNetUtil.h"
 
 namespace mozilla {
 
-MediaResource*
-HLSDecoder::GetResource() const
-{
-  return mResource;
-}
-
 void
 HLSDecoder::Shutdown()
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (mResource) {
     mResource->Detach();
   }
   MediaDecoder::Shutdown();
--- a/dom/media/hls/HLSDecoder.h
+++ b/dom/media/hls/HLSDecoder.h
@@ -39,17 +39,16 @@ public:
 
   void AddSizeOfResources(ResourceSizes* aSizes) override;
   already_AddRefed<nsIPrincipal> GetCurrentPrincipal() override;
   bool IsTransportSeekable() override { return true; }
   void Suspend() override;
   void Resume() override;
 
 private:
-  MediaResource* GetResource() const override final;
   void PinForSeek() override {}
   void UnpinForSeek() override {}
 
   MediaDecoderStateMachine* CreateStateMachine();
 
   bool CanPlayThroughImpl() override final
   {
     // TODO: We don't know how to estimate 'canplaythrough' for this decoder.
--- a/dom/media/mediasource/MediaSourceDecoder.cpp
+++ b/dom/media/mediasource/MediaSourceDecoder.cpp
@@ -28,22 +28,16 @@ namespace mozilla {
 MediaSourceDecoder::MediaSourceDecoder(MediaDecoderInit& aInit)
   : MediaDecoder(aInit)
   , mMediaSource(nullptr)
   , mEnded(false)
 {
   mExplicitDuration.emplace(UnspecifiedNaN<double>());
 }
 
-MediaResource*
-MediaSourceDecoder::GetResource() const
-{
-  return mResource;
-}
-
 MediaDecoderStateMachine*
 MediaSourceDecoder::CreateStateMachine()
 {
   MOZ_ASSERT(NS_IsMainThread());
   mDemuxer = new MediaSourceDemuxer(AbstractMainThread());
   MediaFormatReaderInit init;
   init.mVideoFrameContainer = GetVideoFrameContainer();
   init.mKnowsCompositor = GetCompositor();
--- a/dom/media/mediasource/MediaSourceDecoder.h
+++ b/dom/media/mediasource/MediaSourceDecoder.h
@@ -61,17 +61,16 @@ public:
 
   MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus() override;
 
   bool IsMSE() const override { return true; }
 
   void NotifyInitDataArrived();
 
 private:
-  MediaResource* GetResource() const override final;
   void PinForSeek() override {}
   void UnpinForSeek() override {}
   MediaDecoderStateMachine* CreateStateMachine();
   void DoSetMediaSourceDuration(double aDuration);
   media::TimeInterval ClampIntervalToEnd(const media::TimeInterval& aInterval);
   bool CanPlayThroughImpl() override;
   bool IsLiveStream() override final { return !mEnded; }