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

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

Issue 2084143002: Make AVDA fall back to software decoding if needed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changed _l to auto_lock Created 4 years, 6 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 59
60 static bool IsSupportedAndroidMimeType(const std::string& mime_type) { 60 static bool IsSupportedAndroidMimeType(const std::string& mime_type) {
61 std::vector<std::string> supported{ 61 std::vector<std::string> supported{
62 kMp4aMimeType, kOpusMimeType, kVorbisMimeType, kAvcMimeType, 62 kMp4aMimeType, kOpusMimeType, kVorbisMimeType, kAvcMimeType,
63 kHevcMimeType, kVp8MimeType, kVp9MimeType}; 63 kHevcMimeType, kVp8MimeType, kVp9MimeType};
64 return std::find(supported.begin(), supported.end(), mime_type) != 64 return std::find(supported.begin(), supported.end(), mime_type) !=
65 supported.end(); 65 supported.end();
66 } 66 }
67 67
68 static std::string GetDefaultCodecName(const std::string& mime_type, 68 static std::string GetDefaultCodecName(const std::string& mime_type,
69 MediaCodecDirection direction) { 69 MediaCodecDirection direction,
70 bool require_software) {
DaleCurtis 2016/06/22 21:20:11 require_software_codec here and elsewhere.
liberato (no reviews please) 2016/06/22 21:43:55 done, sorry.
70 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); 71 DCHECK(MediaCodecUtil::IsMediaCodecAvailable());
71 JNIEnv* env = AttachCurrentThread(); 72 JNIEnv* env = AttachCurrentThread();
72 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime_type); 73 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime_type);
73 ScopedJavaLocalRef<jstring> j_codec_name = 74 ScopedJavaLocalRef<jstring> j_codec_name =
74 Java_MediaCodecUtil_getDefaultCodecName(env, j_mime.obj(), direction); 75 Java_MediaCodecUtil_getDefaultCodecName(env, j_mime.obj(), direction,
76 require_software);
75 return ConvertJavaStringToUTF8(env, j_codec_name.obj()); 77 return ConvertJavaStringToUTF8(env, j_codec_name.obj());
76 } 78 }
77 79
78 static bool IsDecoderSupportedByDevice(const std::string& android_mime_type) { 80 static bool IsDecoderSupportedByDevice(const std::string& android_mime_type) {
79 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); 81 DCHECK(MediaCodecUtil::IsMediaCodecAvailable());
80 DCHECK(IsSupportedAndroidMimeType(android_mime_type)); 82 DCHECK(IsSupportedAndroidMimeType(android_mime_type));
81 JNIEnv* env = AttachCurrentThread(); 83 JNIEnv* env = AttachCurrentThread();
82 ScopedJavaLocalRef<jstring> j_mime = 84 ScopedJavaLocalRef<jstring> j_mime =
83 ConvertUTF8ToJavaString(env, android_mime_type); 85 ConvertUTF8ToJavaString(env, android_mime_type);
84 return Java_MediaCodecUtil_isDecoderSupportedForDevice(env, j_mime.obj()); 86 return Java_MediaCodecUtil_isDecoderSupportedForDevice(env, j_mime.obj());
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 return Java_MediaCodecUtil_canDecode(env, j_mime.obj(), is_secure); 142 return Java_MediaCodecUtil_canDecode(env, j_mime.obj(), is_secure);
141 } 143 }
142 144
143 // static 145 // static
144 bool MediaCodecUtil::IsKnownUnaccelerated(const std::string& android_mime_type, 146 bool MediaCodecUtil::IsKnownUnaccelerated(const std::string& android_mime_type,
145 MediaCodecDirection direction) { 147 MediaCodecDirection direction) {
146 DCHECK(IsSupportedAndroidMimeType(android_mime_type)); 148 DCHECK(IsSupportedAndroidMimeType(android_mime_type));
147 if (!IsMediaCodecAvailable()) 149 if (!IsMediaCodecAvailable())
148 return true; 150 return true;
149 151
150 std::string codec_name = GetDefaultCodecName(android_mime_type, direction); 152 std::string codec_name =
153 GetDefaultCodecName(android_mime_type, direction, false);
151 DVLOG(1) << __FUNCTION__ << "Default codec for " << android_mime_type << " : " 154 DVLOG(1) << __FUNCTION__ << "Default codec for " << android_mime_type << " : "
152 << codec_name << ", direction: " << direction; 155 << codec_name << ", direction: " << direction;
153 if (!codec_name.size()) 156 if (!codec_name.size())
154 return true; 157 return true;
155 158
156 // MediaTek hardware vp8 is known slower than the software implementation. 159 // MediaTek hardware vp8 is known slower than the software implementation.
157 // MediaTek hardware vp9 is known crashy, see http://crbug.com/446974 and 160 // MediaTek hardware vp9 is known crashy, see http://crbug.com/446974 and
158 // http://crbug.com/597836. 161 // http://crbug.com/597836.
159 if (base::StartsWith(codec_name, "OMX.MTK.", base::CompareCase::SENSITIVE)) { 162 if (base::StartsWith(codec_name, "OMX.MTK.", base::CompareCase::SENSITIVE)) {
160 if (android_mime_type == kVp8MimeType) 163 if (android_mime_type == kVp8MimeType)
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 if (base::StartsWith(model, model_prefixes[i], 242 if (base::StartsWith(model, model_prefixes[i],
240 base::CompareCase::INSENSITIVE_ASCII)) { 243 base::CompareCase::INSENSITIVE_ASCII)) {
241 return false; 244 return false;
242 } 245 }
243 } 246 }
244 247
245 return true; 248 return true;
246 } 249 }
247 250
248 } // namespace media 251 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698