Bug 1217714 - Remove some unused functions from MediaDecoderReader. r=jya.
authorJW Wang <jwwang@mozilla.com>
Mon, 26 Oct 2015 14:10:29 +0800
changeset 304646 8d3d0a2c6bbcf38a9d2a435ad912f3f3cfc94d66
parent 304645 2f1393553a489873366cee901b16f3440256ac50
child 304647 57714b421d53bd505d2a9d49be2a9f61c76973bc
push id1001
push userraliiev@mozilla.com
push dateMon, 18 Jan 2016 19:06:03 +0000
treeherdermozilla-release@8b89261f3ac4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjya
bugs1217714
milestone44.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 1217714 - Remove some unused functions from MediaDecoderReader. r=jya.
dom/media/MediaDecoderReader.h
dom/media/MediaFormatReader.cpp
dom/media/MediaFormatReader.h
dom/media/android/AndroidMediaReader.h
dom/media/apple/AppleMP3Reader.cpp
dom/media/apple/AppleMP3Reader.h
dom/media/directshow/DirectShowReader.cpp
dom/media/directshow/DirectShowReader.h
dom/media/gstreamer/GStreamerReader.h
dom/media/ogg/OggReader.h
dom/media/omx/MediaCodecReader.h
dom/media/omx/MediaOmxCommonReader.h
dom/media/omx/MediaOmxReader.h
dom/media/raw/RawReader.h
dom/media/wave/WaveReader.h
dom/media/webm/WebMReader.h
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -160,19 +160,16 @@ public:
   // By default, the reader return the decoded data. Some readers support
   // retuning demuxed data.
   virtual bool IsDemuxOnlySupported() const { return false; }
 
   // Configure the reader to return demuxed or decoded data
   // upon calls to Request{Audio,Video}Data.
   virtual void SetDemuxOnly(bool /*aDemuxedOnly*/) {}
 
-  virtual bool HasAudio() = 0;
-  virtual bool HasVideo() = 0;
-
   // The default implementation of AsyncReadMetadata is implemented in terms of
   // synchronous ReadMetadata() calls. Implementations may also
   // override AsyncReadMetadata to create a more proper async implementation.
   virtual RefPtr<MetadataPromise> AsyncReadMetadata();
 
   // Fills aInfo with the latest cached data required to present the media,
   // ReadUpdatedMetadata will always be called once ReadMetadata has succeeded.
   virtual void ReadUpdatedMetadata(MediaInfo* aInfo) {}
@@ -250,31 +247,19 @@ public:
   void NotifyDataArrived(const media::Interval<int64_t>& aInfo)
   {
     MOZ_ASSERT(OnTaskQueue());
     NS_ENSURE_TRUE_VOID(!mShutdown);
     NotifyDataArrivedInternal(aInfo.Length(), aInfo.mStart);
     UpdateBuffered();
   }
 
-  // Notify the reader that data from the resource was evicted
-  // (MediaSource only).
-  virtual void NotifyDataRemoved() {}
-
   virtual MediaQueue<AudioData>& AudioQueue() { return mAudioQueue; }
   virtual MediaQueue<VideoData>& VideoQueue() { return mVideoQueue; }
 
