OLD | NEW |
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" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/lazy_instance.h" | 14 #include "base/lazy_instance.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
16 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
17 #include "base/metrics/histogram.h" | 17 #include "base/metrics/histogram.h" |
18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
19 #include "content/common/gpu/gpu_channel.h" | 19 #include "content/common/gpu/gpu_channel.h" |
20 #include "content/common/gpu/media/android_copying_backing_strategy.h" | 20 #include "content/common/gpu/media/android_copying_backing_strategy.h" |
21 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h
" | 21 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h
" |
22 #include "content/common/gpu/media/avda_return_on_failure.h" | 22 #include "content/common/gpu/media/avda_return_on_failure.h" |
23 #include "content/common/gpu/media/shared_memory_region.h" | 23 #include "content/common/gpu/media/shared_memory_region.h" |
24 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 24 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
25 #include "gpu/command_buffer/service/gpu_switches.h" | |
26 #include "gpu/command_buffer/service/mailbox_manager.h" | 25 #include "gpu/command_buffer/service/mailbox_manager.h" |
27 #include "media/base/android/media_codec_bridge.h" | 26 #include "media/base/android/media_codec_bridge.h" |
28 #include "media/base/android/media_codec_util.h" | 27 #include "media/base/android/media_codec_util.h" |
29 #include "media/base/bind_to_current_loop.h" | 28 #include "media/base/bind_to_current_loop.h" |
30 #include "media/base/bitstream_buffer.h" | 29 #include "media/base/bitstream_buffer.h" |
31 #include "media/base/limits.h" | 30 #include "media/base/limits.h" |
32 #include "media/base/media.h" | 31 #include "media/base/media.h" |
33 #include "media/base/timestamp_constants.h" | 32 #include "media/base/timestamp_constants.h" |
34 #include "media/base/video_decoder_config.h" | 33 #include "media/base/video_decoder_config.h" |
35 #include "media/video/picture.h" | 34 #include "media/video/picture.h" |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 needs_protected_surface_(false), | 260 needs_protected_surface_(false), |
262 state_(NO_ERROR), | 261 state_(NO_ERROR), |
263 picturebuffers_requested_(false), | 262 picturebuffers_requested_(false), |
264 gl_decoder_(decoder), | 263 gl_decoder_(decoder), |
265 media_drm_bridge_cdm_context_(nullptr), | 264 media_drm_bridge_cdm_context_(nullptr), |
266 cdm_registration_id_(0), | 265 cdm_registration_id_(0), |
267 pending_input_buf_index_(-1), | 266 pending_input_buf_index_(-1), |
268 error_sequence_token_(0), | 267 error_sequence_token_(0), |
269 defer_errors_(false), | 268 defer_errors_(false), |
270 weak_this_factory_(this) { | 269 weak_this_factory_(this) { |
271 if (UseDeferredRenderingStrategy()) { | 270 const gpu::GpuPreferences& gpu_preferences = |
| 271 gl_decoder_->GetContextGroup()->gpu_preferences(); |
| 272 if (UseDeferredRenderingStrategy(gpu_preferences)) { |
272 // TODO(liberato, watk): Figure out what we want to do about zero copy for | 273 // TODO(liberato, watk): Figure out what we want to do about zero copy for |
273 // fullscreen external SurfaceView in WebView. http://crbug.com/582170. | 274 // fullscreen external SurfaceView in WebView. http://crbug.com/582170. |
274 DCHECK(!gl_decoder_->GetContextGroup()->mailbox_manager()->UsesSync()); | 275 DCHECK(!gl_decoder_->GetContextGroup()->mailbox_manager()->UsesSync()); |
275 DVLOG(1) << __FUNCTION__ << ", using deferred rendering strategy."; | 276 DVLOG(1) << __FUNCTION__ << ", using deferred rendering strategy."; |
276 strategy_.reset(new AndroidDeferredRenderingBackingStrategy(this)); | 277 strategy_.reset(new AndroidDeferredRenderingBackingStrategy(this)); |
277 } else { | 278 } else { |
278 DVLOG(1) << __FUNCTION__ << ", using copy back strategy."; | 279 DVLOG(1) << __FUNCTION__ << ", using copy back strategy."; |
279 strategy_.reset(new AndroidCopyingBackingStrategy(this)); | 280 strategy_.reset(new AndroidCopyingBackingStrategy(this)); |
280 } | 281 } |
281 } | 282 } |
(...skipping 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1146 most_recent_work_ = now; | 1147 most_recent_work_ = now; |
1147 } | 1148 } |
1148 | 1149 |
1149 if (should_be_running) | 1150 if (should_be_running) |
1150 g_avda_timer.Pointer()->StartTimer(this); | 1151 g_avda_timer.Pointer()->StartTimer(this); |
1151 else | 1152 else |
1152 g_avda_timer.Pointer()->StopTimer(this); | 1153 g_avda_timer.Pointer()->StopTimer(this); |
1153 } | 1154 } |
1154 | 1155 |
1155 // static | 1156 // static |
1156 bool AndroidVideoDecodeAccelerator::UseDeferredRenderingStrategy() { | 1157 bool AndroidVideoDecodeAccelerator::UseDeferredRenderingStrategy( |
1157 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 1158 const gpu::GpuPreferences& gpu_preferences) { |
1158 // TODO(liberato, watk): Figure out what we want to do about zero copy for | 1159 // TODO(liberato, watk): Figure out what we want to do about zero copy for |
1159 // fullscreen external SurfaceView in WebView. http://crbug.com/582170. | 1160 // fullscreen external SurfaceView in WebView. http://crbug.com/582170. |
1160 return !cmd_line->HasSwitch(switches::kEnableThreadedTextureMailboxes); | 1161 return !gpu_preferences.enable_threaded_texture_mailboxes; |
1161 } | 1162 } |
1162 | 1163 |
1163 // static | 1164 // static |
1164 media::VideoDecodeAccelerator::Capabilities | 1165 media::VideoDecodeAccelerator::Capabilities |
1165 AndroidVideoDecodeAccelerator::GetCapabilities() { | 1166 AndroidVideoDecodeAccelerator::GetCapabilities( |
| 1167 const gpu::GpuPreferences& gpu_preferences) { |
1166 Capabilities capabilities; | 1168 Capabilities capabilities; |
1167 SupportedProfiles& profiles = capabilities.supported_profiles; | 1169 SupportedProfiles& profiles = capabilities.supported_profiles; |
1168 | 1170 |
1169 SupportedProfile profile; | 1171 SupportedProfile profile; |
1170 | 1172 |
1171 if (media::MediaCodecUtil::IsVp8DecoderAvailable()) { | 1173 if (media::MediaCodecUtil::IsVp8DecoderAvailable()) { |
1172 profile.profile = media::VP8PROFILE_ANY; | 1174 profile.profile = media::VP8PROFILE_ANY; |
1173 profile.min_resolution.SetSize(0, 0); | 1175 profile.min_resolution.SetSize(0, 0); |
1174 profile.max_resolution.SetSize(1920, 1088); | 1176 profile.max_resolution.SetSize(1920, 1088); |
1175 // If we know MediaCodec will just create a software codec, prefer our | 1177 // If we know MediaCodec will just create a software codec, prefer our |
(...skipping 24 matching lines...) Expand all Loading... |
1200 SupportedProfile profile; | 1202 SupportedProfile profile; |
1201 profile.profile = supported_profile; | 1203 profile.profile = supported_profile; |
1202 profile.min_resolution.SetSize(0, 0); | 1204 profile.min_resolution.SetSize(0, 0); |
1203 // Advertise support for 4k and let the MediaCodec fail when decoding if it | 1205 // Advertise support for 4k and let the MediaCodec fail when decoding if it |
1204 // doesn't support the resolution. It's assumed that consumers won't have | 1206 // doesn't support the resolution. It's assumed that consumers won't have |
1205 // software fallback for H264 on Android anyway. | 1207 // software fallback for H264 on Android anyway. |
1206 profile.max_resolution.SetSize(3840, 2160); | 1208 profile.max_resolution.SetSize(3840, 2160); |
1207 profiles.push_back(profile); | 1209 profiles.push_back(profile); |
1208 } | 1210 } |
1209 | 1211 |
1210 if (UseDeferredRenderingStrategy()) { | 1212 if (UseDeferredRenderingStrategy(gpu_preferences)) { |
1211 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: | 1213 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: |
1212 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE | | 1214 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE | |
1213 media::VideoDecodeAccelerator::Capabilities:: | 1215 media::VideoDecodeAccelerator::Capabilities:: |
1214 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; | 1216 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; |
1215 } | 1217 } |
1216 | 1218 |
1217 return capabilities; | 1219 return capabilities; |
1218 } | 1220 } |
1219 | 1221 |
1220 } // namespace content | 1222 } // namespace content |
OLD | NEW |