Bug 1368839 - Add av1 to MediaSource.isTypeSupported. r=gerald
authorRalph Giles <giles@mozilla.com>
Tue, 30 May 2017 16:37:20 -0700
changeset 361823 167cd75cfda764e5ddce73d6b026363dbb1c2adc
parent 361822 ec18d62f02a94186fee90fc1814efd1c4ced3b51
child 361824 0c50bc93a3dc0c78eae2c3599912b86c03509aea
push id31945
push userryanvm@gmail.com
push dateThu, 01 Jun 2017 20:42:17 +0000
treeherdermozilla-central@15e32469eb04 [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,18 @@
 /* -*- 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"
+#ifdef MOZ_AV1
+#include "AOMDecoder.h"
+#endif
 #include "MediaContainerType.h"
 #include "MediaDecoderStateMachine.h"
 #include "WebMDemuxer.h"
 #include "WebMDecoder.h"
 #include "VideoUtils.h"
 
 namespace mozilla {
 
@@ -46,16 +49,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)