Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/base/android/media_codec_util.h" | 5 #include "media/base/android/media_codec_util.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 97 static bool IsEncoderSupportedByDevice(const std::string& android_mime_type) { | 97 static bool IsEncoderSupportedByDevice(const std::string& android_mime_type) { |
| 98 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); | 98 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); |
| 99 JNIEnv* env = AttachCurrentThread(); | 99 JNIEnv* env = AttachCurrentThread(); |
| 100 ScopedJavaLocalRef<jstring> j_mime = | 100 ScopedJavaLocalRef<jstring> j_mime = |
| 101 ConvertUTF8ToJavaString(env, android_mime_type); | 101 ConvertUTF8ToJavaString(env, android_mime_type); |
| 102 return Java_MediaCodecUtil_isEncoderSupportedByDevice(env, j_mime); | 102 return Java_MediaCodecUtil_isEncoderSupportedByDevice(env, j_mime); |
| 103 } | 103 } |
| 104 | 104 |
| 105 // static | 105 // static |
| 106 bool MediaCodecUtil::IsMediaCodecAvailable() { | 106 bool MediaCodecUtil::IsMediaCodecAvailable() { |
| 107 return IsMediaCodecAvailableForSdk( | |
| 108 base::android::BuildInfo::GetInstance()->sdk_int(), nullptr); | |
| 109 } | |
| 110 | |
| 111 // static | |
| 112 bool MediaCodecUtil::IsMediaCodecAvailableForSdk(int sdk, | |
| 113 const char* model_for_test) { | |
| 107 // Blacklist some devices on Jellybean as MediaCodec is buggy. | 114 // Blacklist some devices on Jellybean as MediaCodec is buggy. |
| 108 // http://crbug.com/365494, http://crbug.com/615872 | 115 // http://crbug.com/365494, http://crbug.com/615872 |
| 109 // Blacklist Lenovo A6600 / A6800 on KitKat, which tends to crash a lot. | 116 // Blacklist Lenovo A6600 / A6800 on KitKat, which tends to crash a lot. |
| 110 // See crbug.com/628059 . We include < K since they don't exist. | 117 // See crbug.com/628059 . We include < K since they don't exist. |
| 111 // Blacklist Samsung Galaxy Star Pro (GT-S7262) (crbug.com/634920). | 118 // Blacklist Samsung Galaxy Star Pro (GT-S7262) (crbug.com/634920). |
| 112 // GT-S5282 and GT-I8552 are for crbug.com/634920 . | 119 // GT-S5282 and GT-I8552 are for crbug.com/634920 . |
| 113 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) { | 120 // Blacklist LGMS330 on L for crbug.com/654905 . |
| 114 std::string model(base::android::BuildInfo::GetInstance()->model()); | 121 |
| 115 return model != "GT-I9100" && model != "GT-I9300" && model != "GT-N7000" && | 122 // None of our tests fail >= marshmallow. |
| 116 model != "GT-N7100" && model != "A6600" && model != "A6800" && | 123 if (sdk >= base::android::SDK_VERSION_MARSHMALLOW) |
| 117 model != "GT-S7262" && model != "GT-S5282" && model != "GT-I8552"; | 124 return true; |
| 118 } else if (base::android::BuildInfo::GetInstance()->sdk_int() < 19) { | 125 |
| 119 // For JB, these tend to fail often (crbug.com/654905), but not with K+. | 126 bool is_supported = true; |
| 120 std::string model(base::android::BuildInfo::GetInstance()->model()); | 127 std::string model(model_for_test |
| 121 return model != "GT-P3113" && model != "GT-P5110" && model != "GT-P5100" && | 128 ? model_for_test |
| 122 model != "GT-P5113" && model != "GT-P3110" && model != "GT-N5110" && | 129 : base::android::BuildInfo::GetInstance()->model()); |
| 123 model != "e-tab4" && model != "GT-I8200Q"; | 130 |
| 131 if (sdk <= base::android::SDK_VERSION_KITKAT) { | |
| 132 is_supported &= | |
| 133 model != "GT-I9100" && model != "GT-I9300" && model != "GT-N7000" && | |
|
CalebRouleau
2017/02/09 00:12:09
Nit: Prefer ordering the operations like:
J
K
L
liberato (no reviews please)
2017/02/09 18:38:56
the (new) map is initialized in order.
| |
| 134 model != "GT-N7100" && model != "A6600" && model != "A6800" && | |
| 135 model != "GT-S7262" && model != "GT-S5282" && model != "GT-I8552"; | |
| 124 } | 136 } |
| 125 | 137 |
| 126 return true; | 138 if (sdk <= base::android::SDK_VERSION_JELLY_BEAN_MR2) { |
| 139 // For JB, these tend to fail often (crbug.com/654905), but not with K+. | |
| 140 is_supported &= model != "GT-P3113" && model != "GT-P5110" && | |
| 141 model != "GT-P5100" && model != "GT-P5113" && | |
| 142 model != "GT-P3110" && model != "GT-N5110" && | |
| 143 model != "e-tab4" && model != "GT-I8200Q"; | |
| 144 } | |
| 145 | |
| 146 // Note that LGMS330 started on L. | |
| 147 if (sdk <= base::android::SDK_VERSION_LOLLIPOP_MR1) | |
| 148 is_supported &= model != "LGMS330"; | |
| 149 | |
| 150 return is_supported; | |
| 127 } | 151 } |
| 128 | 152 |
| 129 // static | 153 // static |
| 130 bool MediaCodecUtil::SupportsSetParameters() { | 154 bool MediaCodecUtil::SupportsSetParameters() { |
| 131 // MediaCodec.setParameters() is only available starting with K. | 155 // MediaCodec.setParameters() is only available starting with K. |
| 132 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; | 156 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; |
| 133 } | 157 } |
| 134 | 158 |
| 135 // static | 159 // static |
| 136 std::set<int> MediaCodecUtil::GetEncoderColorFormats( | 160 std::set<int> MediaCodecUtil::GetEncoderColorFormats( |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || | 296 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || |
| 273 "OMX.SEC.avc.dec.secure" == codec_name)) || | 297 "OMX.SEC.avc.dec.secure" == codec_name)) || |
| 274 (sdk_int == 19 && | 298 (sdk_int == 19 && |
| 275 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), | 299 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), |
| 276 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && | 300 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && |
| 277 ("OMX.Exynos.avc.dec" == codec_name || | 301 ("OMX.Exynos.avc.dec" == codec_name || |
| 278 "OMX.Exynos.avc.dec.secure" == codec_name)); | 302 "OMX.Exynos.avc.dec.secure" == codec_name)); |
| 279 } | 303 } |
| 280 | 304 |
| 281 } // namespace media | 305 } // namespace media |
| OLD | NEW |