| 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/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 new AcceleratedVideoDecoderMsg_Decode(decoder_route_id_, buffer_to_send)); | 128 new AcceleratedVideoDecoderMsg_Decode(decoder_route_id_, buffer_to_send)); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( | 131 void GpuVideoDecodeAcceleratorHost::AssignPictureBuffers( |
| 132 const std::vector<media::PictureBuffer>& buffers) { | 132 const std::vector<media::PictureBuffer>& buffers) { |
| 133 DCHECK(CalledOnValidThread()); | 133 DCHECK(CalledOnValidThread()); |
| 134 if (!channel_) | 134 if (!channel_) |
| 135 return; | 135 return; |
| 136 // Rearrange data for IPC command. | 136 // Rearrange data for IPC command. |
| 137 std::vector<int32_t> buffer_ids; | 137 std::vector<int32_t> buffer_ids; |
| 138 std::vector<uint32_t> texture_ids; | 138 std::vector<media::PictureBuffer::TextureIds> texture_ids; |
| 139 for (uint32_t i = 0; i < buffers.size(); i++) { | 139 for (uint32_t i = 0; i < buffers.size(); i++) { |
| 140 const media::PictureBuffer& buffer = buffers[i]; | 140 const media::PictureBuffer& buffer = buffers[i]; |
| 141 if (buffer.size() != picture_buffer_dimensions_) { | 141 if (buffer.size() != picture_buffer_dimensions_) { |
| 142 DLOG(ERROR) << "buffer.size() invalid: expected " | 142 DLOG(ERROR) << "buffer.size() invalid: expected " |
| 143 << picture_buffer_dimensions_.ToString() | 143 << picture_buffer_dimensions_.ToString() |
| 144 << ", got " << buffer.size().ToString(); | 144 << ", got " << buffer.size().ToString(); |
| 145 PostNotifyError(INVALID_ARGUMENT); | 145 PostNotifyError(INVALID_ARGUMENT); |
| 146 return; | 146 return; |
| 147 } | 147 } |
| 148 texture_ids.push_back(buffer.texture_id()); | 148 texture_ids.push_back(buffer.texture_ids()); |
| 149 buffer_ids.push_back(buffer.id()); | 149 buffer_ids.push_back(buffer.id()); |
| 150 } | 150 } |
| 151 Send(new AcceleratedVideoDecoderMsg_AssignPictureBuffers( | 151 Send(new AcceleratedVideoDecoderMsg_AssignPictureBuffers( |
| 152 decoder_route_id_, buffer_ids, texture_ids)); | 152 decoder_route_id_, buffer_ids, texture_ids)); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( | 155 void GpuVideoDecodeAcceleratorHost::ReusePictureBuffer( |
| 156 int32_t picture_buffer_id) { | 156 int32_t picture_buffer_id) { |
| 157 DCHECK(CalledOnValidThread()); | 157 DCHECK(CalledOnValidThread()); |
| 158 if (!channel_) | 158 if (!channel_) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 | 216 |
| 217 void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed( | 217 void GpuVideoDecodeAcceleratorHost::OnBitstreamBufferProcessed( |
| 218 int32_t bitstream_buffer_id) { | 218 int32_t bitstream_buffer_id) { |
| 219 DCHECK(CalledOnValidThread()); | 219 DCHECK(CalledOnValidThread()); |
| 220 if (client_) | 220 if (client_) |
| 221 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); | 221 client_->NotifyEndOfBitstreamBuffer(bitstream_buffer_id); |
| 222 } | 222 } |
| 223 | 223 |
| 224 void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffer( | 224 void GpuVideoDecodeAcceleratorHost::OnProvidePictureBuffer( |
| 225 uint32_t num_requested_buffers, | 225 uint32_t num_requested_buffers, |
| 226 uint32_t textures_per_buffer, |
| 226 const gfx::Size& dimensions, | 227 const gfx::Size& dimensions, |
| 227 uint32_t texture_target) { | 228 uint32_t texture_target) { |
| 228 DCHECK(CalledOnValidThread()); | 229 DCHECK(CalledOnValidThread()); |
| 229 picture_buffer_dimensions_ = dimensions; | 230 picture_buffer_dimensions_ = dimensions; |
| 231 |
| 232 const int kMaxVideoPlanes = 4; |
| 233 if (textures_per_buffer > kMaxVideoPlanes) { |
| 234 PostNotifyError(PLATFORM_FAILURE); |
| 235 return; |
| 236 } |
| 237 |
| 230 if (client_) { | 238 if (client_) { |
| 231 client_->ProvidePictureBuffers( | 239 client_->ProvidePictureBuffers(num_requested_buffers, textures_per_buffer, |
| 232 num_requested_buffers, dimensions, texture_target); | 240 dimensions, texture_target); |
| 233 } | 241 } |
| 234 } | 242 } |
| 235 | 243 |
| 236 void GpuVideoDecodeAcceleratorHost::OnDismissPictureBuffer( | 244 void GpuVideoDecodeAcceleratorHost::OnDismissPictureBuffer( |
| 237 int32_t picture_buffer_id) { | 245 int32_t picture_buffer_id) { |
| 238 DCHECK(CalledOnValidThread()); | 246 DCHECK(CalledOnValidThread()); |
| 239 if (client_) | 247 if (client_) |
| 240 client_->DismissPictureBuffer(picture_buffer_id); | 248 client_->DismissPictureBuffer(picture_buffer_id); |
| 241 } | 249 } |
| 242 | 250 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 weak_this_factory_.InvalidateWeakPtrs(); | 282 weak_this_factory_.InvalidateWeakPtrs(); |
| 275 | 283 |
| 276 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the | 284 // Client::NotifyError() may Destroy() |this|, so calling it needs to be the |
| 277 // last thing done on this stack! | 285 // last thing done on this stack! |
| 278 media::VideoDecodeAccelerator::Client* client = NULL; | 286 media::VideoDecodeAccelerator::Client* client = NULL; |
| 279 std::swap(client, client_); | 287 std::swap(client, client_); |
| 280 client->NotifyError(static_cast<media::VideoDecodeAccelerator::Error>(error)); | 288 client->NotifyError(static_cast<media::VideoDecodeAccelerator::Error>(error)); |
| 281 } | 289 } |
| 282 | 290 |
| 283 } // namespace content | 291 } // namespace content |
| OLD | NEW |