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/client/gpu_video_decode_accelerator_host.h" | 5 #include "content/common/gpu/client/gpu_video_decode_accelerator_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "content/common/gpu/client/gpu_channel_host.h" | 10 #include "content/common/gpu/client/gpu_channel_host.h" |
11 #include "content/common/gpu/gpu_messages.h" | 11 #include "content/common/gpu/gpu_messages.h" |
12 #include "content/common/view_messages.h" | 12 #include "content/common/view_messages.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 | 15 |
| 16 #if defined(OS_WIN) |
| 17 #include "content/public/common/sandbox_init.h" |
| 18 #endif // OS_WIN |
| 19 |
16 using media::VideoDecodeAccelerator; | 20 using media::VideoDecodeAccelerator; |
17 | 21 |
18 GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost( | 22 GpuVideoDecodeAcceleratorHost::GpuVideoDecodeAcceleratorHost( |
19 GpuChannelHost* channel, | 23 GpuChannelHost* channel, |
20 int32 decoder_route_id, | 24 int32 decoder_route_id, |
21 VideoDecodeAccelerator::Client* client) | 25 VideoDecodeAccelerator::Client* client) |
22 : channel_(channel), | 26 : channel_(channel), |
23 decoder_route_id_(decoder_route_id), | 27 decoder_route_id_(decoder_route_id), |
24 client_(client) { | 28 client_(client) { |
25 DCHECK(channel_); | 29 DCHECK(channel_); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 62 |
59 bool GpuVideoDecodeAcceleratorHost::Initialize( | 63 bool GpuVideoDecodeAcceleratorHost::Initialize( |
60 media::VideoCodecProfile profile) { | 64 media::VideoCodecProfile profile) { |
61 NOTREACHED(); | 65 NOTREACHED(); |
62 return true; | 66 return true; |
63 } | 67 } |
64 | 68 |
65 void GpuVideoDecodeAcceleratorHost::Decode( | 69 void GpuVideoDecodeAcceleratorHost::Decode( |
66 const media::BitstreamBuffer& bitstream_buffer) { | 70 const media::BitstreamBuffer& bitstream_buffer) { |
67 DCHECK(CalledOnValidThread()); | 71 DCHECK(CalledOnValidThread()); |
| 72 base::SharedMemoryHandle buffer_handle = bitstream_buffer.handle(); |
| 73 #if defined(OS_WIN) |
| 74 if (!content::BrokerDuplicateHandle(bitstream_buffer.handle(), |
| 75 channel_->gpu_pid(), |
| 76 &buffer_handle, 0, |
| 77 DUPLICATE_SAME_ACCESS)) { |
| 78 NOTREACHED() << "Failed to duplicate buffer handler"; |
| 79 return; |
| 80 } |
| 81 #endif // OS_WIN |
| 82 |
68 Send(new AcceleratedVideoDecoderMsg_Decode( | 83 Send(new AcceleratedVideoDecoderMsg_Decode( |
69 decoder_route_id_, bitstream_buffer.handle(), | 84 decoder_route_id_, buffer_handle, bitstream_buffer.id(), |
70 bitstream_buffer.id(), bitstream_buffer.size())); | 85 bitstream_buffer.size())); |
71 } | 86 } |
72 | 87 |
73 void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( | 88 void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( |
74 const std::vector<media::PictureBuffer>& buffers) { | 89 const std::vector<media::PictureBuffer>& buffers) { |
75 DCHECK(CalledOnValidThread()); | 90 DCHECK(CalledOnValidThread()); |
76 // Rearrange data for IPC command. | 91 // Rearrange data for IPC command. |
77 std::vector<int32> buffer_ids; | 92 std::vector<int32> buffer_ids; |
78 std::vector<uint32> texture_ids; | 93 std::vector<uint32> texture_ids; |
79 std::vector<gfx::Size> sizes; | 94 std::vector<gfx::Size> sizes; |
80 for (uint32 i = 0; i < buffers.size(); i++) { | 95 for (uint32 i = 0; i < buffers.size(); i++) { |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 client_->NotifyResetDone(); | 179 client_->NotifyResetDone(); |
165 } | 180 } |
166 | 181 |
167 void GpuVideoDecodeAcceleratorHost::OnErrorNotification(uint32 error) { | 182 void GpuVideoDecodeAcceleratorHost::OnErrorNotification(uint32 error) { |
168 DCHECK(CalledOnValidThread()); | 183 DCHECK(CalledOnValidThread()); |
169 if (!client_) | 184 if (!client_) |
170 return; | 185 return; |
171 client_->NotifyError( | 186 client_->NotifyError( |
172 static_cast<media::VideoDecodeAccelerator::Error>(error)); | 187 static_cast<media::VideoDecodeAccelerator::Error>(error)); |
173 } | 188 } |
OLD | NEW |