Bug 1286738 - part3-mediasource: Enable fennec vp9 only if we have hw deocder. r=jya
authorbechen <bechen@mozilla.com>
Wed, 26 Oct 2016 17:08:21 +0800
changeset 347170 aa540c9dbd1178a5e2e03033b0387725970b9e95
parent 347169 05c8cd834019f12c20145fc88a59fe3aa5aa14da
child 347171 577e23f7124a9986278955965c0d666571020af9
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
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)
 {