Chromium Code Reviews| 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" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 247 base::RepeatingTimer io_timer_; | 247 base::RepeatingTimer io_timer_; |
| 248 | 248 |
| 249 DISALLOW_COPY_AND_ASSIGN(AVDATimerManager); | 249 DISALLOW_COPY_AND_ASSIGN(AVDATimerManager); |
| 250 }; | 250 }; |
| 251 | 251 |
| 252 static base::LazyInstance<AVDATimerManager>::Leaky g_avda_timer = | 252 static base::LazyInstance<AVDATimerManager>::Leaky g_avda_timer = |
| 253 LAZY_INSTANCE_INITIALIZER; | 253 LAZY_INSTANCE_INITIALIZER; |
| 254 | 254 |
| 255 AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator( | 255 AndroidVideoDecodeAccelerator::AndroidVideoDecodeAccelerator( |
| 256 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder, | 256 const base::WeakPtr<gpu::gles2::GLES2Decoder> decoder, |
| 257 const gpu::GpuPreferences& gpu_preferences, | |
| 257 const base::Callback<bool(void)>& make_context_current) | 258 const base::Callback<bool(void)>& make_context_current) |
| 258 : client_(NULL), | 259 : client_(NULL), |
| 259 make_context_current_(make_context_current), | 260 make_context_current_(make_context_current), |
| 260 codec_(media::kCodecH264), | 261 codec_(media::kCodecH264), |
| 261 is_encrypted_(false), | 262 is_encrypted_(false), |
| 262 needs_protected_surface_(false), | 263 needs_protected_surface_(false), |
| 263 state_(NO_ERROR), | 264 state_(NO_ERROR), |
| 264 picturebuffers_requested_(false), | 265 picturebuffers_requested_(false), |
| 265 gl_decoder_(decoder), | 266 gl_decoder_(decoder), |
| 266 cdm_registration_id_(0), | 267 cdm_registration_id_(0), |
| 267 pending_input_buf_index_(-1), | 268 pending_input_buf_index_(-1), |
| 268 error_sequence_token_(0), | 269 error_sequence_token_(0), |
| 269 defer_errors_(false), | 270 defer_errors_(false), |
| 270 weak_this_factory_(this) { | 271 weak_this_factory_(this) { |
| 271 if (UseDeferredRenderingStrategy()) { | 272 if (!gpu_preferences.enable_threaded_texture_mailboxes) { |
| 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 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1149 most_recent_work_ = now; | 1150 most_recent_work_ = now; |
| 1150 } | 1151 } |
| 1151 | 1152 |
| 1152 if (should_be_running) | 1153 if (should_be_running) |
| 1153 g_avda_timer.Pointer()->StartTimer(this); | 1154 g_avda_timer.Pointer()->StartTimer(this); |
| 1154 else | 1155 else |
| 1155 g_avda_timer.Pointer()->StopTimer(this); | 1156 g_avda_timer.Pointer()->StopTimer(this); |
| 1156 } | 1157 } |
| 1157 | 1158 |
| 1158 // static | 1159 // static |
| 1159 bool AndroidVideoDecodeAccelerator::UseDeferredRenderingStrategy() { | |
| 1160 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | |
| 1161 // TODO(liberato, watk): Figure out what we want to do about zero copy for | |
| 1162 // fullscreen external SurfaceView in WebView. http://crbug.com/582170. | |
| 1163 return !cmd_line->HasSwitch(switches::kEnableThreadedTextureMailboxes); | |
| 1164 } | |
| 1165 | |
| 1166 // static | |
| 1167 media::VideoDecodeAccelerator::Capabilities | 1160 media::VideoDecodeAccelerator::Capabilities |
| 1168 AndroidVideoDecodeAccelerator::GetCapabilities() { | 1161 AndroidVideoDecodeAccelerator::GetCapabilities( |
| 1162 const gpu::GpuPreferences& gpu_preferences) { | |
| 1169 Capabilities capabilities; | 1163 Capabilities capabilities; |
| 1170 SupportedProfiles& profiles = capabilities.supported_profiles; | 1164 SupportedProfiles& profiles = capabilities.supported_profiles; |
| 1171 | 1165 |
| 1172 SupportedProfile profile; | 1166 SupportedProfile profile; |
| 1173 | 1167 |
| 1174 if (media::MediaCodecUtil::IsVp8DecoderAvailable()) { | 1168 if (media::MediaCodecUtil::IsVp8DecoderAvailable()) { |
| 1175 profile.profile = media::VP8PROFILE_ANY; | 1169 profile.profile = media::VP8PROFILE_ANY; |
| 1176 profile.min_resolution.SetSize(0, 0); | 1170 profile.min_resolution.SetSize(0, 0); |
| 1177 profile.max_resolution.SetSize(1920, 1088); | 1171 profile.max_resolution.SetSize(1920, 1088); |
| 1178 profiles.push_back(profile); | 1172 profiles.push_back(profile); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1189 SupportedProfile profile; | 1183 SupportedProfile profile; |
| 1190 profile.profile = supported_profile; | 1184 profile.profile = supported_profile; |
| 1191 profile.min_resolution.SetSize(0, 0); | 1185 profile.min_resolution.SetSize(0, 0); |
| 1192 // Advertise support for 4k and let the MediaCodec fail when decoding if it | 1186 // 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 | 1187 // doesn't support the resolution. It's assumed that consumers won't have |
| 1194 // software fallback for H264 on Android anyway. | 1188 // software fallback for H264 on Android anyway. |
| 1195 profile.max_resolution.SetSize(3840, 2160); | 1189 profile.max_resolution.SetSize(3840, 2160); |
| 1196 profiles.push_back(profile); | 1190 profiles.push_back(profile); |
| 1197 } | 1191 } |
| 1198 | 1192 |
| 1199 if (UseDeferredRenderingStrategy()) { | 1193 if (!gpu_preferences.enable_threaded_texture_mailboxes) { |
|
liberato (no reviews please)
2016/03/21 16:39:52
rather than have two copies of this check which mu
william.xie
2016/03/22 01:09:24
Done.
| |
| 1200 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: | 1194 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: |
| 1201 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE | | 1195 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE | |
| 1202 media::VideoDecodeAccelerator::Capabilities:: | 1196 media::VideoDecodeAccelerator::Capabilities:: |
| 1203 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; | 1197 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; |
| 1204 } | 1198 } |
| 1205 | 1199 |
| 1206 return capabilities; | 1200 return capabilities; |
| 1207 } | 1201 } |
| 1208 | 1202 |
| 1209 } // namespace content | 1203 } // namespace content |
| OLD | NEW |