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