Revert "Revert "Revert "Reland "Moved congestion controller to task queue.""""

This reverts commit 65792c5a5c542201f7b9feefded505842692e6ed.

Reason for revert: <INSERT REASONING HERE>

Original change's description:
> Revert "Revert "Reland "Moved congestion controller to task queue."""
> 
> This reverts commit 4e849f6925b2ac44b0957a228d7131fc391fca54.
> 
> Reason for revert: <INSERT REASONING HERE>
> 
> Original change's description:
> > Revert "Reland "Moved congestion controller to task queue.""
> > 
> > This reverts commit 57daeb7ac7f3d80992905b53fea500953fcfd793.
> > 
> > Reason for revert: Cause increased congestion and deadlocks in downstream project
> > 
> > Original change's description:
> > > Reland "Moved congestion controller to task queue."
> > > 
> > > This is a reland of 0cbcba7ea0dced1a7f353c64d6cf91d46ccb29f9.
> > > 
> > > Original change's description:
> > > > Moved congestion controller to task queue.
> > > > 
> > > > The goal of this work is to make it easier to experiment with the
> > > > bandwidth estimation implementation. For this reason network control
> > > > functionality is moved from SendSideCongestionController(SSCC),
> > > > PacedSender and BitrateController to the newly created
> > > > GoogCcNetworkController which implements the newly created
> > > > NetworkControllerInterface. This allows the implementation to be
> > > > replaced at runtime in the future.
> > > > 
> > > > This is the first part of a split of a larger CL, see:
> > > > https://webrtc-review.googlesource.com/c/src/+/39788/8
> > > > For further explanations.
> > > > 
> > > > Bug: webrtc:8415
> > > > Change-Id: I770189c04cc31b313bd4e57821acff55fbcb1ad3
> > > > Reviewed-on: https://webrtc-review.googlesource.com/43840
> > > > Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> > > > Reviewed-by: Björn Terelius <terelius@webrtc.org>
> > > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > > Cr-Commit-Position: refs/heads/master@{#21868}
> > > 
> > > Bug: webrtc:8415
> > > Change-Id: I1d1756a30deed5b421b1c91c1918a13b6bb455da
> > > Reviewed-on: https://webrtc-review.googlesource.com/48000
> > > Reviewed-by: Stefan Holmer <stefan@webrtc.org>
> > > Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> > > Cr-Commit-Position: refs/heads/master@{#21899}
> > 
> > TBR=terelius@webrtc.org,stefan@webrtc.org,srte@webrtc.org
> > 
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> > 
> > Bug: webrtc:8415
> > Change-Id: Ida8074dcac2cc28b3629228eb22846d8a8e81b83
> > Reviewed-on: https://webrtc-review.googlesource.com/52980
> > Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
> > Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#22017}
> 
> TBR=danilchap@webrtc.org,terelius@webrtc.org,stefan@webrtc.org,srte@webrtc.org
> 
> Change-Id: I3393b74370c4f4d0955f50728005b2b925be169b
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:8415
> Reviewed-on: https://webrtc-review.googlesource.com/53262
> Reviewed-by: Sebastian Jansson <srte@webrtc.org>
> Commit-Queue: Sebastian Jansson <srte@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22023}

TBR=danilchap@webrtc.org,terelius@webrtc.org,stefan@webrtc.org,srte@webrtc.org

Change-Id: Id68ad986ee51142b7be3381d0793709b4392fe2c
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:8415
Reviewed-on: https://webrtc-review.googlesource.com/53360
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22024}
This commit is contained in:
Sebastian Jansson
2018-02-14 16:53:38 +00:00
committed by Commit Bot
parent 65792c5a5c
commit ea86bb74fc
57 changed files with 844 additions and 3006 deletions

View File

