Bug 973761 - [WebRTC] Check device capabilities (HW codec and Android ver) before enabling vp8 hardware acceleration on Fennec. r=bjacob, r=gcp
authorQiang Lu <qiang.lu@intel.com>
Thu, 20 Mar 2014 21:37:16 +0800
changeset 195212 1f59989940673c0a315e978b840a77fb70e6d69c
parent 195211 8b4c324e81e8d49c0393d5e1961a0d0040891497
child 195213 bf5b4bd387b38cd1a2a64f259467b72b25f32813
push idunknown
push userunknown
push dateunknown
reviewersbjacob, gcp
bugs973761
milestone31.0a1
Bug 973761 - [WebRTC] Check device capabilities (HW codec and Android ver) before enabling vp8 hardware acceleration on Fennec. r=bjacob, r=gcp
modules/libpref/src/init/all.js
widget/android/GfxInfo.cpp
widget/nsIGfxInfo.idl
--- a/modules/libpref/src/init/all.js
+++ b/modules/libpref/src/init/all.js
@@ -272,16 +272,19 @@ pref("media.peerconnection.noise_enabled
 pref("media.peerconnection.noise", 1);
 // Adjustments for OS mediastream+output+OS+input delay (lower bound)
 #if defined(XP_MACOSX)
 pref("media.peerconnection.capture_delay", 50);
 #elif defined(XP_WIN)
 pref("media.peerconnection.capture_delay", 50);
 #elif defined(ANDROID)
 pref("media.peerconnection.capture_delay", 100);
+// Whether to enable Webrtc Hardware acceleration support
+pref("media.navigator.hardware.vp8_encode.acceleration_enabled", false);
+pref("media.navigator.hardware.vp8_decode.acceleration_enabled", false);
 #elif defined(XP_LINUX)
 pref("media.peerconnection.capture_delay", 70);
 #else
 // *BSD, others - merely a guess for now
 pref("media.peerconnection.capture_delay", 50);
 #endif
 #else
 #ifdef ANDROID
--- a/widget/android/GfxInfo.cpp
+++ b/widget/android/GfxInfo.cpp
@@ -475,17 +475,17 @@ GfxInfo::GetFeatureStatusImpl(int32_t aF
           return NS_OK;
         }
       }
       else if (CompareVersions(mOSVersion.get(), "3.0.0") >= 0 &&
           CompareVersions(mOSVersion.get(), "4.0.0") < 0)
       {
         // Honeycomb Samsung devices are whitelisted.
         // All other Honeycomb devices are blacklisted.
-	bool isWhitelisted =
+        bool isWhitelisted =
           cManufacturer.Equals("samsung", nsCaseInsensitiveCStringComparator());
 
         if (!isWhitelisted) {
           *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
           return NS_OK;
         }
       }
       else if (CompareVersions(mOSVersion.get(), "4.0.0") < 0)
@@ -544,16 +544,34 @@ GfxInfo::GetFeatureStatusImpl(int32_t aF
       {
         // Blocklist all Sony devices
         if (cManufacturer.Find("Sony", true) != -1) {
           *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
           return NS_OK;
         }
       }
     }
+
+    if (aFeature == FEATURE_WEBRTC_HW_ACCELERATION) {
+      NS_LossyConvertUTF16toASCII cManufacturer(mManufacturer);
+      NS_LossyConvertUTF16toASCII cModel(mModel);
+      NS_LossyConvertUTF16toASCII cHardware(mHardware);
+
+      if (cHardware.Equals("hammerhead") &&
+          CompareVersions(mOSVersion.get(), "4.4.2") >= 0 &&
+          cManufacturer.Equals("lge", nsCaseInsensitiveCStringComparator()) &&
+          cModel.Equals("nexus 5", nsCaseInsensitiveCStringComparator())) {
+        *aStatus = nsIGfxInfo::FEATURE_NO_INFO;
+        return NS_OK;
+      } else {
+        // Blocklist all other devices except Nexus 5 which VP8 hardware acceleration is supported
+        *aStatus = nsIGfxInfo::FEATURE_BLOCKED_DEVICE;
+        return NS_OK;
+      }
+    }
   }
 
   return GfxInfoBase::GetFeatureStatusImpl(aFeature, aStatus, aSuggestedDriverVersion, aDriverInfo, &os);
 }
 
 #ifdef DEBUG
 
 // Implement nsIGfxInfoDebug
@@ -618,9 +636,9 @@ nsString GfxInfo::Manufacturer()
 
 uint32_t GfxInfo::OperatingSystemVersion()
 {
   EnsureInitialized();
   return mOSVersionInteger;
 }
 
 }
-}
\ No newline at end of file
+}
--- a/widget/nsIGfxInfo.idl
+++ b/widget/nsIGfxInfo.idl
@@ -74,16 +74,18 @@ interface nsIGfxInfo : nsISupports
   /* Whether WebGL is supported via OpenGL. */
   const long FEATURE_WEBGL_OPENGL = 6;
   /* Whether WebGL is supported via ANGLE (D3D9 -- does not check for the presence of ANGLE libs). */
   const long FEATURE_WEBGL_ANGLE = 7;
   /* Whether WebGL antialiasing is supported. */
   const long FEATURE_WEBGL_MSAA = 8;
   /* Whether Stagefright is supported */
   const long FEATURE_STAGEFRIGHT = 9;
+  /* Whether Webrtc Hardware acceleration is supported */
+  const long FEATURE_WEBRTC_HW_ACCELERATION = 10;
 
   /*
    * A set of return values from GetFeatureStatus
    */
 
   /* We don't explicitly block or discourage the feature. Which means we'll try getting it from the
    * hardware, and see what happens. */
   const long FEATURE_NO_INFO = 1;