Bug 1215003. Part 1 - Move MediaDecoderReader::ReadMetadata and overrides to private sections. r=gerald.
authorJW Wang <jwwang@mozilla.com>
Mon, 19 Oct 2015 10:51:48 +0800
changeset 303514 1fccc21df6a5815dd0abb8827ba8b4b8fb34c12b
parent 303513 eca8be0e5336302a3a3de263f90ae4bd40a649bf
child 303515 837ab762d9c93d73af7b7681d525aa2b921809ac
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)
reviewersgerald
bugs1215003
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 1215003. Part 1 - Move MediaDecoderReader::ReadMetadata and overrides to private sections. r=gerald.
dom/media/MediaDecoderReader.h
dom/media/android/AndroidMediaReader.cpp
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.cpp
dom/media/gstreamer/GStreamerReader.h
dom/media/ogg/OggReader.cpp
dom/media/ogg/OggReader.h
dom/media/raw/RawReader.cpp
dom/media/raw/RawReader.h
dom/media/wave/WaveReader.cpp
dom/media/wave/WaveReader.h
--- a/dom/media/MediaDecoderReader.h
+++ b/dom/media/MediaDecoderReader.h
@@ -177,23 +177,16 @@ public:
   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();
 
-  // Read header data for all bitstreams in the file. Fills aInfo with
-  // the data required to present the media, and optionally fills *aTags
-  // with tag metadata from the file.
-  // Returns NS_OK on success, or NS_ERROR_FAILURE on failure.
-  virtual nsresult ReadMetadata(MediaInfo* aInfo,
-                                MetadataTags** aTags) { MOZ_CRASH(); }
-
   // 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) { };
 
   // Moves the decode head to aTime microseconds. aEndTime denotes the end
   // time of the media in usecs. This is only needed for OggReader, and should
   // probably be removed somehow.
   virtual RefPtr<SeekPromise>
@@ -263,16 +256,22 @@ public:
 
   virtual size_t SizeOfVideoQueueInFrames();
   virtual size_t SizeOfAudioQueueInFrames();
 
 private:
   virtual void ReleaseMediaResourcesInternal() {}
   virtual void DisableHardwareAccelerationInternal() {}
 
+  // Read header data for all bitstreams in the file. Fills aInfo with
+  // the data required to present the media, and optionally fills *aTags
+  // with tag metadata from the file.
+  // Returns NS_OK on success, or NS_ERROR_FAILURE on failure.
+  virtual nsresult ReadMetadata(MediaInfo*, MetadataTags**) { MOZ_CRASH(); }
+
 protected:
   friend class TrackBuffer;
   virtual void NotifyDataArrivedInternal(uint32_t aLength, int64_t aOffset) { }
 
   void NotifyDataArrived(const media::Interval<int64_t>& aInfo)
   {
     MOZ_ASSERT(OnTaskQueue());
     NS_ENSURE_TRUE_VOID(!mShutdown);
--- a/dom/media/android/AndroidMediaReader.cpp
+++ b/dom/media/android/AndroidMediaReader.cpp
@@ -30,18 +30,18 @@ AndroidMediaReader::AndroidMediaReader(A
   mPlugin(nullptr),
   mHasAudio(false),
   mHasVideo(false),
   mVideoSeekTimeUs(-1),
   mAudioSeekTimeUs(-1)
 {
 }
 
-nsresult AndroidMediaReader::ReadMetadata(MediaInfo* aInfo,
-                                          MetadataTags** aTags)
+nsresult
+AndroidMediaReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
 {
   MOZ_ASSERT(OnTaskQueue());
 
   if (!mPlugin) {
     mPlugin = GetAndroidMediaPluginHost()->CreateDecoder(mDecoder->GetResource(), mType);
     if (!mPlugin) {
       return NS_ERROR_FAILURE;
     }
--- a/dom/media/android/AndroidMediaReader.h
+++ b/dom/media/android/AndroidMediaReader.h
@@ -59,18 +59,16 @@ public:
   }
 
   virtual bool IsMediaSeekable()
   {
     // not used
     return true;
   }
 
-  virtual nsresult ReadMetadata(MediaInfo* aInfo,
-                                MetadataTags** aTags);
   virtual RefPtr<SeekPromise>
   Seek(int64_t aTime, int64_t aEndTime) override;
 
   virtual RefPtr<ShutdownPromise> Shutdown() override;
 
   class ImageBufferCallback : public MPAPI::BufferCallback {
     typedef mozilla::layers::Image Image;
 
@@ -82,13 +80,15 @@ public:
 
   private:
     uint8_t *CreateI420Image(size_t aWidth, size_t aHeight);
 
     mozilla::layers::ImageContainer *mImageContainer;
     RefPtr<Image> mImage;
   };
 
+private:
+  virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags);
 };
 
 } // namespace mozilla
 
 #endif
