OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "chrome/gpu/arc_gpu_video_decode_accelerator.h" | 5 #include "chrome/gpu/arc_gpu_video_decode_accelerator.h" |
6 | 6 |
7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
10 #include "base/numerics/safe_math.h" | 10 #include "base/numerics/safe_math.h" |
11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/unguessable_token.h" |
12 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
13 #include "media/gpu/gpu_video_decode_accelerator_factory.h" | 14 #include "media/gpu/gpu_video_decode_accelerator_factory.h" |
14 | 15 |
15 namespace chromeos { | 16 namespace chromeos { |
16 namespace arc { | 17 namespace arc { |
17 | 18 |
18 namespace { | 19 namespace { |
19 | 20 |
20 // An arbitrary chosen limit of the number of buffers. The number of | 21 // An arbitrary chosen limit of the number of buffers. The number of |
21 // buffers used is requested from the untrusted client side. | 22 // buffers used is requested from the untrusted client side. |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
288 // Mask against 30 bits, to avoid (undefined) wraparound on signed | 289 // Mask against 30 bits, to avoid (undefined) wraparound on signed |
289 // integer. | 290 // integer. |
290 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; | 291 next_bitstream_buffer_id_ = (next_bitstream_buffer_id_ + 1) & 0x3FFFFFFF; |
291 int dup_fd = HANDLE_EINTR(dup(input_info->handle.get())); | 292 int dup_fd = HANDLE_EINTR(dup(input_info->handle.get())); |
292 if (dup_fd < 0) { | 293 if (dup_fd < 0) { |
293 DLOG(ERROR) << "dup() failed."; | 294 DLOG(ERROR) << "dup() failed."; |
294 arc_client_->OnError(PLATFORM_FAILURE); | 295 arc_client_->OnError(PLATFORM_FAILURE); |
295 return; | 296 return; |
296 } | 297 } |
297 CreateInputRecord(bitstream_buffer_id, index, metadata.timestamp); | 298 CreateInputRecord(bitstream_buffer_id, index, metadata.timestamp); |
| 299 // TODO(rockot): Pass GUIDs through Mojo. https://crbug.com/713763. |
| 300 // TODO(erikchen): This fd comes from a mojo::ScopedHandle in |
| 301 // GpuArcVideoService::BindSharedMemory. That should be passed through, |
| 302 // rather than pulling out the fd. https://crbug.com/713763. |
| 303 base::UnguessableToken guid = base::UnguessableToken::Create(); |
298 vda_->Decode(media::BitstreamBuffer( | 304 vda_->Decode(media::BitstreamBuffer( |
299 bitstream_buffer_id, | 305 bitstream_buffer_id, |
300 base::SharedMemoryHandle(base::FileDescriptor(dup_fd, true)), | 306 base::SharedMemoryHandle(base::FileDescriptor(dup_fd, true), guid), |
301 metadata.bytes_used, input_info->offset)); | 307 metadata.bytes_used, input_info->offset)); |
302 break; | 308 break; |
303 } | 309 } |
304 case PORT_OUTPUT: { | 310 case PORT_OUTPUT: { |
305 // is_valid() is true for the first time the buffer is passed to the VDA. | 311 // is_valid() is true for the first time the buffer is passed to the VDA. |
306 // In that case, VDA needs to import the buffer first. | 312 // In that case, VDA needs to import the buffer first. |
307 OutputBufferInfo& info = buffers_pending_import_[index]; | 313 OutputBufferInfo& info = buffers_pending_import_[index]; |
308 if (info.handle.is_valid()) { | 314 if (info.handle.is_valid()) { |
309 gfx::GpuMemoryBufferHandle handle; | 315 gfx::GpuMemoryBufferHandle handle; |
310 #if defined(USE_OZONE) | 316 #if defined(USE_OZONE) |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 } | 529 } |
524 return true; | 530 return true; |
525 default: | 531 default: |
526 DLOG(ERROR) << "Invalid port: " << port; | 532 DLOG(ERROR) << "Invalid port: " << port; |
527 return false; | 533 return false; |
528 } | 534 } |
529 } | 535 } |
530 | 536 |
531 } // namespace arc | 537 } // namespace arc |
532 } // namespace chromeos | 538 } // namespace chromeos |
OLD | NEW |