Bug 1390748 - Create default MediaDecoder::GetMozDebugReaderData() implementation. r=jwwang draft
authorChris Pearce <cpearce@mozilla.com>
Tue, 15 Aug 2017 17:07:13 +1200
changeset 648060 83d0facbe26f8385c7163dc85d5512e7a43e80f4
parent 648059 e402ec2efd081c8acee3f46925e167323494377e
child 648061 505f9dce979aad0529b07d2c046dca5028af6de6
push id74604
push userbmo:cpearce@mozilla.com
push dateThu, 17 Aug 2017 06:10:02 +0000
reviewersjwwang
bugs1390748
milestone57.0a1
Bug 1390748 - Create default MediaDecoder::GetMozDebugReaderData() implementation. r=jwwang We have three implementations, in the MP4, WebM and MediaSource decoders. The WebM and MP4 are the same. Ogg and other decoders don't have an implementation, but if we create a default implementation in MediaDecoder, they'll get it for free. MediaSourceDecoder needs a custom override still. MozReview-Commit-ID: AXxn2Xhn0Jn
dom/media/MediaDecoder.cpp
dom/media/MediaDecoder.h
dom/media/fmp4/MP4Decoder.cpp
dom/media/fmp4/MP4Decoder.h
dom/media/webm/WebMDecoder.cpp
dom/media/webm/WebMDecoder.h
--- a/dom/media/MediaDecoder.cpp
+++ b/dom/media/MediaDecoder.cpp
@@ -1617,16 +1617,24 @@ MediaDecoder::RequestDebugInfo()
       return DebugInfoPromise::CreateAndResolve(result, __func__);
     },
     [str] () {
       return DebugInfoPromise::CreateAndResolve(str, __func__);
     });
 }
 
 void
+MediaDecoder::GetMozDebugReaderData(nsACString& aString)
+{
+  if (mReader) {
+    mReader->GetMozDebugReaderData(aString);
+  }
+}
+
+void
 MediaDecoder::NotifyAudibleStateChanged()
 {
   MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
   GetOwner()->SetAudibleState(mIsAudioDataAudible);
 }
 
 MediaMemoryTracker::MediaMemoryTracker()
 {
--- a/dom/media/MediaDecoder.h
+++ b/dom/media/MediaDecoder.h
@@ -401,17 +401,17 @@ private:
   virtual MediaDecoderOwner::NextFrameStatus NextFrameStatus()
   {
     return mNextFrameStatus;
   }
   virtual MediaDecoderOwner::NextFrameStatus NextFrameBufferedStatus();
 
   // Returns a string describing the state of the media player internal
   // data. Used for debugging purposes.
-  virtual void GetMozDebugReaderData(nsACString& aString) { }
+  virtual void GetMozDebugReaderData(nsACString& aString);
 
   virtual void DumpDebugInfo();
 
   using DebugInfoPromise = MozPromise<nsCString, bool, true>;
   RefPtr<DebugInfoPromise> RequestDebugInfo();
 
 protected:
   virtual ~MediaDecoder();
--- a/dom/media/fmp4/MP4Decoder.cpp
+++ b/dom/media/fmp4/MP4Decoder.cpp
@@ -273,17 +273,9 @@ MP4Decoder::IsVideoAccelerated(layers::K
              taskQueue->BeginShutdown();
              taskQueue->AwaitShutdownAndIdle();
              promise->MaybeResolve(NS_LITERAL_STRING("No; Failed to initialize H264 decoder"));
            });
 
   return promise.forget();
 }
 
-void
-MP4Decoder::GetMozDebugReaderData(nsACString& aString)
-{
-  if (mReader) {
-    mReader->GetMozDebugReaderData(aString);
-  }
-}
-
 } // namespace mozilla
--- a/dom/media/fmp4/MP4Decoder.h
+++ b/dom/media/fmp4/MP4Decoder.h
@@ -37,18 +37,16 @@ public:
   static bool IsAAC(const nsACString& aMimeType);
 
   // Returns true if the MP4 backend is preffed on.
   static bool IsEnabled();
 
   static already_AddRefed<dom::Promise>
   IsVideoAccelerated(layers::KnowsCompositor* aKnowsCompositor, nsIGlobalObject* aParent);
 
-  void GetMozDebugReaderData(nsACString& aString) override;
-
 private:
   ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override
   {
     if (!IsEnabled()) {
       return nullptr;
     }
     return new MP4Decoder(aInit);
   }
--- a/dom/media/webm/WebMDecoder.cpp
+++ b/dom/media/webm/WebMDecoder.cpp
@@ -53,18 +53,10 @@ WebMDecoder::IsSupportedType(const Media
     }
 #endif
     // Some unsupported codec.
     return false;
   }
   return true;
 }
 
-void
-WebMDecoder::GetMozDebugReaderData(nsACString& aString)
-{
-  if (mReader) {
-    mReader->GetMozDebugReaderData(aString);
-  }
-}
-
 } // namespace mozilla
 
--- a/dom/media/webm/WebMDecoder.h
+++ b/dom/media/webm/WebMDecoder.h
@@ -20,18 +20,16 @@ public:
   {
   }
 
   // Returns true if aContainerType is a WebM type that we think we can render
   // with an enabled platform decoder backend.
   // If provided, codecs are checked for support.
   static bool IsSupportedType(const MediaContainerType& aContainerType);
 
-  void GetMozDebugReaderData(nsACString& aString) override;
-
 private:
   ChannelMediaDecoder* CloneImpl(MediaDecoderInit& aInit) override
   {
     if (!IsWebMEnabled()) {
       return nullptr;
     }
     return new WebMDecoder(aInit);
   }