OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 <inttypes.h> | 5 #include <inttypes.h> |
6 #include <stddef.h> | 6 #include <stddef.h> |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 1628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1639 } | 1639 } |
1640 | 1640 |
1641 void VEAClient::FeedEncoderWithOutput(base::SharedMemory* shm) { | 1641 void VEAClient::FeedEncoderWithOutput(base::SharedMemory* shm) { |
1642 DCHECK(thread_checker_.CalledOnValidThread()); | 1642 DCHECK(thread_checker_.CalledOnValidThread()); |
1643 if (!has_encoder()) | 1643 if (!has_encoder()) |
1644 return; | 1644 return; |
1645 | 1645 |
1646 if (state_ != CS_ENCODING) | 1646 if (state_ != CS_ENCODING) |
1647 return; | 1647 return; |
1648 | 1648 |
1649 base::SharedMemoryHandle dup_handle; | 1649 base::SharedMemoryHandle dup_handle = shm->handle().Duplicate(); |
1650 LOG_ASSERT(shm->ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle)); | 1650 LOG_ASSERT(dup_handle.IsValid()); |
1651 | 1651 |
| 1652 // TODO(erikchen): This may leak the SharedMemoryHandle. |
| 1653 // https://crbug.com/640840. |
1652 BitstreamBuffer bitstream_buffer(next_output_buffer_id_++, dup_handle, | 1654 BitstreamBuffer bitstream_buffer(next_output_buffer_id_++, dup_handle, |
1653 output_buffer_size_); | 1655 output_buffer_size_); |
1654 LOG_ASSERT(output_buffers_at_client_ | 1656 LOG_ASSERT(output_buffers_at_client_ |
1655 .insert(std::make_pair(bitstream_buffer.id(), shm)) | 1657 .insert(std::make_pair(bitstream_buffer.id(), shm)) |
1656 .second); | 1658 .second); |
1657 | 1659 |
1658 encode_task_runner_->PostTask( | 1660 encode_task_runner_->PostTask( |
1659 FROM_HERE, | 1661 FROM_HERE, |
1660 base::Bind(&VideoEncodeAccelerator::UseOutputBitstreamBuffer, | 1662 base::Bind(&VideoEncodeAccelerator::UseOutputBitstreamBuffer, |
1661 encoder_weak_factory_->GetWeakPtr(), bitstream_buffer)); | 1663 encoder_weak_factory_->GetWeakPtr(), bitstream_buffer)); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 output_shms_.push_back(shm); | 1907 output_shms_.push_back(shm); |
1906 FeedEncoderWithOutput(shm, output_size); | 1908 FeedEncoderWithOutput(shm, output_size); |
1907 } | 1909 } |
1908 } | 1910 } |
1909 | 1911 |
1910 void SimpleVEAClientBase::FeedEncoderWithOutput(base::SharedMemory* shm, | 1912 void SimpleVEAClientBase::FeedEncoderWithOutput(base::SharedMemory* shm, |
1911 size_t output_size) { | 1913 size_t output_size) { |
1912 if (!has_encoder()) | 1914 if (!has_encoder()) |
1913 return; | 1915 return; |
1914 | 1916 |
1915 base::SharedMemoryHandle dup_handle; | 1917 base::SharedMemoryHandle dup_handle = shm->handle().Duplicate(); |
1916 LOG_ASSERT(shm->ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle)); | 1918 LOG_ASSERT(dup_handle.IsValid()); |
1917 | 1919 |
1918 BitstreamBuffer bitstream_buffer(next_output_buffer_id_++, dup_handle, | 1920 BitstreamBuffer bitstream_buffer(next_output_buffer_id_++, dup_handle, |
1919 output_size); | 1921 output_size); |
1920 encoder_->UseOutputBitstreamBuffer(bitstream_buffer); | 1922 encoder_->UseOutputBitstreamBuffer(bitstream_buffer); |
1921 } | 1923 } |
1922 | 1924 |
1923 // This client is only used to make sure the encoder does not return an encoded | 1925 // This client is only used to make sure the encoder does not return an encoded |
1924 // frame before getting any input. | 1926 // frame before getting any input. |
1925 class VEANoInputClient : public SimpleVEAClientBase { | 1927 class VEANoInputClient : public SimpleVEAClientBase { |
1926 public: | 1928 public: |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2378 | 2380 |
2379 media::g_env = | 2381 media::g_env = |
2380 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( | 2382 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( |
2381 testing::AddGlobalTestEnvironment( | 2383 testing::AddGlobalTestEnvironment( |
2382 new media::VideoEncodeAcceleratorTestEnvironment( | 2384 new media::VideoEncodeAcceleratorTestEnvironment( |
2383 std::move(test_stream_data), log_path, run_at_fps, | 2385 std::move(test_stream_data), log_path, run_at_fps, |
2384 needs_encode_latency, verify_all_output))); | 2386 needs_encode_latency, verify_all_output))); |
2385 | 2387 |
2386 return RUN_ALL_TESTS(); | 2388 return RUN_ALL_TESTS(); |
2387 } | 2389 } |
OLD | NEW |