Bug 1405531 - Remove unused MediaDataDemuxer::HasTrackType - r=jwwang
authorGerald Squelart <gsquelart@mozilla.com>
Wed, 04 Oct 2017 11:40:29 +1100
changeset 384557 9edb781a90587e4dbf15eb111b2c6a2faac3d5b3
parent 384556 4fe99f70e199cacff46a87deaa0ed55c4308dabe
child 384558 ffd9345660e51ee97c0d753f6e73cbe4e51f8e41
push id32631
push userarchaeopteryx@coole-files.de
push dateThu, 05 Oct 2017 08:51:33 +0000
treeherdermozilla-central@66042a706980 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwwang
bugs1405531
milestone58.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 1405531 - Remove unused MediaDataDemuxer::HasTrackType - r=jwwang The only actual code use in MediaSourceDemuxer can trivially be folded into its caller GetNumberTracks in the same class. MozReview-Commit-ID: E6zh98zmJwJ
dom/media/ADTSDemuxer.cpp
dom/media/ADTSDemuxer.h
dom/media/MediaDataDemuxer.h
dom/media/flac/FlacDemuxer.cpp
dom/media/flac/FlacDemuxer.h
dom/media/fmp4/MP4Demuxer.cpp
dom/media/fmp4/MP4Demuxer.h
dom/media/hls/HLSDemuxer.cpp
dom/media/hls/HLSDemuxer.h
dom/media/mediasource/MediaSourceDemuxer.cpp
dom/media/mediasource/MediaSourceDemuxer.h
dom/media/mp3/MP3Demuxer.cpp
dom/media/mp3/MP3Demuxer.h
dom/media/ogg/OggDemuxer.cpp
dom/media/ogg/OggDemuxer.h
dom/media/wave/WaveDemuxer.cpp
dom/media/wave/WaveDemuxer.h
dom/media/webm/WebMDemuxer.cpp
dom/media/webm/WebMDemuxer.h
--- a/dom/media/ADTSDemuxer.cpp
+++ b/dom/media/ADTSDemuxer.cpp
@@ -325,22 +325,16 @@ ADTSDemuxer::Init()
     return InitPromise::CreateAndReject(
       NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
   }
 
   ADTSLOG("Init() successful");
   return InitPromise::CreateAndResolve(NS_OK, __func__);
 }
 
-bool
-ADTSDemuxer::HasTrackType(TrackInfo::TrackType aType) const
-{
-  return aType == TrackInfo::kAudioTrack;
-}
-
 uint32_t
 ADTSDemuxer::GetNumberTracks(TrackInfo::TrackType aType) const
 {
   return (aType == TrackInfo::kAudioTrack) ? 1 : 0;
 }
 
 already_AddRefed<MediaTrackDemuxer>
 ADTSDemuxer::GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber)
--- a/dom/media/ADTSDemuxer.h
+++ b/dom/media/ADTSDemuxer.h
@@ -23,17 +23,16 @@ class FrameParser;
 class ADTSTrackDemuxer;
 
 class ADTSDemuxer : public MediaDataDemuxer
 {
 public:
   // MediaDataDemuxer interface.
   explicit ADTSDemuxer(MediaResource* aSource);
   RefPtr<InitPromise> Init() override;
-  bool HasTrackType(TrackInfo::TrackType aType) const override;
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
   already_AddRefed<MediaTrackDemuxer>
   GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
   bool IsSeekable() const override;
 
   // Return true if a valid ADTS frame header could be found.
   static bool ADTSSniffer(const uint8_t* aData, const uint32_t aLength);
 
--- a/dom/media/MediaDataDemuxer.h
+++ b/dom/media/MediaDataDemuxer.h
@@ -39,19 +39,16 @@ public:
   // initialization has completed and succeeded.
   // Typically a demuxer will wait to parse the metadata before resolving the
   // promise. The promise must not be resolved until sufficient data is
   // supplied. For example, an incomplete metadata would cause the promise to be
   // rejected should no more data be coming, while the demuxer would wait
   // otherwise.
   virtual RefPtr<InitPromise> Init() = 0;
 
-  // Returns true if a aType track type is available.
-  virtual bool HasTrackType(TrackInfo::TrackType aType) const = 0;
-
   // Returns the number of tracks of aType type available. A value of
   // 0 indicates that no such type is available.
   virtual uint32_t GetNumberTracks(TrackInfo::TrackType aType) const = 0;
 
   // Returns the MediaTrackDemuxer associated with aTrackNumber aType track.
   // aTrackNumber is not to be confused with the Track ID.
   // aTrackNumber must be constrained between  0 and  GetNumberTracks(aType) - 1
   // The actual Track ID is to be retrieved by calling
--- a/dom/media/flac/FlacDemuxer.cpp
+++ b/dom/media/flac/FlacDemuxer.cpp
@@ -573,22 +573,16 @@ FlacDemuxer::Init()
     return InitPromise::CreateAndReject(
       NS_ERROR_DOM_MEDIA_DEMUXER_ERR, __func__);
   }
 
   LOG("Init() successful");
   return InitPromise::CreateAndResolve(NS_OK, __func__);
 }
 
