OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/video/encoder_state_feedback.h" | 11 #include "webrtc/video/encoder_state_feedback.h" |
12 | 12 |
13 #include "testing/gmock/include/gmock/gmock.h" | 13 #include "testing/gmock/include/gmock/gmock.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 15 #include "webrtc/modules/pacing/packet_router.h" |
| 16 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
15 #include "webrtc/modules/utility/include/mock/mock_process_thread.h" | 17 #include "webrtc/modules/utility/include/mock/mock_process_thread.h" |
16 #include "webrtc/video/vie_encoder.h" | 18 #include "webrtc/video/vie_encoder.h" |
17 | 19 |
18 using ::testing::NiceMock; | 20 using ::testing::NiceMock; |
19 | 21 |
20 namespace webrtc { | 22 namespace webrtc { |
21 | 23 |
22 class MockVieEncoder : public ViEEncoder { | 24 class MockVieEncoder : public ViEEncoder { |
23 public: | 25 public: |
24 explicit MockVieEncoder(ProcessThread* process_thread) | 26 explicit MockVieEncoder(ProcessThread* process_thread, PacedSender* pacer) |
25 : ViEEncoder(1, | 27 : ViEEncoder(1, |
26 process_thread, | 28 process_thread, |
27 nullptr, | 29 nullptr, |
28 nullptr) {} | 30 nullptr, |
| 31 nullptr, |
| 32 pacer) {} |
29 ~MockVieEncoder() {} | 33 ~MockVieEncoder() {} |
30 | 34 |
31 MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t)); | 35 MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t)); |
32 MOCK_METHOD1(OnReceivedSLI, void(uint8_t picture_id)); | 36 MOCK_METHOD1(OnReceivedSLI, void(uint8_t picture_id)); |
33 MOCK_METHOD1(OnReceivedRPSI, void(uint64_t picture_id)); | 37 MOCK_METHOD1(OnReceivedRPSI, void(uint64_t picture_id)); |
34 }; | 38 }; |
35 | 39 |
36 class VieKeyRequestTest : public ::testing::Test { | 40 class VieKeyRequestTest : public ::testing::Test { |
37 public: | 41 public: |
38 VieKeyRequestTest() | 42 VieKeyRequestTest() |
39 : encoder_(&process_thread_), | 43 : pacer_(Clock::GetRealTimeClock(), |
| 44 &router_, |
| 45 BitrateController::kDefaultStartBitrateKbps, |
| 46 PacedSender::kDefaultPaceMultiplier * |
| 47 BitrateController::kDefaultStartBitrateKbps, |
| 48 0), |
| 49 encoder_(&process_thread_, &pacer_), |
40 simulated_clock_(123456789), | 50 simulated_clock_(123456789), |
41 encoder_state_feedback_( | 51 encoder_state_feedback_( |
42 &simulated_clock_, | 52 &simulated_clock_, |
43 std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc), | 53 std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc), |
44 &encoder_) {} | 54 &encoder_) {} |
45 | 55 |
46 protected: | 56 protected: |
47 const uint32_t kSsrc = 1234; | 57 const uint32_t kSsrc = 1234; |
48 NiceMock<MockProcessThread> process_thread_; | 58 NiceMock<MockProcessThread> process_thread_; |
| 59 PacketRouter router_; |
| 60 PacedSender pacer_; |
49 MockVieEncoder encoder_; | 61 MockVieEncoder encoder_; |
50 SimulatedClock simulated_clock_; | 62 SimulatedClock simulated_clock_; |
51 EncoderStateFeedback encoder_state_feedback_; | 63 EncoderStateFeedback encoder_state_feedback_; |
52 }; | 64 }; |
53 | 65 |
54 TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) { | 66 TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) { |
55 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); | 67 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); |
56 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 68 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
57 | 69 |
58 const uint8_t sli_picture_id = 3; | 70 const uint8_t sli_picture_id = 3; |
(...skipping 13 matching lines...) Expand all Loading... |
72 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 84 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
73 | 85 |
74 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); | 86 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); |
75 simulated_clock_.AdvanceTimeMilliseconds(300); | 87 simulated_clock_.AdvanceTimeMilliseconds(300); |
76 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 88 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
77 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 89 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
78 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 90 encoder_state_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
79 } | 91 } |
80 | 92 |
81 } // namespace webrtc | 93 } // namespace webrtc |
OLD | NEW |