Remove decoded timestamp extrapolation from NackTracker.
UpdateLastDecodedPacket is anyway only called when a new packet is decoded. Bug: webrtc:10178 Change-Id: I8cfcc5791e71079034a2d0806c44b3b071ac2ffb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/299180 Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39703}
This commit is contained in:
parent
d7510fe1e4
commit
d6c4b1641d
@ -145,43 +145,22 @@ uint32_t NackTracker::EstimateTimestamp(uint16_t sequence_num,
|
||||
return sequence_num_diff * samples_per_packet + timestamp_last_received_rtp_;
|
||||
}
|
||||
|
||||
void NackTracker::UpdateEstimatedPlayoutTimeBy10ms() {
|
||||
while (!nack_list_.empty() &&
|
||||
nack_list_.begin()->second.time_to_play_ms <= 10)
|
||||
nack_list_.erase(nack_list_.begin());
|
||||
|
||||
for (NackList::iterator it = nack_list_.begin(); it != nack_list_.end(); ++it)
|
||||
it->second.time_to_play_ms -= 10;
|
||||
}
|
||||
|
||||
void NackTracker::UpdateLastDecodedPacket(uint16_t sequence_number,
|
||||
uint32_t timestamp) {
|
||||
if (IsNewerSequenceNumber(sequence_number, sequence_num_last_decoded_rtp_) ||
|
||||
!any_rtp_decoded_) {
|
||||
sequence_num_last_decoded_rtp_ = sequence_number;
|
||||
timestamp_last_decoded_rtp_ = timestamp;
|
||||
// Packets in the list with sequence numbers less than the
|
||||
// sequence number of the decoded RTP should be removed from the lists.
|
||||
// They will be discarded by the jitter buffer if they arrive.
|
||||
nack_list_.erase(nack_list_.begin(),
|
||||
nack_list_.upper_bound(sequence_num_last_decoded_rtp_));
|
||||
|
||||
// Update estimated time-to-play.
|
||||
for (NackList::iterator it = nack_list_.begin(); it != nack_list_.end();
|
||||
++it)
|
||||
it->second.time_to_play_ms = TimeToPlay(it->second.estimated_timestamp);
|
||||
} else {
|
||||
RTC_DCHECK_EQ(sequence_number, sequence_num_last_decoded_rtp_);
|
||||
|
||||
// Same sequence number as before. 10 ms is elapsed, update estimations for
|
||||
// time-to-play.
|
||||
UpdateEstimatedPlayoutTimeBy10ms();
|
||||
|
||||
// Update timestamp for better estimate of time-to-play, for packets which
|
||||
// are added to NACK list later on.
|
||||
timestamp_last_decoded_rtp_ += sample_rate_khz_ * 10;
|
||||
}
|
||||
any_rtp_decoded_ = true;
|
||||
sequence_num_last_decoded_rtp_ = sequence_number;
|
||||
timestamp_last_decoded_rtp_ = timestamp;
|
||||
// Packets in the list with sequence numbers less than the
|
||||
// sequence number of the decoded RTP should be removed from the lists.
|
||||
// They will be discarded by the jitter buffer if they arrive.
|
||||
nack_list_.erase(nack_list_.begin(),
|
||||
nack_list_.upper_bound(sequence_num_last_decoded_rtp_));
|
||||
|
||||
// Update estimated time-to-play.
|
||||
for (NackList::iterator it = nack_list_.begin(); it != nack_list_.end();
|
||||
++it) {
|
||||
it->second.time_to_play_ms = TimeToPlay(it->second.estimated_timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
NackTracker::NackList NackTracker::GetNackList() const {
|
||||
|
||||
@ -72,8 +72,7 @@ class NackTracker {
|
||||
// After Reset() is called sampling rate has to be set.
|
||||
void UpdateSampleRate(int sample_rate_hz);
|
||||
|
||||
// Update the sequence number and the timestamp of the last decoded RTP. This
|
||||
// API should be called every time 10 ms audio is pulled from NetEq.
|
||||
// Update the sequence number and the timestamp of the last decoded RTP.
|
||||
void UpdateLastDecodedPacket(uint16_t sequence_number, uint32_t timestamp);
|
||||
|
||||
// Update the sequence number and the timestamp of the last received RTP. This
|
||||
@ -149,10 +148,6 @@ class NackTracker {
|
||||
// computed correctly.
|
||||
NackList GetNackList() const;
|
||||
|
||||
// This function subtracts 10 ms of time-to-play for all packets in NACK list.
|
||||
// This is called when 10 ms elapsed with no new RTP packet decoded.
|
||||
void UpdateEstimatedPlayoutTimeBy10ms();
|
||||
|
||||
// Returns a valid number of samples per packet given the current received
|
||||
// sequence number and timestamp or nullopt of none could be computed.
|
||||
absl::optional<int> GetSamplesPerPacket(
|
||||
|
||||
@ -238,19 +238,6 @@ TEST(NackTrackerTest, EstimateTimestampAndTimeToPlay) {
|
||||
EXPECT_EQ((index + 2) * kPacketSizeMs, it->second.time_to_play_ms);
|
||||
++it;
|
||||
}
|
||||
|
||||
// Pretend 10 ms is passed, and we had pulled audio from NetEq, it still
|
||||
// reports the same sequence number as decoded, time-to-play should be
|
||||
// updated by 10 ms.
|
||||
nack.UpdateLastDecodedPacket(first_seq_num, first_timestamp);
|
||||
nack_list = nack.GetNackList();
|
||||
it = nack_list.begin();
|
||||
while (it != nack_list.end()) {
|
||||
seq_num = it->first - seq_num_offset;
|
||||
int index = seq_num - kLostPackets[0];
|
||||
EXPECT_EQ((index + 2) * kPacketSizeMs - 10, it->second.time_to_play_ms);
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user