-bool
-FlacDemuxer::HasTrackType(TrackInfo::TrackType aType) const
-{
-  return aType == TrackInfo::kAudioTrack;
-}
-
 uint32_t
 FlacDemuxer::GetNumberTracks(TrackInfo::TrackType aType) const
 {
   return (aType == TrackInfo::kAudioTrack) ? 1 : 0;
 }
 
 already_AddRefed<MediaTrackDemuxer>
 FlacDemuxer::GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber)
--- a/dom/media/flac/FlacDemuxer.h
+++ b/dom/media/flac/FlacDemuxer.h
@@ -20,17 +20,16 @@ class FlacTrackDemuxer;
 
 
 class FlacDemuxer : public MediaDataDemuxer
 {
 public:
   // MediaDataDemuxer interface.
   explicit FlacDemuxer(MediaResource* aSource);
   RefPtr<InitPromise> Init() override;
-  bool HasTrackType(TrackInfo::TrackType aType) const override;
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
   already_AddRefed<MediaTrackDemuxer> GetTrackDemuxer(
     TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
   bool IsSeekable() const override;
 
   // Return true if a valid flac frame header could be found.
   static bool FlacSniffer(const uint8_t* aData, const uint32_t aLength);
 
--- a/dom/media/fmp4/MP4Demuxer.cpp
+++ b/dom/media/fmp4/MP4Demuxer.cpp
@@ -269,22 +269,16 @@ MP4Demuxer::Init()
     }
   }
 
   mIsSeekable = metadata.CanSeek();
 
   return InitPromise::CreateAndResolve(result, __func__);
 }
 
-bool
-MP4Demuxer::HasTrackType(TrackInfo::TrackType aType) const
-{
-  return GetNumberTracks(aType) != 0;
-}
-
 uint32_t
 MP4Demuxer::GetNumberTracks(TrackInfo::TrackType aType) const
 {
   switch (aType) {
     case TrackInfo::kAudioTrack: return uint32_t(mAudioDemuxers.Length());
     case TrackInfo::kVideoTrack: return uint32_t(mVideoDemuxers.Length());
     default: return 0;
   }
--- a/dom/media/fmp4/MP4Demuxer.h
+++ b/dom/media/fmp4/MP4Demuxer.h
@@ -24,18 +24,16 @@ class MP4TrackDemuxer;
 
 class MP4Demuxer : public MediaDataDemuxer
 {
 public:
   explicit MP4Demuxer(MediaResource* aResource);
 
   RefPtr<InitPromise> Init() override;
 
-  bool HasTrackType(TrackInfo::TrackType aType) const override;
-
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
 
   already_AddRefed<MediaTrackDemuxer>
   GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
 
   bool IsSeekable() const override;
 
   UniquePtr<EncryptionInfo> GetCrypto() override;
--- a/dom/media/hls/HLSDemuxer.cpp
+++ b/dom/media/hls/HLSDemuxer.cpp
@@ -179,29 +179,16 @@ HLSDemuxer::Init()
     });
 }
 
 void HLSDemuxer::NotifyDataArrived()
 {
   HLS_DEBUG("HLSDemuxer", "NotifyDataArrived");
 }
 
