OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/gpu_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 } | 263 } |
264 #endif | 264 #endif |
265 | 265 |
266 #if defined(OS_WIN) | 266 #if defined(OS_WIN) |
267 if (base::win::GetVersion() < base::win::VERSION_WIN7) { | 267 if (base::win::GetVersion() < base::win::VERSION_WIN7) { |
268 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | 268 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
269 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 269 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
270 return; | 270 return; |
271 } | 271 } |
272 DVLOG(0) << "Initializing DXVA HW decoder for windows."; | 272 DVLOG(0) << "Initializing DXVA HW decoder for windows."; |
273 video_decode_accelerator_.reset(new DXVAVideoDecodeAccelerator( | 273 video_decode_accelerator_.reset( |
274 this, make_context_current_)); | 274 new DXVAVideoDecodeAccelerator(make_context_current_)); |
275 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 275 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11) |
276 scoped_ptr<V4L2Device> device = V4L2Device::Create(); | 276 scoped_ptr<V4L2Device> device = V4L2Device::Create(); |
277 if (!device.get()) { | 277 if (!device.get()) { |
278 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 278 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
279 return; | 279 return; |
280 } | 280 } |
281 video_decode_accelerator_.reset( | 281 video_decode_accelerator_.reset( |
282 new V4L2VideoDecodeAccelerator(gfx::GLSurfaceEGL::GetHardwareDisplay(), | 282 new V4L2VideoDecodeAccelerator(gfx::GLSurfaceEGL::GetHardwareDisplay(), |
283 this, | |
284 weak_factory_for_io_.GetWeakPtr(), | 283 weak_factory_for_io_.GetWeakPtr(), |
285 make_context_current_, | 284 make_context_current_, |
286 device.Pass(), | 285 device.Pass(), |
287 io_message_loop_)); | 286 io_message_loop_)); |
288 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) | 287 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11) |
289 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) { | 288 if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) { |
290 VLOG(1) << "HW video decode acceleration not available without " | 289 VLOG(1) << "HW video decode acceleration not available without " |
291 "DesktopGL (GLX)."; | 290 "DesktopGL (GLX)."; |
292 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 291 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
293 return; | 292 return; |
294 } | 293 } |
295 gfx::GLContextGLX* glx_context = | 294 gfx::GLContextGLX* glx_context = |
296 static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext()); | 295 static_cast<gfx::GLContextGLX*>(stub_->decoder()->GetGLContext()); |
297 video_decode_accelerator_.reset(new VaapiVideoDecodeAccelerator( | 296 video_decode_accelerator_.reset(new VaapiVideoDecodeAccelerator( |
298 glx_context->display(), this, make_context_current_)); | 297 glx_context->display(), make_context_current_)); |
299 #elif defined(OS_ANDROID) | 298 #elif defined(OS_ANDROID) |
300 video_decode_accelerator_.reset(new AndroidVideoDecodeAccelerator( | 299 video_decode_accelerator_.reset(new AndroidVideoDecodeAccelerator( |
301 this, | |
302 stub_->decoder()->AsWeakPtr(), | 300 stub_->decoder()->AsWeakPtr(), |
303 make_context_current_)); | 301 make_context_current_)); |
304 #else | 302 #else |
305 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | 303 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
306 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 304 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
307 return; | 305 return; |
308 #endif | 306 #endif |
309 | 307 |
310 if (video_decode_accelerator_->CanDecodeOnIOThread()) { | 308 if (video_decode_accelerator_->CanDecodeOnIOThread()) { |
311 filter_ = new MessageFilter(this, host_route_id_); | 309 filter_ = new MessageFilter(this, host_route_id_); |
312 stub_->channel()->AddFilter(filter_.get()); | 310 stub_->channel()->AddFilter(filter_.get()); |
313 } | 311 } |
314 | 312 |
315 if (!video_decode_accelerator_->Initialize(profile)) | 313 if (!video_decode_accelerator_->Initialize(profile, this)) |
316 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 314 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
317 } | 315 } |
318 | 316 |
319 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 317 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |
320 // true, otherwise on the main thread. | 318 // true, otherwise on the main thread. |
321 void GpuVideoDecodeAccelerator::OnDecode( | 319 void GpuVideoDecodeAccelerator::OnDecode( |
322 base::SharedMemoryHandle handle, int32 id, uint32 size) { | 320 base::SharedMemoryHandle handle, int32 id, uint32 size) { |
323 DCHECK(video_decode_accelerator_.get()); | 321 DCHECK(video_decode_accelerator_.get()); |
324 if (id < 0) { | 322 if (id < 0) { |
325 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; | 323 DLOG(ERROR) << "BitstreamBuffer id " << id << " out of range"; |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
510 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; | 508 scoped_refptr<gpu::gles2::TextureRef> texture_ref = it->second; |
511 GLenum target = texture_ref->texture()->target(); | 509 GLenum target = texture_ref->texture()->target(); |
512 gpu::gles2::TextureManager* texture_manager = | 510 gpu::gles2::TextureManager* texture_manager = |
513 stub_->decoder()->GetContextGroup()->texture_manager(); | 511 stub_->decoder()->GetContextGroup()->texture_manager(); |
514 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); | 512 DCHECK(!texture_ref->texture()->IsLevelCleared(target, 0)); |
515 texture_manager->SetLevelCleared(texture_ref, target, 0, true); | 513 texture_manager->SetLevelCleared(texture_ref, target, 0, true); |
516 uncleared_textures_.erase(it); | 514 uncleared_textures_.erase(it); |
517 } | 515 } |
518 | 516 |
519 } // namespace content | 517 } // namespace content |
OLD | NEW |