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.
|
|
|
|
|
*/
|
|
|
|
|
|
2016-10-06 08:35:11 -07:00
|
|
|
#include "webrtc/video/encoder_rtcp_feedback.h"
|
2012-09-06 08:19:40 +00:00
|
|
|
|
2016-09-30 22:29:43 -07:00
|
|
|
#include "webrtc/modules/utility/include/mock/mock_process_thread.h"
|
2016-09-28 17:42:01 -07:00
|
|
|
#include "webrtc/test/gmock.h"
|
|
|
|
|
#include "webrtc/test/gtest.h"
|
2015-12-09 12:13:30 +01:00
|
|
|
#include "webrtc/video/vie_encoder.h"
|
2012-09-06 08:19:40 +00:00
|
|
|
|
2014-05-28 07:00:51 +00:00
|
|
|
using ::testing::NiceMock;
|
2012-09-06 08:19:40 +00:00
|
|
|
|
2014-05-28 07:00:51 +00:00
|
|
|
namespace webrtc {
|
2014-05-27 14:12:58 +00:00
|
|
|
|
2012-09-06 08:19:40 +00:00
|
|
|
class MockVieEncoder : public ViEEncoder {
|
|
|
|
|
public:
|
2016-09-01 01:17:40 -07:00
|
|
|
MockVieEncoder()
|
|
|
|
|
: ViEEncoder(1,
|
|
|
|
|
nullptr,
|
|
|
|
|
VideoSendStream::Config::EncoderSettings("fake", 0, nullptr),
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr) {}
|
|
|
|
|
~MockVieEncoder() { Stop(); }
|
2012-09-06 08:19:40 +00:00
|
|
|
|
2016-05-04 11:26:51 -07:00
|
|
|
MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t));
|
|
|
|
|
MOCK_METHOD1(OnReceivedSLI, void(uint8_t picture_id));
|
|
|
|
|
MOCK_METHOD1(OnReceivedRPSI, void(uint64_t picture_id));
|
2012-09-06 08:19:40 +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),
|
2016-10-06 08:35:11 -07:00
|
|
|
encoder_rtcp_feedback_(
|
2016-05-04 11:26:51 -07:00
|
|
|
&simulated_clock_,
|
|
|
|
|
std::vector<uint32_t>(1, VieKeyRequestTest::kSsrc),
|
|
|
|
|
&encoder_) {}
|
2016-02-19 17:36:01 +01:00
|
|
|
|
2016-05-04 11:26:51 -07:00
|
|
|
protected:
|
|
|
|
|
const uint32_t kSsrc = 1234;
|
|
|
|
|
MockVieEncoder encoder_;
|
|
|
|
|
SimulatedClock simulated_clock_;
|
2016-10-06 08:35:11 -07: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) {
|
|
|
|
|
EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1);
|
2016-10-06 08:35:11 -07:00
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
2012-09-06 08:19:40 +00:00
|
|
|
|
|
|
|
|
const uint8_t sli_picture_id = 3;
|
2016-05-04 11:26:51 -07:00
|
|
|
EXPECT_CALL(encoder_, OnReceivedSLI(sli_picture_id)).Times(1);
|
2016-10-06 08:35:11 -07:00
|
|
|
encoder_rtcp_feedback_.OnReceivedSLI(kSsrc, sli_picture_id);
|
2012-09-06 08:19:40 +00:00
|
|
|
|
|
|
|
|
const uint64_t rpsi_picture_id = 9;
|
2016-05-04 11:26:51 -07:00
|
|
|
EXPECT_CALL(encoder_, OnReceivedRPSI(rpsi_picture_id)).Times(1);
|
2016-10-06 08:35:11 -07:00
|
|
|
encoder_rtcp_feedback_.OnReceivedRPSI(kSsrc, rpsi_picture_id);
|
2016-05-04 11:26:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST_F(VieKeyRequestTest, TooManyOnReceivedIntraFrameRequest) {
|
|
|
|
|
EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1);
|
2016-10-06 08:35:11 -07:00
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
|
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
2016-05-04 11:26:51 -07:00
|
|
|
simulated_clock_.AdvanceTimeMilliseconds(10);
|
2016-10-06 08:35:11 -07:00
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
2016-05-04 11:26:51 -07:00
|
|
|
|
|
|
|
|
EXPECT_CALL(encoder_, OnReceivedIntraFrameRequest(0)).Times(1);
|
|
|
|
|
simulated_clock_.AdvanceTimeMilliseconds(300);
|
2016-10-06 08:35:11 -07:00
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
|
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
|
|
|
|
encoder_rtcp_feedback_.OnReceivedIntraFrameRequest(kSsrc);
|
2012-09-06 08:19:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|