| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 #include <string.h> | 6 #include <string.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| 11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
| 12 #include "base/thread_task_runner_handle.h" | 12 #include "base/thread_task_runner_handle.h" |
| 13 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
| 14 #include "content/renderer/media/rtc_video_decoder.h" | 14 #include "content/renderer/media/rtc_video_decoder.h" |
| 15 #include "media/base/gmock_callback_support.h" | 15 #include "media/base/gmock_callback_support.h" |
| 16 #include "media/renderers/mock_gpu_video_accelerator_factories.h" | 16 #include "media/renderers/mock_gpu_video_accelerator_factories.h" |
| 17 #include "media/video/mock_video_decode_accelerator.h" | 17 #include "media/video/mock_video_decode_accelerator.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 19 |
| 20 #if defined(OS_WIN) |
| 21 #include "base/command_line.h" |
| 22 #include "content/public/common/content_switches.h" |
| 23 #endif // defined(OS_WIN) |
| 24 |
| 20 using ::testing::_; | 25 using ::testing::_; |
| 21 using ::testing::Invoke; | 26 using ::testing::Invoke; |
| 22 using ::testing::Return; | 27 using ::testing::Return; |
| 23 using ::testing::SaveArg; | 28 using ::testing::SaveArg; |
| 24 using ::testing::Values; | 29 using ::testing::Values; |
| 25 using ::testing::WithArgs; | 30 using ::testing::WithArgs; |
| 26 | 31 |
| 27 namespace content { | 32 namespace content { |
| 28 | 33 |
| 29 namespace { | 34 namespace { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 .WillRepeatedly(Return(vda_task_runner_)); | 72 .WillRepeatedly(Return(vda_task_runner_)); |
| 68 EXPECT_CALL(*mock_gpu_factories_.get(), | 73 EXPECT_CALL(*mock_gpu_factories_.get(), |
| 69 GetVideoDecodeAcceleratorCapabilities()) | 74 GetVideoDecodeAcceleratorCapabilities()) |
| 70 .WillRepeatedly(Return(capabilities_)); | 75 .WillRepeatedly(Return(capabilities_)); |
| 71 EXPECT_CALL(*mock_gpu_factories_.get(), DoCreateVideoDecodeAccelerator()) | 76 EXPECT_CALL(*mock_gpu_factories_.get(), DoCreateVideoDecodeAccelerator()) |
| 72 .WillRepeatedly(Return(mock_vda_)); | 77 .WillRepeatedly(Return(mock_vda_)); |
| 73 EXPECT_CALL(*mock_vda_, Initialize(_, _)) | 78 EXPECT_CALL(*mock_vda_, Initialize(_, _)) |
| 74 .Times(1) | 79 .Times(1) |
| 75 .WillRepeatedly(Return(true)); | 80 .WillRepeatedly(Return(true)); |
| 76 EXPECT_CALL(*mock_vda_, Destroy()).Times(1); | 81 EXPECT_CALL(*mock_vda_, Destroy()).Times(1); |
| 82 |
| 83 #if defined(OS_WIN) |
| 84 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 85 switches::kEnableWin7WebRtcHWH264Decoding); |
| 86 #endif // defined(OS_WIN) |
| 77 } | 87 } |
| 78 | 88 |
| 79 void TearDown() override { | 89 void TearDown() override { |
| 80 DVLOG(2) << "TearDown"; | 90 DVLOG(2) << "TearDown"; |
| 81 EXPECT_TRUE(vda_thread_.IsRunning()); | 91 EXPECT_TRUE(vda_thread_.IsRunning()); |
| 82 RunUntilIdle(); // Wait until all callbascks complete. | 92 RunUntilIdle(); // Wait until all callbascks complete. |
| 83 vda_task_runner_->DeleteSoon(FROM_HERE, rtc_decoder_.release()); | 93 vda_task_runner_->DeleteSoon(FROM_HERE, rtc_decoder_.release()); |
| 84 // Make sure the decoder is released before stopping the thread. | 94 // Make sure the decoder is released before stopping the thread. |
| 85 RunUntilIdle(); | 95 RunUntilIdle(); |
| 86 vda_thread_.Stop(); | 96 vda_thread_.Stop(); |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 rtc_decoder_->Decode(input_image, false, nullptr, nullptr, 10)); | 318 rtc_decoder_->Decode(input_image, false, nullptr, nullptr, 10)); |
| 309 EXPECT_EQ(0, rtc_decoder_->GetVDAErrorCounterForTesting()); | 319 EXPECT_EQ(0, rtc_decoder_->GetVDAErrorCounterForTesting()); |
| 310 } | 320 } |
| 311 | 321 |
| 312 INSTANTIATE_TEST_CASE_P(CodecProfiles, | 322 INSTANTIATE_TEST_CASE_P(CodecProfiles, |
| 313 RTCVideoDecoderTest, | 323 RTCVideoDecoderTest, |
| 314 Values(webrtc::kVideoCodecVP8, | 324 Values(webrtc::kVideoCodecVP8, |
| 315 webrtc::kVideoCodecH264)); | 325 webrtc::kVideoCodecH264)); |
| 316 | 326 |
| 317 } // content | 327 } // content |
| OLD | NEW |