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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 382 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
383 #if defined(OS_WIN) | 383 #if defined(OS_WIN) |
384 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { | 384 if (base::win::GetVersion() >= base::win::VERSION_WIN7) { |
385 DVLOG(0) << "Initializing DXVA HW decoder for windows."; | 385 DVLOG(0) << "Initializing DXVA HW decoder for windows."; |
386 decoder.reset(new DXVAVideoDecodeAccelerator(make_context_current_, | 386 decoder.reset(new DXVAVideoDecodeAccelerator(make_context_current_, |
387 stub_->decoder()->GetGLContext())); | 387 stub_->decoder()->GetGLContext())); |
388 } else { | 388 } else { |
389 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | 389 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
390 } | 390 } |
391 #endif | 391 #endif |
392 return decoder.Pass(); | 392 return decoder; |
393 } | 393 } |
394 | 394 |
395 scoped_ptr<media::VideoDecodeAccelerator> | 395 scoped_ptr<media::VideoDecodeAccelerator> |
396 GpuVideoDecodeAccelerator::CreateV4L2VDA() { | 396 GpuVideoDecodeAccelerator::CreateV4L2VDA() { |
397 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 397 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
398 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | 398 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
399 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | 399 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
400 if (device.get()) { | 400 if (device.get()) { |
401 decoder.reset(new V4L2VideoDecodeAccelerator( | 401 decoder.reset(new V4L2VideoDecodeAccelerator( |
402 gfx::GLSurfaceEGL::GetHardwareDisplay(), | 402 gfx::GLSurfaceEGL::GetHardwareDisplay(), |
403 stub_->decoder()->GetGLContext()->GetHandle(), | 403 stub_->decoder()->GetGLContext()->GetHandle(), |
404 weak_factory_for_io_.GetWeakPtr(), | 404 weak_factory_for_io_.GetWeakPtr(), |
405 make_context_current_, | 405 make_context_current_, |
406 device, | 406 device, |
407 io_task_runner_)); | 407 io_task_runner_)); |
408 } | 408 } |
409 #endif | 409 #endif |
410 return decoder.Pass(); | 410 return decoder; |
411 } | 411 } |
412 | 412 |
413 scoped_ptr<media::VideoDecodeAccelerator> | 413 scoped_ptr<media::VideoDecodeAccelerator> |
414 GpuVideoDecodeAccelerator::CreateV4L2SliceVDA() { | 414 GpuVideoDecodeAccelerator::CreateV4L2SliceVDA() { |
415 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 415 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
416 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | 416 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) |
417 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); | 417 scoped_refptr<V4L2Device> device = V4L2Device::Create(V4L2Device::kDecoder); |
418 if (device.get()) { | 418 if (device.get()) { |
419 decoder.reset(new V4L2SliceVideoDecodeAccelerator( | 419 decoder.reset(new V4L2SliceVideoDecodeAccelerator( |
420 device, | 420 device, |
421 gfx::GLSurfaceEGL::GetHardwareDisplay(), | 421 gfx::GLSurfaceEGL::GetHardwareDisplay(), |
422 stub_->decoder()->GetGLContext()->GetHandle(), | 422 stub_->decoder()->GetGLContext()->GetHandle(), |
423 weak_factory_for_io_.GetWeakPtr(), | 423 weak_factory_for_io_.GetWeakPtr(), |
424 make_context_current_, | 424 make_context_current_, |
425 io_task_runner_)); | 425 io_task_runner_)); |
426 } | 426 } |
427 #endif | 427 #endif |
428 return decoder.Pass(); | 428 return decoder; |
429 } | 429 } |
430 | 430 |
431 void GpuVideoDecodeAccelerator::BindImage(uint32_t client_texture_id, | 431 void GpuVideoDecodeAccelerator::BindImage(uint32_t client_texture_id, |
432 uint32_t texture_target, | 432 uint32_t texture_target, |
433 scoped_refptr<gl::GLImage> image) { | 433 scoped_refptr<gl::GLImage> image) { |
434 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); | 434 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); |
435 gpu::gles2::TextureManager* texture_manager = | 435 gpu::gles2::TextureManager* texture_manager = |
436 command_decoder->GetContextGroup()->texture_manager(); | 436 command_decoder->GetContextGroup()->texture_manager(); |
437 gpu::gles2::TextureRef* ref = texture_manager->GetTexture(client_texture_id); | 437 gpu::gles2::TextureRef* ref = texture_manager->GetTexture(client_texture_id); |
438 if (ref) { | 438 if (ref) { |
439 texture_manager->SetLevelImage(ref, texture_target, 0, image.get(), | 439 texture_manager->SetLevelImage(ref, texture_target, 0, image.get(), |
440 gpu::gles2::Texture::BOUND); | 440 gpu::gles2::Texture::BOUND); |
441 } | 441 } |
442 } | 442 } |
443 | 443 |
444 scoped_ptr<media::VideoDecodeAccelerator> | 444 scoped_ptr<media::VideoDecodeAccelerator> |
445 GpuVideoDecodeAccelerator::CreateVaapiVDA() { | 445 GpuVideoDecodeAccelerator::CreateVaapiVDA() { |
446 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 446 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
447 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | 447 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) |
448 decoder.reset(new VaapiVideoDecodeAccelerator( | 448 decoder.reset(new VaapiVideoDecodeAccelerator( |
449 make_context_current_, base::Bind(&GpuVideoDecodeAccelerator::BindImage, | 449 make_context_current_, base::Bind(&GpuVideoDecodeAccelerator::BindImage, |
450 base::Unretained(this)))); | 450 base::Unretained(this)))); |
451 #endif | 451 #endif |
452 return decoder.Pass(); | 452 return decoder; |
453 } | 453 } |
454 | 454 |
455 scoped_ptr<media::VideoDecodeAccelerator> | 455 scoped_ptr<media::VideoDecodeAccelerator> |
456 GpuVideoDecodeAccelerator::CreateVTVDA() { | 456 GpuVideoDecodeAccelerator::CreateVTVDA() { |
457 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 457 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
458 #if defined(OS_MACOSX) | 458 #if defined(OS_MACOSX) |
459 decoder.reset(new VTVideoDecodeAccelerator( | 459 decoder.reset(new VTVideoDecodeAccelerator( |
460 make_context_current_, base::Bind(&GpuVideoDecodeAccelerator::BindImage, | 460 make_context_current_, base::Bind(&GpuVideoDecodeAccelerator::BindImage, |
461 base::Unretained(this)))); | 461 base::Unretained(this)))); |
462 #endif | 462 #endif |
463 return decoder.Pass(); | 463 return decoder; |
464 } | 464 } |
465 | 465 |
466 scoped_ptr<media::VideoDecodeAccelerator> | 466 scoped_ptr<media::VideoDecodeAccelerator> |
467 GpuVideoDecodeAccelerator::CreateOzoneVDA() { | 467 GpuVideoDecodeAccelerator::CreateOzoneVDA() { |
468 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 468 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
469 #if !defined(OS_CHROMEOS) && defined(USE_OZONE) | 469 #if !defined(OS_CHROMEOS) && defined(USE_OZONE) |
470 media::MediaOzonePlatform* platform = | 470 media::MediaOzonePlatform* platform = |
471 media::MediaOzonePlatform::GetInstance(); | 471 media::MediaOzonePlatform::GetInstance(); |
472 decoder.reset(platform->CreateVideoDecodeAccelerator(make_context_current_)); | 472 decoder.reset(platform->CreateVideoDecodeAccelerator(make_context_current_)); |
473 #endif | 473 #endif |
474 return decoder.Pass(); | 474 return decoder; |
475 } | 475 } |
476 | 476 |
477 scoped_ptr<media::VideoDecodeAccelerator> | 477 scoped_ptr<media::VideoDecodeAccelerator> |
478 GpuVideoDecodeAccelerator::CreateAndroidVDA() { | 478 GpuVideoDecodeAccelerator::CreateAndroidVDA() { |
479 scoped_ptr<media::VideoDecodeAccelerator> decoder; | 479 scoped_ptr<media::VideoDecodeAccelerator> decoder; |
480 #if defined(OS_ANDROID) | 480 #if defined(OS_ANDROID) |
481 decoder.reset(new AndroidVideoDecodeAccelerator(stub_->decoder()->AsWeakPtr(), | 481 decoder.reset(new AndroidVideoDecodeAccelerator(stub_->decoder()->AsWeakPtr(), |
482 make_context_current_)); | 482 make_context_current_)); |
483 #endif | 483 #endif |
484 return decoder.Pass(); | 484 return decoder; |
485 } | 485 } |
486 | 486 |
487 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { | 487 void GpuVideoDecodeAccelerator::OnSetCdm(int cdm_id) { |
488 DCHECK(video_decode_accelerator_); | 488 DCHECK(video_decode_accelerator_); |
489 video_decode_accelerator_->SetCdm(cdm_id); | 489 video_decode_accelerator_->SetCdm(cdm_id); |
490 } | 490 } |
491 | 491 |
492 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is | 492 // Runs on IO thread if video_decode_accelerator_->CanDecodeOnIOThread() is |
493 // true, otherwise on the main thread. | 493 // true, otherwise on the main thread. |
494 void GpuVideoDecodeAccelerator::OnDecode( | 494 void GpuVideoDecodeAccelerator::OnDecode( |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 uncleared_textures_.erase(it); | 637 uncleared_textures_.erase(it); |
638 } | 638 } |
639 | 639 |
640 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, | 640 void GpuVideoDecodeAccelerator::SendCreateDecoderReply(IPC::Message* message, |
641 bool succeeded) { | 641 bool succeeded) { |
642 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); | 642 GpuCommandBufferMsg_CreateVideoDecoder::WriteReplyParams(message, succeeded); |
643 Send(message); | 643 Send(message); |
644 } | 644 } |
645 | 645 |
646 } // namespace content | 646 } // namespace content |
OLD | NEW |