diff --git a/mobile/android/base/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java b/mobile/android/base/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java index ce4649b7d068..62f805bc9ed1 100644 --- a/mobile/android/base/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java +++ b/mobile/android/base/java/org/mozilla/gecko/util/HardwareCodecCapabilityUtils.java @@ -6,6 +6,7 @@ package org.mozilla.gecko.util; +import org.mozilla.gecko.annotation.WrapForJNI; import org.mozilla.gecko.AppConstants.Versions; import android.media.MediaCodecInfo; @@ -35,6 +36,21 @@ public final class HardwareCodecCapabilityUtils { COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m }; + @WrapForJNI(allowMultithread = true, stubName = "FindDecoderCodecInfoForMimeType") + public static boolean findDecoderCodecInfoForMimeType(String aMimeType) { + for (int i = 0; i < MediaCodecList.getCodecCount(); ++i) { + MediaCodecInfo info = MediaCodecList.getCodecInfoAt(i); + if (info.isEncoder()) { + continue; + } + for (String mimeType : info.getSupportedTypes()) { + if (mimeType.equals(aMimeType)) { + return true; + } + } + } + return false; + } public static boolean getHWEncoderCapability() { if (Versions.feature20Plus) { diff --git a/widget/android/GeneratedJNIWrappers.cpp b/widget/android/GeneratedJNIWrappers.cpp index c0cc12873882..ba30d7c017c1 100644 --- a/widget/android/GeneratedJNIWrappers.cpp +++ b/widget/android/GeneratedJNIWrappers.cpp @@ -1761,6 +1761,16 @@ auto Clipboard::SetClipboardText(mozilla::jni::String::Param a0) -> void return mozilla::jni::Method::Call(nullptr, nullptr, a0); } +constexpr char HardwareCodecCapabilityUtils::name[]; + +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::Call(nullptr, nullptr, a0); +} + constexpr char NativeJSContainer::name[]; constexpr char NativeJSContainer::New_t::name[]; diff --git a/widget/android/GeneratedJNIWrappers.h b/widget/android/GeneratedJNIWrappers.h index 4c16c66f272d..7b5568b8bcd8 100644 --- a/widget/android/GeneratedJNIWrappers.h +++ b/widget/android/GeneratedJNIWrappers.h @@ -4677,6 +4677,40 @@ public: }; +class HardwareCodecCapabilityUtils : public mozilla::jni::Class +{ +public: + typedef mozilla::jni::Ref Ref; + typedef mozilla::jni::LocalRef LocalRef; + typedef mozilla::jni::GlobalRef GlobalRef; + typedef const mozilla::jni::Param& Param; + + static constexpr char name[] = + "org/mozilla/gecko/util/HardwareCodecCapabilityUtils"; + +protected: + HardwareCodecCapabilityUtils(jobject instance) : Class(instance) {} + +public: + 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[] = + "(Ljava/lang/String;)Z"; + static const bool isStatic = true; + static const bool isMultithreaded = true; + static const mozilla::jni::ExceptionMode exceptionMode = + mozilla::jni::ExceptionMode::ABORT; + }; + + static auto FindDecoderCodecInfoForMimeType(mozilla::jni::String::Param) -> bool; + +}; + class NativeJSContainer : public mozilla::jni::Class { public: