Bug 1286738 - part3-mediasource: Enable fennec vp9 only if we have hw deocder. r=jya draft
authorbechen <bechen@mozilla.com>
Wed, 26 Oct 2016 17:08:21 +0800
changeset 429654 85ed47735c51281053b409d25bdebd6dad3aa1bc
parent 429653 fdbc3df00ff8792c9e27a5f8fb2e9321fbde3468
child 429655 b834c1f767b35036928c3d59663b62ead7482ea9
push id33627
push userbechen@mozilla.com
push dateWed, 26 Oct 2016 09:48:18 +0000
reviewersjya
bugs1286738
milestone52.0a1
Bug 1286738 - part3-mediasource: Enable fennec vp9 only if we have hw deocder. r=jya MozReview-Commit-ID: BwAZTrgXcaP
dom/media/Benchmark.cpp
dom/media/mediasource/MediaSource.cpp
--- a/dom/media/Benchmark.cpp
+++ b/dom/media/Benchmark.cpp
@@ -30,17 +30,17 @@ bool VP9Benchmark::sHasRunTest = false;
 
 // static
 bool
 VP9Benchmark::IsVP9DecodeFast()
 {
   MOZ_ASSERT(NS_IsMainThread());
 
 #ifdef MOZ_WIDGET_ANDROID
-  return true;
+  return false;
 #else
   bool hasPref = Preferences::HasUserValue(sBenchmarkFpsPref);
   uint32_t hadRecentUpdate = Preferences::GetUint(sBenchmarkFpsVersionCheck, 0U);
 
   if (!sHasRunTest && (!hasPref || hadRecentUpdate != sBenchmarkVersionID)) {
     sHasRunTest = true;
 
     RefPtr<WebMDemuxer> demuxer =
--- a/dom/media/mediasource/MediaSource.cpp
+++ b/dom/media/mediasource/MediaSource.cpp
@@ -28,16 +28,20 @@
 #include "nsPIDOMWindow.h"
 #include "nsString.h"
 #include "nsThreadUtils.h"
 #include "mozilla/Logging.h"
 #include "nsServiceManagerUtils.h"
 #include "mozilla/gfx/gfxVars.h"
 #include "mozilla/Sprintf.h"
 
+#ifdef MOZ_WIDGET_ANDROID
+#include "AndroidBridge.h"
+#endif
+
 struct JSContext;
 class JSObject;
 
 mozilla::LogModule* GetMediaSourceLog()
 {
   static mozilla::LazyLogModule sLogModule("MediaSource");
   return sLogModule;
 }
@@ -66,17 +70,22 @@ namespace mozilla {
 // 3. The CPU is considered to be fast enough
 static bool
 IsWebMForced(DecoderDoctorDiagnostics* aDiagnostics)
 {
   bool mp4supported =
     DecoderTraits::IsMP4TypeAndEnabled(NS_LITERAL_CSTRING("video/mp4"),
                                        aDiagnostics);
   bool hwsupported = gfx::gfxVars::CanUseHardwareVideoDecoding();
+#ifdef MOZ_WIDGET_ANDROID
+  return !mp4supported || !hwsupported || VP9Benchmark::IsVP9DecodeFast() ||
+         java::HardwareCodecCapabilityUtils::HasHWVP9();
+#else
   return !mp4supported || !hwsupported || VP9Benchmark::IsVP9DecodeFast();
+#endif
 }
 
 namespace dom {
 
 /* static */
 nsresult
 MediaSource::IsTypeSupported(const nsAString& aType, DecoderDoctorDiagnostics* aDiagnostics)
 {