OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/android_video_decode_accelerator.h" | 5 #include "content/common/gpu/media/android_video_decode_accelerator.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
18 #include "content/common/gpu/gpu_channel.h" | 18 #include "content/common/gpu/gpu_channel.h" |
19 #include "content/common/gpu/media/android_copying_backing_strategy.h" | 19 #include "content/common/gpu/media/android_copying_backing_strategy.h" |
20 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h " | 20 #include "content/common/gpu/media/android_deferred_rendering_backing_strategy.h " |
21 #include "content/common/gpu/media/shared_memory_region.h" | |
21 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
22 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 23 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
23 #include "gpu/command_buffer/service/gpu_switches.h" | 24 #include "gpu/command_buffer/service/gpu_switches.h" |
24 #include "gpu/command_buffer/service/mailbox_manager.h" | 25 #include "gpu/command_buffer/service/mailbox_manager.h" |
25 #include "media/base/android/media_codec_util.h" | 26 #include "media/base/android/media_codec_util.h" |
26 #include "media/base/bind_to_current_loop.h" | 27 #include "media/base/bind_to_current_loop.h" |
27 #include "media/base/bitstream_buffer.h" | 28 #include "media/base/bitstream_buffer.h" |
28 #include "media/base/limits.h" | 29 #include "media/base/limits.h" |
29 #include "media/base/media.h" | 30 #include "media/base/media.h" |
30 #include "media/base/media_switches.h" | 31 #include "media/base/media_switches.h" |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
372 pending_bitstream_buffers_.pop(); | 373 pending_bitstream_buffers_.pop(); |
373 TRACE_COUNTER1("media", "AVDA::PendingBitstreamBufferCount", | 374 TRACE_COUNTER1("media", "AVDA::PendingBitstreamBufferCount", |
374 pending_bitstream_buffers_.size()); | 375 pending_bitstream_buffers_.size()); |
375 | 376 |
376 DCHECK_NE(state_, ERROR); | 377 DCHECK_NE(state_, ERROR); |
377 state_ = WAITING_FOR_EOS; | 378 state_ = WAITING_FOR_EOS; |
378 media_codec_->QueueEOS(input_buf_index); | 379 media_codec_->QueueEOS(input_buf_index); |
379 return true; | 380 return true; |
380 } | 381 } |
381 | 382 |
382 scoped_ptr<base::SharedMemory> shm; | 383 scoped_ptr<SharedMemoryRegion> shm; |
383 | 384 |
384 if (pending_input_buf_index_ != -1) { | 385 if (pending_input_buf_index_ != -1) { |
385 // The buffer is already dequeued from MediaCodec, filled with data and | 386 // The buffer is already dequeued from MediaCodec, filled with data and |
386 // bitstream_buffer.handle() is closed. | 387 // bitstream_buffer.handle() is closed. |
387 shm.reset(new base::SharedMemory()); | 388 shm.reset(new SharedMemoryRegion(base::SharedMemoryHandle(), 0, 0, false)); |
dcheng
2016/03/01 01:48:43
Maybe just shm.reset() and null check when initial
Owen Lin
2016/03/02 02:50:53
Thanks.
| |
388 } else { | 389 } else { |
389 shm.reset(new base::SharedMemory(bitstream_buffer.handle(), true)); | 390 shm.reset(new SharedMemoryRegion(bitstream_buffer, true)); |
390 | 391 |
391 if (!shm->Map(bitstream_buffer.size())) { | 392 if (!shm->Map()) { |
392 POST_ERROR(UNREADABLE_INPUT, "Failed to SharedMemory::Map()"); | 393 POST_ERROR(UNREADABLE_INPUT, "Failed to SharedMemoryRegion::Map()"); |
393 return false; | 394 return false; |
394 } | 395 } |
395 } | 396 } |
396 | 397 |
397 const base::TimeDelta presentation_timestamp = | 398 const base::TimeDelta presentation_timestamp = |
398 bitstream_buffer.presentation_timestamp(); | 399 bitstream_buffer.presentation_timestamp(); |
399 DCHECK(presentation_timestamp != media::kNoTimestamp()) | 400 DCHECK(presentation_timestamp != media::kNoTimestamp()) |
400 << "Bitstream buffers must have valid presentation timestamps"; | 401 << "Bitstream buffers must have valid presentation timestamps"; |
401 | 402 |
402 // There may already be a bitstream buffer with this timestamp, e.g., VP9 alt | 403 // There may already be a bitstream buffer with this timestamp, e.g., VP9 alt |
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1050 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: | 1051 capabilities.flags = media::VideoDecodeAccelerator::Capabilities:: |
1051 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE | | 1052 NEEDS_ALL_PICTURE_BUFFERS_TO_DECODE | |
1052 media::VideoDecodeAccelerator::Capabilities:: | 1053 media::VideoDecodeAccelerator::Capabilities:: |
1053 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; | 1054 SUPPORTS_EXTERNAL_OUTPUT_SURFACE; |
1054 } | 1055 } |
1055 | 1056 |
1056 return capabilities; | 1057 return capabilities; |
1057 } | 1058 } |
1058 | 1059 |
1059 } // namespace content | 1060 } // namespace content |
OLD | NEW |