mflodman@webrtc.org | 3be5863 | 2012-09-06 08:19:40 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Elad Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 11 | #include "video/encoder_rtcp_feedback.h" |
mflodman@webrtc.org | 3be5863 | 2012-09-06 08:19:40 | [diff] [blame] | 12 | |
sprang | fda496a | 2017-06-15 11:21:07 | [diff] [blame] | 13 | #include <memory> |
| 14 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 15 | #include "test/gmock.h" |
| 16 | #include "test/gtest.h" |
Sebastian Jansson | 652dc91 | 2018-04-19 15:09:15 | [diff] [blame] | 17 | #include "video/test/mock_video_stream_encoder.h" |
mflodman@webrtc.org | 3be5863 | 2012-09-06 08:19:40 | [diff] [blame] | 18 | |
Philipp Hancke | a1b4eb2 | 2022-11-04 13:45:23 | [diff] [blame] | 19 | using ::testing::_; |
| 20 | |
wuchengli@chromium.org | 637c55f | 2014-05-28 07:00:51 | [diff] [blame] | 21 | namespace webrtc { |
wuchengli@chromium.org | 89e8ffb | 2014-05-27 14:12:58 | [diff] [blame] | 22 | |
perkj | 600246e | 2016-05-04 18:26:51 | [diff] [blame] | 23 | class VieKeyRequestTest : public ::testing::Test { |
| 24 | public: |
| 25 | VieKeyRequestTest() |
perkj | 26091b1 | 2016-09-01 08:17:40 | [diff] [blame] | 26 | : simulated_clock_(123456789), |
Sebastian Jansson | 652dc91 | 2018-04-19 15:09:15 | [diff] [blame] | 27 | encoder_(), |
Elad Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 28 | encoder_rtcp_feedback_( |
perkj | 600246e | 2016-05-04 18:26:51 | [diff] [blame] | 29 | &simulated_clock_, |
| 30 | std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc), |
Tommi | 28e9653 | 2021-06-03 09:52:15 | [diff] [blame] | 31 | &encoder_, |
| 32 | nullptr) {} |
mflodman@webrtc.org | 3be5863 | 2012-09-06 08:19:40 | [diff] [blame] | 33 | |
perkj | 600246e | 2016-05-04 18:26:51 | [diff] [blame] | 34 | protected: |
| 35 | const uint32_t kSsrc = 1234; |
sprang | 552c7c7 | 2017-02-13 12:41:45 | [diff] [blame] | 36 | |
perkj | 600246e | 2016-05-04 18:26:51 | [diff] [blame] | 37 | SimulatedClock simulated_clock_; |
Mirko Bonadei | 6a489f2 | 2019-04-09 13:11:12 | [diff] [blame] | 38 | ::testing::StrictMock<MockVideoStreamEncoder> encoder_; |
Elad Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 39 | EncoderRtcpFeedback encoder_rtcp_feedback_; |
perkj | 600246e | 2016-05-04 18:26:51 | [diff] [blame] | 40 | }; |
mflodman@webrtc.org | 3be5863 | 2012-09-06 08:19:40 | [diff] [blame] | 41 | |
perkj | 600246e | 2016-05-04 18:26:51 | [diff] [blame] | 42 | TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) { |
Philipp Hancke | a1b4eb2 | 2022-11-04 13:45:23 | [diff] [blame] | 43 | EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1); |
Elad Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 44 | encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
perkj | 600246e | 2016-05-04 18:26:51 | [diff] [blame] | 45 | } |
| 46 | |
| 47 | TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) { |
Philipp Hancke | a1b4eb2 | 2022-11-04 13:45:23 | [diff] [blame] | 48 | EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1); |
Elad Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 49 | encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
| 50 | encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
perkj | 600246e | 2016-05-04 18:26:51 | [diff] [blame] | 51 | simulated_clock_.AdvanceTimeMilliseconds(10); |
Elad Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 52 | encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
perkj | 600246e | 2016-05-04 18:26:51 | [diff] [blame] | 53 | |
Philipp Hancke | a1b4eb2 | 2022-11-04 13:45:23 | [diff] [blame] | 54 | EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1); |
perkj | 600246e | 2016-05-04 18:26:51 | [diff] [blame] | 55 | simulated_clock_.AdvanceTimeMilliseconds(300); |
Elad Alon | 14d1c9d | 2019-04-08 12:16:17 | [diff] [blame] | 56 | encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
| 57 | encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
| 58 | encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc); |
Niels Möller | fa89d84 | 2019-01-30 15:33:45 | [diff] [blame] | 59 | } |
| 60 | |
mflodman@webrtc.org | 3be5863 | 2012-09-06 08:19:40 | [diff] [blame] | 61 | } // namespace webrtc |