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/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 | 12 |
13 #if defined(OS_WIN) | |
14 #include "base/win/windows_version.h" | |
15 #endif // OS_WIN | |
16 | |
17 #include "content/common/gpu/gpu_channel.h" | 13 #include "content/common/gpu/gpu_channel.h" |
18 #include "content/common/gpu/gpu_command_buffer_stub.h" | 14 #include "content/common/gpu/gpu_command_buffer_stub.h" |
19 #include "content/common/gpu/gpu_messages.h" | 15 #include "content/common/gpu/gpu_messages.h" |
20 #include "gpu/command_buffer/common/command_buffer.h" | 16 #include "gpu/command_buffer/common/command_buffer.h" |
21 #include "ipc/ipc_message_macros.h" | 17 #include "ipc/ipc_message_macros.h" |
22 #include "ipc/ipc_message_utils.h" | 18 #include "ipc/ipc_message_utils.h" |
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 | |
28 #include "content/common/gpu/media/omx_video_decode_accelerator.h" | |
29 #endif // OS_WIN | |
30 #include "ui/gl/gl_context.h" | 19 #include "ui/gl/gl_context.h" |
31 #include "ui/gl/gl_surface_egl.h" | 20 #include "ui/gl/gl_surface_egl.h" |
| 21 |
| 22 #if defined(OS_WIN) |
| 23 #include "base/win/windows_version.h" |
| 24 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| 25 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 26 #include "content/common/gpu/media/omx_video_decode_accelerator.h" |
| 27 #elif defined(OS_MACOSX) |
| 28 #include "gpu/command_buffer/service/texture_manager.h" |
| 29 #include "content/common/gpu/media/mac_video_decode_accelerator.h" |
32 #endif | 30 #endif |
33 | 31 |
34 #include "gpu/command_buffer/service/texture_manager.h" | 32 #include "gpu/command_buffer/service/texture_manager.h" |
35 #include "ui/gfx/size.h" | 33 #include "ui/gfx/size.h" |
36 | 34 |
37 using gpu::gles2::TextureManager; | 35 using gpu::gles2::TextureManager; |
38 | 36 |
39 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( | 37 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( |
40 IPC::Message::Sender* sender, | 38 IPC::Message::Sender* sender, |
41 int32 host_route_id, | 39 int32 host_route_id, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 116 } |
119 | 117 |
120 void GpuVideoDecodeAccelerator::Initialize( | 118 void GpuVideoDecodeAccelerator::Initialize( |
121 const media::VideoCodecProfile profile, | 119 const media::VideoCodecProfile profile, |
122 IPC::Message* init_done_msg) { | 120 IPC::Message* init_done_msg) { |
123 DCHECK(!video_decode_accelerator_.get()); | 121 DCHECK(!video_decode_accelerator_.get()); |
124 DCHECK(!init_done_msg_); | 122 DCHECK(!init_done_msg_); |
125 DCHECK(init_done_msg); | 123 DCHECK(init_done_msg); |
126 init_done_msg_ = init_done_msg; | 124 init_done_msg_ = init_done_msg; |
127 | 125 |
128 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)) || defined(OS_WIN) | |
129 DCHECK(stub_ && stub_->decoder()); | |
130 #if defined(OS_WIN) | 126 #if defined(OS_WIN) |
131 if (base::win::GetVersion() < base::win::VERSION_WIN7) { | 127 if (base::win::GetVersion() < base::win::VERSION_WIN7) { |
132 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | 128 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
133 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 129 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
134 return; | 130 return; |
135 } | 131 } |
136 DLOG(INFO) << "Initializing DXVA HW decoder for windows."; | 132 DLOG(INFO) << "Initializing DXVA HW decoder for windows."; |
137 DXVAVideoDecodeAccelerator* video_decoder = | 133 scoped_refptr<DXVAVideoDecodeAccelerator> video_decoder( |
138 new DXVAVideoDecodeAccelerator(this); | 134 new DXVAVideoDecodeAccelerator(this)); |
139 #else // OS_WIN | 135 video_decode_accelerator_ = video_decoder; |
140 OmxVideoDecodeAccelerator* video_decoder = | 136 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
141 new OmxVideoDecodeAccelerator(this); | 137 scoped_refptr<OmxVideoDecodeAccelerator> video_decoder( |
| 138 new OmxVideoDecodeAccelerator(this)); |
142 video_decoder->SetEglState( | 139 video_decoder->SetEglState( |
143 gfx::GLSurfaceEGL::GetHardwareDisplay(), | 140 gfx::GLSurfaceEGL::GetHardwareDisplay(), |
144 stub_->decoder()->GetGLContext()->GetHandle()); | 141 stub_->decoder()->GetGLContext()->GetHandle()); |
145 #endif // OS_WIN | 142 #elif defined(OS_MACOSX) |
| 143 scoped_refptr<MacVideoDecodeAccelerator> video_decoder( |
| 144 new MacVideoDecodeAccelerator(this)); |
| 145 video_decoder->SetCGLContext(static_cast<CGLContextObj>( |
| 146 stub_->decoder()->GetGLContext()->GetHandle())); |
146 video_decode_accelerator_ = video_decoder; | 147 video_decode_accelerator_ = video_decoder; |
| 148 #else |
| 149 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
| 150 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 151 return; |
| 152 #endif |
| 153 |
147 if (!video_decode_accelerator_->Initialize(profile)) | 154 if (!video_decode_accelerator_->Initialize(profile)) |
148 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 155 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
149 #else // Update RenderViewImpl::createMediaPlayer when adding clauses. | |
150 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | |
151 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | |
152 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | |
153 } | 156 } |
154 | 157 |
155 void GpuVideoDecodeAccelerator::OnDecode( | 158 void GpuVideoDecodeAccelerator::OnDecode( |
156 base::SharedMemoryHandle handle, int32 id, int32 size) { | 159 base::SharedMemoryHandle handle, int32 id, int32 size) { |
157 DCHECK(video_decode_accelerator_.get()); | 160 DCHECK(video_decode_accelerator_.get()); |
158 video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size)); | 161 video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size)); |
159 } | 162 } |
160 | 163 |
161 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( | 164 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( |
162 const std::vector<int32>& buffer_ids, | 165 const std::vector<int32>& buffer_ids, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 | 241 |
239 void GpuVideoDecodeAccelerator::NotifyResetDone() { | 242 void GpuVideoDecodeAccelerator::NotifyResetDone() { |
240 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) | 243 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) |
241 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; | 244 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; |
242 } | 245 } |
243 | 246 |
244 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { | 247 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { |
245 DCHECK(sender_); | 248 DCHECK(sender_); |
246 return sender_->Send(message); | 249 return sender_->Send(message); |
247 } | 250 } |
OLD | NEW |