Bug 1368839 - Add av1 to MediaSource.isTypeSupported. r=gerald
☠☠ backed out by 1de33be170d6 ☠ ☠
authorRalph Giles <giles@mozilla.com>
Tue, 30 May 2017 16:37:20 -0700
changeset 409848 9a7debda755d22df58bffe5132d7ec47ad5447b1
parent 409790 2df9b5a84a80ba7259e6175c126727b87b4ce808
child 409849 8a78af3f02805279a1ac130a9daa336af3a1d65a
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1368839
milestone55.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 1368839 - Add av1 to MediaSource.isTypeSupported. r=gerald When av1 video playback is enabled, declare it as supported in the webm container in MediaSource.IsTypeSupported. Also support special mime types of the form video/webm; codecs=vp9.experimental.<git-commit-id> so test sites can verify playback support of particular encodings while the av1 bitstream is under development. MozReview-Commit-ID: GS4n7cPxfQ7
dom/media/platforms/agnostic/AOMDecoder.cpp
dom/media/platforms/agnostic/AOMDecoder.h
dom/media/webm/WebMDecoder.cpp
--- a/dom/media/platforms/agnostic/AOMDecoder.cpp
+++ b/dom/media/platforms/agnostic/AOMDecoder.cpp
@@ -216,16 +216,29 @@ bool
 AOMDecoder::IsAV1(const nsACString& aMimeType)
 {
   return aMimeType.EqualsLiteral("video/webm; codecs=av1")
          || aMimeType.EqualsLiteral("video/av1");
 }
 
 /* static */
 bool
+AOMDecoder::IsSupportedCodec(const nsAString& aCodecType)
+{
+  // While AV1 is under development, we describe support
+  // for a specific aom commit hash so sites can check
+  // compatibility.
+  auto version = NS_ConvertASCIItoUTF16("av1.experimental.");
+  version.AppendLiteral("4d668d7feb1f8abd809d1bca0418570a7f142a36");
+  return aCodecType.EqualsLiteral("av1") ||
+         aCodecType.Equals(version);
+}
+
+/* static */
+bool
 AOMDecoder::IsKeyframe(Span<const uint8_t> aBuffer) {
   aom_codec_stream_info_t info;
   PodZero(&info);
   info.sz = sizeof(info);
 
   auto res = aom_codec_peek_stream_info(aom_codec_av1_dx(),
                                         aBuffer.Elements(),
                                         aBuffer.Length(),
--- a/dom/media/platforms/agnostic/AOMDecoder.h
+++ b/dom/media/platforms/agnostic/AOMDecoder.h
@@ -28,16 +28,19 @@ public:
   {
     return "libaom (AV1) video decoder";
   }
 
   // Return true if aMimeType is a one of the strings used
   // by our demuxers to identify AV1 streams.
   static bool IsAV1(const nsACString& aMimeType);
 
+  // Return true if aCodecType is a supported codec description.
+  static bool IsSupportedCodec(const nsAString& aCodecType);
+
   // Return true if a sample is a keyframe.
   static bool IsKeyframe(Span<const uint8_t> aBuffer);
 
   // Return the frame dimensions for a sample.
   static nsIntSize GetFrameSize(Span<const uint8_t> aBuffer);
 
 private:
   ~AOMDecoder();
--- a/dom/media/webm/WebMDecoder.cpp
+++ b/dom/media/webm/WebMDecoder.cpp
@@ -1,15 +1,16 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* vim:set ts=2 sw=2 sts=2 et cindent: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "mozilla/Preferences.h"
+#include "AOMDecoder.h"
 #include "MediaContainerType.h"
 #include "MediaDecoderStateMachine.h"
 #include "WebMDemuxer.h"
 #include "WebMDecoder.h"
 #include "VideoUtils.h"
 
 namespace mozilla {
 
@@ -46,16 +47,21 @@ WebMDecoder::IsSupportedType(const Media
     }
     // Note: Only accept VP8/VP9 in a video container type, not in an audio
     // container type.
     if (isVideo &&
         (codec.EqualsLiteral("vp8") || codec.EqualsLiteral("vp8.0") ||
          codec.EqualsLiteral("vp9") || codec.EqualsLiteral("vp9.0"))) {
       continue;
     }
+#ifdef MOZ_AV1
+    if (isVideo && AOMDecoder::IsSupportedCodec(codec)) {
+      continue;
+    }
+#endif
     // Some unsupported codec.
     return false;
   }
   return true;
 }
 
 void
 WebMDecoder::GetMozDebugReaderData(nsACString& aString)