Splits SendTimeHistory::AddAndRemoveOld into Add/Remove.

Bug: webrtc:9883
Change-Id: I710e6011b63ffd09eb2b115716f6841c88e85c1e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137511
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28014}
This commit is contained in:
Sebastian Jansson
2019-05-20 19:07:48 +02:00
committed by Commit Bot
parent 3b112e2f35
commit 9c91887c3f
3 changed files with 18 additions and 10 deletions

View File

@ -24,9 +24,7 @@ SendTimeHistory::SendTimeHistory(int64_t packet_age_limit_ms)
SendTimeHistory::~SendTimeHistory() {}
void SendTimeHistory::AddAndRemoveOld(const PacketFeedback& packet,
int64_t at_time_ms) {
// Remove old.
void SendTimeHistory::RemoveOld(int64_t at_time_ms) {
while (!history_.empty() &&
at_time_ms - history_.begin()->second.creation_time_ms >
packet_age_limit_ms_) {
@ -34,18 +32,24 @@ void SendTimeHistory::AddAndRemoveOld(const PacketFeedback& packet,
RemovePacketBytes(history_.begin()->second);
history_.erase(history_.begin());
}
}
// Add new.
int64_t unwrapped_seq_num = seq_num_unwrapper_.Unwrap(packet.sequence_number);
PacketFeedback packet_copy = packet;
packet_copy.long_sequence_number = unwrapped_seq_num;
history_.insert(std::make_pair(unwrapped_seq_num, packet_copy));
void SendTimeHistory::AddNewPacket(PacketFeedback packet) {
packet.long_sequence_number =
seq_num_unwrapper_.Unwrap(packet.sequence_number);
history_.insert(std::make_pair(packet.long_sequence_number, packet));
if (packet.send_time_ms >= 0) {
AddPacketBytes(packet_copy);
AddPacketBytes(packet);
last_send_time_ms_ = std::max(last_send_time_ms_, packet.send_time_ms);
}
}
void SendTimeHistory::AddAndRemoveOld(const PacketFeedback& packet,
int64_t at_time_ms) {
RemoveOld(at_time_ms);
AddNewPacket(packet);
}
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.";

View File

@ -29,6 +29,8 @@ class SendTimeHistory {
~SendTimeHistory();
// Cleanup old entries, then add new packet info with provided parameters.
void RemoveOld(int64_t at_time_ms);
void AddNewPacket(PacketFeedback packet);
void AddAndRemoveOld(const PacketFeedback& packet, int64_t at_time_ms);
void AddUntracked(size_t packet_size, int64_t send_time_ms);

View File

@ -13,6 +13,7 @@
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <utility>
#include "api/units/timestamp.h"
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
@ -88,7 +89,8 @@ void TransportFeedbackAdapter::AddPacket(const RtpPacketSendInfo& packet_info,
packet_feedback.ssrc = packet_info.ssrc;
packet_feedback.rtp_sequence_number = packet_info.rtp_sequence_number;
}
send_time_history_.AddAndRemoveOld(packet_feedback, creation_time.ms());
send_time_history_.RemoveOld(creation_time.ms());
send_time_history_.AddNewPacket(std::move(packet_feedback));
}
{