Bug 1286738 - part2-HardwareCodecCapabilityUtils: Add HasHWVP9() function to check the vp9 hw decoder. r=jya draft
authorbechen <bechen@mozilla.com>
Wed, 26 Oct 2016 16:57:55 +0800
changeset 429653 fdbc3df00ff8792c9e27a5f8fb2e9321fbde3468
parent 429652 740b7d6b75e40d0226a94a203d15a958ad675397
child 429654 85ed47735c51281053b409d25bdebd6dad3aa1bc
push id33627
push userbechen@mozilla.com
push dateWed, 26 Oct 2016 09:48:18 +0000
reviewersjya
bugs1286738
milestone52.0a1
Bug 1286738 - part2-HardwareCodecCapabilityUtils: Add HasHWVP9() function to check the vp9 hw decoder. r=jya MozReview-Commit-ID: 1a89GQixKrO
mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java
widget/android/GeneratedJNIWrappers.cpp
widget/android/GeneratedJNIWrappers.h
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java
@@ -19,16 +19,17 @@ public final class HardwareCodecCapabili
 
   // List of supported HW VP8 encoders.
   private static final String[] supportedVp8HwEncCodecPrefixes =
   {"OMX.qcom.", "OMX.Intel." };
   // List of supported HW VP8 decoders.
   private static final String[] supportedVp8HwDecCodecPrefixes =
   {"OMX.qcom.", "OMX.Nvidia.", "OMX.Exynos.", "OMX.Intel." };
   private static final String VP8_MIME_TYPE = "video/x-vnd.on2.vp8";
+  private static final String VP9_MIME_TYPE = "video/x-vnd.on2.vp9";
   // NV12 color format supported by QCOM codec, but not declared in MediaCodec -
   // see /hardware/qcom/media/mm-core/inc/OMX_QCOMExtns.h
   private static final int
     COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m = 0x7FA30C04;
   // Allowable color formats supported by codec - in order of preference.
   private static final int[] supportedColorList = {
     CodecCapabilities.COLOR_FormatYUV420Planar,
     CodecCapabilities.COLOR_FormatYUV420SemiPlanar,
@@ -101,25 +102,34 @@ public final class HardwareCodecCapabili
         }
       }
     }
     // No HW encoder.
     return false;
   }
 
   public static boolean getHWDecoderCapability() {
+    return getHWDecoderCapability(VP8_MIME_TYPE);
+  }
+
+  @WrapForJNI
+  public static boolean HasHWVP9() {
+    return getHWDecoderCapability(VP9_MIME_TYPE);
+  }
+
+  public static boolean getHWDecoderCapability(String aMimeType) {
     if (Versions.feature20Plus) {
       for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) {
         MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i);
         if (info.isEncoder()) {
           continue;
         }
         String name = null;
         for (String mimeType : info.getSupportedTypes()) {
-          if (mimeType.equals(VP8_MIME_TYPE)) {
+          if (mimeType.equals(aMimeType)) {
             name = info.getName();
             break;
           }
         }
         if (name == null) {
           continue;  // No HW support in this codec; try the next one.
         }
         Log.e(LOGTAG, "Found candidate decoder " + name);
@@ -133,17 +143,17 @@ public final class HardwareCodecCapabili
           }
         }
         if (!supportedCodec) {
           continue;
         }
 
         // Check if codec supports either yuv420 or nv12.
         CodecCapabilities capabilities =
-          info.getCapabilitiesForType(VP8_MIME_TYPE);
+          info.getCapabilitiesForType(aMimeType);
         for (int colorFormat : capabilities.colorFormats) {
           Log.v(LOGTAG, "   Color: 0x" + Integer.toHexString(colorFormat));
         }
         for (int supportedColorFormat : supportedColorList) {
           for (int codecColorFormat : capabilities.colorFormats) {
             if (codecColorFormat == supportedColorFormat) {
               // Found supported HW decoder.
               Log.e(LOGTAG, "Found target decoder " + name +
--- a/widget/android/GeneratedJNIWrappers.cpp
+++ b/widget/android/GeneratedJNIWrappers.cpp
@@ -1732,16 +1732,24 @@ constexpr char Clipboard::SetText_t::sig
 auto Clipboard::SetText(mozilla::jni::String::Param a0) -> void
 {
     return mozilla::jni::Method<SetText_t>::Call(Clipboard::Context(), nullptr, a0);
 }
 
 const char HardwareCodecCapabilityUtils::name[] =
         "org/mozilla/gecko/util/HardwareCodecCapabilityUtils";
 
+constexpr char HardwareCodecCapabilityUtils::HasHWVP9_t::name[];
+constexpr char HardwareCodecCapabilityUtils::HasHWVP9_t::signature[];
+
+auto HardwareCodecCapabilityUtils::HasHWVP9() -> bool
+{
+    return mozilla::jni::Method<HasHWVP9_t>::Call(HardwareCodecCapabilityUtils::Context(), nullptr);
+}
+
 constexpr char HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType_t::name[];
 constexpr char HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType_t::signature[];
 
 auto HardwareCodecCapabilityUtils::FindDecoderCodecInfoForMimeType(mozilla::jni::String::Param a0) -> bool
 {
     return mozilla::jni::Method<FindDecoderCodecInfoForMimeType_t>::Call(HardwareCodecCapabilityUtils::Context(), nullptr, a0);
 }
 
--- a/widget/android/GeneratedJNIWrappers.h
+++ b/widget/android/GeneratedJNIWrappers.h
@@ -4790,16 +4790,35 @@ public:
 
 class HardwareCodecCapabilityUtils : public mozilla::jni::ObjectBase<HardwareCodecCapabilityUtils>
 {
 public:
     static const char name[];
 
     explicit HardwareCodecCapabilityUtils(const Context& ctx) : ObjectBase<HardwareCodecCapabilityUtils>(ctx) {}
 
+    struct HasHWVP9_t {
+        typedef HardwareCodecCapabilityUtils Owner;
+        typedef bool ReturnType;
+        typedef bool SetterType;
+        typedef mozilla::jni::Args<> Args;
+        static constexpr char name[] = "HasHWVP9";
+        static constexpr char signature[] =
+                "()Z";
+        static const bool isStatic = true;
+        static const mozilla::jni::ExceptionMode exceptionMode =
+                mozilla::jni::ExceptionMode::ABORT;
+        static const mozilla::jni::CallingThread callingThread =
+                mozilla::jni::CallingThread::ANY;
+        static const mozilla::jni::DispatchTarget dispatchTarget =
+                mozilla::jni::DispatchTarget::CURRENT;
+    };
+
+    static auto HasHWVP9() -> bool;
+
     struct FindDecoderCodecInfoForMimeType_t {
         typedef HardwareCodecCapabilityUtils Owner;
         typedef bool ReturnType;
         typedef bool SetterType;
         typedef mozilla::jni::Args<
                 mozilla::jni::String::Param> Args;
         static constexpr char name[] = "findDecoderCodecInfoForMimeType";
         static constexpr char signature[] =