-  // Returns a pointer to the decoder.
-  AbstractMediaDecoder* GetDecoder()
-  {
-    return mDecoder;
-  }
-
-  MediaInfo GetMediaInfo() { return mInfo; }
-
   AbstractCanonical<media::TimeIntervals>* CanonicalBuffered()
   {
     return &mBuffered;
   }
 
   // Indicates if the media is seekable.
   // ReadMetada should be called before calling this method.
   virtual bool IsMediaSeekable() = 0;
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1539,21 +1539,18 @@ MediaFormatReader::NotifyDemuxer(uint32_
   MOZ_ASSERT(OnTaskQueue());
 
   LOGV("aLength=%u, aOffset=%lld", aLength, aOffset);
   if (mShutdown || !mDemuxer ||
       (!mDemuxerInitDone && !mDemuxerInitRequest.Exists())) {
     return;
   }
 
-  if (aLength || aOffset) {
-    mDemuxer->NotifyDataArrived();
-  } else {
-    mDemuxer->NotifyDataRemoved();
-  }
+  mDemuxer->NotifyDataArrived();
+
   if (!mInitDone) {
     return;
   }
   if (HasVideo()) {
     mVideo.mReceivedNewData = true;
     ScheduleUpdate(TrackType::kVideoTrack);
   }
   if (HasAudio()) {
@@ -1566,24 +1563,16 @@ void
 MediaFormatReader::NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset)
 {
   MOZ_ASSERT(OnTaskQueue());
   MOZ_ASSERT(aLength);
 
   NotifyDemuxer(aLength, aOffset);
 }
 
-void
-MediaFormatReader::NotifyDataRemoved()
-{
-  MOZ_ASSERT(OnTaskQueue());
-
-  NotifyDemuxer(0, 0);
-}
-
 bool
 MediaFormatReader::ForceZeroStartTime() const
 {
   return !mDemuxer->ShouldComputeStartTime();
 }
 
 layers::ImageContainer*
 MediaFormatReader::GetImageContainer()
--- a/dom/media/MediaFormatReader.h
+++ b/dom/media/MediaFormatReader.h
@@ -37,43 +37,32 @@ public:
   size_t SizeOfVideoQueueInFrames() override;
   size_t SizeOfAudioQueueInFrames() override;
 
   RefPtr<VideoDataPromise>
   RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThreshold) override;
 
   RefPtr<AudioDataPromise> RequestAudioData() override;
 
-  bool HasVideo() override
-  {
-    return mVideo.mTrackDemuxer;
-  }
-
-  bool HasAudio() override
-  {
-    return mAudio.mTrackDemuxer;
-  }
-
   RefPtr<MetadataPromise> AsyncReadMetadata() override;
 
   void ReadUpdatedMetadata(MediaInfo* aInfo) override;
 
   RefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aUnused) override;
 
   bool IsMediaSeekable() override
   {
     return mSeekable;
   }
 
 protected:
   void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) override;
+
 public:
-  void NotifyDataRemoved() override;
-
   media::TimeIntervals GetBuffered() override;
 
   virtual bool ForceZeroStartTime() const override;
 
   // For Media Resource Management
   void ReleaseMediaResources() override;
 
   nsresult ResetDecode() override;
@@ -108,16 +97,19 @@ public:
     return mTrackDemuxersMayBlock;
   }
 
 #ifdef MOZ_EME
   void SetCDMProxy(CDMProxy* aProxy) override;
 #endif
 
 private:
+  bool HasVideo() { return mVideo.mTrackDemuxer; }
+  bool HasAudio() { return mAudio.mTrackDemuxer; }
+
   bool IsWaitingOnCDMResource();
 
   bool InitDemuxer();
   // Notify the demuxer that new data has been received.
   // The next queued task calling GetBuffered() is guaranteed to have up to date
   // buffered ranges.
   void NotifyDemuxer(uint32_t aLength, int64_t aOffset);
   void ReturnOutput(MediaData* aData, TrackType aTrack);
--- a/dom/media/android/AndroidMediaReader.h
+++ b/dom/media/android/AndroidMediaReader.h
@@ -43,26 +43,16 @@ public:
                      const nsACString& aContentType);
 
   virtual nsresult ResetDecode();
 
   virtual bool DecodeAudioData();
   virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
                                 int64_t aTimeThreshold);
 
-  virtual bool HasAudio()
-  {
-    return mHasAudio;
-  }
-
-  virtual bool HasVideo()
-  {
-    return mHasVideo;
-  }
-
   virtual bool IsMediaSeekable()
   {
     // not used
     return true;
   }
 
   virtual nsresult ReadMetadata(MediaInfo* aInfo,
                                 MetadataTags** aTags);
--- a/dom/media/apple/AppleMP3Reader.cpp
+++ b/dom/media/apple/AppleMP3Reader.cpp
@@ -298,31 +298,16 @@ AppleMP3Reader::DecodeAudioData()
 bool
 AppleMP3Reader::DecodeVideoFrame(bool &aKeyframeSkip,
                                  int64_t aTimeThreshold)
 {
   MOZ_ASSERT(OnTaskQueue());
   return false;
 }
 
