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 "media/gpu/ipc/client/gpu_video_decode_accelerator_host.h" | 5 #include "media/gpu/ipc/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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 | 44 |
45 bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) { | 45 bool GpuVideoDecodeAcceleratorHost::OnMessageReceived(const IPC::Message& msg) { |
46 DCHECK(CalledOnValidThread()); | 46 DCHECK(CalledOnValidThread()); |
47 bool handled = true; | 47 bool handled = true; |
48 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAcceleratorHost, msg) | 48 IPC_BEGIN_MESSAGE_MAP(GpuVideoDecodeAcceleratorHost, msg) |
49 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_InitializationComplete, | 49 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_InitializationComplete, |
50 OnInitializationComplete) | 50 OnInitializationComplete) |
51 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed, | 51 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_BitstreamBufferProcessed, |
52 OnBitstreamBufferProcessed) | 52 OnBitstreamBufferProcessed) |
53 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers, | 53 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ProvidePictureBuffers, |
54 OnProvidePictureBuffer) | 54 OnProvidePictureBuffers) |
55 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady, | 55 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_PictureReady, |
56 OnPictureReady) | 56 OnPictureReady) |
57 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_FlushDone, OnFlushDone) | 57 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_FlushDone, OnFlushDone) |
58 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ResetDone, OnResetDone) | 58 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ResetDone, OnResetDone) |
59 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ErrorNotification, | 59 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_ErrorNotification, |
60 OnNotifyError) | 60 OnNotifyError) |
61 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer, | 61 IPC_MESSAGE_HANDLER(AcceleratedVideoDecoderHostMsg_DismissPictureBuffer, |
62 OnDismissPictureBuffer) | 62 OnDismissPictureBuffer) |
63 IPC_MESSAGE_UNHANDLED(handled = false) | 63 IPC_MESSAGE_UNHANDLED(handled = false) |
64 IPC_END_MESSAGE_MAP() | 64 IPC_END_MESSAGE_MAP() |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 } | 123 } |
124 | 124 |
125 void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( | 125 void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( |
126 const std::vector<PictureBuffer>& buffers) { | 126 const std::vector<PictureBuffer>& buffers) { |
127 DCHECK(CalledOnValidThread()); | 127 DCHECK(CalledOnValidThread()); |
128 if (!channel_) | 128 if (!channel_) |
129 return; | 129 return; |
130 // Rearrange data for IPC command. | 130 // Rearrange data for IPC command. |
131 std::vector<int32_t> buffer_ids; | 131 std::vector<int32_t> buffer_ids; |
132 std::vector<PictureBuffer::TextureIds> texture_ids; | 132 std::vector<PictureBuffer::TextureIds> texture_ids; |
133 for (uint32_t i = 0; i < buffers.size(); i++) { | 133 uint32_t texture_target = 0; |
134 VideoPixelFormat format = PIXEL_FORMAT_UNKNOWN; | |
135 gfx::Size size; | |
136 | |
137 uint32_t buffers_size = buffers.size(); | |
138 if (buffers_size) { | |
139 texture_target = buffers[0].texture_target(); | |
dcheng
2017/05/18 14:15:41
Is it possible (via something malicious) that the
Chandan
2017/05/18 19:38:53
Can you pls elaborate a bit on 'matching attribute
liberato (no reviews please)
2017/05/18 20:07:01
hrm, it's a good point that i hadn't considerd.
i
Chandan
2017/05/18 20:36:36
Ok. I will remove these 3 extra params from IPC th
| |
140 format = buffers[0].pixel_format(); | |
141 size = buffers[0].size(); | |
142 } | |
143 | |
144 for (uint32_t i = 0; i < buffers_size; i++) { | |
134 const PictureBuffer& buffer = buffers[i]; | 145 const PictureBuffer& buffer = buffers[i]; |
135 if (buffer.size() != picture_buffer_dimensions_) { | 146 if (buffer.size() != picture_buffer_dimensions_) { |
136 DLOG(ERROR) << "buffer.size() invalid: expected " | 147 DLOG(ERROR) << "buffer.size() invalid: expected " |
137 << picture_buffer_dimensions_.ToString() << ", got " | 148 << picture_buffer_dimensions_.ToString() << ", got " |
138 << buffer.size().ToString(); | 149 << buffer.size().ToString(); |
139 PostNotifyError(INVALID_ARGUMENT); | 150 PostNotifyError(INVALID_ARGUMENT); |
140 return; | 151 return; |
141 } | 152 } |
142 texture_ids.push_back(buffer.client_texture_ids()); | 153 texture_ids.push_back(buffer.client_texture_ids()); |
143 buffer_ids.push_back(buffer.id()); | 154 buffer_ids.push_back(buffer.id()); |
144 } | 155 } |
156 | |
145 Send(new AcceleratedVideoDecoderMsg_AssignPictureBuffers( | 157 Send(new AcceleratedVideoDecoderMsg_AssignPictureBuffers( |
146 decoder_route_id_, buffer_ids, texture_ids)); | 158 decoder_route_id_, buffer_ids, texture_ids, texture_target, format, |
159 size)); | |
147 } | 160 } |
148 | 161 |
149 void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( | 162 void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( |
150 int32_t picture_buffer_id) { | 163 int32_t picture_buffer_id) { |
151 DCHECK(CalledOnValidThread()); | 164 DCHECK(CalledOnValidThread()); |
152 if (!channel_) | 165 if (!channel_) |
153 return; | 166 return; |
154 Send(new AcceleratedVideoDecoderMsg_ReusePictureBuffer(decoder_route_id_, | 167 Send(new AcceleratedVideoDecoderMsg_ReusePictureBuffer(decoder_route_id_, |
155 picture_buffer_id)); | 168 picture_buffer_id)); |
156 } | 169 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
218 client_->NotifyInitializationComplete(success); | 231 client_->NotifyInitializationComplete(success); |
219 } | 232 } |
220 | 233 |
221 void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed( | 234 void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed( |
222 int32_t bitstream_buffer_id) { | 235 int32_t bitstream_buffer_id) { |
223 DCHECK(CalledOnValidThread()); | 236 DCHECK(CalledOnValidThread()); |
224 if (client_) | 237 if (client_) |
225 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); | 238 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); |
226 } | 239 } |
227 | 240 |
228 void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffer( | 241 void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffers( |
229 uint32_t num_requested_buffers, | 242 uint32_t num_requested_buffers, |
230 VideoPixelFormat format, | 243 VideoPixelFormat format, |
231 uint32_t textures_per_buffer, | 244 uint32_t textures_per_buffer, |
232 const gfx::Size& dimensions, | 245 const gfx::Size& dimensions, |
233 uint32_t texture_target) { | 246 uint32_t texture_target) { |
234 DCHECK(CalledOnValidThread()); | 247 DCHECK(CalledOnValidThread()); |
235 picture_buffer_dimensions_ = dimensions; | 248 picture_buffer_dimensions_ = dimensions; |
236 | 249 |
237 const int kMaxVideoPlanes = 4; | 250 const int kMaxVideoPlanes = 4; |
238 if (textures_per_buffer > kMaxVideoPlanes) { | 251 if (textures_per_buffer > kMaxVideoPlanes) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
287 weak_this_factory_.InvalidateWeakPtrs(); | 300 weak_this_factory_.InvalidateWeakPtrs(); |
288 | 301 |
289 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 302 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
290 // last thing done on this stack! | 303 // last thing done on this stack! |
291 VideoDecodeAccelerator::Client* client = nullptr; | 304 VideoDecodeAccelerator::Client* client = nullptr; |
292 std::swap(client, client_); | 305 std::swap(client, client_); |
293 client->NotifyError(static_cast<VideoDecodeAccelerator::Error>(error)); | 306 client->NotifyError(static_cast<VideoDecodeAccelerator::Error>(error)); |
294 } | 307 } |
295 | 308 |
296 } // namespace media | 309 } // namespace media |
OLD | NEW |