blob: f1ac65d48fc858f164e4ab5c53a1f279a848cb08 [file] [log] [blame]
mflodman@webrtc.org3be58632012-09-06 08:19:40 +00001/*
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 14:16:17 +020011#include "video/encoder_rtcp_feedback.h"
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000012
sprangfda496a2017-06-15 04:21:07 -070013#include <memory>
14
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020015#include "test/gmock.h"
16#include "test/gtest.h"
Sebastian Jansson652dc912018-04-19 17:09:15 +020017#include "video/test/mock_video_stream_encoder.h"
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000018
Philipp Hanckea1b4eb22022-11-04 14:45:23 +010019using ::testing::_;
20
wuchengli@chromium.org637c55f2014-05-28 07:00:51 +000021namespace webrtc {
wuchengli@chromium.org89e8ffb2014-05-27 14:12:58 +000022
perkj600246e2016-05-04 11:26:51 -070023class VieKeyRequestTest : public ::testing::Test {
24 public:
25 VieKeyRequestTest()
perkj26091b12016-09-01 01:17:40 -070026 : simulated_clock_(123456789),
Sebastian Jansson652dc912018-04-19 17:09:15 +020027 encoder_(),
Elad Alon14d1c9d2019-04-08 14:16:17 +020028 encoder_rtcp_feedback_(
perkj600246e2016-05-04 11:26:51 -070029 &simulated_clock_,
30 std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc),
Tommi28e96532021-06-03 11:52:15 +020031 &encoder_,
32 nullptr) {}
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000033
perkj600246e2016-05-04 11:26:51 -070034 protected:
35 const uint32_t kSsrc = 1234;
sprang552c7c72017-02-13 04:41:45 -080036
perkj600246e2016-05-04 11:26:51 -070037 SimulatedClock simulated_clock_;
Mirko Bonadei6a489f22019-04-09 15:11:12 +020038 ::testing::StrictMock<MockVideoStreamEncoder> encoder_;
Elad Alon14d1c9d2019-04-08 14:16:17 +020039 EncoderRtcpFeedback encoder_rtcp_feedback_;
perkj600246e2016-05-04 11:26:51 -070040};
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000041
perkj600246e2016-05-04 11:26:51 -070042TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) {
Philipp Hanckea1b4eb22022-11-04 14:45:23 +010043 EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
Elad Alon14d1c9d2019-04-08 14:16:17 +020044 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
perkj600246e2016-05-04 11:26:51 -070045}
46
47TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) {
Philipp Hanckea1b4eb22022-11-04 14:45:23 +010048 EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
Elad Alon14d1c9d2019-04-08 14:16:17 +020049 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
50 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
perkj600246e2016-05-04 11:26:51 -070051 simulated_clock_.AdvanceTimeMilliseconds(10);
Elad Alon14d1c9d2019-04-08 14:16:17 +020052 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
perkj600246e2016-05-04 11:26:51 -070053
Philipp Hanckea1b4eb22022-11-04 14:45:23 +010054 EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
perkj600246e2016-05-04 11:26:51 -070055 simulated_clock_.AdvanceTimeMilliseconds(300);
Elad Alon14d1c9d2019-04-08 14:16:17 +020056 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
57 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
58 encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
Niels Möllerfa89d842019-01-30 16:33:45 +010059}
60
mflodman@webrtc.org3be58632012-09-06 08:19:40 +000061} // namespace webrtc