@ -11,26 +11,19 @@
#ifndef MODULES_CONGESTION_CONTROLLER_INCLUDE_SEND_SIDE_CONGESTION_CONTROLLER_H_
#define MODULES_CONGESTION_CONTROLLER_INCLUDE_SEND_SIDE_CONGESTION_CONTROLLER_H_
#include <atomic>
#include <functional>
#include <map>
#include <memory>
#include <vector>
#include "common_types.h" // NOLINT(build/include)
#include "modules/congestion_controller/network_control/include/network_control.h"
#include "modules/congestion_controller/network_control/include/network_types.h"
#include "modules/congestion_controller/pacer_controller.h"
#include "modules/congestion_controller/delay_based_bwe.h"
#include "modules/congestion_controller/transport_feedback_adapter.h"
#include "modules/include/module.h"
#include "modules/include/module_common_types.h"
#include "modules/pacing/paced_sender.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "rtc_base/constructormagic.h"
#include "rtc_base/criticalsection.h"
#include "rtc_base/networkroute.h"
#include "rtc_base/race_checker.h"
#include "rtc_base/task_queue.h"
namespace rtc {
struct SentPacket;
@ -38,23 +31,16 @@ struct SentPacket;
namespace webrtc {
class BitrateController;
class Clock;
class AcknowledgedBitrateEstimator;
class ProbeController;
class RateLimiter;
class RtcEventLog;
namespace send_side_cc_internal {
// This is used to observe the network controller state and route calls to
// the proper handler. It also keeps cached values for safe asynchronous use.
// This makes sure that things running on the worker queue can't access state
// in SendSideCongestionController, which would risk causing data race on
// destruction unless members are properly ordered.
class ControlHandler;
} // namespace send_side_cc_internal
class SendSideCongestionController : public CallStatsObserver,
public Module,
public TransportFeedbackObserver,
public RtcpBandwidthObserver {
public TransportFeedbackObserver {
public:
// Observer class for bitrate changes announced due to change in bandwidth
// estimate or due to that the send pacer is full. Fraction loss and rtt is
@ -100,7 +86,10 @@ class SendSideCongestionController : public CallStatsObserver,
virtual void SignalNetworkState(NetworkState state);
virtual void SetTransportOverhead(size_t transport_overhead_bytes_per_packet);
virtual RtcpBandwidthObserver* GetBandwidthObserver();
// Deprecated: Use GetBandwidthObserver instead.
RTC_DEPRECATED virtual BitrateController* GetBitrateController() const;
virtual RtcpBandwidthObserver* GetBandwidthObserver() const;
virtual bool AvailableBandwidth(uint32_t* bandwidth) const;
virtual int64_t GetPacerQueuingDelayMs() const;
@ -113,11 +102,6 @@ class SendSideCongestionController : public CallStatsObserver,
virtual void OnSentPacket(const rtc::SentPacket& sent_packet);
// Implements RtcpBandwidthObserver
void OnReceivedEstimatedBitrate(uint32_t bitrate) override;
void OnReceivedRtcpReceiverReport(const ReportBlockList& report_blocks,
int64_t rtt,
int64_t now_ms) override;
// Implements CallStatsObserver.
void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) override;
@ -133,64 +117,52 @@ class SendSideCongestionController : public CallStatsObserver,
void OnTransportFeedback(const rtcp::TransportFeedback& feedback) override;
std::vector<PacketFeedback> GetTransportFeedbackVector() const override;
// Sets the minimum send bitrate and maximum padding bitrate requested by send
// streams.
// |min_send_bitrate_bps| might be higher that the estimated available network
// bitrate and if so, the pacer will send with |min_send_bitrate_bps|.
// |max_padding_bitrate_bps| might be higher than the estimate available
// network bitrate and if so, the pacer will send padding packets to reach
// the min of the estimated available bitrate and |max_padding_bitrate_bps|.
void SetSendBitrateLimits(int64_t min_send_bitrate_bps,
int64_t max_padding_bitrate_bps);
void SetPacingFactor(float pacing_factor);
protected:
// Waits long enough that any outstanding tasks should be finished.
void WaitOnTasks();
private:
SendSideCongestionController(
const Clock* clock,
RtcEventLog* event_log,
PacedSender* pacer,
NetworkControllerFactoryInterface::uptr controller_factory);
void UpdateStreamsConfig();
void WaitOnTask(std::function<void()> closure);
void MaybeUpdateOutstandingData();
void OnReceivedRtcpReceiverReportBlocks(const ReportBlockList& report_blocks,
int64_t now_ms);
void MaybeTriggerOnNetworkChanged();
bool IsSendQueueFull() const;
bool IsNetworkDown() const;
bool HasNetworkParametersToReportChanged(uint32_t bitrate_bps,
uint8_t fraction_loss,
int64_t rtt);
void LimitOutstandingBytes(size_t num_outstanding_bytes);
const Clock* const clock_;
rtc::CriticalSection observer_lock_;
Observer* observer_ RTC_GUARDED_BY(observer_lock_);
RtcEventLog* const event_log_;
PacedSender* const pacer_;
const std::unique_ptr<BitrateController> bitrate_controller_;
std::unique_ptr<AcknowledgedBitrateEstimator> acknowledged_bitrate_estimator_;
const std::unique_ptr<ProbeController> probe_controller_;
const std::unique_ptr<RateLimiter> retransmission_rate_limiter_;
TransportFeedbackAdapter transport_feedback_adapter_;
const std::unique_ptr<PacerController> pacer_controller_;
const std::unique_ptr<send_side_cc_internal::ControlHandler> control_handler;
const std::unique_ptr<NetworkControllerInterface> controller_;
TimeDelta process_interval_;
int64_t last_process_update_ms_ = 0;
std::map<uint32_t, RTCPReportBlock> last_report_blocks_;
Timestamp last_report_block_time_;
StreamsConfig streams_config_;
rtc::CriticalSection network_state_lock_;
uint32_t last_reported_bitrate_bps_ RTC_GUARDED_BY(network_state_lock_);
uint8_t last_reported_fraction_loss_ RTC_GUARDED_BY(network_state_lock_);
int64_t last_reported_rtt_ RTC_GUARDED_BY(network_state_lock_);
NetworkState network_state_ RTC_GUARDED_BY(network_state_lock_);
bool pause_pacer_ RTC_GUARDED_BY(network_state_lock_);
// Duplicate the pacer paused state to avoid grabbing a lock when
// pausing the pacer. This can be removed when we move this class
// over to the task queue.
bool pacer_paused_;
rtc::CriticalSection bwe_lock_;
int min_bitrate_bps_ RTC_GUARDED_BY(bwe_lock_);
std::unique_ptr<DelayBasedBwe> delay_based_bwe_ RTC_GUARDED_BY(bwe_lock_);
bool in_cwnd_experiment_;
int64_t accepted_queue_ms_;
bool was_in_alr_;
const bool send_side_bwe_with_overhead_;
std::atomic<size_t> transport_overhead_bytes_per_packet_;
std::atomic<bool> network_available_;
size_t transport_overhead_bytes_per_packet_ RTC_GUARDED_BY(bwe_lock_);
rtc::RaceChecker worker_race_;
// Note that moving ownership of the task queue makes it neccessary to make
// sure that there is no outstanding tasks on it using destructed objects.
// This is currently guranteed by using explicit reset in the destructor of
// this class. It is declared last to indicate that it's lifetime is shorter
// than all other members.
std::unique_ptr<rtc::TaskQueue> task_queue_;
bool pacer_pushback_experiment_ = false;
float encoding_rate_ = 1.0;
RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(SendSideCongestionController);
};
} // namespace webrtc
#endif // MODULES_CONGESTION_CONTROLLER_INCLUDE_SEND_SIDE_CONGESTION_CONTROLLER_H_