| 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_rtcp_feedback.h" | 11 #include "webrtc/video/encoder_rtcp_feedback.h" |
| 12 | 12 |
| 13 #include <memory> | 13 #include <memory> |
| 14 | 14 |
| 15 #include "webrtc/modules/utility/include/mock/mock_process_thread.h" | 15 #include "webrtc/modules/utility/include/mock/mock_process_thread.h" |
| 16 #include "webrtc/test/gmock.h" | 16 #include "webrtc/test/gmock.h" |
| 17 #include "webrtc/test/gtest.h" | 17 #include "webrtc/test/gtest.h" |
| 18 #include "webrtc/video/send_statistics_proxy.h" | 18 #include "webrtc/video/send_statistics_proxy.h" |
| 19 #include "webrtc/video/vie_encoder.h" | 19 #include "webrtc/video/video_stream_encoder.h" |
| 20 | 20 |
| 21 using ::testing::NiceMock; | 21 using ::testing::NiceMock; |
| 22 | 22 |
| 23 namespace webrtc { | 23 namespace webrtc { |
| 24 | 24 |
| 25 class MockVieEncoder : public ViEEncoder { | 25 class MockVideoStreamEncoder : public VideoStreamEncoder { |
| 26 public: | 26 public: |
| 27 explicit MockVieEncoder(SendStatisticsProxy* send_stats_proxy) | 27 explicit MockVideoStreamEncoder(SendStatisticsProxy* send_stats_proxy) |
| 28 : ViEEncoder(1, | 28 : VideoStreamEncoder(1, |
| 29 send_stats_proxy, | 29 send_stats_proxy, |
| 30 VideoSendStream::Config::EncoderSettings("fake", 0, nullptr), | 30 VideoSendStream::Config::EncoderSettings("fake", 0, |
| 31 nullptr, | 31 nullptr), |
| 32 nullptr, | 32 nullptr, |
| 33 std::unique_ptr<OveruseFrameDetector>()) {} | 33 nullptr, |
| 34 ~MockVieEncoder() { Stop(); } | 34 std::unique_ptr<OveruseFrameDetector>()) {} |
| 35 ~MockVideoStreamEncoder() { Stop(); } |
| 35 | 36 |
| 36 MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t)); | 37 MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t)); |
| 37 }; | 38 }; |
| 38 | 39 |
| 39 class VieKeyRequestTest : public ::testing::Test { | 40 class VieKeyRequestTest : public ::testing::Test { |
| 40 public: | 41 public: |
| 41 VieKeyRequestTest() | 42 VieKeyRequestTest() |
| 42 : simulated_clock_(123456789), | 43 : simulated_clock_(123456789), |
| 43 send_stats_proxy_(&simulated_clock_, | 44 send_stats_proxy_(&simulated_clock_, |
| 44 VideoSendStream::Config(nullptr), | 45 VideoSendStream::Config(nullptr), |
| 45 VideoEncoderConfig::ContentType::kRealtimeVideo), | 46 VideoEncoderConfig::ContentType::kRealtimeVideo), |
| 46 encoder_(&send_stats_proxy_), | 47 encoder_(&send_stats_proxy_), |
| 47 encoder_rtcp_feedback_( | 48 encoder_rtcp_feedback_( |
| 48 &simulated_clock_, | 49 &simulated_clock_, |
| 49 std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc), | 50 std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc), |
| 50 &encoder_) {} | 51 &encoder_) {} |
| 51 | 52 |
| 52 protected: | 53 protected: |
| 53 const uint32_t kSsrc = 1234; | 54 const uint32_t kSsrc = 1234; |
| 54 | 55 |
| 55 SimulatedClock simulated_clock_; | 56 SimulatedClock simulated_clock_; |
| 56 SendStatisticsProxy send_stats_proxy_; | 57 SendStatisticsProxy send_stats_proxy_; |
| 57 MockVieEncoder encoder_; | 58 MockVideoStreamEncoder encoder_; |
| 58 EncoderRtcpFeedback encoder_rtcp_feedback_; | 59 EncoderRtcpFeedback encoder_rtcp_feedback_; |
| 59 }; | 60 }; |
| 60 | 61 |
| 61 TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) { | 62 TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) { |
| 62 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); | 63 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); |
| 63 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 64 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
| 64 } | 65 } |
| 65 | 66 |
| 66 TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) { | 67 TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) { |
| 67 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); | 68 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); |
| 68 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 69 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
| 69 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 70 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
| 70 simulated_clock_.AdvanceTimeMilliseconds(10); | 71 simulated_clock_.AdvanceTimeMilliseconds(10); |
| 71 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 72 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
| 72 | 73 |
| 73 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); | 74 EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1); |
| 74 simulated_clock_.AdvanceTimeMilliseconds(300); | 75 simulated_clock_.AdvanceTimeMilliseconds(300); |
| 75 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 76 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
| 76 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 77 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
| 77 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); | 78 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
| 78 } | 79 } |
| 79 | 80 |
| 80 } // namespace webrtc | 81 } // namespace webrtc |
| OLD | NEW |