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

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

Issue 2686963002: Fix and update MediaCodec blacklist. (Closed)
Patch Set: added E-TAB4 Created 3 years, 10 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 #include <vector>
10 11
11 #include "base/android/build_info.h" 12 #include "base/android/build_info.h"
12 #include "base/android/jni_android.h" 13 #include "base/android/jni_android.h"
13 #include "base/android/jni_array.h" 14 #include "base/android/jni_array.h"
14 #include "base/android/jni_string.h" 15 #include "base/android/jni_string.h"
15 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/strings/string_piece.h"
16 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
17 #include "jni/MediaCodecUtil_jni.h" 19 #include "jni/MediaCodecUtil_jni.h"
18 #include "media/base/android/media_codec_bridge.h" 20 #include "media/base/android/media_codec_bridge.h"
19 #include "url/gurl.h" 21 #include "url/gurl.h"
20 22
21 using base::android::AttachCurrentThread; 23 using base::android::AttachCurrentThread;
22 using base::android::ConvertJavaStringToUTF8; 24 using base::android::ConvertJavaStringToUTF8;
23 using base::android::ConvertUTF8ToJavaString; 25 using base::android::ConvertUTF8ToJavaString;
24 using base::android::JavaIntArrayToIntVector; 26 using base::android::JavaIntArrayToIntVector;
25 using base::android::ScopedJavaLocalRef; 27 using base::android::ScopedJavaLocalRef;
28 using base::android::SDK_VERSION_JELLY_BEAN_MR2;
29 using base::android::SDK_VERSION_KITKAT;
30 using base::android::SDK_VERSION_LOLLIPOP_MR1;
26 31
27 namespace media { 32 namespace media {
28 33
29 namespace { 34 namespace {
30 35
31 const char kMp4aMimeType[] = "audio/mp4a-latm"; 36 const char kMp4aMimeType[] = "audio/mp4a-latm";
32 const char kOpusMimeType[] = "audio/opus"; 37 const char kOpusMimeType[] = "audio/opus";
33 const char kVorbisMimeType[] = "audio/vorbis"; 38 const char kVorbisMimeType[] = "audio/vorbis";
34 const char kAc3MimeType[] = "audio/ac3"; 39 const char kAc3MimeType[] = "audio/ac3";
35 const char kEac3MimeType[] = "audio/eac3"; 40 const char kEac3MimeType[] = "audio/eac3";
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 static bool IsEncoderSupportedByDevice(const std::string& android_mime_type) { 102 static bool IsEncoderSupportedByDevice(const std::string& android_mime_type) {
98 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); 103 DCHECK(MediaCodecUtil::IsMediaCodecAvailable());
99 JNIEnv* env = AttachCurrentThread(); 104 JNIEnv* env = AttachCurrentThread();
100 ScopedJavaLocalRef<jstring> j_mime = 105 ScopedJavaLocalRef<jstring> j_mime =
101 ConvertUTF8ToJavaString(env, android_mime_type); 106 ConvertUTF8ToJavaString(env, android_mime_type);
102 return Java_MediaCodecUtil_isEncoderSupportedByDevice(env, j_mime); 107 return Java_MediaCodecUtil_isEncoderSupportedByDevice(env, j_mime);
103 } 108 }
104 109
105 // static 110 // static
106 bool MediaCodecUtil::IsMediaCodecAvailable() { 111 bool MediaCodecUtil::IsMediaCodecAvailable() {
112 return IsMediaCodecAvailableForSdk(
113 base::android::BuildInfo::GetInstance()->sdk_int(),
114 base::android::BuildInfo::GetInstance()->model());
115 }
116
117 // static
118 bool MediaCodecUtil::IsMediaCodecAvailableForSdk(int sdk, const char* model) {
watk 2017/02/10 22:14:13 nit: Either make it "ForDevice" or remove the suff
liberato (no reviews please) 2017/02/13 21:24:09 true, but it's not just the device, either. :) i
107 // Blacklist some devices on Jellybean as MediaCodec is buggy. 119 // Blacklist some devices on Jellybean as MediaCodec is buggy.
108 // http://crbug.com/365494, http://crbug.com/615872 120 // http://crbug.com/365494, http://crbug.com/615872
109 // Blacklist Lenovo A6600 / A6800 on KitKat, which tends to crash a lot. 121 // 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. 122 // See crbug.com/628059 . We include < K since they don't exist.
111 // Blacklist Samsung Galaxy Star Pro (GT-S7262) (crbug.com/634920). 123 // Blacklist Samsung Galaxy Star Pro (GT-S7262) (crbug.com/634920).
112 // GT-S5282 and GT-I8552 are for crbug.com/634920 . 124 // GT-S5282 and GT-I8552 are for crbug.com/634920 .
113 if (base::android::BuildInfo::GetInstance()->sdk_int() <= 19) { 125 // Blacklist LGMS330 on L for crbug.com/654905 .
watk 2017/02/10 22:14:13 Why don't we just intersperse the crbug # comments
liberato (no reviews please) 2017/02/13 21:24:09 Done.
114 std::string model(base::android::BuildInfo::GetInstance()->model());
115 return model != "GT-I9100" && model != "GT-I9300" && model != "GT-N7000" &&
116 model != "GT-N7100" && model != "A6600" && model != "A6800" &&
117 model != "GT-S7262" && model != "GT-S5282" && model != "GT-I8552";
118 } else if (base::android::BuildInfo::GetInstance()->sdk_int() < 19) {
119 // For JB, these tend to fail often (crbug.com/654905), but not with K+.
120 std::string model(base::android::BuildInfo::GetInstance()->model());
121 return model != "GT-P3113" && model != "GT-P5110" && model != "GT-P5100" &&
122 model != "GT-P5113" && model != "GT-P3110" && model != "GT-N5110" &&
123 model != "e-tab4" && model != "GT-I8200Q";
124 }
125 126
126 return true; 127 // None of our tests fail >= marshmallow.
128 if (sdk >= base::android::SDK_VERSION_MARSHMALLOW)
aelias_OOO_until_Jul13 2017/02/10 21:57:46 This line doesn't do anything and it might cause a
liberato (no reviews please) 2017/02/13 21:24:09 Done.
129 return true;
130
131 // ["model name"] == last bad revision. We will blacklist the model on any
watk 2017/02/10 22:14:13 "["model name"] == last bad revision." no longer r
liberato (no reviews please) 2017/02/13 21:24:09 Done.
132 // sdk that is as old or older.
133 struct BlacklistEntry {
134 BlacklistEntry(const char* m, int s) : model(m), last_bad_sdk(s) {}
135 base::StringPiece model;
136 int last_bad_sdk;
137 bool operator==(const BlacklistEntry& other) const {
138 // Search on name only. Ignore |last_bad_sdk|.
139 return model == other.model;
140 }
141 };
142 static const std::vector<BlacklistEntry> blacklist = {
143 {"LGMS330", SDK_VERSION_LOLLIPOP_MR1},
144
145 {"GT-I9100", SDK_VERSION_KITKAT},
146 {"GT-I9300", SDK_VERSION_KITKAT},
147 {"GT-N7000", SDK_VERSION_KITKAT},
148 {"GT-N7100", SDK_VERSION_KITKAT},
149 {"A6600", SDK_VERSION_KITKAT},
150 {"A6800", SDK_VERSION_KITKAT},
151 {"GT-S7262", SDK_VERSION_KITKAT},
152 {"GT-S5282", SDK_VERSION_KITKAT},
153 {"GT-I8552", SDK_VERSION_KITKAT},
154
155 {"GT-P3113", SDK_VERSION_JELLY_BEAN_MR2},
156 {"GT-P5110", SDK_VERSION_JELLY_BEAN_MR2},
157 {"GT-P5100", SDK_VERSION_JELLY_BEAN_MR2},
158 {"GT-P5113", SDK_VERSION_JELLY_BEAN_MR2},
159 {"GT-P3110", SDK_VERSION_JELLY_BEAN_MR2},
160 {"GT-N5110", SDK_VERSION_JELLY_BEAN_MR2},
161 {"e-tab4", SDK_VERSION_JELLY_BEAN_MR2},
162 {"E-TAB4", SDK_VERSION_JELLY_BEAN_MR2},
163 {"GT-I8200Q", SDK_VERSION_JELLY_BEAN_MR2},
164 };
165
166 const auto iter =
167 std::find(blacklist.begin(), blacklist.end(), BlacklistEntry(model, 0));
168 return iter == blacklist.end() || sdk > iter->last_bad_sdk;
127 } 169 }
128 170
129 // static 171 // static
130 bool MediaCodecUtil::SupportsSetParameters() { 172 bool MediaCodecUtil::SupportsSetParameters() {
131 // MediaCodec.setParameters() is only available starting with K. 173 // MediaCodec.setParameters() is only available starting with K.
132 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19; 174 return base::android::BuildInfo::GetInstance()->sdk_int() >= 19;
133 } 175 }
134 176
135 // static 177 // static
136 std::set<int> MediaCodecUtil::GetEncoderColorFormats( 178 std::set<int> MediaCodecUtil::GetEncoderColorFormats(
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || 314 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name ||
273 "OMX.SEC.avc.dec.secure" == codec_name)) || 315 "OMX.SEC.avc.dec.secure" == codec_name)) ||
274 (sdk_int == 19 && 316 (sdk_int == 19 &&
275 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), 317 base::StartsWith(base::android::BuildInfo::GetInstance()->model(),
276 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && 318 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) &&
277 ("OMX.Exynos.avc.dec" == codec_name || 319 ("OMX.Exynos.avc.dec" == codec_name ||
278 "OMX.Exynos.avc.dec.secure" == codec_name)); 320 "OMX.Exynos.avc.dec.secure" == codec_name));
279 } 321 }
280 322
281 } // namespace media 323 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698