Index: content/common/gpu/client/gpu_video_decode_accelerator_host.cc |
diff --git a/content/common/gpu/client/gpu_video_decode_accelerator_host.cc b/content/common/gpu/client/gpu_video_decode_accelerator_host.cc |
index 19a336b9ca30af573159449f4eef9911b2b01b8d..56ace4053ff69fdca8d071579de7291669e18386 100644 |
--- a/content/common/gpu/client/gpu_video_decode_accelerator_host.cc |
+++ b/content/common/gpu/client/gpu_video_decode_accelerator_host.cc |
@@ -7,118 +7,68 @@ |
#include "base/bind.h" |
#include "base/logging.h" |
#include "base/message_loop/message_loop.h" |
+#include "base/thread_task_runner_handle.h" |
#include "build/build_config.h" |
#include "content/common/gpu/client/gpu_channel_host.h" |
-#include "content/common/gpu/gpu_messages.h" |
-#include "content/common/view_messages.h" |
-#include "ipc/ipc_message_macros.h" |
-#include "ipc/ipc_message_utils.h" |
+#include "content/common/gpu/client/ipc/chrome/chrome_command_buffer_ipc_transport.h" |
+#include "content/common/gpu/video_decode_params.h" |
#if defined(OS_WIN) |
#include "content/public/common/sandbox_init.h" |
#endif // OS_WIN |
using media::VideoDecodeAccelerator; |
+ |
namespace content { |
GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost( |
GpuChannelHost* channel, |
+ scoped_ptr<GpuVideoDecodeAcceleratorHostIPCTransport> transport, |
CommandBufferProxyImpl* impl) |
: channel_(channel), |
- decoder_route_id_(MSG_ROUTING_NONE), |
- client_(NULL), |
+ transport_(std::move(transport)), |
+ client_(nullptr), |
impl_(impl), |
weak_this_factory_(this) { |
- DCHECK(channel_); |
DCHECK(impl_); |
impl_->AddDeletionObserver(this); |
+ transport_->SetClient(this); |
} |
GpuVideoDecodeAcceleratorHost::~GpuVideoDecodeAcceleratorHost() { |
DCHECK(CalledOnValidThread()); |
- |
- if (channel_ && decoder_route_id_ != MSG_ROUTING_NONE) |
- channel_->RemoveRoute(decoder_route_id_); |
+ transport_.reset(); |
if (impl_) |
impl_->RemoveDeletionObserver(this); |
} |
-bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) { |
- DCHECK(CalledOnValidThread()); |
- bool handled = true; |
- IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAcceleratorHost, msg) |
- IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_CdmAttached, |
- OnCdmAttached) |
- IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed, |
- OnBitstreamBufferProcessed) |
- IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers, |
- OnProvidePictureBuffer) |
- IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady, |
- OnPictureReady) |
- IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_FlushDone, |
- OnFlushDone) |
- IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ResetDone, |
- OnResetDone) |
- IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ErrorNotification, |
- OnNotifyError) |
- IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer, |
- OnDismissPictureBuffer) |
- IPC_MESSAGE_UNHANDLED(handled = false) |
- IPC_END_MESSAGE_MAP() |
- DCHECK(handled); |
- // See OnNotifyError for why |this| mustn't be used after OnNotifyError might |
- // have been called above. |
- return handled; |
-} |
- |
-void GpuVideoDecodeAcceleratorHost::OnChannelError() { |
- DCHECK(CalledOnValidThread()); |
- if (channel_) { |
- if (decoder_route_id_ != MSG_ROUTING_NONE) |
- channel_->RemoveRoute(decoder_route_id_); |
- channel_ = NULL; |
- } |
- DLOG(ERROR) << "OnChannelError()"; |
- PostNotifyError(PLATFORM_FAILURE); |
-} |
- |
-bool GpuVideoDecodeAcceleratorHost::Initialize(const Config& config, |
- Client* client) { |
+bool GpuVideoDecodeAcceleratorHost::Initialize( |
+ const Config& config, |
+ media::VideoDecodeAccelerator::Client* client) { |
DCHECK(CalledOnValidThread()); |
client_ = client; |
if (!impl_) |
return false; |
- int32_t route_id = channel_->GenerateRouteID(); |
- channel_->AddRoute(route_id, weak_this_factory_.GetWeakPtr()); |
- |
bool succeeded = false; |
- Send(new GpuCommandBufferMsg_CreateVideoDecoder(impl_->route_id(), config, |
- route_id, &succeeded)); |
- |
+ impl_->transport()->CreateVideoDecoder(transport_.get(), config, &succeeded); |
if (!succeeded) { |
- DLOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoDecoder()) failed"; |
+ DLOG(ERROR) << "CreateVideoDecoder() failed"; |
PostNotifyError(PLATFORM_FAILURE); |
- channel_->RemoveRoute(route_id); |
return false; |
} |
- decoder_route_id_ = route_id; |
return true; |
} |
void GpuVideoDecodeAcceleratorHost::SetCdm(int cdm_id) { |
DCHECK(CalledOnValidThread()); |
- if (!channel_) |
- return; |
- Send(new AcceleratedVideoDecoderMsg_SetCdm(decoder_route_id_, cdm_id)); |
+ transport_->SetCdm(cdm_id); |
} |
void GpuVideoDecodeAcceleratorHost::Decode( |
const media::BitstreamBuffer& bitstream_buffer) { |
DCHECK(CalledOnValidThread()); |
- if (!channel_) |
- return; |
base::SharedMemoryHandle handle = channel_->ShareToGpuProcess( |
bitstream_buffer.handle()); |
@@ -127,7 +77,7 @@ void GpuVideoDecodeAcceleratorHost::Decode( |
return; |
} |
- AcceleratedVideoDecoderMsg_Decode_Params params; |
+ VideoDecodeParams params; |
params.bitstream_buffer_id = bitstream_buffer.id(); |
params.buffer_handle = handle; |
params.size = bitstream_buffer.size(); |
@@ -136,7 +86,7 @@ void GpuVideoDecodeAcceleratorHost::Decode( |
params.iv = bitstream_buffer.iv(); |
params.subsamples = bitstream_buffer.subsamples(); |
- Send(new AcceleratedVideoDecoderMsg_Decode(decoder_route_id_, params)); |
+ transport_->Decode(params); |
} |
void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( |
@@ -159,8 +109,7 @@ void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( |
texture_ids.push_back(buffer.texture_id()); |
buffer_ids.push_back(buffer.id()); |
} |
- Send(new AcceleratedVideoDecoderMsg_AssignPictureBuffers( |
- decoder_route_id_, buffer_ids, texture_ids)); |
+ transport_->AssignPictureBuffers(buffer_ids, texture_ids); |
} |
void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( |
@@ -168,38 +117,34 @@ void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( |
DCHECK(CalledOnValidThread()); |
if (!channel_) |
return; |
- Send(new AcceleratedVideoDecoderMsg_ReusePictureBuffer( |
- decoder_route_id_, picture_buffer_id)); |
+ transport_->ReusePictureBuffer(picture_buffer_id); |
} |
void GpuVideoDecodeAcceleratorHost::Flush() { |
DCHECK(CalledOnValidThread()); |
if (!channel_) |
return; |
- Send(new AcceleratedVideoDecoderMsg_Flush(decoder_route_id_)); |
+ transport_->Flush(); |
} |
void GpuVideoDecodeAcceleratorHost::Reset() { |
DCHECK(CalledOnValidThread()); |
if (!channel_) |
return; |
- Send(new AcceleratedVideoDecoderMsg_Reset(decoder_route_id_)); |
+ transport_->Reset(); |
} |
void GpuVideoDecodeAcceleratorHost::Destroy() { |
DCHECK(CalledOnValidThread()); |
if (channel_) |
- Send(new AcceleratedVideoDecoderMsg_Destroy(decoder_route_id_)); |
- client_ = NULL; |
+ transport_->Destroy(); |
+ client_ = nullptr; |
delete this; |
} |
void GpuVideoDecodeAcceleratorHost::OnWillDeleteImpl() { |
DCHECK(CalledOnValidThread()); |
- impl_ = NULL; |
- |
- // The CommandBufferProxyImpl is going away; error out this VDA. |
- OnChannelError(); |
+ impl_ = nullptr; |
} |
void GpuVideoDecodeAcceleratorHost::PostNotifyError(Error error) { |
@@ -210,15 +155,6 @@ void GpuVideoDecodeAcceleratorHost::PostNotifyError(Error error) { |
weak_this_factory_.GetWeakPtr(), error)); |
} |
-void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) { |
- DCHECK(CalledOnValidThread()); |
- uint32_t message_type = message->type(); |
- if (!channel_->Send(message)) { |
- DLOG(ERROR) << "Send(" << message_type << ") failed"; |
- PostNotifyError(PLATFORM_FAILURE); |
- } |
-} |
- |
void GpuVideoDecodeAcceleratorHost::OnCdmAttached(bool success) { |
DCHECK(CalledOnValidThread()); |
if (client_) |
@@ -284,7 +220,7 @@ void GpuVideoDecodeAcceleratorHost::OnNotifyError(uint32_t error) { |
// Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
// last thing done on this stack! |
- media::VideoDecodeAccelerator::Client* client = NULL; |
+ media::VideoDecodeAccelerator::Client* client = nullptr; |
std::swap(client, client_); |
client->NotifyError(static_cast<media::VideoDecodeAccelerator::Error>(error)); |
} |