| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/media/gpu_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_video_decode_accelerator.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
| 12 #include "gpu/command_buffer/common/command_buffer.h" | 12 #include "gpu/command_buffer/common/command_buffer.h" |
| 13 #include "ipc/ipc_message_macros.h" | 13 #include "ipc/ipc_message_macros.h" |
| 14 #include "ipc/ipc_message_utils.h" | 14 #include "ipc/ipc_message_utils.h" |
| 15 #include "content/common/gpu/gpu_channel.h" | 15 #include "content/common/gpu/gpu_channel.h" |
| 16 #include "content/common/gpu/gpu_command_buffer_stub.h" | 16 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 17 #include "content/common/gpu/gpu_messages.h" | 17 #include "content/common/gpu/gpu_messages.h" |
| 18 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 18 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 19 #include "content/common/gpu/media/omx_video_decode_accelerator.h" | 19 #include "content/common/gpu/media/omx_video_decode_accelerator.h" |
| 20 #include "ui/gfx/gl/gl_surface_egl.h" | 20 #include "ui/gfx/gl/gl_surface_egl.h" |
| 21 #endif | 21 #endif |
| 22 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
| 23 | 23 |
| 24 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( | 24 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( |
| 25 IPC::Message::Sender* sender, | 25 IPC::Message::Sender* sender, |
| 26 int32 host_route_id, | 26 int32 host_route_id, |
| 27 GpuCommandBufferStub* stub) | 27 GpuCommandBufferStub* stub) |
| 28 : sender_(sender), | 28 : sender_(sender), |
| 29 init_done_msg_(NULL), |
| 29 host_route_id_(host_route_id), | 30 host_route_id_(host_route_id), |
| 30 stub_(stub), | 31 stub_(stub), |
| 31 video_decode_accelerator_(NULL) { | 32 video_decode_accelerator_(NULL) { |
| 32 } | 33 } |
| 33 | 34 |
| 34 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { | 35 GpuVideoDecodeAccelerator::~GpuVideoDecodeAccelerator() { |
| 35 } | 36 } |
| 36 | 37 |
| 37 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { | 38 bool GpuVideoDecodeAccelerator::OnMessageReceived(const IPC::Message& msg) { |
| 38 bool handled = true; | 39 bool handled = true; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 | 86 |
| 86 void GpuVideoDecodeAccelerator::NotifyError( | 87 void GpuVideoDecodeAccelerator::NotifyError( |
| 87 media::VideoDecodeAccelerator::Error error) { | 88 media::VideoDecodeAccelerator::Error error) { |
| 88 if (!Send(new AcceleratedVideoDecoderHostMsg_ErrorNotification( | 89 if (!Send(new AcceleratedVideoDecoderHostMsg_ErrorNotification( |
| 89 host_route_id_, error))) { | 90 host_route_id_, error))) { |
| 90 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ErrorNotification) " | 91 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ErrorNotification) " |
| 91 << "failed"; | 92 << "failed"; |
| 92 } | 93 } |
| 93 } | 94 } |
| 94 | 95 |
| 95 void GpuVideoDecodeAccelerator::Initialize(const std::vector<uint32>& configs) { | 96 void GpuVideoDecodeAccelerator::Initialize( |
| 97 const std::vector<uint32>& configs, |
| 98 IPC::Message* init_done_msg) { |
| 96 DCHECK(!video_decode_accelerator_.get()); | 99 DCHECK(!video_decode_accelerator_.get()); |
| 100 DCHECK(!init_done_msg_); |
| 101 DCHECK(init_done_msg); |
| 97 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 102 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 98 DCHECK(stub_ && stub_->scheduler()); | 103 DCHECK(stub_ && stub_->scheduler()); |
| 104 init_done_msg_ = init_done_msg; |
| 99 OmxVideoDecodeAccelerator* omx_decoder = new OmxVideoDecodeAccelerator(this); | 105 OmxVideoDecodeAccelerator* omx_decoder = new OmxVideoDecodeAccelerator(this); |
| 100 omx_decoder->SetEglState( | 106 omx_decoder->SetEglState( |
| 101 gfx::GLSurfaceEGL::GetHardwareDisplay(), | 107 gfx::GLSurfaceEGL::GetHardwareDisplay(), |
| 102 stub_->scheduler()->decoder()->GetGLContext()->GetHandle()); | 108 stub_->scheduler()->decoder()->GetGLContext()->GetHandle()); |
| 103 video_decode_accelerator_ = omx_decoder; | 109 video_decode_accelerator_ = omx_decoder; |
| 104 video_decode_accelerator_->Initialize(configs); | 110 video_decode_accelerator_->Initialize(configs); |
| 105 #else | 111 #else |
| 106 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | 112 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
| 107 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 113 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 108 } | 114 } |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 int32 bitstream_buffer_id) { | 166 int32 bitstream_buffer_id) { |
| 161 if (!Send(new AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed( | 167 if (!Send(new AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed( |
| 162 host_route_id_, bitstream_buffer_id))) { | 168 host_route_id_, bitstream_buffer_id))) { |
| 163 DLOG(ERROR) | 169 DLOG(ERROR) |
| 164 << "Send(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed) " | 170 << "Send(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed) " |
| 165 << "failed"; | 171 << "failed"; |
| 166 } | 172 } |
| 167 } | 173 } |
| 168 | 174 |
| 169 void GpuVideoDecodeAccelerator::NotifyInitializeDone() { | 175 void GpuVideoDecodeAccelerator::NotifyInitializeDone() { |
| 170 if (!Send(new AcceleratedVideoDecoderHostMsg_InitializeDone(host_route_id_))) | 176 if (!Send(init_done_msg_)) |
| 171 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_InitializeDone) failed"; | 177 LOG(ERROR) << "Send(init_done_msg_) failed"; |
| 178 init_done_msg_ = NULL; |
| 172 } | 179 } |
| 173 | 180 |
| 174 void GpuVideoDecodeAccelerator::NotifyFlushDone() { | 181 void GpuVideoDecodeAccelerator::NotifyFlushDone() { |
| 175 if (!Send(new AcceleratedVideoDecoderHostMsg_FlushDone(host_route_id_))) | 182 if (!Send(new AcceleratedVideoDecoderHostMsg_FlushDone(host_route_id_))) |
| 176 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_FlushDone) failed"; | 183 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_FlushDone) failed"; |
| 177 } | 184 } |
| 178 | 185 |
| 179 void GpuVideoDecodeAccelerator::NotifyResetDone() { | 186 void GpuVideoDecodeAccelerator::NotifyResetDone() { |
| 180 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) | 187 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) |
| 181 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; | 188 LOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; |
| 182 } | 189 } |
| 183 | 190 |
| 184 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { | 191 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { |
| 185 DCHECK(sender_); | 192 DCHECK(sender_); |
| 186 return sender_->Send(message); | 193 return sender_->Send(message); |
| 187 } | 194 } |
| OLD | NEW |