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

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

Issue 2237943002: Remove now-unnecessary .obj() in Java method calls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@switch-context
Patch Set: Rebase *again* :( Created 4 years, 4 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
« no previous file with comments | « media/audio/android/audio_record_input.cc ('k') | media/base/android/media_drm_bridge.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 supported.end(); 66 supported.end();
67 } 67 }
68 68
69 static std::string GetDefaultCodecName(const std::string& mime_type, 69 static std::string GetDefaultCodecName(const std::string& mime_type,
70 MediaCodecDirection direction, 70 MediaCodecDirection direction,
71 bool require_software_codec) { 71 bool require_software_codec) {
72 DCHECK(MediaCodecUtil::IsMediaCodecAvailable()); 72 DCHECK(MediaCodecUtil::IsMediaCodecAvailable());
73 JNIEnv* env = AttachCurrentThread(); 73 JNIEnv* env = AttachCurrentThread();
74 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime_type); 74 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime_type);
75 ScopedJavaLocalRef<jstring> j_codec_name = 75 ScopedJavaLocalRef<jstring> j_codec_name =
76 Java_MediaCodecUtil_getDefaultCodecName(env, j_mime.obj(), direction, 76 Java_MediaCodecUtil_getDefaultCodecName(env, j_mime, direction,
77 require_software_codec); 77 require_software_codec);
78 return ConvertJavaStringToUTF8(env, j_codec_name.obj()); 78 return ConvertJavaStringToUTF8(env, j_codec_name.obj());
79 } 79 }
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.obj()); 87 return Java_MediaCodecUtil_isDecoderSupportedForDevice(env, j_mime);
88 } 88 }
89 89
90 // static 90 // static
91 bool MediaCodecUtil::IsMediaCodecAvailable() { 91 bool MediaCodecUtil::IsMediaCodecAvailable() {
92 // MediaCodec is only available on JB and greater. 92 // MediaCodec is only available on JB and greater.
93 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16) 93 if (base::android::BuildInfo::GetInstance()->sdk_int() < 16)
94 return false; 94 return false;
95 95
96 // Blacklist some devices on Jellybean as for MediaCodec support is buggy. 96 // Blacklist some devices on Jellybean as for MediaCodec support is buggy.
97 // http://crbug.com/365494, http://crbug.com/615872 97 // http://crbug.com/365494, http://crbug.com/615872
(...skipping 14 matching lines...) Expand all
112 // static 112 // static
113 std::set<int> MediaCodecUtil::GetEncoderColorFormats( 113 std::set<int> MediaCodecUtil::GetEncoderColorFormats(
114 const std::string& mime_type) { 114 const std::string& mime_type) {
115 std::set<int> color_formats; 115 std::set<int> color_formats;
116 if (!IsMediaCodecAvailable()) 116 if (!IsMediaCodecAvailable())
117 return color_formats; 117 return color_formats;
118 118
119 JNIEnv* env = AttachCurrentThread(); 119 JNIEnv* env = AttachCurrentThread();
120 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime_type); 120 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime_type);
121 ScopedJavaLocalRef<jintArray> j_color_format_array = 121 ScopedJavaLocalRef<jintArray> j_color_format_array =
122 Java_MediaCodecUtil_getEncoderColorFormatsForMime(env, j_mime.obj()); 122 Java_MediaCodecUtil_getEncoderColorFormatsForMime(env, j_mime);
123 123
124 if (j_color_format_array.obj()) { 124 if (j_color_format_array.obj()) {
125 std::vector<int> formats; 125 std::vector<int> formats;
126 JavaIntArrayToIntVector(env, j_color_format_array.obj(), &formats); 126 JavaIntArrayToIntVector(env, j_color_format_array.obj(), &formats);
127 color_formats = std::set<int>(formats.begin(), formats.end()); 127 color_formats = std::set<int>(formats.begin(), formats.end());
128 } 128 }
129 129
130 return color_formats; 130 return color_formats;
131 } 131 }
132 132
133 // static 133 // static
134 bool MediaCodecUtil::CanDecode(const std::string& codec, bool is_secure) { 134 bool MediaCodecUtil::CanDecode(const std::string& codec, bool is_secure) {
135 if (!IsMediaCodecAvailable()) 135 if (!IsMediaCodecAvailable())
136 return false; 136 return false;
137 137
138 JNIEnv* env = AttachCurrentThread(); 138 JNIEnv* env = AttachCurrentThread();
139 std::string mime = CodecTypeToAndroidMimeType(codec); 139 std::string mime = CodecTypeToAndroidMimeType(codec);
140 if (mime.empty()) 140 if (mime.empty())
141 return false; 141 return false;
142 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); 142 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime);
143 return Java_MediaCodecUtil_canDecode(env, j_mime.obj(), is_secure); 143 return Java_MediaCodecUtil_canDecode(env, j_mime, is_secure);
144 } 144 }
145 145
146 // static 146 // static
147 bool MediaCodecUtil::IsKnownUnaccelerated(const std::string& android_mime_type, 147 bool MediaCodecUtil::IsKnownUnaccelerated(const std::string& android_mime_type,
148 MediaCodecDirection direction) { 148 MediaCodecDirection direction) {
149 DCHECK(IsSupportedAndroidMimeType(android_mime_type)); 149 DCHECK(IsSupportedAndroidMimeType(android_mime_type));
150 if (!IsMediaCodecAvailable()) 150 if (!IsMediaCodecAvailable())
151 return true; 151 return true;
152 152
153 std::string codec_name = 153 std::string codec_name =
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name || 244 (sdk_int == 18 && ("OMX.SEC.avc.dec" == codec_name ||
245 "OMX.SEC.avc.dec.secure" == codec_name)) || 245 "OMX.SEC.avc.dec.secure" == codec_name)) ||
246 (sdk_int == 19 && 246 (sdk_int == 19 &&
247 base::StartsWith(base::android::BuildInfo::GetInstance()->model(), 247 base::StartsWith(base::android::BuildInfo::GetInstance()->model(),
248 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) && 248 "SM-G800", base::CompareCase::INSENSITIVE_ASCII) &&
249 ("OMX.Exynos.avc.dec" == codec_name || 249 ("OMX.Exynos.avc.dec" == codec_name ||
250 "OMX.Exynos.avc.dec.secure" == codec_name)); 250 "OMX.Exynos.avc.dec.secure" == codec_name));
251 } 251 }
252 252
253 } // namespace media 253 } // namespace media
OLDNEW
« no previous file with comments | « media/audio/android/audio_record_input.cc ('k') | media/base/android/media_drm_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698