2012-09-06 08:19:40 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-04-08 14:16:17 +02:00
|
|
|
#include "video/encoder_rtcp_feedback.h"
|
2012-09-06 08:19:40 +00:00
|
|
|
|
2017-06-15 04:21:07 -07:00
|
|
|
#include <memory>
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "test/gmock.h"
|
|
|
|
|
#include "test/gtest.h"
|
2018-04-19 17:09:15 +02:00
|
|
|
#include "video/test/mock_video_stream_encoder.h"
|
2012-09-06 08:19:40 +00:00
|
|
|
|
2022-11-04 14:45:23 +01:00
|
|
|
using ::testing::_;
|
|
|
|
|
|
2014-05-28 07:00:51 +00:00
|
|
|
namespace webrtc {
|
2014-05-27 14:12:58 +00:00
|
|
|
|
2016-05-04 11:26:51 -07:00
|
|
|
class VieKeyRequestTest : public ::testing::Test {
|
|
|
|
|
public:
|
|
|
|
|
VieKeyRequestTest()
|
2016-09-01 01:17:40 -07:00
|
|
|
: simulated_clock_(123456789),
|
2018-04-19 17:09:15 +02:00
|
|
|
encoder_(),
|
2019-04-08 14:16:17 +02:00
|
|
|
encoder_rtcp_feedback_(
|
2016-05-04 11:26:51 -07:00
|
|
|
&simulated_clock_,
|
|
|
|
|
std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc),
|
2021-06-03 11:52:15 +02:00
|
|
|
&encoder_,
|
|
|
|
|
nullptr) {}
|
2016-02-19 17:36:01 +01:00
|
|
|
|
2016-05-04 11:26:51 -07:00
|
|
|
protected:
|
|
|
|
|
const uint32_t kSsrc = 1234;
|
2017-02-13 04:41:45 -08:00
|
|
|
|
2016-05-04 11:26:51 -07:00
|
|
|
SimulatedClock simulated_clock_;
|
2019-04-09 15:11:12 +02:00
|
|
|
::testing::StrictMock<MockVideoStreamEncoder> encoder_;
|
2019-04-08 14:16:17 +02:00
|
|
|
EncoderRtcpFeedback encoder_rtcp_feedback_;
|
2016-05-04 11:26:51 -07:00
|
|
|
};
|
2016-02-19 17:36:01 +01:00
|
|
|
|
2016-05-04 11:26:51 -07:00
|
|
|
TEST_F(VieKeyRequestTest, CreateAndTriggerRequests) {
|
2022-11-04 14:45:23 +01:00
|
|
|
EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
|
2019-04-08 14:16:17 +02:00
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
2016-05-04 11:26:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) {
|
2022-11-04 14:45:23 +01:00
|
|
|
EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
|
2019-04-08 14:16:17 +02:00
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
|
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
2016-05-04 11:26:51 -07:00
|
|
|
simulated_clock_.AdvanceTimeMilliseconds(10);
|
2019-04-08 14:16:17 +02:00
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
2016-05-04 11:26:51 -07:00
|
|
|
|
2022-11-04 14:45:23 +01:00
|
|
|
EXPECT_CALL(encoder_, SendKeyFrame(_)).Times(1);
|
2016-05-04 11:26:51 -07:00
|
|
|
simulated_clock_.AdvanceTimeMilliseconds(300);
|
2019-04-08 14:16:17 +02:00
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
|
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
|
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
2019-01-30 16:33:45 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-06 08:19:40 +00:00
|
|
|
} // namespace webrtc
|