Bug 1182444 - Show audio as enabled when an audio track is present in stream. r=jesup, a=lmandel
authorJean-Yves Avenard <jyavenard@mozilla.com>
Thu, 16 Jul 2015 19:15:06 +1000
changeset 281591 20553f5788f37213b7ff74e13d70b3a2abb0725b
parent 281590 6c85547293b4f83d5d9e48f092e85fcce0ea3f7e
child 281592 d45c029bc1552ddb317458c25d2fddca5ecab333
push id4932
push userjlund@mozilla.com
push dateMon, 10 Aug 2015 18:23:06 +0000
treeherdermozilla-beta@6dd5a4f5f745 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjesup, lmandel
bugs1182444
milestone41.0a2
Bug 1182444 - Show audio as enabled when an audio track is present in stream. r=jesup, a=lmandel
dom/html/HTMLMediaElement.cpp
dom/media/MediaInfo.h
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -3563,16 +3563,22 @@ HTMLMediaElement::UpdateReadyStateIntern
     if ((!hasAudio && !hasVideo) ||
         (IsVideo() && hasVideo && !HasVideo())) {
       return;
     }
 
     // We are playing a stream that has video and a video frame is now set.
     // This means we have all metadata needed to change ready state.
     MediaInfo mediaInfo = mMediaInfo;
+    if (hasAudio) {
+      mediaInfo.EnableAudio();
+    }
+    if (hasVideo) {
+      mediaInfo.EnableVideo();
+    }
     MetadataLoaded(&mediaInfo, nsAutoPtr<const MetadataTags>(nullptr));
   }
 
   if (NextFrameStatus() == MediaDecoderOwner::NEXT_FRAME_UNAVAILABLE_SEEKING) {
     ChangeReadyState(nsIDOMHTMLMediaElement::HAVE_METADATA);
     return;
   }
 
--- a/dom/media/MediaInfo.h
+++ b/dom/media/MediaInfo.h
@@ -334,21 +334,42 @@ private:
 
 class MediaInfo {
 public:
   bool HasVideo() const
   {
     return mVideo.IsValid();
   }
 
+  void EnableVideo()
+  {
+    if (HasVideo()) {
+      return;
+    }
+    // Set dummy values so that HasVideo() will return true;
+    // See VideoInfo::IsValid()
+    mVideo.mDisplay = nsIntSize(1, 1);
+  }
+
   bool HasAudio() const
   {
     return mAudio.IsValid();
   }
 
+  void EnableAudio()
+  {
+    if (HasAudio()) {
+      return;
+    }
+    // Set dummy values so that HasAudio() will return true;
+    // See AudioInfo::IsValid()
+    mAudio.mChannels = 2;
+    mAudio.mRate = 44100;
+  }
+
   bool IsEncrypted() const
   {
     return mCrypto.IsEncrypted();
   }
 
   bool HasValidMedia() const
   {
     return HasVideo() || HasAudio();