| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/renderer/pepper/pepper_video_encoder_host.h" | 5 #include "content/renderer/pepper/pepper_video_encoder_host.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
| 11 #include "base/numerics/safe_math.h" | 11 #include "base/numerics/safe_math.h" |
| 12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
| 13 #include "content/common/gpu/client/command_buffer_proxy_impl.h" | |
| 14 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" | 13 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h" |
| 15 #include "content/common/gpu/media/gpu_video_accelerator_util.h" | 14 #include "content/common/gpu/media/gpu_video_accelerator_util.h" |
| 16 #include "content/common/pepper_file_util.h" | 15 #include "content/common/pepper_file_util.h" |
| 17 #include "content/public/renderer/renderer_ppapi_host.h" | 16 #include "content/public/renderer/renderer_ppapi_host.h" |
| 18 #include "content/renderer/pepper/gfx_conversion.h" | 17 #include "content/renderer/pepper/gfx_conversion.h" |
| 19 #include "content/renderer/pepper/host_globals.h" | 18 #include "content/renderer/pepper/host_globals.h" |
| 20 #include "content/renderer/pepper/video_encoder_shim.h" | 19 #include "content/renderer/pepper/video_encoder_shim.h" |
| 21 #include "content/renderer/render_thread_impl.h" | 20 #include "content/renderer/render_thread_impl.h" |
| 21 #include "gpu/ipc/client/command_buffer_proxy_impl.h" |
| 22 #include "media/base/bind_to_current_loop.h" | 22 #include "media/base/bind_to_current_loop.h" |
| 23 #include "media/base/video_frame.h" | 23 #include "media/base/video_frame.h" |
| 24 #include "media/renderers/gpu_video_accelerator_factories.h" | 24 #include "media/renderers/gpu_video_accelerator_factories.h" |
| 25 #include "media/video/video_encode_accelerator.h" | 25 #include "media/video/video_encode_accelerator.h" |
| 26 #include "ppapi/c/pp_codecs.h" | 26 #include "ppapi/c/pp_codecs.h" |
| 27 #include "ppapi/c/pp_errors.h" | 27 #include "ppapi/c/pp_errors.h" |
| 28 #include "ppapi/c/pp_graphics_3d.h" | 28 #include "ppapi/c/pp_graphics_3d.h" |
| 29 #include "ppapi/host/dispatch_host_message.h" | 29 #include "ppapi/host/dispatch_host_message.h" |
| 30 #include "ppapi/host/ppapi_host.h" | 30 #include "ppapi/host/ppapi_host.h" |
| 31 #include "ppapi/proxy/ppapi_messages.h" | 31 #include "ppapi/proxy/ppapi_messages.h" |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 499 // There is no guarantee that we have a 3D context to work with. So | 499 // There is no guarantee that we have a 3D context to work with. So |
| 500 // we create a dummy command buffer to communicate with the gpu process. | 500 // we create a dummy command buffer to communicate with the gpu process. |
| 501 channel_ = RenderThreadImpl::current()->EstablishGpuChannelSync( | 501 channel_ = RenderThreadImpl::current()->EstablishGpuChannelSync( |
| 502 CAUSE_FOR_GPU_LAUNCH_PEPPERVIDEOENCODERACCELERATOR_INITIALIZE); | 502 CAUSE_FOR_GPU_LAUNCH_PEPPERVIDEOENCODERACCELERATOR_INITIALIZE); |
| 503 if (!channel_) | 503 if (!channel_) |
| 504 return false; | 504 return false; |
| 505 | 505 |
| 506 std::vector<int32_t> attribs(1, PP_GRAPHICS3DATTRIB_NONE); | 506 std::vector<int32_t> attribs(1, PP_GRAPHICS3DATTRIB_NONE); |
| 507 command_buffer_ = channel_->CreateCommandBuffer( | 507 command_buffer_ = channel_->CreateCommandBuffer( |
| 508 gpu::kNullSurfaceHandle, gfx::Size(), nullptr, | 508 gpu::kNullSurfaceHandle, gfx::Size(), nullptr, |
| 509 GpuChannelHost::kDefaultStreamId, GpuChannelHost::kDefaultStreamPriority, | 509 gpu::GpuChannelHost::kDefaultStreamId, |
| 510 attribs, GURL::EmptyGURL(), gfx::PreferIntegratedGpu); | 510 gpu::GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), |
| 511 gfx::PreferIntegratedGpu); |
| 511 if (!command_buffer_) { | 512 if (!command_buffer_) { |
| 512 Close(); | 513 Close(); |
| 513 return false; | 514 return false; |
| 514 } | 515 } |
| 515 | 516 |
| 516 command_buffer_->SetContextLostCallback(media::BindToCurrentLoop( | 517 command_buffer_->SetContextLostCallback(media::BindToCurrentLoop( |
| 517 base::Bind(&PepperVideoEncoderHost::NotifyPepperError, | 518 base::Bind(&PepperVideoEncoderHost::NotifyPepperError, |
| 518 weak_ptr_factory_.GetWeakPtr(), PP_ERROR_RESOURCE_FAILED))); | 519 weak_ptr_factory_.GetWeakPtr(), PP_ERROR_RESOURCE_FAILED))); |
| 519 if (!command_buffer_->Initialize()) { | 520 if (!command_buffer_->Initialize()) { |
| 520 Close(); | 521 Close(); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 } | 661 } |
| 661 | 662 |
| 662 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { | 663 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { |
| 663 DCHECK(RenderThreadImpl::current()); | 664 DCHECK(RenderThreadImpl::current()); |
| 664 DCHECK_GE(buffer_id, 0); | 665 DCHECK_GE(buffer_id, 0); |
| 665 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); | 666 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); |
| 666 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); | 667 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); |
| 667 } | 668 } |
| 668 | 669 |
| 669 } // namespace content | 670 } // namespace content |
| OLD | NEW |