| 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 #if DCHECK_IS_ON() | |
| 237 // This should never occur more than once. | |
| 238 DCHECK(!lost_context_); | |
| 239 lost_context_ = true; | |
| 240 #endif | |
| 241 NotifyPepperError(PP_ERROR_RESOURCE_FAILED); | |
| 242 } | |
| 243 | |
| 244 int32_t PepperVideoEncoderHost::OnHostMsgGetSupportedProfiles( | 235 int32_t PepperVideoEncoderHost::OnHostMsgGetSupportedProfiles( |
| 245 ppapi::host::HostMessageContext* context) { | 236 ppapi::host::HostMessageContext* context) { |
| 246 std::vector<PP_VideoProfileDescription> pp_profiles; | 237 std::vector<PP_VideoProfileDescription> pp_profiles; |
| 247 GetSupportedProfiles(&pp_profiles); | 238 GetSupportedProfiles(&pp_profiles); |
| 248 | 239 |
| 249 host()->SendReply( | 240 host()->SendReply( |
| 250 context->MakeReplyMessageContext(), | 241 context->MakeReplyMessageContext(), |
| 251 PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply(pp_profiles)); | 242 PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply(pp_profiles)); |
| 252 | 243 |
| 253 return PP_OK_COMPLETIONPENDING; | 244 return PP_OK_COMPLETIONPENDING; |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 command_buffer_ = channel_->CreateCommandBuffer( | 512 command_buffer_ = channel_->CreateCommandBuffer( |
| 522 gpu::kNullSurfaceHandle, gfx::Size(), nullptr, | 513 gpu::kNullSurfaceHandle, gfx::Size(), nullptr, |
| 523 gpu::GpuChannelHost::kDefaultStreamId, | 514 gpu::GpuChannelHost::kDefaultStreamId, |
| 524 gpu::GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), | 515 gpu::GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), |
| 525 gfx::PreferIntegratedGpu); | 516 gfx::PreferIntegratedGpu); |
| 526 if (!command_buffer_) { | 517 if (!command_buffer_) { |
| 527 Close(); | 518 Close(); |
| 528 return false; | 519 return false; |
| 529 } | 520 } |
| 530 | 521 |
| 531 command_buffer_->SetGpuControlClient(this); | 522 command_buffer_->SetContextLostCallback(media::BindToCurrentLoop( |
| 532 | 523 base::Bind(&PepperVideoEncoderHost::NotifyPepperError, |
| 524 weak_ptr_factory_.GetWeakPtr(), PP_ERROR_RESOURCE_FAILED))); |
| 533 if (!command_buffer_->Initialize()) { | 525 if (!command_buffer_->Initialize()) { |
| 534 Close(); | 526 Close(); |
| 535 return false; | 527 return false; |
| 536 } | 528 } |
| 537 | 529 |
| 538 return true; | 530 return true; |
| 539 } | 531 } |
| 540 | 532 |
| 541 bool PepperVideoEncoderHost::InitializeHardware( | 533 bool PepperVideoEncoderHost::InitializeHardware( |
| 542 media::VideoPixelFormat input_format, | 534 media::VideoPixelFormat input_format, |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 } | 666 } |
| 675 | 667 |
| 676 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { | 668 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { |
| 677 DCHECK(RenderThreadImpl::current()); | 669 DCHECK(RenderThreadImpl::current()); |
| 678 DCHECK_GE(buffer_id, 0); | 670 DCHECK_GE(buffer_id, 0); |
| 679 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); | 671 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); |
| 680 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); | 672 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); |
| 681 } | 673 } |
| 682 | 674 |
| 683 } // namespace content | 675 } // namespace content |
| OLD | NEW |