-bool
-HLSDemuxer::HasTrackType(TrackType aType) const
-{
-  HLS_DEBUG("HLSDemuxer", "HasTrackType(%d)", aType);
-  if (mAudioDemuxer && aType == TrackType::kAudioTrack) {
-    return mAudioDemuxer->IsTrackValid();
-  }
-  if (mVideoDemuxer && aType == TrackType::kVideoTrack) {
-    return mVideoDemuxer->IsTrackValid();
-  }
-  return false;
-}
-
 uint32_t
 HLSDemuxer::GetNumberTracks(TrackType aType) const
 {
   switch (aType) {
     case TrackType::kAudioTrack:
       return mHLSDemuxerWrapper->GetNumberOfTracks(TrackType::kAudioTrack);
     case TrackType::kVideoTrack:
       return mHLSDemuxerWrapper->GetNumberOfTracks(TrackType::kVideoTrack);
--- a/dom/media/hls/HLSDemuxer.h
+++ b/dom/media/hls/HLSDemuxer.h
@@ -28,18 +28,16 @@ class HLSTrackDemuxer;
 class HLSDemuxer final : public MediaDataDemuxer
 {
   class HLSDemuxerCallbacksSupport;
 public:
   explicit HLSDemuxer(int aPlayerId);
 
   RefPtr<InitPromise> Init() override;
 
-  bool HasTrackType(TrackInfo::TrackType aType) const override;
-
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
 
   already_AddRefed<MediaTrackDemuxer>
   GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
 
   bool IsSeekable() const override;
 
   UniquePtr<EncryptionInfo> GetCrypto() override;
--- a/dom/media/mediasource/MediaSourceDemuxer.cpp
+++ b/dom/media/mediasource/MediaSourceDemuxer.cpp
@@ -112,37 +112,31 @@ MediaSourceDemuxer::ScanSourceBuffersFor
   }
   if (mInfo.HasAudio() && mInfo.HasVideo()) {
     // We have both audio and video. We can ignore non-ready source buffer.
     return true;
   }
   return !haveEmptySourceBuffer;
 }
 
-bool
-MediaSourceDemuxer::HasTrackType(TrackType aType) const
+uint32_t
+MediaSourceDemuxer::GetNumberTracks(TrackType aType) const
 {
   MonitorAutoLock mon(mMonitor);
 
   switch (aType) {
     case TrackType::kAudioTrack:
-      return mInfo.HasAudio();
+      return mInfo.HasAudio() ? 1u : 0;
     case TrackType::kVideoTrack:
-      return mInfo.HasVideo();
+      return mInfo.HasVideo() ? 1u : 0;
     default:
-      return false;
+      return 0;
   }
 }
 
-uint32_t
-MediaSourceDemuxer::GetNumberTracks(TrackType aType) const
-{
-  return HasTrackType(aType) ? 1u : 0;
-}
-
 already_AddRefed<MediaTrackDemuxer>
 MediaSourceDemuxer::GetTrackDemuxer(TrackType aType, uint32_t aTrackNumber)
 {
   RefPtr<TrackBuffersManager> manager = GetManager(aType);
   if (!manager) {
     return nullptr;
   }
   RefPtr<MediaSourceTrackDemuxer> e =
--- a/dom/media/mediasource/MediaSourceDemuxer.h
+++ b/dom/media/mediasource/MediaSourceDemuxer.h
@@ -25,18 +25,16 @@ class MediaSourceTrackDemuxer;
 
 class MediaSourceDemuxer : public MediaDataDemuxer
 {
 public:
   explicit MediaSourceDemuxer(AbstractThread* aAbstractMainThread);
 
   RefPtr<InitPromise> Init() override;
 
-  bool HasTrackType(TrackInfo::TrackType aType) const override;
-
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
 
   already_AddRefed<MediaTrackDemuxer>
   GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
 
   bool IsSeekable() const override;
 
   UniquePtr<EncryptionInfo> GetCrypto() override;
--- a/dom/media/mp3/MP3Demuxer.cpp
+++ b/dom/media/mp3/MP3Demuxer.cpp
@@ -50,22 +50,16 @@ MP3Demuxer::Init()
     return InitPromise::CreateAndReject(
       NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
   }
 
   MP3LOG("MP3Demuxer::Init() successful");
   return InitPromise::CreateAndResolve(NS_OK, __func__);
 }
 
-bool
-MP3Demuxer::HasTrackType(TrackInfo::TrackType aType) const
-{
-  return aType == TrackInfo::kAudioTrack;
-}
-
 uint32_t
 MP3Demuxer::GetNumberTracks(TrackInfo::TrackType aType) const
 {
   return aType == TrackInfo::kAudioTrack ? 1u : 0u;
 }
 
 already_AddRefed<MediaTrackDemuxer>
 MP3Demuxer::GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber)
--- a/dom/media/mp3/MP3Demuxer.h
+++ b/dom/media/mp3/MP3Demuxer.h
@@ -14,17 +14,16 @@ namespace mozilla {
 class MP3TrackDemuxer;
 
 class MP3Demuxer : public MediaDataDemuxer
 {
 public:
   // MediaDataDemuxer interface.
   explicit MP3Demuxer(MediaResource* aSource);
   RefPtr<InitPromise> Init() override;
-  bool HasTrackType(TrackInfo::TrackType aType) const override;
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
   already_AddRefed<MediaTrackDemuxer> GetTrackDemuxer(
       TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
   bool IsSeekable() const override;
   void NotifyDataArrived() override;
   void NotifyDataRemoved() override;
 
 private:
--- a/dom/media/ogg/OggDemuxer.cpp
+++ b/dom/media/ogg/OggDemuxer.cpp
@@ -212,22 +212,16 @@ OggDemuxer::Init()
   if (!GetNumberTracks(TrackInfo::kAudioTrack) &&
       !GetNumberTracks(TrackInfo::kVideoTrack)) {
     return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
   }
 
   return InitPromise::CreateAndResolve(NS_OK, __func__);
 }
 
-bool
-OggDemuxer::HasTrackType(TrackInfo::TrackType aType) const
-{
-  return !!GetNumberTracks(aType);
-}
-
 OggCodecState*
 OggDemuxer::GetTrackCodecState(TrackInfo::TrackType aType) const
 {
   switch(aType) {
     case TrackInfo::kAudioTrack:
       if (mVorbisState) {
         return mVorbisState;
       } else if (mOpusState) {
--- a/dom/media/ogg/OggDemuxer.h
+++ b/dom/media/ogg/OggDemuxer.h
@@ -18,18 +18,16 @@ class OggTrackDemuxer;
 
 class OggDemuxer : public MediaDataDemuxer
 {
 public:
   explicit OggDemuxer(MediaResource* aResource);
 
   RefPtr<InitPromise> Init() override;
 
-  bool HasTrackType(TrackInfo::TrackType aType) const override;
-
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
 
   already_AddRefed<MediaTrackDemuxer> GetTrackDemuxer(TrackInfo::TrackType aType,
                                                       uint32_t aTrackNumber) override;
 
   bool IsSeekable() const override;
 
   UniquePtr<EncryptionInfo> GetCrypto() override;
--- a/dom/media/wave/WaveDemuxer.cpp
+++ b/dom/media/wave/WaveDemuxer.cpp
@@ -42,22 +42,16 @@ WAVDemuxer::Init()
 {
   if (!InitInternal()) {
     return InitPromise::CreateAndReject(
       NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
   }
   return InitPromise::CreateAndResolve(NS_OK, __func__);
 }
 
-bool
-WAVDemuxer::HasTrackType(TrackInfo::TrackType aType) const
-{
-  return aType == TrackInfo::kAudioTrack;
-}
-
 uint32_t
 WAVDemuxer::GetNumberTracks(TrackInfo::TrackType aType) const
 {
   return aType == TrackInfo::kAudioTrack ? 1u : 0u;
 }
 
 already_AddRefed<MediaTrackDemuxer>
 WAVDemuxer::GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber)
--- a/dom/media/wave/WaveDemuxer.h
+++ b/dom/media/wave/WaveDemuxer.h
@@ -31,17 +31,16 @@ static const uint16_t DATA_CHUNK_SIZE = 
 class WAVTrackDemuxer;
 
 class WAVDemuxer : public MediaDataDemuxer
 {
 public:
   // MediaDataDemuxer interface.
   explicit WAVDemuxer(MediaResource* aSource);
   RefPtr<InitPromise> Init() override;
-  bool HasTrackType(TrackInfo::TrackType aType) const override;
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
   already_AddRefed<MediaTrackDemuxer> GetTrackDemuxer(
     TrackInfo::TrackType aType, uint32_t aTrackNumber) override;
   bool IsSeekable() const override;
 
 private:
   // Synchronous Initialization.
   bool InitInternal();
--- a/dom/media/webm/WebMDemuxer.cpp
+++ b/dom/media/webm/WebMDemuxer.cpp
@@ -207,22 +207,16 @@ WebMDemuxer::Init()
 
 void
 WebMDemuxer::InitBufferedState()
 {
   MOZ_ASSERT(!mBufferedState);
   mBufferedState = new WebMBufferedState;
 }
 
-bool
-WebMDemuxer::HasTrackType(TrackInfo::TrackType aType) const
-{
-  return !!GetNumberTracks(aType);
-}
-
 uint32_t
 WebMDemuxer::GetNumberTracks(TrackInfo::TrackType aType) const
 {
   switch(aType) {
     case TrackInfo::kAudioTrack:
       return mHasAudio ? 1 : 0;
     case TrackInfo::kVideoTrack:
       return mHasVideo ? 1 : 0;
--- a/dom/media/webm/WebMDemuxer.h
+++ b/dom/media/webm/WebMDemuxer.h
@@ -127,18 +127,16 @@ class WebMDemuxer : public MediaDataDemu
 public:
   explicit WebMDemuxer(MediaResource* aResource);
   // Indicate if the WebMDemuxer is to be used with MediaSource. In which
   // case the demuxer will stop reads to the last known complete block.
   WebMDemuxer(MediaResource* aResource, bool aIsMediaSource);
 
   RefPtr<InitPromise> Init() override;
 
-  bool HasTrackType(TrackInfo::TrackType aType) const override;
-
   uint32_t GetNumberTracks(TrackInfo::TrackType aType) const override;
 
   UniquePtr<TrackInfo> GetTrackInfo(TrackInfo::TrackType aType,
                                     size_t aTrackNumber) const;
 
   already_AddRefed<MediaTrackDemuxer>
   GetTrackDemuxer(TrackInfo::TrackType aType, uint32_t aTrackNumber) override;