--- a/dom/media/apple/AppleMP3Reader.cpp
+++ b/dom/media/apple/AppleMP3Reader.cpp
@@ -346,18 +346,17 @@ GetProperty(AudioFileStreamID aAudioFile
   rv = AudioFileStreamGetProperty(aAudioFileStream, aPropertyID,
                                   &size, aData);
 
   return NS_OK;
 }
 
 
 nsresult
-AppleMP3Reader::ReadMetadata(MediaInfo* aInfo,
-                             MetadataTags** aTags)
+AppleMP3Reader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
 {
   MOZ_ASSERT(OnTaskQueue());
 
   *aTags = nullptr;
 
   /*
    * Feed bytes into the parser until we have all the metadata we need to
    * set up the decoder. When the parser has enough data, it will
--- a/dom/media/apple/AppleMP3Reader.h
+++ b/dom/media/apple/AppleMP3Reader.h
@@ -26,39 +26,37 @@ public:
 
   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,
                            const void *aData,
                            AudioStreamPacketDescription *aPackets);
 
   void AudioMetadataCallback(AudioFileStreamID aFileStream,
                              AudioFileStreamPropertyID aPropertyID,
                              UInt32 *aFlags);
 
 protected:
   virtual void NotifyDataArrivedInternal(uint32_t aLength,
                                          int64_t aOffset) override;
 public:
-
   virtual bool IsMediaSeekable() override;
 
 private:
+  virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
+
   void SetupDecoder();
   nsresult Read(uint32_t *aNumBytes, char *aData);
 
   static OSStatus PassthroughInputDataCallback(AudioConverterRef aAudioConverter,
                                                UInt32 *aNumDataPackets,
                                                AudioBufferList *aData,
                                                AudioStreamPacketDescription **aPacketDesc,
                                                void *aUserData);
--- a/dom/media/directshow/DirectShowReader.cpp
+++ b/dom/media/directshow/DirectShowReader.cpp
@@ -85,18 +85,17 @@ ParseMP3Headers(MP3FrameParser *aParser,
 }
 
 // Windows XP's MP3 decoder filter. This is available on XP only, on Vista
 // and later we can use the DMO Wrapper filter and MP3 decoder DMO.
 static const GUID CLSID_MPEG_LAYER_3_DECODER_FILTER =
 { 0x38BE3000, 0xDBF4, 0x11D0, {0x86, 0x0E, 0x00, 0xA0, 0x24, 0xCF, 0xEF, 0x6D} };
 
 nsresult
-DirectShowReader::ReadMetadata(MediaInfo* aInfo,
-                               MetadataTags** aTags)
+DirectShowReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
 {
   MOZ_ASSERT(OnTaskQueue());
   HRESULT hr;
   nsresult rv;
 
   // Create the filter graph, reference it by the GraphBuilder interface,
   // to make graph building more convenient.
   hr = CoCreateInstance(CLSID_FilterGraph,
--- a/dom/media/directshow/DirectShowReader.h
+++ b/dom/media/directshow/DirectShowReader.h
@@ -45,30 +45,28 @@ public:
 
   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,
                                  int64_t aOffset) override;
 public:
 
   bool IsMediaSeekable() override;
 
 private:
+  nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
 
   // Notifies the filter graph that playback is complete. aStatus is
   // the code to send to the filter graph. Always returns false, so
   // that we can just "return Finish()" from DecodeAudioData().
   bool Finish(HRESULT aStatus);
 
   nsresult SeekInternal(int64_t aTime);
 
--- a/dom/media/gstreamer/GStreamerReader.cpp
+++ b/dom/media/gstreamer/GStreamerReader.cpp
@@ -355,18 +355,18 @@ GStreamerReader::GetDataLength()
 
   if (streamLen < 0) {
     return streamLen;
   }
 
   return streamLen - mDataOffset;
 }
 
-nsresult GStreamerReader::ReadMetadata(MediaInfo* aInfo,
-                                       MetadataTags** aTags)
+nsresult
+GStreamerReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
 {
   MOZ_ASSERT(OnTaskQueue());
   nsresult ret = NS_OK;
 
   /*
    * Parse MP3 headers before we kick off the GStreamer pipeline otherwise there
    * might be concurrent stream operations happening on both decoding and gstreamer
    * threads which will screw the GStreamer state machine.
--- a/dom/media/gstreamer/GStreamerReader.h
+++ b/dom/media/gstreamer/GStreamerReader.h
@@ -41,18 +41,16 @@ public:
   virtual ~GStreamerReader();
 
   virtual nsresult Init() override;
   virtual RefPtr<ShutdownPromise> Shutdown() override;
   virtual nsresult ResetDecode() override;
   virtual bool DecodeAudioData() override;
   virtual bool DecodeVideoFrame(bool &aKeyframeSkip,
                                 int64_t aTimeThreshold) override;
-  virtual nsresult ReadMetadata(MediaInfo* aInfo,
-                                MetadataTags** aTags) override;
   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:
@@ -65,16 +63,17 @@ public:
     return mInfo.HasVideo();
   }
 
   layers::ImageContainer* GetImageContainer() { return mDecoder->GetImageContainer(); }
 
   virtual bool IsMediaSeekable() override;
 
 private:
+  virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
 
   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
--- a/dom/media/ogg/OggReader.cpp
+++ b/dom/media/ogg/OggReader.cpp
@@ -366,18 +366,18 @@ void OggReader::SetupMediaTracksInfo(con
       }
 
       mInfo.mAudio.mRate = opusState->mRate;
       mInfo.mAudio.mChannels = opusState->mChannels;
     }
   }
 }
 
-nsresult OggReader::ReadMetadata(MediaInfo* aInfo,
-                                 MetadataTags** aTags)
+nsresult
+OggReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
 {
   MOZ_ASSERT(OnTaskQueue());
 
   // We read packets until all bitstreams have read all their header packets.
   // We record the offset of the first non-header page so that we know
   // what page to seek to when seeking to the media start.
 
   NS_ASSERTION(aTags, "Called with null MetadataTags**.");
--- a/dom/media/ogg/OggReader.h
+++ b/dom/media/ogg/OggReader.h
@@ -64,25 +64,25 @@ public:
     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:
+  virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
+
   // 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/raw/RawReader.cpp
+++ b/dom/media/raw/RawReader.cpp
@@ -27,18 +27,18 @@ RawReader::~RawReader()
 }
 
 nsresult RawReader::ResetDecode()
 {
   mCurrentFrame = 0;
   return MediaDecoderReader::ResetDecode();
 }
 
-nsresult RawReader::ReadMetadata(MediaInfo* aInfo,
-                                 MetadataTags** aTags)
+nsresult
+RawReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
 {
   MOZ_ASSERT(OnTaskQueue());
 
   if (!ReadFromResource(reinterpret_cast<uint8_t*>(&mMetadata),
                         sizeof(mMetadata)))
     return NS_ERROR_FAILURE;
 
   // Validate the header
--- a/dom/media/raw/RawReader.h
+++ b/dom/media/raw/RawReader.h
@@ -31,26 +31,25 @@ public:
     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;
 
 private:
+  virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
   bool ReadFromResource(uint8_t *aBuf, uint32_t aLength);
 
   RawVideoHeader mMetadata;
   uint32_t mCurrentFrame;
   double mFrameRate;
   uint32_t mFrameSize;
   nsIntRect mPicture;
   MediaResourceIndex mResource;
--- a/dom/media/wave/WaveReader.cpp
+++ b/dom/media/wave/WaveReader.cpp
@@ -111,18 +111,18 @@ WaveReader::WaveReader(AbstractMediaDeco
   MOZ_COUNT_CTOR(WaveReader);
 }
 
 WaveReader::~WaveReader()
 {
   MOZ_COUNT_DTOR(WaveReader);
 }
 
-nsresult WaveReader::ReadMetadata(MediaInfo* aInfo,
-                                  MetadataTags** aTags)
+nsresult
+WaveReader::ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags)
 {
   MOZ_ASSERT(OnTaskQueue());
 
   bool loaded = LoadRIFFChunk();
   if (!loaded) {
     return NS_ERROR_FAILURE;
   }
 
--- a/dom/media/wave/WaveReader.h
+++ b/dom/media/wave/WaveReader.h
@@ -31,26 +31,25 @@ public:
     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;
 
 private:
+  virtual nsresult ReadMetadata(MediaInfo* aInfo, MetadataTags** aTags) override;
   bool ReadAll(char* aBuf, int64_t aSize, int64_t* aBytesRead = nullptr);
   bool LoadRIFFChunk();
   bool LoadFormatChunk(uint32_t aChunkSize);
   bool FindDataOffset(uint32_t aChunkSize);
   bool LoadListChunk(uint32_t aChunkSize, nsAutoPtr<dom::HTMLMediaElement::MetadataTags> &aTags);
   bool LoadAllChunks(nsAutoPtr<dom::HTMLMediaElement::MetadataTags> &aTags);
 
   // Returns the number of seconds that aBytes represents based on the