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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 static bool IsDecoderSupportedByDevice(const std::string& android_mime_type) { | 81 static bool IsDecoderSupportedByDevice(const std::string& android_mime_type) { |
82 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); | 82 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); |
83 DCHECK(IsSupportedAndroidMimeType(android_mime_type)); | 83 DCHECK(IsSupportedAndroidMimeType(android_mime_type)); |
84 JNIEnv* env = AttachCurrentThread(); | 84 JNIEnv* env = AttachCurrentThread(); |
85 ScopedJavaLocalRef<jstring> j_mime = | 85 ScopedJavaLocalRef<jstring> j_mime = |
86 ConvertUTF8ToJavaString(env, android_mime_type); | 86 ConvertUTF8ToJavaString(env, android_mime_type); |
87 return Java_MediaCodecUtil_isDecoderSupportedForDevice(env, j_mime); | 87 return Java_MediaCodecUtil_isDecoderSupportedForDevice(env, j_mime); |
88 } | 88 } |
89 | 89 |
| 90 static bool IsEncoderSupportedByDevice(const std::string& android_mime_type) { |
| 91 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); |
| 92 JNIEnv* env = AttachCurrentThread(); |
| 93 ScopedJavaLocalRef<jstring> j_mime = |
| 94 ConvertUTF8ToJavaString(env, android_mime_type); |
| 95 return Java_MediaCodecUtil_isEncoderSupportedByDevice(env, j_mime); |
| 96 } |
| 97 |
90 // static | 98 // static |
91 bool MediaCodecUtil::IsMediaCodecAvailable() { | 99 bool MediaCodecUtil::IsMediaCodecAvailable() { |
92 // Blacklist some devices on Jellybean as MediaCodec is buggy. | 100 // Blacklist some devices on Jellybean as MediaCodec is buggy. |
93 // http://crbug.com/365494, http://crbug.com/615872 | 101 // http://crbug.com/365494, http://crbug.com/615872 |
94 // Blacklist Lenovo A6600 / A6800 on KitKat, which tends to crash a lot. | 102 // Blacklist Lenovo A6600 / A6800 on KitKat, which tends to crash a lot. |
95 // See crbug.com/628059 . We include < K since they don't exist. | 103 // See crbug.com/628059 . We include < K since they don't exist. |
96 // GT-S5282 and GT-I8552 are for crbug.com/634920 . | 104 // GT-S5282 and GT-I8552 are for crbug.com/634920 . |
97 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) { | 105 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) { |
98 std::string model(base::android::BuildInfo::GetInstance()->model()); | 106 std::string model(base::android::BuildInfo::GetInstance()->model()); |
99 return model != "GT-I9100" && model != "GT-I9300" && model != "GT-N7000" && | 107 return model != "GT-I9100" && model != "GT-I9300" && model != "GT-N7000" && |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // but we have a second method for clarity in future issues. | 213 // but we have a second method for clarity in future issues. |
206 return IsVp8DecoderAvailable(); | 214 return IsVp8DecoderAvailable(); |
207 } | 215 } |
208 | 216 |
209 // static | 217 // static |
210 bool MediaCodecUtil::IsVp9DecoderAvailable() { | 218 bool MediaCodecUtil::IsVp9DecoderAvailable() { |
211 return IsMediaCodecAvailable() && IsDecoderSupportedByDevice(kVp9MimeType); | 219 return IsMediaCodecAvailable() && IsDecoderSupportedByDevice(kVp9MimeType); |
212 } | 220 } |
213 | 221 |
214 // static | 222 // static |
| 223 bool MediaCodecUtil::IsH264EncoderAvailable() { |
| 224 return IsMediaCodecAvailable() && IsEncoderSupportedByDevice(kAvcMimeType); |
| 225 } |
| 226 |
| 227 // static |
215 bool MediaCodecUtil::IsSurfaceViewOutputSupported() { | 228 bool MediaCodecUtil::IsSurfaceViewOutputSupported() { |
216 // Disable SurfaceView output for the Samsung Galaxy S3; it does not work | 229 // Disable SurfaceView output for the Samsung Galaxy S3; it does not work |
217 // well enough for even 360p24 H264 playback. http://crbug.com/602870. | 230 // well enough for even 360p24 H264 playback. http://crbug.com/602870. |
218 // | 231 // |
219 // Notably this is codec agnostic at present, so any devices added to | 232 // Notably this is codec agnostic at present, so any devices added to |
220 // the blacklist will avoid trying to play any codecs on SurfaceView. If | 233 // the blacklist will avoid trying to play any codecs on SurfaceView. If |
221 // needed in the future this can be expanded to be codec specific. | 234 // needed in the future this can be expanded to be codec specific. |
222 const char* model_prefixes[] = {// Exynos 4 (Mali-400) | 235 const char* model_prefixes[] = {// Exynos 4 (Mali-400) |
223 "GT-I9300", "GT-I9305", "SHV-E210", | 236 "GT-I9300", "GT-I9305", "SHV-E210", |
224 // Snapdragon S4 (Adreno-225) | 237 // Snapdragon S4 (Adreno-225) |
(...skipping 20 matching lines...) Expand all Loading... |
245 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || | 258 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || |
246 "OMX.SEC.avc.dec.secure" == codec_name)) || | 259 "OMX.SEC.avc.dec.secure" == codec_name)) || |
247 (sdk_int == 19 && | 260 (sdk_int == 19 && |
248 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), | 261 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), |
249 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && | 262 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && |
250 ("OMX.Exynos.avc.dec" == codec_name || | 263 ("OMX.Exynos.avc.dec" == codec_name || |
251 "OMX.Exynos.avc.dec.secure" == codec_name)); | 264 "OMX.Exynos.avc.dec.secure" == codec_name)); |
252 } | 265 } |
253 | 266 |
254 } // namespace media | 267 } // namespace media |
OLD | NEW |