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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This file includes unit tests for EncoderStateFeedback.
|
2015-12-09 12:13:30 +01:00
|
|
|
#include "webrtc/video/encoder_state_feedback.h"
|
2012-09-06 08:19:40 +00:00
|
|
|
|
2013-05-17 13:44:48 +00:00
|
|
|
#include "testing/gmock/include/gmock/gmock.h"
|
|
|
|
|
#include "testing/gtest/include/gtest/gtest.h"
|
2012-09-06 08:19:40 +00:00
|
|
|
|
2015-09-15 15:08:03 +02:00
|
|
|
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
|
2015-11-16 11:12:24 +01:00
|
|
|
#include "webrtc/modules/pacing/paced_sender.h"
|
|
|
|
|
#include "webrtc/modules/pacing/packet_router.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/utility/include/mock/mock_process_thread.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:
|
2015-03-26 11:11:06 +01:00
|
|
|
explicit MockVieEncoder(ProcessThread* process_thread, PacedSender* pacer)
|
2016-02-05 11:13:28 +01:00
|
|
|
: ViEEncoder(1,
|
|
|
|
|
process_thread,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
nullptr,
|
|
|
|
|
pacer,
|
2016-02-05 11:25:46 +01:00
|
|
|
nullptr,
|
2016-02-05 11:13:28 +01:00
|
|
|
nullptr) {}
|
2012-09-06 08:19:40 +00:00
|
|
|
~MockVieEncoder() {}
|
|
|
|
|
|
|
|
|
|
MOCK_METHOD1(OnReceivedIntraFrameRequest,
|
|
|
|
|
void(uint32_t));
|
|
|
|
|
MOCK_METHOD2(OnReceivedSLI,
|
|
|
|
|
void(uint32_t ssrc, uint8_t picture_id));
|
|
|
|
|
MOCK_METHOD2(OnReceivedRPSI,
|
|
|
|
|
void(uint32_t ssrc, uint64_t picture_id));
|
2012-10-05 16:17:41 +00:00
|
|
|
MOCK_METHOD2(OnLocalSsrcChanged,
|
|
|
|
|
void(uint32_t old_ssrc, uint32_t new_ssrc));
|
2012-09-06 08:19:40 +00:00
|
|
|
};
|
|
|
|
|
|
2016-02-19 17:36:01 +01:00
|
|
|
TEST(VieKeyRequestTest, CreateAndTriggerRequests) {
|
|
|
|
|
static const uint32_t kSsrc = 1234;
|
|
|
|
|
NiceMock<MockProcessThread> process_thread;
|
|
|
|
|
PacketRouter router;
|
|
|
|
|
PacedSender pacer(Clock::GetRealTimeClock(), &router,
|
|
|
|
|
BitrateController::kDefaultStartBitrateKbps,
|
|
|
|
|
PacedSender::kDefaultPaceMultiplier *
|
|
|
|
|
BitrateController::kDefaultStartBitrateKbps,
|
|
|
|
|
0);
|
|
|
|
|
MockVieEncoder encoder(&process_thread, &pacer);
|
|
|
|
|
|
|
|
|
|
EncoderStateFeedback encoder_state_feedback;
|
|
|
|
|
encoder_state_feedback.Init(std::vector<uint32_t>(1, kSsrc), &encoder);
|
|
|
|
|
|
|
|
|
|
EXPECT_CALL(encoder, OnReceivedIntraFrameRequest(kSsrc))
|
2012-09-06 08:19:40 +00:00
|
|
|
.Times(1);
|
2016-02-19 17:36:01 +01:00
|
|
|
encoder_state_feedback.OnReceivedIntraFrameRequest(kSsrc);
|
2012-09-06 08:19:40 +00:00
|
|
|
|
|
|
|
|
const uint8_t sli_picture_id = 3;
|
2016-02-19 17:36:01 +01:00
|
|
|
EXPECT_CALL(encoder, OnReceivedSLI(kSsrc, sli_picture_id))
|
2012-09-06 08:19:40 +00:00
|
|
|
.Times(1);
|
2016-02-19 17:36:01 +01:00
|
|
|
encoder_state_feedback.OnReceivedSLI(kSsrc, sli_picture_id);
|
2012-09-06 08:19:40 +00:00
|
|
|
|
|
|
|
|
const uint64_t rpsi_picture_id = 9;
|
2016-02-19 17:36:01 +01:00
|
|
|
EXPECT_CALL(encoder, OnReceivedRPSI(kSsrc, rpsi_picture_id))
|
2012-09-06 08:19:40 +00:00
|
|
|
.Times(1);
|
2016-02-19 17:36:01 +01:00
|
|
|
encoder_state_feedback.OnReceivedRPSI(kSsrc, rpsi_picture_id);
|
2012-09-06 08:19:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|