| 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, PacedSender* pacer) | 28 explicit MockVieEncoder(ProcessThread* process_thread) |
| 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) {} | |
| 36 ~MockVieEncoder() {} | 34 ~MockVieEncoder() {} |
| 37 | 35 |
| 38 MOCK_METHOD1(OnReceivedIntraFrameRequest, | 36 MOCK_METHOD1(OnReceivedIntraFrameRequest, |
| 39 void(uint32_t)); | 37 void(uint32_t)); |
| 40 MOCK_METHOD2(OnReceivedSLI, | 38 MOCK_METHOD2(OnReceivedSLI, |
| 41 void(uint32_t ssrc, uint8_t picture_id)); | 39 void(uint32_t ssrc, uint8_t picture_id)); |
| 42 MOCK_METHOD2(OnReceivedRPSI, | 40 MOCK_METHOD2(OnReceivedRPSI, |
| 43 void(uint32_t ssrc, uint64_t picture_id)); | 41 void(uint32_t ssrc, uint64_t picture_id)); |
| 44 }; | 42 }; |
| 45 | 43 |
| 46 TEST(VieKeyRequestTest, CreateAndTriggerRequests) { | 44 TEST(VieKeyRequestTest, CreateAndTriggerRequests) { |
| 47 static const uint32_t kSsrc = 1234; | 45 static const uint32_t kSsrc = 1234; |
| 48 NiceMock<MockProcessThread> process_thread; | 46 NiceMock<MockProcessThread> process_thread; |
| 49 PacketRouter router; | 47 PacketRouter router; |
| 50 PacedSender pacer(Clock::GetRealTimeClock(), &router, | 48 MockVieEncoder encoder(&process_thread); |
| 51 BitrateController::kDefaultStartBitrateKbps, | |
| 52 PacedSender::kDefaultPaceMultiplier * | |
| 53 BitrateController::kDefaultStartBitrateKbps, | |
| 54 0); | |
| 55 MockVieEncoder encoder(&process_thread, &pacer); | |
| 56 | 49 |
| 57 EncoderStateFeedback encoder_state_feedback; | 50 EncoderStateFeedback encoder_state_feedback; |
| 58 encoder_state_feedback.Init(std::vector<uint32_t>(1, kSsrc), &encoder); | 51 encoder_state_feedback.Init(std::vector<uint32_t>(1, kSsrc), &encoder); |
| 59 | 52 |
| 60 EXPECT_CALL(encoder, OnReceivedIntraFrameRequest(kSsrc)) | 53 EXPECT_CALL(encoder, OnReceivedIntraFrameRequest(kSsrc)) |
| 61 .Times(1); | 54 .Times(1); |
| 62 encoder_state_feedback.OnReceivedIntraFrameRequest(kSsrc); | 55 encoder_state_feedback.OnReceivedIntraFrameRequest(kSsrc); |
| 63 | 56 |
| 64 const uint8_t sli_picture_id = 3; | 57 const uint8_t sli_picture_id = 3; |
| 65 EXPECT_CALL(encoder, OnReceivedSLI(kSsrc, sli_picture_id)) | 58 EXPECT_CALL(encoder, OnReceivedSLI(kSsrc, sli_picture_id)) |
| 66 .Times(1); | 59 .Times(1); |
| 67 encoder_state_feedback.OnReceivedSLI(kSsrc, sli_picture_id); | 60 encoder_state_feedback.OnReceivedSLI(kSsrc, sli_picture_id); |
| 68 | 61 |
| 69 const uint64_t rpsi_picture_id = 9; | 62 const uint64_t rpsi_picture_id = 9; |
| 70 EXPECT_CALL(encoder, OnReceivedRPSI(kSsrc, rpsi_picture_id)) | 63 EXPECT_CALL(encoder, OnReceivedRPSI(kSsrc, rpsi_picture_id)) |
| 71 .Times(1); | 64 .Times(1); |
| 72 encoder_state_feedback.OnReceivedRPSI(kSsrc, rpsi_picture_id); | 65 encoder_state_feedback.OnReceivedRPSI(kSsrc, rpsi_picture_id); |
| 73 } | 66 } |
| 74 | 67 |
| 75 } // namespace webrtc | 68 } // namespace webrtc |
| OLD | NEW |