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)) || defined(OS_WIN) |
| 19 #if defined(OS_WIN) |
| 20 #include "content/common/gpu/media/dxva_video_decode_accelerator.h" |
| 21 #else // OS_WIN |
19 #include "content/common/gpu/media/omx_video_decode_accelerator.h" | 22 #include "content/common/gpu/media/omx_video_decode_accelerator.h" |
| 23 #endif |
20 #include "ui/gfx/gl/gl_context.h" | 24 #include "ui/gfx/gl/gl_context.h" |
21 #include "ui/gfx/gl/gl_surface_egl.h" | 25 #include "ui/gfx/gl/gl_surface_egl.h" |
22 #endif | 26 #endif |
23 #include "ui/gfx/size.h" | 27 #include "ui/gfx/size.h" |
24 | 28 |
25 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( | 29 GpuVideoDecodeAccelerator::GpuVideoDecodeAccelerator( |
26 IPC::Message::Sender* sender, | 30 IPC::Message::Sender* sender, |
27 int32 host_route_id, | 31 int32 host_route_id, |
28 GpuCommandBufferStub* stub) | 32 GpuCommandBufferStub* stub) |
29 : sender_(sender), | 33 : sender_(sender), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 << "failed"; | 106 << "failed"; |
103 } | 107 } |
104 } | 108 } |
105 | 109 |
106 void GpuVideoDecodeAccelerator::Initialize( | 110 void GpuVideoDecodeAccelerator::Initialize( |
107 const media::VideoDecodeAccelerator::Profile profile, | 111 const media::VideoDecodeAccelerator::Profile profile, |
108 IPC::Message* init_done_msg) { | 112 IPC::Message* init_done_msg) { |
109 DCHECK(!video_decode_accelerator_.get()); | 113 DCHECK(!video_decode_accelerator_.get()); |
110 DCHECK(!init_done_msg_); | 114 DCHECK(!init_done_msg_); |
111 DCHECK(init_done_msg); | 115 DCHECK(init_done_msg); |
112 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 116 #if (defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)) || defined(OS_WIN) |
113 DCHECK(stub_ && stub_->decoder()); | 117 DCHECK(stub_ && stub_->decoder()); |
114 init_done_msg_ = init_done_msg; | 118 init_done_msg_ = init_done_msg; |
115 OmxVideoDecodeAccelerator* omx_decoder = new OmxVideoDecodeAccelerator(this); | 119 #if defined(OS_WIN) |
116 omx_decoder->SetEglState( | 120 DLOG(INFO) << "Initializing DXVA HW decoder for windows."; |
| 121 DXVAVideoDecodeAccelerator* video_decoder = |
| 122 new DXVAVideoDecodeAccelerator(this); |
| 123 #else // OS_WIN |
| 124 OmxVideoDecodeAccelerator* video_decoder = |
| 125 new OmxVideoDecodeAccelerator(this); |
| 126 #endif // OS_WIN |
| 127 video_decoder->SetEglState( |
117 gfx::GLSurfaceEGL::GetHardwareDisplay(), | 128 gfx::GLSurfaceEGL::GetHardwareDisplay(), |
118 stub_->decoder()->GetGLContext()->GetHandle()); | 129 stub_->decoder()->GetGLContext()->GetHandle()); |
119 video_decode_accelerator_ = omx_decoder; | 130 video_decode_accelerator_ = video_decoder; |
120 video_decode_accelerator_->Initialize(profile); | 131 video_decode_accelerator_->Initialize(profile); |
121 #else | 132 #else |
122 NOTIMPLEMENTED() << "HW video decode acceleration not available."; | 133 NOTIMPLEMENTED() << "HW video decode acceleration not available."; |
123 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 134 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
124 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) | 135 #endif // defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
125 } | 136 } |
126 | 137 |
127 void GpuVideoDecodeAccelerator::OnDecode( | 138 void GpuVideoDecodeAccelerator::OnDecode( |
128 base::SharedMemoryHandle handle, int32 id, int32 size) { | 139 base::SharedMemoryHandle handle, int32 id, int32 size, |
| 140 int32 source_process_id) { |
129 DCHECK(video_decode_accelerator_.get()); | 141 DCHECK(video_decode_accelerator_.get()); |
130 video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size)); | 142 video_decode_accelerator_->Decode(media::BitstreamBuffer(id, handle, size, |
| 143 source_process_id)); |
131 } | 144 } |
132 | 145 |
133 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( | 146 void GpuVideoDecodeAccelerator::OnAssignPictureBuffers( |
134 const std::vector<int32>& buffer_ids, | 147 const std::vector<int32>& buffer_ids, |
135 const std::vector<uint32>& texture_ids, | 148 const std::vector<uint32>& texture_ids, |
136 const std::vector<gfx::Size>& sizes) { | 149 const std::vector<gfx::Size>& sizes) { |
137 DCHECK(stub_ && stub_->decoder()); // Ensure already Initialize()'d. | 150 DCHECK(stub_ && stub_->decoder()); // Ensure already Initialize()'d. |
138 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); | 151 gpu::gles2::GLES2Decoder* command_decoder = stub_->decoder(); |
139 | 152 |
140 std::vector<media::PictureBuffer> buffers; | 153 std::vector<media::PictureBuffer> buffers; |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 209 |
197 void GpuVideoDecodeAccelerator::NotifyResetDone() { | 210 void GpuVideoDecodeAccelerator::NotifyResetDone() { |
198 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) | 211 if (!Send(new AcceleratedVideoDecoderHostMsg_ResetDone(host_route_id_))) |
199 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; | 212 DLOG(ERROR) << "Send(AcceleratedVideoDecoderHostMsg_ResetDone) failed"; |
200 } | 213 } |
201 | 214 |
202 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { | 215 bool GpuVideoDecodeAccelerator::Send(IPC::Message* message) { |
203 DCHECK(sender_); | 216 DCHECK(sender_); |
204 return sender_->Send(message); | 217 return sender_->Send(message); |
205 } | 218 } |
OLD | NEW |