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" |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
225 OnHostMsgRecycleBitstreamBuffer) | 225 OnHostMsgRecycleBitstreamBuffer) |
226 PPAPI_DISPATCH_HOST_RESOURCE_CALL( | 226 PPAPI_DISPATCH_HOST_RESOURCE_CALL( |
227 PpapiHostMsg_VideoEncoder_RequestEncodingParametersChange, | 227 PpapiHostMsg_VideoEncoder_RequestEncodingParametersChange, |
228 OnHostMsgRequestEncodingParametersChange) | 228 OnHostMsgRequestEncodingParametersChange) |
229 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoEncoder_Close, | 229 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoEncoder_Close, |
230 OnHostMsgClose) | 230 OnHostMsgClose) |
231 PPAPI_END_MESSAGE_MAP() | 231 PPAPI_END_MESSAGE_MAP() |
232 return PP_ERROR_FAILED; | 232 return PP_ERROR_FAILED; |
233 } | 233 } |
234 | 234 |
| 235 void PepperVideoEncoderHost::OnGpuControlLostContext() { |
| 236 NotifyPepperError(PP_ERROR_RESOURCE_FAILED); |
| 237 } |
| 238 |
235 int32_t PepperVideoEncoderHost::OnHostMsgGetSupportedProfiles( | 239 int32_t PepperVideoEncoderHost::OnHostMsgGetSupportedProfiles( |
236 ppapi::host::HostMessageContext* context) { | 240 ppapi::host::HostMessageContext* context) { |
237 std::vector<PP_VideoProfileDescription> pp_profiles; | 241 std::vector<PP_VideoProfileDescription> pp_profiles; |
238 GetSupportedProfiles(&pp_profiles); | 242 GetSupportedProfiles(&pp_profiles); |
239 | 243 |
240 host()->SendReply( | 244 host()->SendReply( |
241 context->MakeReplyMessageContext(), | 245 context->MakeReplyMessageContext(), |
242 PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply(pp_profiles)); | 246 PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply(pp_profiles)); |
243 | 247 |
244 return PP_OK_COMPLETIONPENDING; | 248 return PP_OK_COMPLETIONPENDING; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 command_buffer_ = channel_->CreateCommandBuffer( | 516 command_buffer_ = channel_->CreateCommandBuffer( |
513 gpu::kNullSurfaceHandle, gfx::Size(), nullptr, | 517 gpu::kNullSurfaceHandle, gfx::Size(), nullptr, |
514 gpu::GpuChannelHost::kDefaultStreamId, | 518 gpu::GpuChannelHost::kDefaultStreamId, |
515 gpu::GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), | 519 gpu::GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), |
516 gfx::PreferIntegratedGpu); | 520 gfx::PreferIntegratedGpu); |
517 if (!command_buffer_) { | 521 if (!command_buffer_) { |
518 Close(); | 522 Close(); |
519 return false; | 523 return false; |
520 } | 524 } |
521 | 525 |
522 command_buffer_->SetContextLostCallback(media::BindToCurrentLoop( | 526 command_buffer_->SetGpuControlClient(this); |
523 base::Bind(&PepperVideoEncoderHost::NotifyPepperError, | 527 |
524 weak_ptr_factory_.GetWeakPtr(), PP_ERROR_RESOURCE_FAILED))); | |
525 if (!command_buffer_->Initialize()) { | 528 if (!command_buffer_->Initialize()) { |
526 Close(); | 529 Close(); |
527 return false; | 530 return false; |
528 } | 531 } |
529 | 532 |
530 return true; | 533 return true; |
531 } | 534 } |
532 | 535 |
533 bool PepperVideoEncoderHost::InitializeHardware( | 536 bool PepperVideoEncoderHost::InitializeHardware( |
534 media::VideoPixelFormat input_format, | 537 media::VideoPixelFormat input_format, |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
666 } | 669 } |
667 | 670 |
668 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { | 671 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { |
669 DCHECK(RenderThreadImpl::current()); | 672 DCHECK(RenderThreadImpl::current()); |
670 DCHECK_GE(buffer_id, 0); | 673 DCHECK_GE(buffer_id, 0); |
671 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); | 674 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); |
672 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); | 675 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); |
673 } | 676 } |
674 | 677 |
675 } // namespace content | 678 } // namespace content |
OLD | NEW |