Bug 1393346. P1 - virtualize IsTransportSeekable(). draft
authorJW Wang <jwwang@mozilla.com>
Thu, 24 Aug 2017 00:06:23 +0800
changeset 652639 9e7dd3329e506407a915502be6f6368c40cbc0d2
parent 651907 ce5951b5cfd266cb20a72cd545f2326e5d5a1358
child 652640 c96e79d377198b9b403ab14d5f67a48d3386638e
push id76104
push userjwwang@mozilla.com
push dateFri, 25 Aug 2017 02:02:31 +0000
bugs1393346
milestone57.0a1
Bug 1393346. P1 - virtualize IsTransportSeekable(). MozReview-Commit-ID: LIwEEbH3tBT
dom/media/ChannelMediaDecoder.cpp
dom/media/ChannelMediaDecoder.h
dom/media/MediaDecoder.cpp
dom/media/MediaDecoder.h
dom/media/hls/HLSDecoder.h
dom/media/mediasource/MediaSourceDecoder.h
--- a/dom/media/ChannelMediaDecoder.cpp
+++ b/dom/media/ChannelMediaDecoder.cpp
@@ -482,16 +482,23 @@ ChannelMediaDecoder::ShouldThrottleDownl
   if (!stats.mDownloadRateReliable || !stats.mPlaybackRateReliable) {
     return false;
   }
   uint32_t factor =
     std::max(2u, Preferences::GetUint("media.throttle-factor", 2));
   return stats.mDownloadRate > factor * stats.mPlaybackRate;
 }
 
+bool
+ChannelMediaDecoder::IsTransportSeekable()
+{
+  MOZ_ASSERT(NS_IsMainThread());
+  return mResource->IsTransportSeekable();
+}
+
 void
 ChannelMediaDecoder::SetLoadInBackground(bool aLoadInBackground)
 {
   MOZ_ASSERT(NS_IsMainThread());
   if (mResource) {
     mResource->SetLoadInBackground(aLoadInBackground);
   }
 }
--- a/dom/media/ChannelMediaDecoder.h
+++ b/dom/media/ChannelMediaDecoder.h
@@ -73,16 +73,17 @@ public:
 
   // Create a new decoder of the same type as this one.
   already_AddRefed<ChannelMediaDecoder> Clone(MediaDecoderInit& aInit);
 
   nsresult Load(nsIChannel* aChannel,
                 bool aIsPrivateBrowsing,
                 nsIStreamListener** aStreamListener);
 
+  bool IsTransportSeekable() override;
   void SetLoadInBackground(bool aLoadInBackground) override;
   void Suspend() override;
   void Resume() override;
 
 private:
   MediaResource* GetResource() const override final;
 
   // Create a new state machine to run this decoder.
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1163,23 +1163,16 @@ MediaDecoder::UpdateVideoDecodeMode()
 bool
 MediaDecoder::HasSuspendTaint() const
 {
   MOZ_ASSERT(NS_IsMainThread());
   return mHasSuspendTaint;
 }
 
 bool
-MediaDecoder::IsTransportSeekable()
-{
-  MOZ_ASSERT(NS_IsMainThread());
-  return GetResource()->IsTransportSeekable();
-}
-
-bool
 MediaDecoder::IsMediaSeekable()
 {
   MOZ_ASSERT(NS_IsMainThread());
   NS_ENSURE_TRUE(GetStateMachine(), false);
   return mMediaSeekable;
 }
 
 media::TimeIntervals
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -194,17 +194,17 @@ public:
   // Must be called before Shutdown().
   bool OwnerHasError() const;
 
   // Returns true if this media supports random seeking. False for example with
   // chained ogg files.
   bool IsMediaSeekable();
   // Returns true if seeking is supported on a transport level (e.g. the server
   // supports range requests, we are playing a file, etc.).
-  bool IsTransportSeekable();
+  virtual bool IsTransportSeekable() = 0;
 
   // Return the time ranges that can be seeked into.
   virtual media::TimeIntervals GetSeekable();
 
   // Set the end time of the media resource. When playback reaches
   // this point the media pauses. aTime is in seconds.
   virtual void SetFragmentEndTime(double aTime);
 
--- a/dom/media/hls/HLSDecoder.h
+++ b/dom/media/hls/HLSDecoder.h
@@ -32,16 +32,17 @@ public:
   static bool IsSupportedType(const MediaContainerType& aContainerType);
 
   nsresult Load(nsIChannel* aChannel);
 
   nsresult Play() override;
 
   void Pause() override;
 
+  bool IsTransportSeekable() override { return true; }
   void Suspend() override;
   void Resume() override;
 
 private:
   MediaResource* GetResource() const override final;
 
   MediaDecoderStateMachine* CreateStateMachine();
 
--- a/dom/media/mediasource/MediaSourceDecoder.h
+++ b/dom/media/mediasource/MediaSourceDecoder.h
@@ -44,16 +44,18 @@ public:
   void SetInitialDuration(int64_t aDuration);
   void SetMediaSourceDuration(double aDuration);
 
   MediaSourceDemuxer* GetDemuxer()
   {
     return mDemuxer;
   }
 
+  bool IsTransportSeekable() override { return true; }
+
   // Returns a string describing the state of the MediaSource internal
   // buffered data. Used for debugging purposes.
   void GetMozDebugReaderData(nsACString& aString) override;
 
   void AddSizeOfResources(ResourceSizes* aSizes) override;
 
   MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus() override;