Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: media/base/android/media_codec_util.cc

Issue 2358683002: Android: enable/disable WebRTC HW H264 with a flag. (Closed)
Patch Set: add back the removed entry in software_rendering_list_jason.cc and remove the change in gpu_data_manager_impl_private.cc Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // MediaCodec is only available on JB and greater. 100 // MediaCodec is only available on JB and greater.
93 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) 101 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16)
94 return false; 102 return false;
95 103
96 // Blacklist some devices on Jellybean as for MediaCodec support is buggy. 104 // Blacklist some devices on Jellybean as for MediaCodec support is buggy.
97 // http://crbug.com/365494, http://crbug.com/615872 105 // http://crbug.com/365494, http://crbug.com/615872
98 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) { 106 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) {
99 std::string model(base::android::BuildInfo::GetInstance()->model()); 107 std::string model(base::android::BuildInfo::GetInstance()->model());
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // but we have a second method for clarity in future issues. 212 // but we have a second method for clarity in future issues.
205 return IsVp8DecoderAvailable(); 213 return IsVp8DecoderAvailable();
206 } 214 }
207 215
208 // static 216 // static
209 bool MediaCodecUtil::IsVp9DecoderAvailable() { 217 bool MediaCodecUtil::IsVp9DecoderAvailable() {
210 return IsMediaCodecAvailable() && IsDecoderSupportedByDevice(kVp9MimeType); 218 return IsMediaCodecAvailable() && IsDecoderSupportedByDevice(kVp9MimeType);
211 } 219 }
212 220
213 // static 221 // static
222 bool MediaCodecUtil::IsH264EncoderAvailable() {
223 return IsMediaCodecAvailable() && IsEncoderSupportedByDevice(kAvcMimeType);
224 }
225
226 // static
214 bool MediaCodecUtil::IsSurfaceViewOutputSupported() { 227 bool MediaCodecUtil::IsSurfaceViewOutputSupported() {
215 // Disable SurfaceView output for the Samsung Galaxy S3; it does not work 228 // Disable SurfaceView output for the Samsung Galaxy S3; it does not work
216 // well enough for even 360p24 H264 playback. http://crbug.com/602870. 229 // well enough for even 360p24 H264 playback. http://crbug.com/602870.
217 // 230 //
218 // Notably this is codec agnostic at present, so any devices added to 231 // 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 232 // 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. 233 // needed in the future this can be expanded to be codec specific.
221 const char* model_prefixes[] = {// Exynos 4 (Mali-400) 234 const char* model_prefixes[] = {// Exynos 4 (Mali-400)
222 "GT-I9300", "GT-I9305", "SHV-E210", 235 "GT-I9300", "GT-I9305", "SHV-E210",
223 // Snapdragon S4 (Adreno-225) 236 // Snapdragon S4 (Adreno-225)
(...skipping 20 matching lines...) Expand all
244 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || 257 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name ||
245 "OMX.SEC.avc.dec.secure" == codec_name)) || 258 "OMX.SEC.avc.dec.secure" == codec_name)) ||
246 (sdk_int == 19 && 259 (sdk_int == 19 &&
247 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), 260 base::StartsWith(base::android::BuildInfo::GetInstance()->model(),
248 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && 261 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) &&
249 ("OMX.Exynos.avc.dec" == codec_name || 262 ("OMX.Exynos.avc.dec" == codec_name ||
250 "OMX.Exynos.avc.dec.secure" == codec_name)); 263 "OMX.Exynos.avc.dec.secure" == codec_name));
251 } 264 }
252 265
253 } // namespace media 266 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698