| 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 make sure the encoder does not return an encoded |
| 1674 // frame before getting any input. |
| 1675 class VEANoInputClient : public VideoEncodeAccelerator::Client { |
| 1676 public: |
| 1677 explicit VEANoInputClient(ClientStateNotification<ClientState>* note); |
| 1678 ~VEANoInputClient() override; |
| 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 std::unique_ptr<VideoEncodeAccelerator> encoder_; |
| 1701 |
| 1702 // Used to notify another thread about the state. VEAClient does not own this. |
| 1703 ClientStateNotification<ClientState>* note_; |
| 1704 |
| 1705 // All methods of this class should be run on the same thread. |
| 1706 base::ThreadChecker thread_checker_; |
| 1707 |
| 1708 // Ids for output BitstreamBuffers. |
| 1709 ScopedVector<base::SharedMemory> output_shms_; |
| 1710 int32_t next_output_buffer_id_; |
| 1711 |
| 1712 // The timer used to monitor the encoder doesn't return an output buffer in |
| 1713 // a period of time. |
| 1714 std::unique_ptr<base::Timer> timer_; |
| 1715 }; |
| 1716 |
| 1717 VEANoInputClient::VEANoInputClient(ClientStateNotification<ClientState>* note) |
| 1718 : note_(note), next_output_buffer_id_(0) {} |
| 1719 |
| 1720 VEANoInputClient::~VEANoInputClient() { |
| 1721 LOG_ASSERT(!has_encoder()); |
| 1722 } |
| 1723 |
| 1724 void VEANoInputClient::CreateEncoder() { |
| 1725 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1726 LOG_ASSERT(!has_encoder()); |
| 1727 |
| 1728 const int kDefaultWidth = 320; |
| 1729 const int kDefaultHeight = 240; |
| 1730 const int kDefaultBitrate = 200000; |
| 1731 const int kDefaultFps = 30; |
| 1732 |
| 1733 std::unique_ptr<VideoEncodeAccelerator> encoders[] = { |
| 1734 CreateFakeVEA(), CreateV4L2VEA(), CreateVaapiVEA(), CreateVTVEA(), |
| 1735 CreateMFVEA()}; |
| 1736 |
| 1737 // The test case is no input. Use default visible size, bitrate, and fps. |
| 1738 gfx::Size visible_size(kDefaultWidth, kDefaultHeight); |
| 1739 for (auto& encoder : encoders) { |
| 1740 if (!encoder) |
| 1741 continue; |
| 1742 encoder_ = std::move(encoder); |
| 1743 if (encoder_->Initialize(kInputFormat, visible_size, VP8PROFILE_ANY, |
| 1744 kDefaultBitrate, this)) { |
| 1745 encoder_->RequestEncodingParametersChange(kDefaultBitrate, kDefaultFps); |
| 1746 SetState(CS_INITIALIZED); |
| 1747 return; |
| 1748 } |
| 1749 } |
| 1750 encoder_.reset(); |
| 1751 LOG(ERROR) << "VideoEncodeAccelerator::Initialize() failed"; |
| 1752 SetState(CS_ERROR); |
| 1753 } |
| 1754 |
| 1755 void VEANoInputClient::DestroyEncoder() { |
| 1756 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1757 if (!has_encoder()) |
| 1758 return; |
| 1759 // Clear the objects that should be destroyed on the same thread as creation. |
| 1760 encoder_.reset(); |
| 1761 timer_.reset(); |
| 1762 } |
| 1763 |
| 1764 void VEANoInputClient::RequireBitstreamBuffers( |
| 1765 unsigned int input_count, |
| 1766 const gfx::Size& input_coded_size, |
| 1767 size_t output_size) { |
| 1768 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1769 SetState(CS_ENCODING); |
| 1770 ASSERT_GT(output_size, 0UL); |
| 1771 |
| 1772 for (unsigned int i = 0; i < kNumOutputBuffers; ++i) { |
| 1773 base::SharedMemory* shm = new base::SharedMemory(); |
| 1774 LOG_ASSERT(shm->CreateAndMapAnonymous(output_size)); |
| 1775 output_shms_.push_back(shm); |
| 1776 FeedEncoderWithOutput(shm, output_size); |
| 1777 } |
| 1778 // Timer is used to make sure there is no output frame in 100ms. |
| 1779 timer_.reset(new base::Timer(FROM_HERE, |
| 1780 base::TimeDelta::FromMilliseconds(100), |
| 1781 base::Bind(&VEANoInputClient::SetState, |
| 1782 base::Unretained(this), CS_FINISHED), |
| 1783 false)); |
| 1784 timer_->Reset(); |
| 1785 } |
| 1786 |
| 1787 void VEANoInputClient::BitstreamBufferReady(int32_t bitstream_buffer_id, |
| 1788 size_t payload_size, |
| 1789 bool key_frame, |
| 1790 base::TimeDelta timestamp) { |
| 1791 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1792 SetState(CS_ERROR); |
| 1793 } |
| 1794 |
| 1795 void VEANoInputClient::NotifyError(VideoEncodeAccelerator::Error error) { |
| 1796 DCHECK(thread_checker_.CalledOnValidThread()); |
| 1797 SetState(CS_ERROR); |
| 1798 } |
| 1799 |
| 1800 void VEANoInputClient::SetState(ClientState new_state) { |
| 1801 DVLOG(4) << "Changing state to " << new_state; |
| 1802 note_->Notify(new_state); |
| 1803 } |
| 1804 |
| 1805 void VEANoInputClient::FeedEncoderWithOutput(base::SharedMemory* shm, |
| 1806 size_t output_size) { |
| 1807 if (!has_encoder()) |
| 1808 return; |
| 1809 |
| 1810 base::SharedMemoryHandle dup_handle; |
| 1811 LOG_ASSERT(shm->ShareToProcess(base::GetCurrentProcessHandle(), &dup_handle)); |
| 1812 |
| 1813 BitstreamBuffer bitstream_buffer(next_output_buffer_id_++, dup_handle, |
| 1814 output_size); |
| 1815 encoder_->UseOutputBitstreamBuffer(bitstream_buffer); |
| 1816 } |
| 1817 |
| 1679 // Test parameters: | 1818 // Test parameters: |
| 1680 // - Number of concurrent encoders. The value takes effect when there is only | 1819 // - Number of concurrent encoders. The value takes effect when there is only |
| 1681 // one input stream; otherwise, one encoder per input stream will be | 1820 // one input stream; otherwise, one encoder per input stream will be |
| 1682 // instantiated. | 1821 // instantiated. |
| 1683 // - If true, save output to file (provided an output filename was supplied). | 1822 // - If true, save output to file (provided an output filename was supplied). |
| 1684 // - Force a keyframe every n frames. | 1823 // - Force a keyframe every n frames. |
| 1685 // - Force bitrate; the actual required value is provided as a property | 1824 // - Force bitrate; the actual required value is provided as a property |
| 1686 // of the input stream, because it depends on stream type/resolution/etc. | 1825 // of the input stream, because it depends on stream type/resolution/etc. |
| 1687 // - If true, measure performance. | 1826 // - If true, measure performance. |
| 1688 // - If true, switch bitrate mid-stream. | 1827 // - If true, switch bitrate mid-stream. |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1737 enum ClientState state_transitions[] = { | 1876 enum ClientState state_transitions[] = { |
| 1738 CS_ENCODER_SET, CS_INITIALIZED, CS_ENCODING, CS_FINISHED, CS_VALIDATED}; | 1877 CS_ENCODER_SET, CS_INITIALIZED, CS_ENCODING, CS_FINISHED, CS_VALIDATED}; |
| 1739 | 1878 |
| 1740 // Wait for all encoders to go through all states and finish. | 1879 // 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 | 1880 // 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. | 1881 // 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 | 1882 // 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. | 1883 // encoders are created/destroyed, is a single GPU Process ChildThread. |
| 1745 // Moreover, we can't have proper multithreading on X11, so this could cause | 1884 // Moreover, we can't have proper multithreading on X11, so this could cause |
| 1746 // hard to debug issues there, if there were multiple "ChildThreads". | 1885 // hard to debug issues there, if there were multiple "ChildThreads". |
| 1747 for (size_t state_no = 0; state_no < arraysize(state_transitions); | 1886 for (const auto& state : state_transitions) { |
| 1748 ++state_no) { | |
| 1749 for (size_t i = 0; i < num_concurrent_encoders; i++) | 1887 for (size_t i = 0; i < num_concurrent_encoders; i++) |
| 1750 ASSERT_EQ(notes[i]->Wait(), state_transitions[state_no]); | 1888 ASSERT_EQ(notes[i]->Wait(), state); |
| 1751 } | 1889 } |
| 1752 | 1890 |
| 1753 for (size_t i = 0; i < num_concurrent_encoders; ++i) { | 1891 for (size_t i = 0; i < num_concurrent_encoders; ++i) { |
| 1754 encoder_thread.task_runner()->PostTask( | 1892 encoder_thread.task_runner()->PostTask( |
| 1755 FROM_HERE, | 1893 FROM_HERE, |
| 1756 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); | 1894 base::Bind(&VEAClient::DestroyEncoder, base::Unretained(clients[i]))); |
| 1757 } | 1895 } |
| 1758 | 1896 |
| 1759 // This ensures all tasks have finished. | 1897 // This ensures all tasks have finished. |
| 1760 encoder_thread.Stop(); | 1898 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), | 1949 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), | 1950 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))); | 1951 std::make_tuple(3, false, 0, true, false, true, false, false, false))); |
| 1814 | 1952 |
| 1815 INSTANTIATE_TEST_CASE_P( | 1953 INSTANTIATE_TEST_CASE_P( |
| 1816 VerifyTimestamp, | 1954 VerifyTimestamp, |
| 1817 VideoEncodeAcceleratorTest, | 1955 VideoEncodeAcceleratorTest, |
| 1818 ::testing::Values( | 1956 ::testing::Values( |
| 1819 std::make_tuple(1, false, 0, false, false, false, false, false, true))); | 1957 std::make_tuple(1, false, 0, false, false, false, false, false, true))); |
| 1820 | 1958 |
| 1959 TEST(VEANoInputTest, CheckOutput) { |
| 1960 std::unique_ptr<ClientStateNotification<ClientState>> note( |
| 1961 new ClientStateNotification<ClientState>()); |
| 1962 std::unique_ptr<VEANoInputClient> client(new VEANoInputClient(note.get())); |
| 1963 base::Thread encoder_thread("EncoderThread"); |
| 1964 ASSERT_TRUE(encoder_thread.Start()); |
| 1965 |
| 1966 encoder_thread.task_runner()->PostTask( |
| 1967 FROM_HERE, base::Bind(&VEANoInputClient::CreateEncoder, |
| 1968 base::Unretained(client.get()))); |
| 1969 |
| 1970 // Encoder must pass through states in this order. |
| 1971 enum ClientState state_transitions[] = {CS_INITIALIZED, CS_ENCODING, |
| 1972 CS_FINISHED}; |
| 1973 |
| 1974 for (const auto& state : state_transitions) { |
| 1975 ASSERT_EQ(note->Wait(), state); |
| 1976 } |
| 1977 |
| 1978 encoder_thread.task_runner()->PostTask( |
| 1979 FROM_HERE, base::Bind(&VEANoInputClient::DestroyEncoder, |
| 1980 base::Unretained(client.get()))); |
| 1981 |
| 1982 // This ensures all tasks have finished. |
| 1983 encoder_thread.Stop(); |
| 1984 } |
| 1985 |
| 1821 #elif defined(OS_MACOSX) || defined(OS_WIN) | 1986 #elif defined(OS_MACOSX) || defined(OS_WIN) |
| 1822 INSTANTIATE_TEST_CASE_P( | 1987 INSTANTIATE_TEST_CASE_P( |
| 1823 SimpleEncode, | 1988 SimpleEncode, |
| 1824 VideoEncodeAcceleratorTest, | 1989 VideoEncodeAcceleratorTest, |
| 1825 ::testing::Values( | 1990 ::testing::Values( |
| 1826 std::make_tuple(1, true, 0, false, false, false, false, false, false), | 1991 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))); | 1992 std::make_tuple(1, true, 0, false, false, false, false, true, false))); |
| 1828 | 1993 |
| 1829 INSTANTIATE_TEST_CASE_P( | 1994 INSTANTIATE_TEST_CASE_P( |
| 1830 EncoderPerf, | 1995 EncoderPerf, |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1941 | 2106 |
| 1942 media::g_env = | 2107 media::g_env = |
| 1943 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( | 2108 reinterpret_cast<media::VideoEncodeAcceleratorTestEnvironment*>( |
| 1944 testing::AddGlobalTestEnvironment( | 2109 testing::AddGlobalTestEnvironment( |
| 1945 new media::VideoEncodeAcceleratorTestEnvironment( | 2110 new media::VideoEncodeAcceleratorTestEnvironment( |
| 1946 std::move(test_stream_data), log_path, run_at_fps, | 2111 std::move(test_stream_data), log_path, run_at_fps, |
| 1947 needs_encode_latency, verify_all_output))); | 2112 needs_encode_latency, verify_all_output))); |
| 1948 | 2113 |
| 1949 return RUN_ALL_TESTS(); | 2114 return RUN_ALL_TESTS(); |
| 1950 } | 2115 } |
| OLD | NEW |