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
|
|
|
|
2017-06-15 04:21:07 -07:00
|
|
|
#include <memory>
|
|
|
|
|
|
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"
|
2017-02-13 04:41:45 -08:00
|
|
|
#include "webrtc/video/send_statistics_proxy.h"
|
2017-08-03 08:27:51 -07:00
|
|
|
#include "webrtc/video/video_stream_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
|
|
|
|
2017-08-03 08:27:51 -07:00
|
|
|
class MockVideoStreamEncoder : public VideoStreamEncoder {
|
2012-09-06 08:19:40 +00:00
|
|
|
public:
|
2017-08-03 08:27:51 -07:00
|
|
|
explicit MockVideoStreamEncoder(SendStatisticsProxy* send_stats_proxy)
|
|
|
|
|
: VideoStreamEncoder(1,
|
|
|
|
|
send_stats_proxy,
|
|
|
|
|
VideoSendStream::Config::EncoderSettings("fake", 0,
|
|
|
|
|
nullptr),
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
std::unique_ptr<OveruseFrameDetector>()) {}
|
|
|
|
|
~MockVideoStreamEncoder() { Stop(); }
|
2012-09-06 08:19:40 +00:00
|
|
|
|
2016-05-04 11:26:51 -07:00
|
|
|
MOCK_METHOD1(OnReceivedIntraFrameRequest, void(size_t));
|
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),
|
2017-02-13 04:41:45 -08:00
|
|
|
send_stats_proxy_(&simulated_clock_,
|
|
|
|
|
VideoSendStream::Config(nullptr),
|
|
|
|
|
VideoEncoderConfig::ContentType::kRealtimeVideo),
|
|
|
|
|
encoder_(&send_stats_proxy_),
|
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;
|
2017-02-13 04:41:45 -08:00
|
|
|
|
2016-05-04 11:26:51 -07:00
|
|
|
SimulatedClock simulated_clock_;
|
2017-02-13 04:41:45 -08:00
|
|
|
SendStatisticsProxy send_stats_proxy_;
|
2017-08-03 08:27:51 -07:00
|
|
|
MockVideoStreamEncoder encoder_;
|
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);
|
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
|