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 | 15 |
16 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" | 16 #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" |
17 #include "webrtc/modules/pacing/paced_sender.h" | 17 #include "webrtc/modules/pacing/paced_sender.h" |
18 #include "webrtc/modules/pacing/packet_router.h" | 18 #include "webrtc/modules/pacing/packet_router.h" |
19 #include "webrtc/modules/utility/include/mock/mock_process_thread.h" | 19 #include "webrtc/modules/utility/include/mock/mock_process_thread.h" |
20 #include "webrtc/video/vie_encoder.h" | 20 #include "webrtc/video/vie_encoder.h" |
21 | 21 |
22 using ::testing::NiceMock; | 22 using ::testing::NiceMock; |
23 | 23 |
24 namespace webrtc { | 24 namespace webrtc { |
25 | 25 |
26 class MockVieEncoder : public ViEEncoder { | 26 class MockVieEncoder : public ViEEncoder { |
27 public: | 27 public: |
28 explicit MockVieEncoder(ProcessThread* process_thread) | 28 explicit MockVieEncoder(ProcessThread* process_thread, PacedSender* pacer) |
29 : ViEEncoder(1, | 29 : ViEEncoder(1, |
30 std::vector<uint32_t>(), | 30 std::vector<uint32_t>(), |
31 process_thread, | 31 process_thread, |
32 nullptr, | 32 nullptr, |
33 nullptr) {} | 33 nullptr, |
| 34 nullptr, |
| 35 pacer) {} |
34 ~MockVieEncoder() {} | 36 ~MockVieEncoder() {} |
35 | 37 |
36 MOCK_METHOD1(OnReceivedIntraFrameRequest, | 38 MOCK_METHOD1(OnReceivedIntraFrameRequest, |
37 void(uint32_t)); | 39 void(uint32_t)); |
38 MOCK_METHOD2(OnReceivedSLI, | 40 MOCK_METHOD2(OnReceivedSLI, |
39 void(uint32_t ssrc, uint8_t picture_id)); | 41 void(uint32_t ssrc, uint8_t picture_id)); |
40 MOCK_METHOD2(OnReceivedRPSI, | 42 MOCK_METHOD2(OnReceivedRPSI, |
41 void(uint32_t ssrc, uint64_t picture_id)); | 43 void(uint32_t ssrc, uint64_t picture_id)); |
42 }; | 44 }; |
43 | 45 |
44 TEST(VieKeyRequestTest, CreateAndTriggerRequests) { | 46 TEST(VieKeyRequestTest, CreateAndTriggerRequests) { |
45 static const uint32_t kSsrc = 1234; | 47 static const uint32_t kSsrc = 1234; |
46 NiceMock<MockProcessThread> process_thread; | 48 NiceMock<MockProcessThread> process_thread; |
47 PacketRouter router; | 49 PacketRouter router; |
48 MockVieEncoder encoder(&process_thread); | 50 PacedSender pacer(Clock::GetRealTimeClock(), &router, |
| 51 BitrateController::kDefaultStartBitrateKbps, |
| 52 PacedSender::kDefaultPaceMultiplier * |
| 53 BitrateController::kDefaultStartBitrateKbps, |
| 54 0); |
| 55 MockVieEncoder encoder(&process_thread, &pacer); |
49 | 56 |
50 EncoderStateFeedback encoder_state_feedback; | 57 EncoderStateFeedback encoder_state_feedback; |
51 encoder_state_feedback.Init(std::vector<uint32_t>(1, kSsrc), &encoder); | 58 encoder_state_feedback.Init(std::vector<uint32_t>(1, kSsrc), &encoder); |
52 | 59 |
53 EXPECT_CALL(encoder, OnReceivedIntraFrameRequest(kSsrc)) | 60 EXPECT_CALL(encoder, OnReceivedIntraFrameRequest(kSsrc)) |
54 .Times(1); | 61 .Times(1); |
55 encoder_state_feedback.OnReceivedIntraFrameRequest(kSsrc); | 62 encoder_state_feedback.OnReceivedIntraFrameRequest(kSsrc); |
56 | 63 |
57 const uint8_t sli_picture_id = 3; | 64 const uint8_t sli_picture_id = 3; |
58 EXPECT_CALL(encoder, OnReceivedSLI(kSsrc, sli_picture_id)) | 65 EXPECT_CALL(encoder, OnReceivedSLI(kSsrc, sli_picture_id)) |
59 .Times(1); | 66 .Times(1); |
60 encoder_state_feedback.OnReceivedSLI(kSsrc, sli_picture_id); | 67 encoder_state_feedback.OnReceivedSLI(kSsrc, sli_picture_id); |
61 | 68 |
62 const uint64_t rpsi_picture_id = 9; | 69 const uint64_t rpsi_picture_id = 9; |
63 EXPECT_CALL(encoder, OnReceivedRPSI(kSsrc, rpsi_picture_id)) | 70 EXPECT_CALL(encoder, OnReceivedRPSI(kSsrc, rpsi_picture_id)) |
64 .Times(1); | 71 .Times(1); |
65 encoder_state_feedback.OnReceivedRPSI(kSsrc, rpsi_picture_id); | 72 encoder_state_feedback.OnReceivedRPSI(kSsrc, rpsi_picture_id); |
66 } | 73 } |
67 | 74 |
68 } // namespace webrtc | 75 } // namespace webrtc |
OLD | NEW |