-
-bool
-AppleMP3Reader::HasAudio()
-{
-  MOZ_ASSERT(OnTaskQueue());
-  return mStreamReady;
-}
-
-bool
-AppleMP3Reader::HasVideo()
-{
-  MOZ_ASSERT(OnTaskQueue());
-  return false;
-}
-
 bool
 AppleMP3Reader::IsMediaSeekable()
 {
   // not used
   return true;
 }
 
 /*
--- a/dom/media/apple/AppleMP3Reader.h
+++ b/dom/media/apple/AppleMP3Reader.h
@@ -23,19 +23,16 @@ public:
   virtual nsresult Init() override;
 
   nsresult PushDataToDemuxer();
 
   virtual bool DecodeAudioData() override;
   virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
                                 int64_t aTimeThreshold) override;
 
-  virtual bool HasAudio() override;
-  virtual bool HasVideo() override;
-
   virtual nsresult ReadMetadata(MediaInfo* aInfo,
                                 MetadataTags** aTags) override;
 
   virtual RefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aEndTime) override;
 
   void AudioSampleCallback(UInt32 aNumBytes,
                            UInt32 aNumPackets,
--- a/dom/media/directshow/DirectShowReader.cpp
+++ b/dom/media/directshow/DirectShowReader.cpp
@@ -336,30 +336,16 @@ DirectShowReader::DecodeAudioData()
 bool
 DirectShowReader::DecodeVideoFrame(bool &aKeyframeSkip,
                                    int64_t aTimeThreshold)
 {
   MOZ_ASSERT(OnTaskQueue());
   return false;
 }
 
-bool
-DirectShowReader::HasAudio()
-{
-  MOZ_ASSERT(OnTaskQueue());
-  return true;
-}
-
-bool
-DirectShowReader::HasVideo()
-{
-  MOZ_ASSERT(OnTaskQueue());
-  return false;
-}
-
 RefPtr<MediaDecoderReader::SeekPromise>
 DirectShowReader::Seek(int64_t aTargetUs, int64_t aEndTime)
 {
   nsresult res = SeekInternal(aTargetUs);
   if (NS_FAILED(res)) {
     return SeekPromise::CreateAndReject(res, __func__);
   } else {
     return SeekPromise::CreateAndResolve(aTargetUs, __func__);
--- a/dom/media/directshow/DirectShowReader.h
+++ b/dom/media/directshow/DirectShowReader.h
@@ -42,19 +42,16 @@ public:
   DirectShowReader(AbstractMediaDecoder* aDecoder);
 
   virtual ~DirectShowReader();
 
   bool DecodeAudioData() override;
   bool DecodeVideoFrame(bool &aKeyframeSkip,
                         int64_t aTimeThreshold) override;
 
-  bool HasAudio() override;
-  bool HasVideo() override;
-
   nsresult ReadMetadata(MediaInfo* aInfo,
                         MetadataTags** aTags) override;
 
   RefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aEndTime) override;
 
 protected:
   void NotifyDataArrivedInternal(uint32_t aLength,
--- a/dom/media/gstreamer/GStreamerReader.h
+++ b/dom/media/gstreamer/GStreamerReader.h
@@ -51,31 +51,23 @@ public:
   virtual RefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aEndTime) override;
   virtual media::TimeIntervals GetBuffered() override;
 
 protected:
   virtual void NotifyDataArrivedInternal(uint32_t aLength,
                                          int64_t aOffset) override;
 public:
-
-  virtual bool HasAudio() override {
-    return mInfo.HasAudio();
-  }
-
-  virtual bool HasVideo() override {
-    return mInfo.HasVideo();
-  }
-
   layers::ImageContainer* GetImageContainer() { return mDecoder->GetImageContainer(); }
 
   virtual bool IsMediaSeekable() override;
 
 private:
-
+  bool HasAudio() { return mInfo.HasAudio(); }
+  bool HasVideo() { return mInfo.HasVideo(); }
   void ReadAndPushData(guint aLength);
   RefPtr<layers::PlanarYCbCrImage> GetImageFromBuffer(GstBuffer* aBuffer);
   void CopyIntoImageBuffer(GstBuffer *aBuffer, GstBuffer** aOutBuffer, RefPtr<layers::PlanarYCbCrImage> &image);
   GstCaps* BuildAudioSinkCaps();
   void InstallPadCallbacks();
 
 #if GST_VERSION_MAJOR >= 1
   void ImageDataFromVideoFrame(GstVideoFrame *aFrame, layers::PlanarYCbCrImage::Data *aData);
--- a/dom/media/ogg/OggReader.h
+++ b/dom/media/ogg/OggReader.h
@@ -55,34 +55,34 @@ public:
   virtual bool DecodeAudioData() override;
 
   // If the Theora granulepos has not been captured, it may read several packets
   // until one with a granulepos has been captured, to ensure that all packets
   // read have valid time info.
   virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
                                 int64_t aTimeThreshold) override;
 
-  virtual bool HasAudio() override {
-    return (mVorbisState != 0 && mVorbisState->mActive) ||
-           (mOpusState != 0 && mOpusState->mActive);
-  }
-
-  virtual bool HasVideo() override {
-    return mTheoraState != 0 && mTheoraState->mActive;
-  }
-
   virtual nsresult ReadMetadata(MediaInfo* aInfo,
                                 MetadataTags** aTags) override;
   virtual RefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aEndTime) override;
   virtual media::TimeIntervals GetBuffered() override;
 
   virtual bool IsMediaSeekable() override;
 
 private:
+  bool HasAudio() {
+    return (mVorbisState != 0 && mVorbisState->mActive) ||
+           (mOpusState != 0 && mOpusState->mActive);
+  }
+
+  bool HasVideo() {
+    return mTheoraState != 0 && mTheoraState->mActive;
+  }
+
   // TODO: DEPRECATED. This uses synchronous decoding.
   // Stores the presentation time of the first frame we'd be able to play if
   // we started playback at the current position. Returns the first video
   // frame, if we have video.
   VideoData* FindStartTime(int64_t& aOutStartTime);
   AudioData* SyncDecodeToFirstAudioData();
   VideoData* SyncDecodeToFirstVideoData();
 
--- a/dom/media/omx/MediaCodecReader.h
+++ b/dom/media/omx/MediaCodecReader.h
@@ -81,19 +81,16 @@ public:
   // Disptach a DecodeVideoFrameTask to decode video data.
   virtual RefPtr<VideoDataPromise>
   RequestVideoData(bool aSkipToNextKeyframe,
                    int64_t aTimeThreshold) override;
 
   // Disptach a DecodeAduioDataTask to decode video data.
   virtual RefPtr<AudioDataPromise> RequestAudioData() override;
 
-  virtual bool HasAudio();
-  virtual bool HasVideo();
-
   virtual RefPtr<MediaDecoderReader::MetadataPromise> AsyncReadMetadata() override;
 
   // Moves the decode head to aTime microseconds. aStartTime and aEndTime
   // denote the start and end times of the media in usecs, and aCurrentTime
   // is the current playback position in microseconds.
   virtual RefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aEndTime) override;
 
@@ -176,16 +173,18 @@ protected:
   android::sp<android::MediaExtractor> mExtractor;
 
   MozPromiseHolder<MediaDecoderReader::MetadataPromise> mMetadataPromise;
   // XXX Remove after bug 1168008 land.
   MozPromiseRequestHolder<MediaResourcePromise> mMediaResourceRequest;
   MozPromiseHolder<MediaResourcePromise> mMediaResourcePromise;
 
 private:
+  virtual bool HasAudio() override;
+  virtual bool HasVideo() override;
 
   // An intermediary class that can be managed by android::sp<T>.
   // Redirect codecReserved() and codecCanceled() to MediaCodecReader.
   class VideoResourceListener : public android::MediaCodecProxy::CodecResourceListener
   {
   public:
     VideoResourceListener(MediaCodecReader* aReader);
     ~VideoResourceListener();
--- a/dom/media/omx/MediaOmxCommonReader.h
+++ b/dom/media/omx/MediaOmxCommonReader.h
@@ -44,13 +44,17 @@ public:
 
 protected:
   dom::AudioChannel mAudioChannel;
   // Weak reference to the MediaStreamSource that will be created by either
   // MediaOmxReader or MediaCodecReader.
   android::MediaStreamSource* mStreamSource;
   // Get value from the preferece, if true, we stop the audio offload.
   bool IsMonoAudioEnabled();
+
+private:
+  virtual bool HasAudio() = 0;
+  virtual bool HasVideo() = 0;
 };
 
 } // namespace mozilla
 
 #endif // MEDIA_OMX_COMMON_READER_H
--- a/dom/media/omx/MediaOmxReader.h
+++ b/dom/media/omx/MediaOmxReader.h
@@ -80,26 +80,16 @@ public:
     mSeekPromise.RejectIfExists(NS_OK, __func__);
     return MediaDecoderReader::ResetDecode();
   }
 
   virtual bool DecodeAudioData();
   virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
                                 int64_t aTimeThreshold);
 
-  virtual bool HasAudio()
-  {
-    return mHasAudio;
-  }
-
-  virtual bool HasVideo()
-  {
-    return mHasVideo;
-  }
-
   virtual void ReleaseMediaResources() override;
 
   virtual RefPtr<MediaDecoderReader::MetadataPromise> AsyncReadMetadata() override;
 
   virtual RefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aEndTime) override;
 
   virtual bool IsMediaSeekable() override;
@@ -113,16 +103,19 @@ public:
   // This method is intended only for private use but public only for
   // MozPromise::InvokeCallbackMethod().
   void ReleaseDecoder();
 
 private:
   class ProcessCachedDataTask;
   class NotifyDataArrivedRunnable;
 
+  virtual bool HasAudio() override { return mHasAudio; }
+  virtual bool HasVideo() override { return mHasVideo; }
+
   bool IsShutdown() {
     MutexAutoLock lock(mShutdownMutex);
     return mIsShutdown;
   }
 
   int64_t ProcessCachedData(int64_t aOffset);
 
   already_AddRefed<AbstractMediaDecoder> SafeGetDecoder();
--- a/dom/media/raw/RawReader.h
+++ b/dom/media/raw/RawReader.h
@@ -21,26 +21,16 @@ protected:
 
 public:
   virtual nsresult ResetDecode() override;
   virtual bool DecodeAudioData() override;
 
   virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
                                   int64_t aTimeThreshold) override;
 
-  virtual bool HasAudio() override
-  {
-    return false;
-  }
-
-  virtual bool HasVideo() override
-  {
-    return true;
-  }
-
   virtual nsresult ReadMetadata(MediaInfo* aInfo,
                                 MetadataTags** aTags) override;
   virtual RefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aEndTime) override;
 
   virtual media::TimeIntervals GetBuffered() override;
 
   virtual bool IsMediaSeekable() override;
--- a/dom/media/wave/WaveReader.h
+++ b/dom/media/wave/WaveReader.h
@@ -21,26 +21,16 @@ public:
 protected:
   ~WaveReader();
 
 public:
   virtual bool DecodeAudioData() override;
   virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
                                   int64_t aTimeThreshold) override;
 
-  virtual bool HasAudio() override
-  {
-    return true;
-  }
-
-  virtual bool HasVideo() override
-  {
-    return false;
-  }
-
   virtual nsresult ReadMetadata(MediaInfo* aInfo,
                                 MetadataTags** aTags) override;
   virtual RefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aEndTime) override;
 
   virtual media::TimeIntervals GetBuffered() override;
 
   virtual bool IsMediaSeekable() override;
--- a/dom/media/webm/WebMReader.h
+++ b/dom/media/webm/WebMReader.h
@@ -64,36 +64,32 @@ class WebMReader : public MediaDecoderRe
 {
 public:
   explicit WebMReader(AbstractMediaDecoder* aDecoder);
 
 protected:
   ~WebMReader();
 
 public:
+  // Returns a pointer to the decoder.
+  AbstractMediaDecoder* GetDecoder()
+  {
+    return mDecoder;
+  }
+
+  MediaInfo GetMediaInfo() { return mInfo; }
+
   virtual RefPtr<ShutdownPromise> Shutdown() override;
   virtual nsresult Init() override;
   virtual nsresult ResetDecode() override;
   virtual bool DecodeAudioData() override;
 
   virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
                                 int64_t aTimeThreshold) override;
 
-  virtual bool HasAudio() override
-  {
-    MOZ_ASSERT(OnTaskQueue());
-    return mHasAudio;
-  }
-
-  virtual bool HasVideo() override
-  {
-    MOZ_ASSERT(OnTaskQueue());
-    return mHasVideo;
-  }
-
   virtual RefPtr<MetadataPromise> AsyncReadMetadata() override;
 
   virtual RefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aEndTime) override;
 
   virtual media::TimeIntervals GetBuffered() override;
 
   virtual bool IsMediaSeekable() override;