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 IsH264EncoderSupported() { |
| 91 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); |
| 92 JNIEnv* env = AttachCurrentThread(); |
| 93 return Java_MediaCodecUtil_isH264EncoderSupported(env); |
| 94 } |
| 95 |
90 // static | 96 // static |
91 bool MediaCodecUtil::IsMediaCodecAvailable() { | 97 bool MediaCodecUtil::IsMediaCodecAvailable() { |
92 // MediaCodec is only available on JB and greater. | 98 // MediaCodec is only available on JB and greater. |
93 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) | 99 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) |
94 return false; | 100 return false; |
95 | 101 |
96 // Blacklist some devices on Jellybean as for MediaCodec support is buggy. | 102 // Blacklist some devices on Jellybean as for MediaCodec support is buggy. |
97 // http://crbug.com/365494, http://crbug.com/615872 | 103 // http://crbug.com/365494, http://crbug.com/615872 |
98 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) { | 104 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) { |
99 std::string model(base::android::BuildInfo::GetInstance()->model()); | 105 std::string model(base::android::BuildInfo::GetInstance()->model()); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 // but we have a second method for clarity in future issues. | 210 // but we have a second method for clarity in future issues. |
205 return IsVp8DecoderAvailable(); | 211 return IsVp8DecoderAvailable(); |
206 } | 212 } |
207 | 213 |
208 // static | 214 // static |
209 bool MediaCodecUtil::IsVp9DecoderAvailable() { | 215 bool MediaCodecUtil::IsVp9DecoderAvailable() { |
210 return IsMediaCodecAvailable() && IsDecoderSupportedByDevice(kVp9MimeType); | 216 return IsMediaCodecAvailable() && IsDecoderSupportedByDevice(kVp9MimeType); |
211 } | 217 } |
212 | 218 |
213 // static | 219 // static |
| 220 bool MediaCodecUtil::IsH264EncoderAvailable() { |
| 221 return IsMediaCodecAvailable() && IsH264EncoderSupported(); |
| 222 } |
| 223 |
| 224 // static |
214 bool MediaCodecUtil::IsSurfaceViewOutputSupported() { | 225 bool MediaCodecUtil::IsSurfaceViewOutputSupported() { |
215 // Disable SurfaceView output for the Samsung Galaxy S3; it does not work | 226 // Disable SurfaceView output for the Samsung Galaxy S3; it does not work |
216 // well enough for even 360p24 H264 playback. http://crbug.com/602870. | 227 // well enough for even 360p24 H264 playback. http://crbug.com/602870. |
217 // | 228 // |
218 // Notably this is codec agnostic at present, so any devices added to | 229 // Notably this is codec agnostic at present, so any devices added to |
219 // the blacklist will avoid trying to play any codecs on SurfaceView. If | 230 // the blacklist will avoid trying to play any codecs on SurfaceView. If |
220 // needed in the future this can be expanded to be codec specific. | 231 // needed in the future this can be expanded to be codec specific. |
221 const char* model_prefixes[] = {// Exynos 4 (Mali-400) | 232 const char* model_prefixes[] = {// Exynos 4 (Mali-400) |
222 "GT-I9300", "GT-I9305", "SHV-E210", | 233 "GT-I9300", "GT-I9305", "SHV-E210", |
223 // Snapdragon S4 (Adreno-225) | 234 // Snapdragon S4 (Adreno-225) |
(...skipping 20 matching lines...) Expand all Loading... |
244 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || | 255 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || |
245 "OMX.SEC.avc.dec.secure" == codec_name)) || | 256 "OMX.SEC.avc.dec.secure" == codec_name)) || |
246 (sdk_int == 19 && | 257 (sdk_int == 19 && |
247 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), | 258 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), |
248 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && | 259 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && |
249 ("OMX.Exynos.avc.dec" == codec_name || | 260 ("OMX.Exynos.avc.dec" == codec_name || |
250 "OMX.Exynos.avc.dec.secure" == codec_name)); | 261 "OMX.Exynos.avc.dec.secure" == codec_name)); |
251 } | 262 } |
252 | 263 |
253 } // namespace media | 264 } // namespace media |
OLD | NEW |