blob: f1ac65d48fc858f164e4ab5c53a1f279a848cb08 [file] [log] [blame]
mflodman@webrtc.org3be58632012-09-06 08:19:401/*
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 Alon14d1c9d2019-04-08 12:16:1711#include "video/encoder_rtcp_feedback.h"
mflodman@webrtc.org3be58632012-09-06 08:19:4012
sprangfda496a2017-06-15 11:21:0713#include <memory>
14
Mirko Bonadei92ea95e2017-09-15 04:47:3115#include "test/gmock.h"
16#include "test/gtest.h"
Sebastian Jansson652dc912018-04-19 15:09:1517#include "video/test/mock_video_stream_encoder.h"
mflodman@webrtc.org3be58632012-09-06 08:19:4018
Philipp Hanckea1b4eb22022-11-04 13:45:2319using ::testing::_;
20
wuchengli@chromium.org637c55f2014-05-28 07:00:5121namespace webrtc {
wuchengli@chromium.org89e8ffb2014-05-27 14:12:5822
perkj600246e2016-05-04 18:26:5123class VieKeyRequestTest : public ::testing::Test {
24 public:
25 VieKeyRequestTest()
perkj26091b12016-09-01 08:17:4026 : simulated_clock_(123456789),
Sebastian Jansson652dc912018-04-19 15:09:1527 encoder_(),
Elad Alon14d1c9d2019-04-08 12:16:1728 encoder_rtcp_feedback_(
perkj600246e2016-05-04 18:26:5129 &simulated_clock_,
30 std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc),
Tommi28e96532021-06-03 09:52:1531 &encoder_,
32 nullptr) {}
mflodman@webrtc.org3be58632012-09-06 08:19:4033
perkj600246e2016-05-04 18:26:5134 protected:
35 const uint32_t kSsrc = 1234;
sprang552c7c72017-02-13 12:41:4536
perkj600246e2016-05-04 18:26:5137 SimulatedClock simulated_clock_;
Mirko Bonadei6a489f22019-04-09 13:11:1238 ::testing::StrictMock<MockVideoStreamEncoder> encoder_;
Elad Alon14d1c9d2019-04-08 12:16:1739 EncoderRtcpFeedback encoder_rtcp_feedback_;
perkj600246e2016-05-04 18:26:5140};
mflodman@webrtc.org3be58632012-09-06 08:19:4041
perkj600246e2016-05-04 18:26:5142TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) {
Philipp Hanckea1b4eb22022-11-04 13:45:2343 EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
Elad Alon14d1c9d2019-04-08 12:16:1744 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
perkj600246e2016-05-04 18:26:5145}
46
47TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) {
Philipp Hanckea1b4eb22022-11-04 13:45:2348 EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
Elad Alon14d1c9d2019-04-08 12:16:1749 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
50 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
perkj600246e2016-05-04 18:26:5151 simulated_clock_.AdvanceTimeMilliseconds(10);
Elad Alon14d1c9d2019-04-08 12:16:1752 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
perkj600246e2016-05-04 18:26:5153
Philipp Hanckea1b4eb22022-11-04 13:45:2354 EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
perkj600246e2016-05-04 18:26:5155 simulated_clock_.AdvanceTimeMilliseconds(300);
Elad Alon14d1c9d2019-04-08 12:16:1756 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
57 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
58 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
Niels Möllerfa89d842019-01-30 15:33:4559}
60
mflodman@webrtc.org3be58632012-09-06 08:19:4061} // namespace webrtc