Chromium Code Reviews| 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 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 431 } | 431 } |
| 432 | 432 |
| 433 if (fields.size() >= 9 && !fields[8].empty()) { | 433 if (fields.size() >= 9 && !fields[8].empty()) { |
| 434 LOG_ASSERT(base::StringToUint( | 434 LOG_ASSERT(base::StringToUint( |
| 435 fields[8], &test_stream->requested_subsequent_framerate)); | 435 fields[8], &test_stream->requested_subsequent_framerate)); |
| 436 } | 436 } |
| 437 test_streams->push_back(test_stream); | 437 test_streams->push_back(test_stream); |
| 438 } | 438 } |
| 439 } | 439 } |
| 440 | 440 |
| 441 static std::unique_ptr<VideoEncodeAccelerator> CreateFakeVEA() { | |
| 442 std::unique_ptr<VideoEncodeAccelerator> encoder; | |
| 443 if (g_fake_encoder) { | |
| 444 encoder.reset(new FakeVideoEncodeAccelerator( | |
| 445 scoped_refptr<base::SingleThreadTaskRunner>( | |
| 446 base::ThreadTaskRunnerHandle::Get()))); | |
| 447 } | |
| 448 return encoder; | |
| 449 } | |
| 450 | |
| 451 static std::unique_ptr<VideoEncodeAccelerator> CreateV4L2VEA() { | |
| 452 std::unique_ptr<VideoEncodeAccelerator> encoder; | |
| 453 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | |
| 454 scoped_refptr<V4L2Device> device = V4L2Device::Create(); | |
| 455 if (device) | |
| 456 encoder.reset(new V4L2VideoEncodeAccelerator(device)); | |
| 457 #endif | |
| 458 return encoder; | |
| 459 } | |
| 460 | |
| 461 static std::unique_ptr<VideoEncodeAccelerator> CreateVaapiVEA() { | |
| 462 std::unique_ptr<VideoEncodeAccelerator> encoder; | |
| 463 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
| 464 encoder.reset(new VaapiVideoEncodeAccelerator()); | |
| 465 #endif | |
| 466 return encoder; | |
| 467 } | |
| 468 | |
| 469 static std::unique_ptr<VideoEncodeAccelerator> CreateVTVEA() { | |
| 470 std::unique_ptr<VideoEncodeAccelerator> encoder; | |
| 471 #if defined(OS_MACOSX) | |
| 472 encoder.reset(new VTVideoEncodeAccelerator()); | |
| 473 #endif | |
| 474 return encoder; | |
| 475 } | |
| 476 | |
| 477 static std::unique_ptr<VideoEncodeAccelerator> CreateMFVEA() { | |
| 478 std::unique_ptr<VideoEncodeAccelerator> encoder; | |
| 479 #if defined(OS_WIN) | |
| 480 MediaFoundationVideoEncodeAccelerator::PreSandboxInitialization(); | |
| 481 encoder.reset(new MediaFoundationVideoEncodeAccelerator()); | |
| 482 #endif | |
| 483 return encoder; | |
| 484 } | |
| 485 | |
| 441 // Basic test environment shared across multiple test cases. We only need to | 486 // Basic test environment shared across multiple test cases. We only need to |
| 442 // setup it once for all test cases. | 487 // setup it once for all test cases. |
| 443 // It helps | 488 // It helps |
| 444 // - maintain test stream data and other test settings. | 489 // - maintain test stream data and other test settings. |
| 445 // - clean up temporary aligned files. | 490 // - clean up temporary aligned files. |
| 446 // - output log to file. | 491 // - output log to file. |
| 447 class VideoEncodeAcceleratorTestEnvironment : public ::testing::Environment { | 492 class VideoEncodeAcceleratorTestEnvironment : public ::testing::Environment { |
| 448 public: | 493 public: |
| 449 VideoEncodeAcceleratorTestEnvironment( | 494 VideoEncodeAcceleratorTestEnvironment( |
| 450 std::unique_ptr<base::FilePath::StringType> data, | 495 std::unique_ptr<base::FilePath::StringType> data, |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 854 bool key_frame, | 899 bool key_frame, |
| 855 base::TimeDelta timestamp) override; | 900 base::TimeDelta timestamp) override; |
| 856 void NotifyError(VideoEncodeAccelerator::Error error) override; | 901 void NotifyError(VideoEncodeAccelerator::Error error) override; |
| 857 | 902 |
| 858 private: | 903 private: |
| 859 bool has_encoder() { return encoder_.get(); } | 904 bool has_encoder() { return encoder_.get(); } |
| 860 | 905 |
| 861 // Return the number of encoded frames per second. | 906 // Return the number of encoded frames per second. |
| 862 double frames_per_second(); | 907 double frames_per_second(); |
| 863 | 908 |
| 864 std::unique_ptr<VideoEncodeAccelerator> CreateFakeVEA(); | |
| 865 std::unique_ptr<VideoEncodeAccelerator> CreateV4L2VEA(); | |
| 866 std::unique_ptr<VideoEncodeAccelerator> CreateVaapiVEA(); | |
| 867 std::unique_ptr<VideoEncodeAccelerator> CreateVTVEA(); | |
| 868 std::unique_ptr<VideoEncodeAccelerator> CreateMFVEA(); | |
| 869 | |
| 870 void SetState(ClientState new_state); | 909 void SetState(ClientState new_state); |
| 871 | 910 |
| 872 // Set current stream parameters to given |bitrate| at |framerate|. | 911 // Set current stream parameters to given |bitrate| at |framerate|. |
| 873 void SetStreamParameters(unsigned int bitrate, unsigned int framerate); | 912 void SetStreamParameters(unsigned int bitrate, unsigned int framerate); |
| 874 | 913 |
| 875 // Called when encoder is done with a VideoFrame. | 914 // Called when encoder is done with a VideoFrame. |
| 876 void InputNoLongerNeededCallback(int32_t input_id); | 915 void InputNoLongerNeededCallback(int32_t input_id); |
| 877 | 916 |
| 878 // Feed the encoder with one input frame. | 917 // Feed the encoder with one input frame. |
| 879 void FeedEncoderWithOneInput(); | 918 void FeedEncoderWithOneInput(); |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1111 // Initialize the parameters of the test streams. | 1150 // Initialize the parameters of the test streams. |
| 1112 UpdateTestStreamData(mid_stream_bitrate_switch, mid_stream_framerate_switch); | 1151 UpdateTestStreamData(mid_stream_bitrate_switch, mid_stream_framerate_switch); |
| 1113 | 1152 |
| 1114 thread_checker_.DetachFromThread(); | 1153 thread_checker_.DetachFromThread(); |
| 1115 } | 1154 } |
| 1116 | 1155 |
| 1117 VEAClient::~VEAClient() { | 1156 VEAClient::~VEAClient() { |
| 1118 LOG_ASSERT(!has_encoder()); | 1157 LOG_ASSERT(!has_encoder()); |
| 1119 } | 1158 } |
| 1120 | 1159 |
| 1121 std::unique_ptr<VideoEncodeAccelerator> VEAClient::CreateFakeVEA() { | |
| 1122 std::unique_ptr<VideoEncodeAccelerator> encoder; | |
| 1123 if (g_fake_encoder) { | |
| 1124 encoder.reset(new FakeVideoEncodeAccelerator( | |
| 1125 scoped_refptr<base::SingleThreadTaskRunner>( | |
| 1126 base::ThreadTaskRunnerHandle::Get()))); | |
| 1127 } | |
| 1128 return encoder; | |
| 1129 } | |
| 1130 | |
| 1131 std::unique_ptr<VideoEncodeAccelerator> VEAClient::CreateV4L2VEA() { | |
| 1132 std::unique_ptr<VideoEncodeAccelerator> encoder; | |
| 1133 #if defined(OS_CHROMEOS) && defined(USE_V4L2_CODEC) | |
| 1134 scoped_refptr<V4L2Device> device = V4L2Device::Create(); | |
| 1135 if (device) | |
| 1136 encoder.reset(new V4L2VideoEncodeAccelerator(device)); | |
| 1137 #endif | |
| 1138 return encoder; | |
| 1139 } | |
| 1140 | |
| 1141 std::unique_ptr<VideoEncodeAccelerator> VEAClient::CreateVaapiVEA() { | |
| 1142 std::unique_ptr<VideoEncodeAccelerator> encoder; | |
| 1143 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) | |
| 1144 encoder.reset(new VaapiVideoEncodeAccelerator()); | |
| 1145 #endif | |
| 1146 return encoder; | |
| 1147 } | |
| 1148 | |
| 1149 std::unique_ptr<VideoEncodeAccelerator> VEAClient::CreateVTVEA() { | |
| 1150 std::unique_ptr<VideoEncodeAccelerator> encoder; | |
| 1151 #if defined(OS_MACOSX) | |
| 1152 encoder.reset(new VTVideoEncodeAccelerator()); | |
| 1153 #endif | |
| 1154 return encoder; | |
| 1155 } | |
| 1156 | |
| 1157 std::unique_ptr<VideoEncodeAccelerator> VEAClient::CreateMFVEA() { | |
| 1158 std::unique_ptr<VideoEncodeAccelerator> encoder; | |
| 1159 #if defined(OS_WIN) | |
| 1160 MediaFoundationVideoEncodeAccelerator::PreSandboxInitialization(); | |
| 1161 encoder.reset(new MediaFoundationVideoEncodeAccelerator()); | |
| 1162 #endif | |
| 1163 return encoder; | |
| 1164 } | |
| 1165 | |
| 1166 void VEAClient::CreateEncoder() { | 1160 void VEAClient::CreateEncoder() { |
| 1167 DCHECK(thread_checker_.CalledOnValidThread()); | 1161 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1168 LOG_ASSERT(!has_encoder()); | 1162 LOG_ASSERT(!has_encoder()); |
| 1169 | 1163 |
| 1170 std::unique_ptr<VideoEncodeAccelerator> encoders[] = { | 1164 std::unique_ptr<VideoEncodeAccelerator> encoders[] = { |
| 1171 CreateFakeVEA(), CreateV4L2VEA(), CreateVaapiVEA(), CreateVTVEA(), | 1165 CreateFakeVEA(), CreateV4L2VEA(), CreateVaapiVEA(), CreateVTVEA(), |
| 1172 CreateMFVEA()}; | 1166 CreateMFVEA()}; |
| 1173 | 1167 |
| 1174 DVLOG(1) << "Profile: " << test_stream_->requested_profile | 1168 DVLOG(1) << "Profile: " << test_stream_->requested_profile |
| 1175 << ", initial bitrate: " << requested_bitrate_; | 1169 << ", initial bitrate: " << requested_bitrate_; |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1669 IvfFrameHeader header = {}; | 1663 IvfFrameHeader header = {}; |
| 1670 | 1664 |
| 1671 header.frame_size = static_cast<uint32_t>(frame_size); | 1665 header.frame_size = static_cast<uint32_t>(frame_size); |
| 1672 header.timestamp = frame_index; | 1666 header.timestamp = frame_index; |
| 1673 header.ByteSwap(); | 1667 header.ByteSwap(); |
| 1674 EXPECT_TRUE(base::AppendToFile( | 1668 EXPECT_TRUE(base::AppendToFile( |
| 1675 base::FilePath::FromUTF8Unsafe(test_stream_->out_filename), | 1669 base::FilePath::FromUTF8Unsafe(test_stream_->out_filename), |
| 1676 reinterpret_cast<char*>(&header), sizeof(header))); | 1670 reinterpret_cast<char*>(&header), sizeof(header))); |
| 1677 } | 1671 } |
| 1678 | 1672 |
| 1673 // This client is only used to test crbug.com/641600 to make sure the encoder | |
|
wuchengli
2016/11/07 04:25:17
s/test crbug.com/641600 to//
henryhsu
2016/11/07 04:29:55
Done.
| |
| 1674 // does not return an encoded frame before getting any input. | |
| 1675 class VEANoInputClient : public VideoEncodeAccelerator::Client { | |
| 1676 public: | |
| 1677 explicit VEANoInputClient(ClientStateNotification<ClientState>* note); | |
| 1678 ~VEANoInputClient() = default; | |
| 1679 void CreateEncoder(); | |
| 1680 void DestroyEncoder(); | |
| 1681 | |
| 1682 // VideoDecodeAccelerator::Client implementation. | |
| 1683 void RequireBitstreamBuffers(unsigned int input_count, | |
| 1684 const gfx::Size& input_coded_size, | |
| 1685 size_t output_buffer_size) override; | |
| 1686 void BitstreamBufferReady(int32_t bitstream_buffer_id, | |
| 1687 size_t payload_size, | |
| 1688 bool key_frame, | |
| 1689 base::TimeDelta timestamp) override; | |
| 1690 void NotifyError(VideoEncodeAccelerator::Error error) override; | |
| 1691 | |
| 1692 private: | |
| 1693 bool has_encoder() { return encoder_.get(); } | |
| 1694 | |
| 1695 void SetState(ClientState new_state); | |
| 1696 | |
| 1697 // Provide the encoder with a new output buffer. | |
| 1698 void FeedEncoderWithOutput(base::SharedMemory* shm, size_t output_size); | |
| 1699 | |
| 1700 ClientState state_; | |
| 1701 std::unique_ptr<VideoEncodeAccelerator> encoder_; | |
| 1702 | |
| 1703 // Used to notify another thread about the state. VEAClient does not own this. | |
| 1704 ClientStateNotification<ClientState>* note_; | |
| 1705 | |
| 1706 // All methods of this class should be run on the same thread. | |
| 1707 base::ThreadChecker thread_checker_; | |
| 1708 | |
| 1709 // Ids for output BitstreamBuffers. | |
| 1710 ScopedVector<base::SharedMemory> output_shms_; | |
| 1711 int32_t next_output_buffer_id_; | |
| 1712 | |
| 1713 // The timer used to monitor the encoder doesn't return an output buffer in | |
| 1714 // a period of time. | |
| 1715 std::unique_ptr<base::Timer> timer_; | |
| 1716 }; | |
| 1717 | |
| 1718 VEANoInputClient::VEANoInputClient(ClientStateNotification<ClientState>* note) | |
| 1719 : state_(CS_CREATED), note_(note), next_output_buffer_id_(0) {} | |
| 1720 | |
| 1721 void VEANoInputClient::CreateEncoder() { | |
| 1722 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1723 LOG_ASSERT(!has_encoder()); | |
| 1724 | |
| 1725 const int kDefaultWidth = 320; | |
| 1726 const int kDefaultHeight = 200; | |
|
wuchengli
2016/11/07 04:25:17
s/200/240/
henryhsu
2016/11/07 04:29:55
Done.
| |
| 1727 const int kDefaultBitrate = 200000; | |
| 1728 const int kDefaultFps = 30; | |
| 1729 | |
| 1730 std::unique_ptr<VideoEncodeAccelerator> encoders[] = { | |
| 1731 CreateFakeVEA(), CreateV4L2VEA(), CreateVaapiVEA(), CreateVTVEA(), | |
| 1732 CreateMFVEA()}; | |
| 1733 | |
| 1734 // The test case is no input. Use default visible size, bitrate, and fps. | |
| 1735 gfx::Size visible_size(kDefaultWidth, kDefaultHeight); | |
| 1736 for (auto& encoder : encoders) { | |
| 1737 if (!encoder) | |
| 1738 continue; | |
| 1739 encoder_ = std::move(encoder); | |
| 1740 if (encoder_->Initialize(kInputFormat, visible_size, VP8PROFILE_ANY, | |
| 1741 kDefaultBitrate, this)) { | |
| 1742 encoder_->RequestEncodingParametersChange(kDefaultBitrate, kDefaultFps); | |
| 1743 SetState(CS_INITIALIZED); | |
| 1744 return; | |
| 1745 } | |
| 1746 } | |
| 1747 encoder_.reset(); | |
| 1748 LOG(ERROR) << "VideoEncodeAccelerator::Initialize() failed"; | |
| 1749 SetState(CS_ERROR); | |
| 1750 } | |
| 1751 | |
| 1752 void VEANoInputClient::DestroyEncoder() { | |
| 1753 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1754 if (!has_encoder()) | |
| 1755 return; | |
| 1756 // Clear the objects that should be destroyed on the same thread as creation. | |
| 1757 encoder_.reset(); | |
| 1758 timer_.reset(); | |
| 1759 } | |
| 1760 | |
| 1761 void VEANoInputClient::RequireBitstreamBuffers( | |
| 1762 unsigned int input_count, | |
| 1763 const gfx::Size& input_coded_size, | |
| 1764 size_t output_size) { | |
| 1765 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1766 SetState(CS_ENCODING); | |
| 1767 ASSERT_GT(output_size, 0UL); | |
| 1768 | |
| 1769 for (unsigned int i = 0; i < kNumOutputBuffers; ++i) { | |
| 1770 base::SharedMemory* shm = new base::SharedMemory(); | |
| 1771 LOG_ASSERT(shm->CreateAndMapAnonymous(output_size)); | |
| 1772 output_shms_.push_back(shm); | |
| 1773 FeedEncoderWithOutput(shm, output_size); | |
| 1774 } | |
|
wuchengli
2016/11/07 04:25:17
add a comment to explain. something like "// Make
henryhsu
2016/11/07 04:29:55
Done.
| |
| 1775 timer_.reset(new base::Timer(FROM_HERE, | |
| 1776 base::TimeDelta::FromMilliseconds(100), | |
| 1777 base::Bind(&VEANoInputClient::SetState, | |
| 1778 base::Unretained(this), CS_FINISHED), | |
| 1779 false)); | |
| 1780 timer_->Reset(); | |
| 1781 } | |
| 1782 | |
| 1783 void VEANoInputClient::BitstreamBufferReady(int32_t bitstream_buffer_id, | |
| 1784 size_t payload_size, | |
| 1785 bool key_frame, | |
| 1786 base::TimeDelta timestamp) { | |
| 1787 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1788 SetState(CS_ERROR); | |
| 1789 } | |
| 1790 | |
| 1791 void VEANoInputClient::NotifyError(VideoEncodeAccelerator::Error error) { | |
| 1792 DCHECK(thread_checker_.CalledOnValidThread()); | |
| 1793 SetState(CS_ERROR); | |
| 1794 } | |
| 1795 | |
| 1796 void VEANoInputClient::SetState(ClientState new_state) { | |
| 1797 DVLOG(4) << "Changing state " << state_ << "->" << new_state; | |
| 1798 note_->Notify(new_state); | |
| 1799 state_ = new_state; | |
|
wuchengli
2016/11/07 04:25:17
Remove state_ because it's not used.
henryhsu
2016/11/07 04:29:55
Done.
| |
| 1800 } | |
| 1801 | |
| 1802 void VEANoInputClient::FeedEncoderWithOutput(base::SharedMemory* shm, | |
| 1803 size_t output_size) { | |
| 1804 if (!has_encoder()) | |
| 1805 return; | |
| 1806 | |
| 1807 base::SharedMemoryHandle dup_handle; | |
| 1808 LOG_ASSERT(shm->ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle)); | |
| 1809 | |
| 1810 BitstreamBuffer bitstream_buffer(next_output_buffer_id_++, dup_handle, | |
| 1811 output_size); | |
| 1812 encoder_->UseOutputBitstreamBuffer(bitstream_buffer); | |
| 1813 } | |
| 1814 | |
| 1679 // Test parameters: | 1815 // Test parameters: |
| 1680 // - Number of concurrent encoders. The value takes effect when there is only | 1816 // - Number of concurrent encoders. The value takes effect when there is only |
| 1681 // one input stream; otherwise, one encoder per input stream will be | 1817 // one input stream; otherwise, one encoder per input stream will be |
| 1682 // instantiated. | 1818 // instantiated. |
| 1683 // - If true, save output to file (provided an output filename was supplied). | 1819 // - If true, save output to file (provided an output filename was supplied). |
| 1684 // - Force a keyframe every n frames. | 1820 // - Force a keyframe every n frames. |
| 1685 // - Force bitrate; the actual required value is provided as a property | 1821 // - Force bitrate; the actual required value is provided as a property |
| 1686 // of the input stream, because it depends on stream type/resolution/etc. | 1822 // of the input stream, because it depends on stream type/resolution/etc. |
| 1687 // - If true, measure performance. | 1823 // - If true, measure performance. |
| 1688 // - If true, switch bitrate mid-stream. | 1824 // - If true, switch bitrate mid-stream. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1737 enum ClientState state_transitions[] = { | 1873 enum ClientState state_transitions[] = { |
| 1738 CS_ENCODER_SET, CS_INITIALIZED, CS_ENCODING, CS_FINISHED, CS_VALIDATED}; | 1874 CS_ENCODER_SET, CS_INITIALIZED, CS_ENCODING, CS_FINISHED, CS_VALIDATED}; |
| 1739 | 1875 |
| 1740 // Wait for all encoders to go through all states and finish. | 1876 // Wait for all encoders to go through all states and finish. |
| 1741 // Do this by waiting for all encoders to advance to state n before checking | 1877 // Do this by waiting for all encoders to advance to state n before checking |
| 1742 // state n+1, to verify that they are able to operate concurrently. | 1878 // state n+1, to verify that they are able to operate concurrently. |
| 1743 // It also simulates the real-world usage better, as the main thread, on which | 1879 // It also simulates the real-world usage better, as the main thread, on which |
| 1744 // encoders are created/destroyed, is a single GPU Process ChildThread. | 1880 // encoders are created/destroyed, is a single GPU Process ChildThread. |
| 1745 // Moreover, we can't have proper multithreading on X11, so this could cause | 1881 // Moreover, we can't have proper multithreading on X11, so this could cause |
| 1746 // hard to debug issues there, if there were multiple "ChildThreads". | 1882 // hard to debug issues there, if there were multiple "ChildThreads". |
| 1747 for (size_t state_no = 0; state_no < arraysize(state_transitions); | 1883 for (const auto& state : state_transitions) { |
| 1748 ++state_no) { | |
| 1749 for (size_t i = 0; i < num_concurrent_encoders; i++) | 1884 for (size_t i = 0; i < num_concurrent_encoders; i++) |
| 1750 ASSERT_EQ(notes[i]->Wait(), state_transitions[state_no]); | 1885 ASSERT_EQ(notes[i]->Wait(), state); |
| 1751 } | 1886 } |
| 1752 | 1887 |
| 1753 for (size_t i = 0; i < num_concurrent_encoders; ++i) { | 1888 for (size_t i = 0; i < num_concurrent_encoders; ++i) { |
| 1754 encoder_thread.task_runner()->PostTask( | 1889 encoder_thread.task_runner()->PostTask( |
| 1755 FROM_HERE, | 1890 FROM_HERE, |
| 1756 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); | 1891 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); |
| 1757 } | 1892 } |
| 1758 | 1893 |
| 1759 // This ensures all tasks have finished. | 1894 // This ensures all tasks have finished. |
| 1760 encoder_thread.Stop(); | 1895 encoder_thread.Stop(); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1811 std::make_tuple(3, false, 0, false, false, false, false, false, false), | 1946 std::make_tuple(3, false, 0, false, false, false, false, false, false), |
| 1812 std::make_tuple(3, false, 0, true, false, false, true, false, false), | 1947 std::make_tuple(3, false, 0, true, false, false, true, false, false), |
| 1813 std::make_tuple(3, false, 0, true, false, true, false, false, false))); | 1948 std::make_tuple(3, false, 0, true, false, true, false, false, false))); |
| 1814 | 1949 |
| 1815 INSTANTIATE_TEST_CASE_P( | 1950 INSTANTIATE_TEST_CASE_P( |
| 1816 VerifyTimestamp, | 1951 VerifyTimestamp, |
| 1817 VideoEncodeAcceleratorTest, | 1952 VideoEncodeAcceleratorTest, |
| 1818 ::testing::Values( | 1953 ::testing::Values( |
| 1819 std::make_tuple(1, false, 0, false, false, false, false, false, true))); | 1954 std::make_tuple(1, false, 0, false, false, false, false, false, true))); |
| 1820 | 1955 |
| 1956 TEST(VEANoInputTest, CheckOutput) { | |
| 1957 std::unique_ptr<ClientStateNotification<ClientState>> note( | |
| 1958 new ClientStateNotification<ClientState>()); | |
| 1959 std::unique_ptr<VEANoInputClient> client(new VEANoInputClient(note.get())); | |
| 1960 base::Thread encoder_thread("EncoderThread"); | |
| 1961 ASSERT_TRUE(encoder_thread.Start()); | |
| 1962 | |
| 1963 encoder_thread.task_runner()->PostTask( | |
| 1964 FROM_HERE, base::Bind(&VEANoInputClient::CreateEncoder, | |
| 1965 base::Unretained(client.get()))); | |
| 1966 | |
| 1967 // All encoders must pass through states in this order. | |
| 1968 enum ClientState state_transitions[] = {CS_INITIALIZED, CS_ENCODING, | |
| 1969 CS_FINISHED}; | |
| 1970 | |
| 1971 for (const auto& state : state_transitions) { | |
| 1972 ASSERT_EQ(note->Wait(), state); | |
| 1973 } | |
| 1974 | |
| 1975 encoder_thread.task_runner()->PostTask( | |
| 1976 FROM_HERE, base::Bind(&VEANoInputClient::DestroyEncoder, | |
| 1977 base::Unretained(client.get()))); | |
| 1978 | |
| 1979 // This ensures all tasks have finished. | |
| 1980 encoder_thread.Stop(); | |
| 1981 } | |
| 1982 | |
| 1821 #elif defined(OS_MACOSX) || defined(OS_WIN) | 1983 #elif defined(OS_MACOSX) || defined(OS_WIN) |
| 1822 INSTANTIATE_TEST_CASE_P( | 1984 INSTANTIATE_TEST_CASE_P( |
| 1823 SimpleEncode, | 1985 SimpleEncode, |
| 1824 VideoEncodeAcceleratorTest, | 1986 VideoEncodeAcceleratorTest, |
| 1825 ::testing::Values( | 1987 ::testing::Values( |
| 1826 std::make_tuple(1, true, 0, false, false, false, false, false, false), | 1988 std::make_tuple(1, true, 0, false, false, false, false, false, false), |
| 1827 std::make_tuple(1, true, 0, false, false, false, false, true, false))); | 1989 std::make_tuple(1, true, 0, false, false, false, false, true, false))); |
| 1828 | 1990 |
| 1829 INSTANTIATE_TEST_CASE_P( | 1991 INSTANTIATE_TEST_CASE_P( |
| 1830 EncoderPerf, | 1992 EncoderPerf, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1941 | 2103 |
| 1942 media::g_env = | 2104 media::g_env = |
| 1943 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( | 2105 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( |
| 1944 testing::AddGlobalTestEnvironment( | 2106 testing::AddGlobalTestEnvironment( |
| 1945 new media::VideoEncodeAcceleratorTestEnvironment( | 2107 new media::VideoEncodeAcceleratorTestEnvironment( |
| 1946 std::move(test_stream_data), log_path, run_at_fps, | 2108 std::move(test_stream_data), log_path, run_at_fps, |
| 1947 needs_encode_latency, verify_all_output))); | 2109 needs_encode_latency, verify_all_output))); |
| 1948 | 2110 |
| 1949 return RUN_ALL_TESTS(); | 2111 return RUN_ALL_TESTS(); |
| 1950 } | 2112 } |
| OLD | NEW |