| 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/client/gpu_video_decode_accelerator_host.h" | 5 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/common/gpu/client/gpu_channel_host.h" | 10 #include "content/common/gpu/client/gpu_channel_host.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 if (channel_ && decoder_route_id_ != MSG_ROUTING_NONE) | 39 if (channel_ && decoder_route_id_ != MSG_ROUTING_NONE) |
| 40 channel_->RemoveRoute(decoder_route_id_); | 40 channel_->RemoveRoute(decoder_route_id_); |
| 41 if (impl_) | 41 if (impl_) |
| 42 impl_->RemoveDeletionObserver(this); | 42 impl_->RemoveDeletionObserver(this); |
| 43 } | 43 } |
| 44 | 44 |
| 45 bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) { | 45 bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) { |
| 46 DCHECK(CalledOnValidThread()); | 46 DCHECK(CalledOnValidThread()); |
| 47 bool handled = true; | 47 bool handled = true; |
| 48 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAcceleratorHost, msg) | 48 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAcceleratorHost, msg) |
| 49 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_CdmAttached, |
| 50 OnCdmAttached) |
| 49 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed, | 51 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed, |
| 50 OnBitstreamBufferProcessed) | 52 OnBitstreamBufferProcessed) |
| 51 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers, | 53 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers, |
| 52 OnProvidePictureBuffer) | 54 OnProvidePictureBuffer) |
| 53 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady, | 55 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady, |
| 54 OnPictureReady) | 56 OnPictureReady) |
| 55 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_FlushDone, | 57 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_FlushDone, |
| 56 OnFlushDone) | 58 OnFlushDone) |
| 57 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ResetDone, | 59 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ResetDone, |
| 58 OnResetDone) | 60 OnResetDone) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 if (!succeeded) { | 99 if (!succeeded) { |
| 98 DLOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoDecoder()) failed"; | 100 DLOG(ERROR) << "Send(GpuCommandBufferMsg_CreateVideoDecoder()) failed"; |
| 99 PostNotifyError(PLATFORM_FAILURE); | 101 PostNotifyError(PLATFORM_FAILURE); |
| 100 channel_->RemoveRoute(route_id); | 102 channel_->RemoveRoute(route_id); |
| 101 return false; | 103 return false; |
| 102 } | 104 } |
| 103 decoder_route_id_ = route_id; | 105 decoder_route_id_ = route_id; |
| 104 return true; | 106 return true; |
| 105 } | 107 } |
| 106 | 108 |
| 109 void GpuVideoDecodeAcceleratorHost::SetCdm(int cdm_id) { |
| 110 DCHECK(CalledOnValidThread()); |
| 111 if (!channel_) |
| 112 return; |
| 113 Send(new AcceleratedVideoDecoderMsg_SetCdm(decoder_route_id_, cdm_id)); |
| 114 } |
| 115 |
| 107 void GpuVideoDecodeAcceleratorHost::Decode( | 116 void GpuVideoDecodeAcceleratorHost::Decode( |
| 108 const media::BitstreamBuffer& bitstream_buffer) { | 117 const media::BitstreamBuffer& bitstream_buffer) { |
| 109 DCHECK(CalledOnValidThread()); | 118 DCHECK(CalledOnValidThread()); |
| 110 if (!channel_) | 119 if (!channel_) |
| 111 return; | 120 return; |
| 112 | 121 |
| 113 base::SharedMemoryHandle handle = channel_->ShareToGpuProcess( | 122 base::SharedMemoryHandle handle = channel_->ShareToGpuProcess( |
| 114 bitstream_buffer.handle()); | 123 bitstream_buffer.handle()); |
| 115 if (!base::SharedMemory::IsHandleValid(handle)) { | 124 if (!base::SharedMemory::IsHandleValid(handle)) { |
| 116 NOTREACHED() << "Failed to duplicate buffer handler"; | 125 NOTREACHED() << "Failed to duplicate buffer handler"; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 | 211 |
| 203 void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) { | 212 void GpuVideoDecodeAcceleratorHost::Send(IPC::Message* message) { |
| 204 DCHECK(CalledOnValidThread()); | 213 DCHECK(CalledOnValidThread()); |
| 205 uint32 message_type = message->type(); | 214 uint32 message_type = message->type(); |
| 206 if (!channel_->Send(message)) { | 215 if (!channel_->Send(message)) { |
| 207 DLOG(ERROR) << "Send(" << message_type << ") failed"; | 216 DLOG(ERROR) << "Send(" << message_type << ") failed"; |
| 208 PostNotifyError(PLATFORM_FAILURE); | 217 PostNotifyError(PLATFORM_FAILURE); |
| 209 } | 218 } |
| 210 } | 219 } |
| 211 | 220 |
| 221 void GpuVideoDecodeAcceleratorHost::OnCdmAttached(bool success) { |
| 222 DCHECK(CalledOnValidThread()); |
| 223 if (client_) |
| 224 client_->NotifyCdmAttached(success); |
| 225 } |
| 226 |
| 212 void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed( | 227 void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed( |
| 213 int32 bitstream_buffer_id) { | 228 int32 bitstream_buffer_id) { |
| 214 DCHECK(CalledOnValidThread()); | 229 DCHECK(CalledOnValidThread()); |
| 215 if (client_) | 230 if (client_) |
| 216 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); | 231 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); |
| 217 } | 232 } |
| 218 | 233 |
| 219 void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffer( | 234 void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffer( |
| 220 uint32 num_requested_buffers, | 235 uint32 num_requested_buffers, |
| 221 const gfx::Size& dimensions, | 236 const gfx::Size& dimensions, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 weak_this_factory_.InvalidateWeakPtrs(); | 282 weak_this_factory_.InvalidateWeakPtrs(); |
| 268 | 283 |
| 269 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 284 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
| 270 // last thing done on this stack! | 285 // last thing done on this stack! |
| 271 media::VideoDecodeAccelerator::Client* client = NULL; | 286 media::VideoDecodeAccelerator::Client* client = NULL; |
| 272 std::swap(client, client_); | 287 std::swap(client, client_); |
| 273 client->NotifyError(static_cast<media::VideoDecodeAccelerator::Error>(error)); | 288 client->NotifyError(static_cast<media::VideoDecodeAccelerator::Error>(error)); |
| 274 } | 289 } |
| 275 | 290 |
| 276 } // namespace content | 291 } // namespace content |
| OLD | NEW |