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

Side by Side Diff: content/common/gpu/media/android_video_decode_accelerator.cc

Issue 1820553002: Expose encrypted_only attribute on VDA supported profiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment. Created 4 years, 9 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 "content/common/gpu/media/android_video_decode_accelerator.h" 5 #include "content/common/gpu/media/android_video_decode_accelerator.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 codec_ == media::kCodecVP9 || 310 codec_ == media::kCodecVP9 ||
311 codec_ == media::kCodecH264; 311 codec_ == media::kCodecH264;
312 312
313 if (!profile_supported) { 313 if (!profile_supported) {
314 LOG(ERROR) << "Unsupported profile: " << config.profile; 314 LOG(ERROR) << "Unsupported profile: " << config.profile;
315 return false; 315 return false;
316 } 316 }
317 317
318 // Only use MediaCodec for VP8/9 if it's likely backed by hardware 318 // Only use MediaCodec for VP8/9 if it's likely backed by hardware
319 // or if the stream is encrypted. 319 // or if the stream is encrypted.
320 if ((codec_ == media::kCodecVP8 || codec_ == media::kCodecVP9) && 320 if (codec_ == media::kCodecVP8 || codec_ == media::kCodecVP9) {
321 !is_encrypted_) { 321 DCHECK(is_encrypted_ ||
322 if (media::VideoCodecBridge::IsKnownUnaccelerated( 322 !media::VideoCodecBridge::IsKnownUnaccelerated(
323 codec_, media::MEDIA_CODEC_DECODER)) { 323 codec_, media::MEDIA_CODEC_DECODER));
324 DVLOG(1) << "Initialization failed: "
325 << (codec_ == media::kCodecVP8 ? "vp8" : "vp9")
326 << " is not hardware accelerated";
327 return false;
328 }
329 } 324 }
330 325
331 if (!make_context_current_.Run()) { 326 if (!make_context_current_.Run()) {
332 LOG(ERROR) << "Failed to make this decoder's GL context current."; 327 LOG(ERROR) << "Failed to make this decoder's GL context current.";
333 return false; 328 return false;
334 } 329 }
335 330
336 if (!gl_decoder_) { 331 if (!gl_decoder_) {
337 LOG(ERROR) << "Failed to get gles2 decoder instance."; 332 LOG(ERROR) << "Failed to get gles2 decoder instance.";
338 return false; 333 return false;
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 AndroidVideoDecodeAccelerator::GetCapabilities() { 1163 AndroidVideoDecodeAccelerator::GetCapabilities() {
1169 Capabilities capabilities; 1164 Capabilities capabilities;
1170 SupportedProfiles& profiles = capabilities.supported_profiles; 1165 SupportedProfiles& profiles = capabilities.supported_profiles;
1171 1166
1172 SupportedProfile profile; 1167 SupportedProfile profile;
1173 1168
1174 if (media::MediaCodecUtil::IsVp8DecoderAvailable()) { 1169 if (media::MediaCodecUtil::IsVp8DecoderAvailable()) {
1175 profile.profile = media::VP8PROFILE_ANY; 1170 profile.profile = media::VP8PROFILE_ANY;
1176 profile.min_resolution.SetSize(0, 0); 1171 profile.min_resolution.SetSize(0, 0);
1177 profile.max_resolution.SetSize(1920, 1088); 1172 profile.max_resolution.SetSize(1920, 1088);
1173 // If we know MediaCodec will just create a software codec, prefer our
1174 // internal software decoder instead. It's more up to date and secured
1175 // within the renderer sandbox. However if the content is encrypted, we
1176 // must use MediaCodec anyways since MediaDrm offers no way to decrypt
1177 // the buffers and let us use our internal software decoders.
1178 profile.encrypted_only = media::VideoCodecBridge::IsKnownUnaccelerated(
1179 media::kCodecVP8, media::MEDIA_CODEC_DECODER);
1178 profiles.push_back(profile); 1180 profiles.push_back(profile);
1179 } 1181 }
1180 1182
1181 if (media::PlatformHasVp9Support()) { 1183 if (media::PlatformHasVp9Support()) {
1182 profile.profile = media::VP9PROFILE_ANY; 1184 profile.profile = media::VP9PROFILE_ANY;
1183 profile.min_resolution.SetSize(0, 0); 1185 profile.min_resolution.SetSize(0, 0);
1184 profile.max_resolution.SetSize(1920, 1088); 1186 profile.max_resolution.SetSize(1920, 1088);
1187 // If we know MediaCodec will just create a software codec, prefer our
1188 // internal software decoder instead. It's more up to date and secured
1189 // within the renderer sandbox. However if the content is encrypted, we
1190 // must use MediaCodec anyways since MediaDrm offers no way to decrypt
1191 // the buffers and let us use our internal software decoders.
1192 profile.encrypted_only = media::VideoCodecBridge::IsKnownUnaccelerated(
1193 media::kCodecVP9, media::MEDIA_CODEC_DECODER);
1185 profiles.push_back(profile); 1194 profiles.push_back(profile);
1186 } 1195 }
1187 1196
1188 for (const auto& supported_profile : kSupportedH264Profiles) { 1197 for (const auto& supported_profile : kSupportedH264Profiles) {
1189 SupportedProfile profile; 1198 SupportedProfile profile;
1190 profile.profile = supported_profile; 1199 profile.profile = supported_profile;
1191 profile.min_resolution.SetSize(0, 0); 1200 profile.min_resolution.SetSize(0, 0);
1192 // Advertise support for 4k and let the MediaCodec fail when decoding if it 1201 // Advertise support for 4k and let the MediaCodec fail when decoding if it
1193 // doesn't support the resolution. It's assumed that consumers won't have 1202 // doesn't support the resolution. It's assumed that consumers won't have
1194 // software fallback for H264 on Android anyway. 1203 // software fallback for H264 on Android anyway.
1195 profile.max_resolution.SetSize(3840, 2160); 1204 profile.max_resolution.SetSize(3840, 2160);
1196 profiles.push_back(profile); 1205 profiles.push_back(profile);
1197 } 1206 }
1198 1207
1199 if (UseDeferredRenderingStrategy()) { 1208 if (UseDeferredRenderingStrategy()) {
1200 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: 1209 capabilities.flags = media::VideoDecodeAccelerator::Capabilities::
1201 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE | 1210 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE |
1202 media::VideoDecodeAccelerator::Capabilities:: 1211 media::VideoDecodeAccelerator::Capabilities::
1203 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; 1212 SUPPORTS_EXTERNAL_OUTPUT_SURFACE;
1204 } 1213 }
1205 1214
1206 return capabilities; 1215 return capabilities;
1207 } 1216 }
1208 1217
1209 } // namespace content 1218 } // namespace content
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_param_traits_macros.h ('k') | content/common/gpu/media/gpu_video_accelerator_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698