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