Delete old CongestionController class
Replaced by ReceiveSideCongestionController and SendSideCongestionController. Bug: webrtc:6847 Change-Id: I79caa019c883f8f716d0dd52d56bbdc2f8df0ded Reviewed-on: https://chromium-review.googlesource.com/616763 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Stefan Holmer <stefan@webrtc.org> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Cr-Commit-Position: refs/heads/master@{#19423}
This commit is contained in:
parent
c2d4d57755
commit
245f17e344
@ -14,10 +14,8 @@ rtc_static_library("congestion_controller") {
|
||||
"acknowledged_bitrate_estimator.h",
|
||||
"bitrate_estimator.cc",
|
||||
"bitrate_estimator.h",
|
||||
"congestion_controller.cc",
|
||||
"delay_based_bwe.cc",
|
||||
"delay_based_bwe.h",
|
||||
"include/congestion_controller.h",
|
||||
"include/receive_side_congestion_controller.h",
|
||||
"include/send_side_congestion_controller.h",
|
||||
"median_slope_estimator.cc",
|
||||
@ -76,7 +74,6 @@ if (rtc_include_tests) {
|
||||
}
|
||||
sources = [
|
||||
"acknowledged_bitrate_estimator_unittest.cc",
|
||||
"congestion_controller_unittest.cc",
|
||||
"congestion_controller_unittests_helper.cc",
|
||||
"congestion_controller_unittests_helper.h",
|
||||
"delay_based_bwe_unittest.cc",
|
||||
@ -85,6 +82,8 @@ if (rtc_include_tests) {
|
||||
"median_slope_estimator_unittest.cc",
|
||||
"probe_bitrate_estimator_unittest.cc",
|
||||
"probe_controller_unittest.cc",
|
||||
"receive_side_congestion_controller_unittest.cc",
|
||||
"send_side_congestion_controller_unittest.cc",
|
||||
"transport_feedback_adapter_unittest.cc",
|
||||
"trendline_estimator_unittest.cc",
|
||||
]
|
||||
@ -99,7 +98,6 @@ if (rtc_include_tests) {
|
||||
"../../test:test_support",
|
||||
"../bitrate_controller:bitrate_controller",
|
||||
"../pacing:pacing",
|
||||
"../remote_bitrate_estimator:mock_remote_bitrate_observer",
|
||||
"../remote_bitrate_estimator:remote_bitrate_estimator",
|
||||
"../rtp_rtcp:rtp_rtcp",
|
||||
"//testing/gmock",
|
||||
|
||||
@ -1,126 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
|
||||
#include "webrtc/modules/congestion_controller/probe_controller.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_single_stream.h"
|
||||
#include "webrtc/rtc_base/checks.h"
|
||||
#include "webrtc/rtc_base/logging.h"
|
||||
#include "webrtc/rtc_base/rate_limiter.h"
|
||||
#include "webrtc/rtc_base/socket.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
void CongestionController::OnReceivedPacket(int64_t arrival_time_ms,
|
||||
size_t payload_size,
|
||||
const RTPHeader& header) {
|
||||
receive_side_cc_.OnReceivedPacket(arrival_time_ms, payload_size, header);
|
||||
}
|
||||
|
||||
void CongestionController::SetBweBitrates(int min_bitrate_bps,
|
||||
int start_bitrate_bps,
|
||||
int max_bitrate_bps) {
|
||||
send_side_cc_.SetBweBitrates(min_bitrate_bps, start_bitrate_bps,
|
||||
max_bitrate_bps);
|
||||
}
|
||||
|
||||
// TODO(holmer): Split this up and use SetBweBitrates in combination with
|
||||
// OnNetworkRouteChanged.
|
||||
void CongestionController::OnNetworkRouteChanged(
|
||||
const rtc::NetworkRoute& network_route,
|
||||
int bitrate_bps,
|
||||
int min_bitrate_bps,
|
||||
int max_bitrate_bps) {
|
||||
send_side_cc_.OnNetworkRouteChanged(network_route, bitrate_bps,
|
||||
min_bitrate_bps, max_bitrate_bps);
|
||||
}
|
||||
|
||||
BitrateController* CongestionController::GetBitrateController() const {
|
||||
return send_side_cc_.GetBitrateController();
|
||||
}
|
||||
|
||||
RemoteBitrateEstimator* CongestionController::GetRemoteBitrateEstimator(
|
||||
bool send_side_bwe) {
|
||||
return receive_side_cc_.GetRemoteBitrateEstimator(send_side_bwe);
|
||||
}
|
||||
|
||||
RateLimiter* CongestionController::GetRetransmissionRateLimiter() {
|
||||
return send_side_cc_.GetRetransmissionRateLimiter();
|
||||
}
|
||||
|
||||
void CongestionController::EnablePeriodicAlrProbing(bool enable) {
|
||||
send_side_cc_.EnablePeriodicAlrProbing(enable);
|
||||
}
|
||||
|
||||
void CongestionController::SetAllocatedSendBitrateLimits(
|
||||
int min_send_bitrate_bps,
|
||||
int max_padding_bitrate_bps) {
|
||||
send_side_cc_.SetAllocatedSendBitrateLimits(min_send_bitrate_bps,
|
||||
max_padding_bitrate_bps);
|
||||
}
|
||||
|
||||
int64_t CongestionController::GetPacerQueuingDelayMs() const {
|
||||
return send_side_cc_.GetPacerQueuingDelayMs();
|
||||
}
|
||||
|
||||
void CongestionController::SignalNetworkState(NetworkState state) {
|
||||
send_side_cc_.SignalNetworkState(state);
|
||||
}
|
||||
|
||||
void CongestionController::SetTransportOverhead(
|
||||
size_t transport_overhead_bytes_per_packet) {
|
||||
send_side_cc_.SetTransportOverhead(transport_overhead_bytes_per_packet);
|
||||
}
|
||||
|
||||
void CongestionController::OnSentPacket(const rtc::SentPacket& sent_packet) {
|
||||
send_side_cc_.OnSentPacket(sent_packet);
|
||||
}
|
||||
|
||||
void CongestionController::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
|
||||
receive_side_cc_.OnRttUpdate(avg_rtt_ms, max_rtt_ms);
|
||||
send_side_cc_.OnRttUpdate(avg_rtt_ms, max_rtt_ms);
|
||||
}
|
||||
|
||||
int64_t CongestionController::TimeUntilNextProcess() {
|
||||
return std::min(send_side_cc_.TimeUntilNextProcess(),
|
||||
receive_side_cc_.TimeUntilNextProcess());
|
||||
}
|
||||
|
||||
void CongestionController::Process() {
|
||||
send_side_cc_.Process();
|
||||
receive_side_cc_.Process();
|
||||
}
|
||||
|
||||
void CongestionController::AddPacket(uint32_t ssrc,
|
||||
uint16_t sequence_number,
|
||||
size_t length,
|
||||
const PacedPacketInfo& pacing_info) {
|
||||
send_side_cc_.AddPacket(ssrc, sequence_number, length, pacing_info);
|
||||
}
|
||||
|
||||
void CongestionController::OnTransportFeedback(
|
||||
const rtcp::TransportFeedback& feedback) {
|
||||
send_side_cc_.OnTransportFeedback(feedback);
|
||||
}
|
||||
|
||||
std::vector<PacketFeedback> CongestionController::GetTransportFeedbackVector()
|
||||
const {
|
||||
return send_side_cc_.GetTransportFeedbackVector();
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
@ -15,7 +15,6 @@
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
||||
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
|
||||
#include "webrtc/modules/pacing/paced_sender.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h"
|
||||
|
||||
@ -1,141 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_
|
||||
#define WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_
|
||||
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/common_types.h"
|
||||
#include "webrtc/modules/congestion_controller/delay_based_bwe.h"
|
||||
#include "webrtc/modules/congestion_controller/include/receive_side_congestion_controller.h"
|
||||
#include "webrtc/modules/congestion_controller/include/send_side_congestion_controller.h"
|
||||
#include "webrtc/modules/congestion_controller/transport_feedback_adapter.h"
|
||||
#include "webrtc/modules/include/module.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/modules/pacing/paced_sender.h"
|
||||
#include "webrtc/modules/pacing/packet_router.h"
|
||||
#include "webrtc/rtc_base/constructormagic.h"
|
||||
#include "webrtc/rtc_base/criticalsection.h"
|
||||
#include "webrtc/rtc_base/networkroute.h"
|
||||
#include "webrtc/rtc_base/thread_checker.h"
|
||||
|
||||
namespace rtc {
|
||||
struct SentPacket;
|
||||
}
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class BitrateController;
|
||||
class Clock;
|
||||
class ProbeController;
|
||||
class RateLimiter;
|
||||
class RemoteBitrateEstimator;
|
||||
class RemoteBitrateObserver;
|
||||
class RtcEventLog;
|
||||
|
||||
class CongestionController : public CallStatsObserver,
|
||||
public Module,
|
||||
public TransportFeedbackObserver {
|
||||
public:
|
||||
using Observer = SendSideCongestionController::Observer;
|
||||
|
||||
CongestionController(const Clock* clock,
|
||||
Observer* observer,
|
||||
RemoteBitrateObserver* /* remote_bitrate_observer */,
|
||||
RtcEventLog* event_log,
|
||||
PacketRouter* packet_router)
|
||||
: send_side_cc_(clock, observer, event_log, packet_router),
|
||||
receive_side_cc_(clock, packet_router) {}
|
||||
CongestionController(const Clock* clock,
|
||||
Observer* observer,
|
||||
RemoteBitrateObserver* /* remote_bitrate_observer */,
|
||||
RtcEventLog* event_log,
|
||||
PacketRouter* packet_router,
|
||||
std::unique_ptr<PacedSender> pacer)
|
||||
: send_side_cc_(clock, observer, event_log, std::move(pacer)),
|
||||
receive_side_cc_(clock, packet_router) {}
|
||||
|
||||
virtual ~CongestionController() {}
|
||||
|
||||
virtual void OnReceivedPacket(int64_t arrival_time_ms,
|
||||
size_t payload_size,
|
||||
const RTPHeader& header);
|
||||
|
||||
virtual void SetBweBitrates(int min_bitrate_bps,
|
||||
int start_bitrate_bps,
|
||||
int max_bitrate_bps);
|
||||
// Resets both the BWE state and the bitrate estimator. Note the first
|
||||
// argument is the bitrate_bps.
|
||||
virtual void OnNetworkRouteChanged(const rtc::NetworkRoute& network_route,
|
||||
int bitrate_bps,
|
||||
int min_bitrate_bps,
|
||||
int max_bitrate_bps);
|
||||
virtual void SignalNetworkState(NetworkState state);
|
||||
virtual void SetTransportOverhead(size_t transport_overhead_bytes_per_packet);
|
||||
|
||||
virtual BitrateController* GetBitrateController() const;
|
||||
virtual RemoteBitrateEstimator* GetRemoteBitrateEstimator(
|
||||
bool send_side_bwe);
|
||||
virtual int64_t GetPacerQueuingDelayMs() const;
|
||||
// TODO(nisse): Delete this accessor function. The pacer should be
|
||||
// internal to the congestion controller. Currently needed by Call,
|
||||
// to register the pacer module on the right thread.
|
||||
virtual PacedSender* pacer() { return send_side_cc_.pacer(); }
|
||||
// TODO(nisse): Delete this method, as soon as downstream projects
|
||||
// are updated.
|
||||
virtual TransportFeedbackObserver* GetTransportFeedbackObserver() {
|
||||
return this;
|
||||
}
|
||||
RateLimiter* GetRetransmissionRateLimiter();
|
||||
void EnablePeriodicAlrProbing(bool enable);
|
||||
|
||||
// SetAllocatedSendBitrateLimits sets bitrates limits imposed by send codec
|
||||
// settings.
|
||||
// |min_send_bitrate_bps| is the total minimum send bitrate required by all
|
||||
// sending streams. This is the minimum bitrate the PacedSender will use.
|
||||
// Note that CongestionController::OnNetworkChanged can still be called with
|
||||
// a lower bitrate estimate.
|
||||
// |max_padding_bitrate_bps| is the max bitrate the send streams request for
|
||||
// padding. This can be higher than the current network estimate and tells
|
||||
// the PacedSender how much it should max pad unless there is real packets to
|
||||
// send.
|
||||
void SetAllocatedSendBitrateLimits(int min_send_bitrate_bps,
|
||||
int max_padding_bitrate_bps);
|
||||
|
||||
virtual void OnSentPacket(const rtc::SentPacket& sent_packet);
|
||||
|
||||
// Implements CallStatsObserver.
|
||||
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
|
||||
|
||||
// Implements Module.
|
||||
int64_t TimeUntilNextProcess() override;
|
||||
void Process() override;
|
||||
|
||||
// Implements TransportFeedbackObserver.
|
||||
void AddPacket(uint32_t ssrc,
|
||||
uint16_t sequence_number,
|
||||
size_t length,
|
||||
const PacedPacketInfo& pacing_info) override;
|
||||
void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override;
|
||||
std::vector<PacketFeedback> GetTransportFeedbackVector() const override;
|
||||
|
||||
private:
|
||||
SendSideCongestionController send_side_cc_;
|
||||
ReceiveSideCongestionController receive_side_cc_;
|
||||
|
||||
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(CongestionController);
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_CONGESTION_CONTROLLER_H_
|
||||
@ -11,13 +11,13 @@
|
||||
#ifndef WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_MOCK_MOCK_CONGESTION_OBSERVER_H_
|
||||
#define WEBRTC_MODULES_CONGESTION_CONTROLLER_INCLUDE_MOCK_MOCK_CONGESTION_OBSERVER_H_
|
||||
|
||||
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
|
||||
#include "webrtc/modules/congestion_controller/include/send_side_congestion_controller.h"
|
||||
#include "webrtc/test/gmock.h"
|
||||
|
||||
namespace webrtc {
|
||||
namespace test {
|
||||
|
||||
class MockCongestionObserver : public CongestionController::Observer {
|
||||
class MockCongestionObserver : public SendSideCongestionController::Observer {
|
||||
public:
|
||||
MOCK_METHOD4(OnNetworkChanged,
|
||||
void(uint32_t bitrate_bps,
|
||||
|
||||
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2016 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.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/congestion_controller/include/receive_side_congestion_controller.h"
|
||||
#include "webrtc/modules/pacing/packet_router.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/test/gmock.h"
|
||||
#include "webrtc/test/gtest.h"
|
||||
|
||||
using testing::_;
|
||||
using testing::AtLeast;
|
||||
using testing::NiceMock;
|
||||
using testing::Return;
|
||||
using testing::SaveArg;
|
||||
using testing::StrictMock;
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
namespace {
|
||||
|
||||
// Helper to convert some time format to resolution used in absolute send time
|
||||
// header extension, rounded upwards. |t| is the time to convert, in some
|
||||
// resolution. |denom| is the value to divide |t| by to get whole seconds,
|
||||
// e.g. |denom| = 1000 if |t| is in milliseconds.
|
||||
uint32_t AbsSendTime(int64_t t, int64_t denom) {
|
||||
return (((t << 18) + (denom >> 1)) / denom) & 0x00fffffful;
|
||||
}
|
||||
|
||||
class MockPacketRouter : public PacketRouter {
|
||||
public:
|
||||
MOCK_METHOD2(OnReceiveBitrateChanged,
|
||||
void(const std::vector<uint32_t>& ssrcs, uint32_t bitrate));
|
||||
};
|
||||
|
||||
const uint32_t kInitialBitrateBps = 60000;
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace test {
|
||||
|
||||
TEST(ReceiveSideCongestionControllerTest, OnReceivedPacketWithAbsSendTime) {
|
||||
StrictMock<MockPacketRouter> packet_router;
|
||||
SimulatedClock clock_(123456);
|
||||
|
||||
ReceiveSideCongestionController controller(&clock_, &packet_router);
|
||||
|
||||
size_t payload_size = 1000;
|
||||
RTPHeader header;
|
||||
header.ssrc = 0x11eb21c;
|
||||
header.extension.hasAbsoluteSendTime = true;
|
||||
|
||||
std::vector<unsigned int> ssrcs;
|
||||
EXPECT_CALL(packet_router, OnReceiveBitrateChanged(_, _))
|
||||
.WillRepeatedly(SaveArg<0>(&ssrcs));
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
clock_.AdvanceTimeMilliseconds((1000 * payload_size) / kInitialBitrateBps);
|
||||
int64_t now_ms = clock_.TimeInMilliseconds();
|
||||
header.extension.absoluteSendTime = AbsSendTime(now_ms, 1000);
|
||||
controller.OnReceivedPacket(now_ms, payload_size, header);
|
||||
}
|
||||
|
||||
ASSERT_EQ(1u, ssrcs.size());
|
||||
EXPECT_EQ(header.ssrc, ssrcs[0]);
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
} // namespace webrtc
|
||||
@ -8,14 +8,13 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
|
||||
#include "webrtc/modules/congestion_controller/include/send_side_congestion_controller.h"
|
||||
#include "webrtc/logging/rtc_event_log/mock/mock_rtc_event_log.h"
|
||||
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
|
||||
#include "webrtc/modules/congestion_controller/congestion_controller_unittests_helper.h"
|
||||
#include "webrtc/modules/congestion_controller/include/mock/mock_congestion_observer.h"
|
||||
#include "webrtc/modules/pacing/mock/mock_paced_sender.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/mock/mock_remote_bitrate_observer.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_packet/transport_feedback.h"
|
||||
#include "webrtc/rtc_base/socket.h"
|
||||
@ -36,19 +35,10 @@ namespace {
|
||||
const webrtc::PacedPacketInfo kPacingInfo0(0, 5, 2000);
|
||||
const webrtc::PacedPacketInfo kPacingInfo1(1, 8, 4000);
|
||||
|
||||
// Helper to convert some time format to resolution used in absolute send time
|
||||
// header extension, rounded upwards. |t| is the time to convert, in some
|
||||
// resolution. |denom| is the value to divide |t| by to get whole seconds,
|
||||
// e.g. |denom| = 1000 if |t| is in milliseconds.
|
||||
uint32_t AbsSendTime(int64_t t, int64_t denom) {
|
||||
return (((t << 18) + (denom >> 1)) / denom) & 0x00fffffful;
|
||||
}
|
||||
|
||||
class MockPacketRouter : public PacketRouter {
|
||||
public:
|
||||
MOCK_METHOD2(OnReceiveBitrateChanged,
|
||||
void(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate));
|
||||
void(const std::vector<uint32_t>& ssrcs, uint32_t bitrate));
|
||||
};
|
||||
|
||||
const uint32_t kInitialBitrateBps = 60000;
|
||||
@ -57,17 +47,17 @@ const uint32_t kInitialBitrateBps = 60000;
|
||||
|
||||
namespace test {
|
||||
|
||||
class CongestionControllerTest : public ::testing::Test {
|
||||
class SendSideCongestionControllerTest : public ::testing::Test {
|
||||
protected:
|
||||
CongestionControllerTest() : clock_(123456), target_bitrate_observer_(this) {}
|
||||
~CongestionControllerTest() override {}
|
||||
SendSideCongestionControllerTest()
|
||||
: clock_(123456), target_bitrate_observer_(this) {}
|
||||
~SendSideCongestionControllerTest() override {}
|
||||
|
||||
void SetUp() override {
|
||||
pacer_ = new NiceMock<MockPacedSender>();
|
||||
std::unique_ptr<PacedSender> pacer(pacer_); // Passes ownership.
|
||||
controller_.reset(new CongestionController(
|
||||
&clock_, &observer_, &remote_bitrate_observer_, &event_log_,
|
||||
&packet_router_, std::move(pacer)));
|
||||
controller_.reset(new SendSideCongestionController(
|
||||
&clock_, &observer_, &event_log_, std::move(pacer)));
|
||||
bandwidth_observer_.reset(
|
||||
controller_->GetBitrateController()->CreateRtcpBandwidthObserver());
|
||||
|
||||
@ -84,9 +74,8 @@ class CongestionControllerTest : public ::testing::Test {
|
||||
// prescribing on which iterations it must change (like a mock would).
|
||||
void TargetBitrateTrackingSetup() {
|
||||
std::unique_ptr<PacedSender> pacer(new NiceMock<MockPacedSender>());
|
||||
controller_.reset(new CongestionController(
|
||||
&clock_, &target_bitrate_observer_, &remote_bitrate_observer_,
|
||||
&event_log_, &packet_router_, std::move(pacer)));
|
||||
controller_.reset(new SendSideCongestionController(
|
||||
&clock_, &target_bitrate_observer_, &event_log_, std::move(pacer)));
|
||||
controller_->SetBweBitrates(0, kInitialBitrateBps, 5 * kInitialBitrateBps);
|
||||
}
|
||||
|
||||
@ -101,9 +90,9 @@ class CongestionControllerTest : public ::testing::Test {
|
||||
|
||||
// Allows us to track the target bitrate, without prescribing the exact
|
||||
// iterations when this would hapen, like a mock would.
|
||||
class TargetBitrateObserver : public CongestionController::Observer {
|
||||
class TargetBitrateObserver : public SendSideCongestionController::Observer {
|
||||
public:
|
||||
explicit TargetBitrateObserver(CongestionControllerTest* owner)
|
||||
explicit TargetBitrateObserver(SendSideCongestionControllerTest* owner)
|
||||
: owner_(owner) {}
|
||||
~TargetBitrateObserver() override = default;
|
||||
void OnNetworkChanged(uint32_t bitrate_bps,
|
||||
@ -114,7 +103,7 @@ class CongestionControllerTest : public ::testing::Test {
|
||||
}
|
||||
|
||||
private:
|
||||
CongestionControllerTest* owner_;
|
||||
SendSideCongestionControllerTest* owner_;
|
||||
};
|
||||
|
||||
void PacketTransmissionAndFeedbackBlock(uint16_t* seq_num,
|
||||
@ -150,16 +139,14 @@ class CongestionControllerTest : public ::testing::Test {
|
||||
StrictMock<MockCongestionObserver> observer_;
|
||||
TargetBitrateObserver target_bitrate_observer_;
|
||||
NiceMock<MockPacedSender>* pacer_;
|
||||
NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
|
||||
NiceMock<MockRtcEventLog> event_log_;
|
||||
std::unique_ptr<RtcpBandwidthObserver> bandwidth_observer_;
|
||||
PacketRouter packet_router_;
|
||||
std::unique_ptr<CongestionController> controller_;
|
||||
std::unique_ptr<SendSideCongestionController> controller_;
|
||||
|
||||
rtc::Optional<uint32_t> target_bitrate_bps_;
|
||||
};
|
||||
|
||||
TEST_F(CongestionControllerTest, OnNetworkChanged) {
|
||||
TEST_F(SendSideCongestionControllerTest, OnNetworkChanged) {
|
||||
// Test no change.
|
||||
clock_.AdvanceTimeMilliseconds(25);
|
||||
controller_->Process();
|
||||
@ -177,7 +164,7 @@ TEST_F(CongestionControllerTest, OnNetworkChanged) {
|
||||
controller_->Process();
|
||||
}
|
||||
|
||||
TEST_F(CongestionControllerTest, OnSendQueueFull) {
|
||||
TEST_F(SendSideCongestionControllerTest, OnSendQueueFull) {
|
||||
EXPECT_CALL(*pacer_, ExpectedQueueTimeMs())
|
||||
.WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1));
|
||||
|
||||
@ -192,7 +179,7 @@ TEST_F(CongestionControllerTest, OnSendQueueFull) {
|
||||
controller_->Process();
|
||||
}
|
||||
|
||||
TEST_F(CongestionControllerTest, OnSendQueueFullAndEstimateChange) {
|
||||
TEST_F(SendSideCongestionControllerTest, OnSendQueueFullAndEstimateChange) {
|
||||
EXPECT_CALL(*pacer_, ExpectedQueueTimeMs())
|
||||
.WillOnce(Return(PacedSender::kMaxQueueLengthMs + 1));
|
||||
EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _));
|
||||
@ -216,7 +203,7 @@ TEST_F(CongestionControllerTest, OnSendQueueFullAndEstimateChange) {
|
||||
controller_->Process();
|
||||
}
|
||||
|
||||
TEST_F(CongestionControllerTest, SignalNetworkState) {
|
||||
TEST_F(SendSideCongestionControllerTest, SignalNetworkState) {
|
||||
EXPECT_CALL(observer_, OnNetworkChanged(0, _, _, _));
|
||||
controller_->SignalNetworkState(kNetworkDown);
|
||||
|
||||
@ -227,7 +214,7 @@ TEST_F(CongestionControllerTest, SignalNetworkState) {
|
||||
controller_->SignalNetworkState(kNetworkDown);
|
||||
}
|
||||
|
||||
TEST_F(CongestionControllerTest, OnNetworkRouteChanged) {
|
||||
TEST_F(SendSideCongestionControllerTest, OnNetworkRouteChanged) {
|
||||
int new_bitrate = 200000;
|
||||
testing::Mock::VerifyAndClearExpectations(pacer_);
|
||||
EXPECT_CALL(observer_, OnNetworkChanged(new_bitrate, _, _, _));
|
||||
@ -247,7 +234,7 @@ TEST_F(CongestionControllerTest, OnNetworkRouteChanged) {
|
||||
controller_->OnNetworkRouteChanged(route, -1, -1, -1);
|
||||
}
|
||||
|
||||
TEST_F(CongestionControllerTest, OldFeedback) {
|
||||
TEST_F(SendSideCongestionControllerTest, OldFeedback) {
|
||||
int new_bitrate = 200000;
|
||||
testing::Mock::VerifyAndClearExpectations(pacer_);
|
||||
EXPECT_CALL(observer_, OnNetworkChanged(new_bitrate, _, _, _));
|
||||
@ -290,7 +277,7 @@ TEST_F(CongestionControllerTest, OldFeedback) {
|
||||
controller_->OnNetworkRouteChanged(route, -1, -1, -1);
|
||||
}
|
||||
|
||||
TEST_F(CongestionControllerTest,
|
||||
TEST_F(SendSideCongestionControllerTest,
|
||||
SignalNetworkStateAndQueueIsFullAndEstimateChange) {
|
||||
// Send queue is full
|
||||
EXPECT_CALL(*pacer_, ExpectedQueueTimeMs())
|
||||
@ -319,7 +306,7 @@ TEST_F(CongestionControllerTest,
|
||||
controller_->Process();
|
||||
}
|
||||
|
||||
TEST_F(CongestionControllerTest, GetPacerQueuingDelayMs) {
|
||||
TEST_F(SendSideCongestionControllerTest, GetPacerQueuingDelayMs) {
|
||||
EXPECT_CALL(observer_, OnNetworkChanged(_, _, _, _)).Times(AtLeast(1));
|
||||
|
||||
const int64_t kQueueTimeMs = 123;
|
||||
@ -335,7 +322,7 @@ TEST_F(CongestionControllerTest, GetPacerQueuingDelayMs) {
|
||||
EXPECT_EQ(kQueueTimeMs, controller_->GetPacerQueuingDelayMs());
|
||||
}
|
||||
|
||||
TEST_F(CongestionControllerTest, GetProbingInterval) {
|
||||
TEST_F(SendSideCongestionControllerTest, GetProbingInterval) {
|
||||
clock_.AdvanceTimeMilliseconds(25);
|
||||
controller_->Process();
|
||||
|
||||
@ -346,33 +333,7 @@ TEST_F(CongestionControllerTest, GetProbingInterval) {
|
||||
controller_->Process();
|
||||
}
|
||||
|
||||
TEST(ReceiveSideCongestionControllerTest, OnReceivedPacketWithAbsSendTime) {
|
||||
StrictMock<MockPacketRouter> packet_router;
|
||||
SimulatedClock clock_(123456);
|
||||
|
||||
ReceiveSideCongestionController controller(&clock_, &packet_router);
|
||||
|
||||
size_t payload_size = 1000;
|
||||
RTPHeader header;
|
||||
header.ssrc = 0x11eb21c;
|
||||
header.extension.hasAbsoluteSendTime = true;
|
||||
|
||||
std::vector<unsigned int> ssrcs;
|
||||
EXPECT_CALL(packet_router, OnReceiveBitrateChanged(_, _))
|
||||
.WillRepeatedly(SaveArg<0>(&ssrcs));
|
||||
|
||||
for (int i = 0; i < 10; ++i) {
|
||||
clock_.AdvanceTimeMilliseconds((1000 * payload_size) / kInitialBitrateBps);
|
||||
int64_t now_ms = clock_.TimeInMilliseconds();
|
||||
header.extension.absoluteSendTime = AbsSendTime(now_ms, 1000);
|
||||
controller.OnReceivedPacket(now_ms, payload_size, header);
|
||||
}
|
||||
|
||||
ASSERT_EQ(1u, ssrcs.size());
|
||||
EXPECT_EQ(header.ssrc, ssrcs[0]);
|
||||
}
|
||||
|
||||
TEST_F(CongestionControllerTest, ProbeOnRouteChange) {
|
||||
TEST_F(SendSideCongestionControllerTest, ProbeOnRouteChange) {
|
||||
testing::Mock::VerifyAndClearExpectations(pacer_);
|
||||
EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 6));
|
||||
EXPECT_CALL(*pacer_, CreateProbeCluster(kInitialBitrateBps * 12));
|
||||
@ -385,7 +346,7 @@ TEST_F(CongestionControllerTest, ProbeOnRouteChange) {
|
||||
|
||||
// Estimated bitrate reduced when the feedbacks arrive with such a long delay,
|
||||
// that the send-time-history no longer holds the feedbacked packets.
|
||||
TEST_F(CongestionControllerTest, LongFeedbackDelays) {
|
||||
TEST_F(SendSideCongestionControllerTest, LongFeedbackDelays) {
|
||||
TargetBitrateTrackingSetup();
|
||||
|
||||
const int64_t kFeedbackTimeoutMs = 60001;
|
||||
@ -476,7 +437,7 @@ TEST_F(CongestionControllerTest, LongFeedbackDelays) {
|
||||
|
||||
// Bandwidth estimation is updated when feedbacks are received.
|
||||
// Feedbacks which show an increasing delay cause the estimation to be reduced.
|
||||
TEST_F(CongestionControllerTest, UpdatesDelayBasedEstimate) {
|
||||
TEST_F(SendSideCongestionControllerTest, UpdatesDelayBasedEstimate) {
|
||||
TargetBitrateTrackingSetup();
|
||||
|
||||
const int64_t kRunTimeMs = 6000;
|
||||
@ -188,7 +188,6 @@ if (rtc_include_tests) {
|
||||
]
|
||||
deps = [
|
||||
":bwe_simulator_lib",
|
||||
":mock_remote_bitrate_observer",
|
||||
":remote_bitrate_estimator",
|
||||
"../..:webrtc_common",
|
||||
"../../rtc_base:rtc_base",
|
||||
@ -212,17 +211,6 @@ if (rtc_include_tests) {
|
||||
}
|
||||
}
|
||||
|
||||
rtc_source_set("mock_remote_bitrate_observer") {
|
||||
testonly = true
|
||||
sources = [
|
||||
"include/mock/mock_remote_bitrate_observer.h",
|
||||
]
|
||||
deps = [
|
||||
":remote_bitrate_estimator",
|
||||
"../../test:test_support",
|
||||
]
|
||||
}
|
||||
|
||||
rtc_test("bwe_simulations_tests") {
|
||||
testonly = true
|
||||
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_MOCK_MOCK_REMOTE_BITRATE_OBSERVER_H_
|
||||
#define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_MOCK_MOCK_REMOTE_BITRATE_OBSERVER_H_
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
#include "webrtc/test/gmock.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class MockRemoteBitrateObserver : public RemoteBitrateObserver {
|
||||
public:
|
||||
MOCK_METHOD2(OnReceiveBitrateChanged,
|
||||
void(const std::vector<unsigned int>& ssrcs, unsigned int bitrate));
|
||||
};
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
#endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_INCLUDE_MOCK_MOCK_REMOTE_BITRATE_OBSERVER_H_
|
||||
@ -27,7 +27,7 @@
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/neteq_test.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h"
|
||||
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
|
||||
#include "webrtc/modules/congestion_controller/include/send_side_congestion_controller.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
@ -528,15 +528,11 @@ EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log)
|
||||
}
|
||||
}
|
||||
|
||||
class BitrateObserver : public CongestionController::Observer,
|
||||
class BitrateObserver : public SendSideCongestionController::Observer,
|
||||
public RemoteBitrateObserver {
|
||||
public:
|
||||
BitrateObserver() : last_bitrate_bps_(0), bitrate_updated_(false) {}
|
||||
|
||||
// TODO(minyue): remove this when old OnNetworkChanged is deprecated. See
|
||||
// https://bugs.chromium.org/p/webrtc/issues/detail?id=6796
|
||||
using CongestionController::Observer::OnNetworkChanged;
|
||||
|
||||
void OnNetworkChanged(uint32_t bitrate_bps,
|
||||
uint8_t fraction_loss,
|
||||
int64_t rtt_ms,
|
||||
@ -1130,8 +1126,8 @@ void EventLogAnalyzer::CreateBweSimulationGraph(Plot* plot) {
|
||||
BitrateObserver observer;
|
||||
RtcEventLogNullImpl null_event_log;
|
||||
PacketRouter packet_router;
|
||||
CongestionController cc(&clock, &observer, &observer, &null_event_log,
|
||||
&packet_router);
|
||||
SendSideCongestionController cc(&clock, &observer, &null_event_log,
|
||||
&packet_router);
|
||||
// TODO(holmer): Log the call config and use that here instead.
|
||||
static const uint32_t kDefaultStartBitrateBps = 300000;
|
||||
cc.SetBweBitrates(0, kDefaultStartBitrateBps, -1);
|
||||
|
||||
@ -193,7 +193,8 @@ webrtc_fuzzer_test("congestion_controller_feedback_fuzzer") {
|
||||
deps = [
|
||||
"../../logging:rtc_event_log_api",
|
||||
"../../logging:rtc_event_log_impl",
|
||||
"../../modules/congestion_controller/",
|
||||
"../../modules/congestion_controller",
|
||||
"../../modules/pacing",
|
||||
"../../modules/remote_bitrate_estimator:remote_bitrate_estimator",
|
||||
"../../modules/rtp_rtcp",
|
||||
]
|
||||
|
||||
@ -8,40 +8,20 @@
|
||||
* be found in the AUTHORS file in the root of the source tree.
|
||||
*/
|
||||
|
||||
#include "webrtc/logging/rtc_event_log/rtc_event_log.h"
|
||||
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
|
||||
#include "webrtc/modules/congestion_controller/include/receive_side_congestion_controller.h"
|
||||
#include "webrtc/modules/pacing/packet_router.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class NullBitrateObserver : public CongestionController::Observer,
|
||||
public RemoteBitrateObserver {
|
||||
public:
|
||||
~NullBitrateObserver() override {}
|
||||
|
||||
// TODO(minyue): remove this when old OnNetworkChanged is deprecated. See
|
||||
// https://bugs.chromium.org/p/webrtc/issues/detail?id=6796
|
||||
using CongestionController::Observer::OnNetworkChanged;
|
||||
|
||||
void OnNetworkChanged(uint32_t bitrate_bps,
|
||||
uint8_t fraction_loss,
|
||||
int64_t rtt_ms,
|
||||
int64_t bwe_period_ms) override {}
|
||||
void OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs,
|
||||
uint32_t bitrate) override {}
|
||||
};
|
||||
|
||||
void FuzzOneInput(const uint8_t* data, size_t size) {
|
||||
size_t i = 0;
|
||||
if (size < sizeof(int64_t) + sizeof(uint8_t) + sizeof(uint32_t))
|
||||
return;
|
||||
SimulatedClock clock(data[i++]);
|
||||
NullBitrateObserver observer;
|
||||
RtcEventLogNullImpl event_log;
|
||||
PacketRouter packet_router;
|
||||
CongestionController cc(&clock, &observer, &observer, &event_log,
|
||||
&packet_router);
|
||||
ReceiveSideCongestionController cc(&clock, &packet_router);
|
||||
RemoteBitrateEstimator* rbe = cc.GetRemoteBitrateEstimator(true);
|
||||
RTPHeader header;
|
||||
header.ssrc = ByteReader<uint32_t>::ReadBigEndian(&data[i]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user