Adds tracking of allocated but unacknowledged bitrate.

This adds tracking of traffic for streams that are part of bitrate
allocation but without packet feedback to send side congestion
controller.

This is part of a series of CLs that allows GoogCC to track sent bitrate
that is included in bitrate allocation but without transport feedback.

Bug: webrtc:9796
Change-Id: I13e994461c26638d76e8f2f115e6d375e4403116
Reviewed-on: https://webrtc-review.googlesource.com/c/104940
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Christoffer Rodbro <crodbro@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25126}
This commit is contained in:
Sebastian Jansson
2018-10-11 18:48:49 +02:00
committed by Commit Bot
parent 26968bafc2
commit 20ad2544b4
6 changed files with 60 additions and 22 deletions

View File

@ -547,10 +547,7 @@ void SendSideCongestionController::SignalNetworkState(NetworkState state) {
void SendSideCongestionController::OnSentPacket(
const rtc::SentPacket& sent_packet) {
// We're not interested in packets without an id, which may be stun packets,
// etc, sent on the same transport.
if (sent_packet.packet_id == -1)
return;
if (sent_packet.packet_id != -1) {
transport_feedback_adapter_.OnSentPacket(sent_packet.packet_id,
sent_packet.send_time_ms);
MaybeUpdateOutstandingData();
@ -560,6 +557,7 @@ void SendSideCongestionController::OnSentPacket(
msg.size = DataSize::bytes(packet->payload_size);
msg.send_time = Timestamp::ms(packet->send_time_ms);
msg.sequence_number = packet->long_sequence_number;
msg.prior_unacked_data = DataSize::bytes(packet->unacknowledged_data);
msg.data_in_flight =
DataSize::bytes(transport_feedback_adapter_.GetOutstandingBytes());
task_queue_->PostTask([this, msg]() {
@ -568,6 +566,10 @@ void SendSideCongestionController::OnSentPacket(
control_handler_->PostUpdates(controller_->OnSentPacket(msg));
});
}
} else if (sent_packet.info.included_in_allocation) {
transport_feedback_adapter_.AddUntracked(sent_packet.info.packet_size_bytes,
sent_packet.send_time_ms);
}
}
void SendSideCongestionController::OnRttUpdate(int64_t avg_rtt_ms,

View File

@ -108,8 +108,11 @@ class SendSideCongestionControllerTest : public ::testing::Test {
controller_->AddPacket(ssrc, packet_feedback.sequence_number,
packet_feedback.payload_size,
packet_feedback.pacing_info);
rtc::PacketInfo packet_info;
packet_info.included_in_feedback = true;
controller_->OnSentPacket(rtc::SentPacket(packet_feedback.sequence_number,
packet_feedback.send_time_ms));
packet_feedback.send_time_ms,
packet_info));
}
// Allows us to track the target bitrate, without prescribing the exact

View File

@ -15,6 +15,7 @@
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
#include "system_wrappers/include/clock.h"
namespace webrtc {
@ -41,8 +42,19 @@ void SendTimeHistory::AddAndRemoveOld(const PacketFeedback& packet) {
PacketFeedback packet_copy = packet;
packet_copy.long_sequence_number = unwrapped_seq_num;
history_.insert(std::make_pair(unwrapped_seq_num, packet_copy));
if (packet.send_time_ms >= 0)
if (packet.send_time_ms >= 0) {
AddPacketBytes(packet_copy);
last_send_time_ms_ = std::max(last_send_time_ms_, packet.send_time_ms);
}
}
void SendTimeHistory::AddUntracked(size_t packet_size, int64_t send_time_ms) {
if (send_time_ms < last_send_time_ms_) {
RTC_LOG(LS_WARNING) << "ignoring untracked data for out of order packet.";
}
pending_untracked_size_ += packet_size;
last_untracked_send_time_ms_ =
std::max(last_untracked_send_time_ms_, send_time_ms);
}
bool SendTimeHistory::OnSentPacket(uint16_t sequence_number,
@ -53,8 +65,17 @@ bool SendTimeHistory::OnSentPacket(uint16_t sequence_number,
return false;
bool packet_retransmit = it->second.send_time_ms >= 0;
it->second.send_time_ms = send_time_ms;
last_send_time_ms_ = std::max(last_send_time_ms_, send_time_ms);
if (!packet_retransmit)
AddPacketBytes(it->second);
if (pending_untracked_size_ > 0) {
if (send_time_ms < last_untracked_send_time_ms_)
RTC_LOG(LS_WARNING)
<< "appending acknowledged data for out of order packet. (Diff: "
<< last_untracked_send_time_ms_ - send_time_ms << " ms.)";
it->second.unacknowledged_data += pending_untracked_size_;
pending_untracked_size_ = 0;
}
return true;
}

View File

@ -29,6 +29,8 @@ class SendTimeHistory {
// Cleanup old entries, then add new packet info with provided parameters.
void AddAndRemoveOld(const PacketFeedback& packet);
void AddUntracked(size_t packet_size, int64_t send_time_ms);
// Updates packet info identified by |sequence_number| with |send_time_ms|.
// Return false if not found.
bool OnSentPacket(uint16_t sequence_number, int64_t send_time_ms);
@ -52,6 +54,9 @@ class SendTimeHistory {
void UpdateAckedSeqNum(int64_t acked_seq_num);
const Clock* const clock_;
const int64_t packet_age_limit_ms_;
size_t pending_untracked_size_ = 0;
int64_t last_send_time_ms_ = -1;
int64_t last_untracked_send_time_ms_ = -1;
SequenceNumberUnwrapper seq_num_unwrapper_;
std::map<int64_t, PacketFeedback> history_;
absl::optional<int64_t> last_ack_seq_num_;

View File

@ -77,6 +77,12 @@ void TransportFeedbackAdapter::AddPacket(uint32_t ssrc,
}
}
void TransportFeedbackAdapter::AddUntracked(size_t packet_size,
int64_t send_time_ms) {
rtc::CritScope cs(&lock_);
send_time_history_.AddUntracked(packet_size, send_time_ms);
}
void TransportFeedbackAdapter::OnSentPacket(uint16_t sequence_number,
int64_t send_time_ms) {
rtc::CritScope cs(&lock_);

View File

@ -42,6 +42,7 @@ class TransportFeedbackAdapter {
uint16_t sequence_number,
size_t length,
const PacedPacketInfo& pacing_info);
void AddUntracked(size_t packet_size, int64_t send_time_ms);
void OnSentPacket(uint16_t sequence_number, int64_t send_time_ms);
// TODO(holmer): This method should return DelayBasedBwe::Result so that we