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