Bug 1394591 - P3. Add codec type to decoder description name. r?gerald draft
authorJean-Yves Avenard <jyavenard@mozilla.com>
Fri, 01 Sep 2017 14:58:19 +0200
changeset 658324 1643c84f6ea58a970b96d808b0909ff2fa399254
parent 658323 fa7a86bcc6e0aed36aa22f02d1bf8c221e7de3f4
child 658325 6517d8730f70fa1c5d15688eff7d268236de79d2
push id77716
push userbmo:jyavenard@mozilla.com
push dateSun, 03 Sep 2017 19:33:08 +0000
reviewersgerald
bugs1394591
milestone57.0a1
Bug 1394591 - P3. Add codec type to decoder description name. r?gerald MozReview-Commit-ID: 8vQUFhhMtqO
dom/media/MediaFormatReader.cpp
dom/media/platforms/wmf/WMFVideoMFTManager.cpp
dom/media/platforms/wmf/WMFVideoMFTManager.h
--- a/dom/media/MediaFormatReader.cpp
+++ b/dom/media/MediaFormatReader.cpp
@@ -1397,17 +1397,20 @@ MediaFormatReader::OnDemuxerInitDone(con
     videoActive = videoInfo && videoInfo->IsValid();
     if (videoActive) {
       if (platform
           && !platform->SupportsMimeType(videoInfo->mMimeType, nullptr)) {
         // We have no decoder for this track. Error.
         mMetadataPromise.Reject(NS_ERROR_DOM_MEDIA_METADATA_ERR, __func__);
         return;
       }
-      mInfo.mVideo = *videoInfo->GetAsVideoInfo();
+      {
+        MutexAutoLock lock(mVideo.mMutex);
+        mInfo.mVideo = *videoInfo->GetAsVideoInfo();
+      }
       for (const MetadataTag& tag : videoInfo->mTags) {
         tags->Put(tag.mKey, tag.mValue);
       }
       mVideo.mOriginalInfo = Move(videoInfo);
       mTrackDemuxersMayBlock |= mVideo.mTrackDemuxer->GetSamplesMayBlock();
     } else {
       mVideo.mTrackDemuxer->BreakCycles();
       mVideo.mTrackDemuxer = nullptr;
@@ -1426,17 +1429,20 @@ MediaFormatReader::OnDemuxerInitDone(con
     // We actively ignore audio tracks that we know we can't play.
     audioActive =
       audioInfo
       && audioInfo->IsValid()
       && (!platform || platform->SupportsMimeType(audioInfo->mMimeType,
                                                   nullptr));
 
     if (audioActive) {
-      mInfo.mAudio = *audioInfo->GetAsAudioInfo();
+      {
+        MutexAutoLock lock(mAudio.mMutex);
+        mInfo.mAudio = *audioInfo->GetAsAudioInfo();
+      }
       for (const MetadataTag& tag : audioInfo->mTags) {
         tags->Put(tag.mKey, tag.mValue);
       }
       mAudio.mOriginalInfo = Move(audioInfo);
       mTrackDemuxersMayBlock |= mAudio.mTrackDemuxer->GetSamplesMayBlock();
     } else {
       mAudio.mTrackDemuxer->BreakCycles();
       mAudio.mTrackDemuxer = nullptr;
@@ -3108,29 +3114,34 @@ MediaFormatReader::GetImageContainer()
   return mVideoFrameContainer ? mVideoFrameContainer->GetImageContainer()
                               : nullptr;
 }
 
 void
 MediaFormatReader::GetMozDebugReaderData(nsACString& aString)
 {
   nsAutoCString result;
-  nsAutoCString audioName("unavailable");
-  nsAutoCString videoName = audioName;
+  nsAutoCString audioDecoderName("unavailable");
+  nsAutoCString videoDecoderName = audioDecoderName;
+  nsAutoCString audioType("none");
+  nsAutoCString videoType("none");
 
   if (HasAudio()) {
     MutexAutoLock lock(mAudio.mMutex);
-    audioName = mAudio.mDescription;
+    audioDecoderName = mAudio.mDescription;
+    audioType = mInfo.mAudio.mMimeType;
   }
   if (HasVideo()) {
     MutexAutoLock mon(mVideo.mMutex);
-    videoName = mVideo.mDescription;
+    videoDecoderName = mVideo.mDescription;
+    videoType = mInfo.mVideo.mMimeType;
   }
 
-  result += nsPrintfCString("Audio Decoder: %s\n", audioName.get());
+  result += nsPrintfCString(
+    "Audio Decoder(%s): %s\n", audioType.get(), audioDecoderName.get());
   result += nsPrintfCString("Audio Frames Decoded: %" PRIu64 "\n",
                             mAudio.mNumSamplesOutputTotal);
   if (HasAudio()) {
     result += nsPrintfCString(
       "Audio State: ni=%d no=%d wp=%d demuxr=%d demuxq=%u decoder=%d tt=%.1f "
       "tths=%d in=%" PRIu64 " out=%" PRIu64
       " qs=%u pending=%u wfd=%d eos=%d ds=%d wfk=%d sid=%u\n",
       NeedInput(mAudio),
@@ -3147,17 +3158,18 @@ MediaFormatReader::GetMozDebugReaderData
       unsigned(size_t(mAudio.mSizeOfQueue)),
       unsigned(mAudio.mOutput.Length()),
       mAudio.mWaitingForData,
       mAudio.mDemuxEOS,
       int32_t(mAudio.mDrainState),
       mAudio.mWaitingForKey,
       mAudio.mLastStreamSourceID);
   }
-  result += nsPrintfCString("Video Decoder: %s\n", videoName.get());
+  result += nsPrintfCString(
+    "Video Decoder(%s): %s\n", videoType.get(), videoDecoderName.get());
   result +=
     nsPrintfCString("Hardware Video Decoding: %s\n",
                     VideoIsHardwareAccelerated() ? "enabled" : "disabled");
   result +=
     nsPrintfCString("Video Frames Decoded: %" PRIu64 " (skipped=%" PRIu64 ")\n",
                     mVideo.mNumSamplesOutputTotal,
                     mVideo.mNumSamplesSkippedTotal);
   if (HasVideo()) {
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -1176,9 +1176,21 @@ WMFVideoMFTManager::Shutdown()
 
 bool
 WMFVideoMFTManager::IsHardwareAccelerated(nsACString& aFailureReason) const
 {
   aFailureReason = mDXVAFailureReason;
   return mDecoder && mUseHwAccel;
 }
 
+nsCString
+WMFVideoMFTManager::GetDescriptionName() const
+{
+  nsCString failureReason;
+  if (mAMDVP9InUse) {
+      return NS_LITERAL_CSTRING("amd vp9 hardware video decoder");
+  }
+  return nsPrintfCString("wmf %s video decoder",
+                         IsHardwareAccelerated(failureReason) ? "hardware"
+                                                              : "software");
+}
+
 } // namespace mozilla
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.h
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.h
@@ -35,25 +35,17 @@ public:
   HRESULT Output(int64_t aStreamOffset, RefPtr<MediaData>& aOutput) override;
 
   void Shutdown() override;
 
   bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
 
   TrackInfo::TrackType GetType() override { return TrackInfo::kVideoTrack; }
 
-  nsCString GetDescriptionName() const override
-  {
-    nsCString failureReason;
-    return IsHardwareAccelerated(failureReason)
-      ? mAMDVP9InUse
-        ? NS_LITERAL_CSTRING("AMD VP9 hardware video decoder")
-        : NS_LITERAL_CSTRING("wmf hardware video decoder")
-      : NS_LITERAL_CSTRING("wmf software video decoder");
-  }
+  nsCString GetDescriptionName() const override;
 
   void Flush() override
   {
     MFTManager::Flush();
     mDraining = false;
     mSamplesCount = 0;
   }