| 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 |
| 13 #if defined(OS_WIN) |
| 14 #include "base/win/windows_version.h" |
| 15 #endif // OS_WIN |
| 16 |
| 12 #include "gpu/command_buffer/common/command_buffer.h" | 17 #include "gpu/command_buffer/common/command_buffer.h" |
| 13 #include "ipc/ipc_message_macros.h" | 18 #include "ipc/ipc_message_macros.h" |
| 14 #include "ipc/ipc_message_utils.h" | 19 #include "ipc/ipc_message_utils.h" |
| 15 #include "content/common/gpu/gpu_channel.h" | 20 #include "content/common/gpu/gpu_channel.h" |
| 16 #include "content/common/gpu/gpu_command_buffer_stub.h" | 21 #include "content/common/gpu/gpu_command_buffer_stub.h" |
| 17 #include "content/common/gpu/gpu_messages.h" | 22 #include "content/common/gpu/gpu_messages.h" |
| 18 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 23 |
| 24 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)) || defined(OS_WIN) |
| 25 #if defined(OS_WIN) |
| 26 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| 27 #else // OS_WIN |
| 19 #include "content/common/gpu/media/omx_video_decode_accelerator.h" | 28 #include "content/common/gpu/media/omx_video_decode_accelerator.h" |
| 29 #endif // OS_WIN |
| 20 #include "ui/gfx/gl/gl_context.h" | 30 #include "ui/gfx/gl/gl_context.h" |
| 21 #include "ui/gfx/gl/gl_surface_egl.h" | 31 #include "ui/gfx/gl/gl_surface_egl.h" |
| 22 #endif | 32 #endif |
| 33 |
| 23 #include "gpu/command_buffer/service/texture_manager.h" | 34 #include "gpu/command_buffer/service/texture_manager.h" |
| 24 #include "ui/gfx/size.h" | 35 #include "ui/gfx/size.h" |
| 25 | 36 |
| 26 using gpu::gles2::TextureManager; | 37 using gpu::gles2::TextureManager; |
| 27 | 38 |
| 28 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( | 39 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( |
| 29 IPC::Message::Sender* sender, | 40 IPC::Message::Sender* sender, |
| 30 int32 host_route_id, | 41 int32 host_route_id, |
| 31 GpuCommandBufferStub* stub) | 42 GpuCommandBufferStub* stub) |
| 32 : sender_(sender), | 43 : sender_(sender), |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 112 } |
| 102 if (!Send(new AcceleratedVideoDecoderHostMsg_ErrorNotification( | 113 if (!Send(new AcceleratedVideoDecoderHostMsg_ErrorNotification( |
| 103 host_route_id_, error))) { | 114 host_route_id_, error))) { |
| 104 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ErrorNotification) " | 115 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ErrorNotification) " |
| 105 << "failed"; | 116 << "failed"; |
| 106 } | 117 } |
| 107 } | 118 } |
| 108 | 119 |
| 109 void GpuVideoDecodeAccelerator::Initialize( | 120 void GpuVideoDecodeAccelerator::Initialize( |
| 110 const media::VideoDecodeAccelerator::Profile profile, | 121 const media::VideoDecodeAccelerator::Profile profile, |
| 111 IPC::Message* init_done_msg) { | 122 IPC::Message* init_done_msg, |
| 123 base::ProcessHandle renderer_process) { |
| 112 DCHECK(!video_decode_accelerator_.get()); | 124 DCHECK(!video_decode_accelerator_.get()); |
| 113 DCHECK(!init_done_msg_); | 125 DCHECK(!init_done_msg_); |
| 114 DCHECK(init_done_msg); | 126 DCHECK(init_done_msg); |
| 115 init_done_msg_ = init_done_msg; | 127 init_done_msg_ = init_done_msg; |
| 116 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 128 |
| 129 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)) || defined(OS_WIN) |
| 117 DCHECK(stub_ && stub_->decoder()); | 130 DCHECK(stub_ && stub_->decoder()); |
| 118 OmxVideoDecodeAccelerator* omx_decoder = new OmxVideoDecodeAccelerator(this); | 131 #if defined(OS_WIN) |
| 119 omx_decoder->SetEglState( | 132 if (base::win::GetVersion() < base::win::VERSION_WIN7) { |
| 133 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
| 134 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 135 return; |
| 136 } |
| 137 DLOG(INFO) << "Initializing DXVA HW decoder for windows."; |
| 138 DXVAVideoDecodeAccelerator* video_decoder = |
| 139 new DXVAVideoDecodeAccelerator(this, renderer_process); |
| 140 #else // OS_WIN |
| 141 OmxVideoDecodeAccelerator* video_decoder = |
| 142 new OmxVideoDecodeAccelerator(this); |
| 143 video_decoder->SetEglState( |
| 120 gfx::GLSurfaceEGL::GetHardwareDisplay(), | 144 gfx::GLSurfaceEGL::GetHardwareDisplay(), |
| 121 stub_->decoder()->GetGLContext()->GetHandle()); | 145 stub_->decoder()->GetGLContext()->GetHandle()); |
| 122 video_decode_accelerator_ = omx_decoder; | 146 #endif // OS_WIN |
| 147 video_decode_accelerator_ = video_decoder; |
| 123 video_decode_accelerator_->Initialize(profile); | 148 video_decode_accelerator_->Initialize(profile); |
| 124 #else // Update RenderViewImpl::createMediaPlayer when adding clauses. | 149 #else // Update RenderViewImpl::createMediaPlayer when adding clauses. |
| 125 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | 150 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
| 126 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 151 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 127 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 152 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 128 } | 153 } |
| 129 | 154 |
| 130 void GpuVideoDecodeAccelerator::OnDecode( | 155 void GpuVideoDecodeAccelerator::OnDecode( |
| 131 base::SharedMemoryHandle handle, int32 id, int32 size) { | 156 base::SharedMemoryHandle handle, int32 id, int32 size) { |
| 132 DCHECK(video_decode_accelerator_.get()); | 157 DCHECK(video_decode_accelerator_.get()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 234 |
| 210 void GpuVideoDecodeAccelerator::NotifyResetDone() { | 235 void GpuVideoDecodeAccelerator::NotifyResetDone() { |
| 211 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) | 236 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) |
| 212 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; | 237 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; |
| 213 } | 238 } |
| 214 | 239 |
| 215 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { | 240 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { |
| 216 DCHECK(sender_); | 241 DCHECK(sender_); |
| 217 return sender_->Send(message); | 242 return sender_->Send(message); |
| 218 } | 243 } |
| OLD | NEW |