| Index: media/base/android/media_codec_bridge.cc
|
| diff --git a/media/base/android/media_codec_bridge.cc b/media/base/android/media_codec_bridge.cc
|
| index 7ece5d558e6fa03937e5efc3b6fb1a1d5cbcccfb..ae48d7660349142b36689d85760be65ed7ab7eb2 100644
|
| --- a/media/base/android/media_codec_bridge.cc
|
| +++ b/media/base/android/media_codec_bridge.cc
|
| @@ -114,6 +114,12 @@ bool MediaCodecBridge::SupportsSetParameters() {
|
| }
|
|
|
| // static
|
| +bool MediaCodecBridge::SupportsGetName() {
|
| + // MediaCodec.getName() is only available on JB MR2 and greater.
|
| + return base::android::BuildInfo::GetInstance()->sdk_int() >= 18;
|
| +}
|
| +
|
| +// static
|
| std::vector<MediaCodecBridge::CodecsInfo> MediaCodecBridge::GetCodecsInfo() {
|
| std::vector<CodecsInfo> codecs_info;
|
| if (!IsAvailable())
|
| @@ -143,6 +149,20 @@ std::vector<MediaCodecBridge::CodecsInfo> MediaCodecBridge::GetCodecsInfo() {
|
| }
|
|
|
| // static
|
| +std::string MediaCodecBridge::GetDefaultCodecName(
|
| + const std::string& mime_type,
|
| + MediaCodecDirection direction) {
|
| + if (!IsAvailable())
|
| + return std::string();
|
| +
|
| + JNIEnv* env = AttachCurrentThread();
|
| + ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime_type);
|
| + ScopedJavaLocalRef<jstring> j_codec_name =
|
| + Java_MediaCodecBridge_getDefaultCodecName(env, j_mime.obj(), direction);
|
| + return ConvertJavaStringToUTF8(env, j_codec_name.obj());
|
| +}
|
| +
|
| +// static
|
| bool MediaCodecBridge::CanDecode(const std::string& codec, bool is_secure) {
|
| if (!IsAvailable())
|
| return false;
|
| @@ -167,19 +187,32 @@ bool MediaCodecBridge::IsKnownUnaccelerated(const std::string& mime_type,
|
| if (!IsAvailable())
|
| return true;
|
|
|
| - std::string codec_type = AndroidMimeTypeToCodecType(mime_type);
|
| - std::vector<media::MediaCodecBridge::CodecsInfo> codecs_info =
|
| - MediaCodecBridge::GetCodecsInfo();
|
| - for (size_t i = 0; i < codecs_info.size(); ++i) {
|
| - if (codecs_info[i].codecs == codec_type &&
|
| - codecs_info[i].direction == direction) {
|
| - // It would be nice if MediaCodecInfo externalized some notion of
|
| - // HW-acceleration but it doesn't. Android Media guidance is that the
|
| - // prefix below is always used for SW decoders, so that's what we use.
|
| - if (!StartsWithASCII(codecs_info[i].name, "OMX.google.", true))
|
| - return false;
|
| + std::string codec_name;
|
| + if (SupportsGetName()) {
|
| + codec_name = GetDefaultCodecName(mime_type, direction);
|
| + } else {
|
| + std::string codec_type = AndroidMimeTypeToCodecType(mime_type);
|
| + std::vector<media::MediaCodecBridge::CodecsInfo> codecs_info =
|
| + MediaCodecBridge::GetCodecsInfo();
|
| + for (size_t i = 0; i < codecs_info.size(); ++i) {
|
| + if (codecs_info[i].codecs == codec_type &&
|
| + codecs_info[i].direction == direction) {
|
| + codec_name = codecs_info[i].name;
|
| + break;
|
| + }
|
| }
|
| }
|
| + DVLOG(1) << __PRETTY_FUNCTION__ << "Default codec for " << mime_type <<
|
| + " : " << codec_name;
|
| + // It would be nice if MediaCodecInfo externalized some notion of
|
| + // HW-acceleration but it doesn't. Android Media guidance is that the
|
| + // "OMX.google" prefix is always used for SW decoders, so that's what we
|
| + // use. "OMX.SEC.*" codec is Samsung software implementation - report it
|
| + // as unaccelerated as well.
|
| + if (codec_name.length() > 0) {
|
| + return (StartsWithASCII(codec_name, "OMX.google.", true) ||
|
| + StartsWithASCII(codec_name, "OMX.SEC.", true));
|
| + }
|
| return true;
|
| }
|
|
|
|
|