Fix setting max reordering threshold in ReceiveStatistics

By ensuring new max reordering threshold applies to future statisticians too.

Bug: b/38179459
Change-Id: I0df32fb893a930b93faaf2161cd03626f9544a74
Reviewed-on: https://webrtc-review.googlesource.com/c/111752
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25756}
This commit is contained in:
Danil Chapovalov
2018-11-22 14:04:02 +01:00
committed by Commit Bot
parent 286df00f72
commit ebb50c217d
2 changed files with 18 additions and 6 deletions

View File

@ -33,13 +33,14 @@ StreamStatisticianImpl::StreamStatisticianImpl(
uint32_t ssrc,
Clock* clock,
bool enable_retransmit_detection,
int max_reordering_threshold,
RtcpStatisticsCallback* rtcp_callback,
StreamDataCountersCallback* rtp_callback)
: ssrc_(ssrc),
clock_(clock),
incoming_bitrate_(kStatisticsProcessIntervalMs,
RateStatistics::kBpsScale),
max_reordering_threshold_(kDefaultMaxReorderingThreshold),
max_reordering_threshold_(max_reordering_threshold),
enable_retransmit_detection_(enable_retransmit_detection),
jitter_q4_(0),
cumulative_loss_(0),
@ -340,6 +341,7 @@ ReceiveStatistics* ReceiveStatistics::Create(Clock* clock) {
ReceiveStatisticsImpl::ReceiveStatisticsImpl(Clock* clock)
: clock_(clock),
last_returned_ssrc_(0),
max_reordering_threshold_(kDefaultMaxReorderingThreshold),
rtcp_stats_callback_(NULL),
rtp_stats_callback_(NULL) {}
@ -360,7 +362,7 @@ void ReceiveStatisticsImpl::OnRtpPacket(const RtpPacketReceived& packet) {
} else {
impl = new StreamStatisticianImpl(
packet.Ssrc(), clock_, /* enable_retransmit_detection = */ false,
this, this);
max_reordering_threshold_, this, this);
statisticians_[packet.Ssrc()] = impl;
}
}
@ -395,8 +397,13 @@ StreamStatistician* ReceiveStatisticsImpl::GetStatistician(
void ReceiveStatisticsImpl::SetMaxReorderingThreshold(
int max_reordering_threshold) {
rtc::CritScope cs(&receive_statistics_lock_);
for (auto& statistician : statisticians_) {
std::map<uint32_t, StreamStatisticianImpl*> statisticians;
{
rtc::CritScope cs(&receive_statistics_lock_);
max_reordering_threshold_ = max_reordering_threshold;
statisticians = statisticians_;
}
for (auto& statistician : statisticians) {
statistician.second->SetMaxReorderingThreshold(max_reordering_threshold);
}
}
@ -408,7 +415,8 @@ void ReceiveStatisticsImpl::EnableRetransmitDetection(uint32_t ssrc,
rtc::CritScope cs(&receive_statistics_lock_);
StreamStatisticianImpl*& impl_ref = statisticians_[ssrc];
if (impl_ref == nullptr) { // new element
impl_ref = new StreamStatisticianImpl(ssrc, clock_, enable, this, this);
impl_ref = new StreamStatisticianImpl(
ssrc, clock_, enable, max_reordering_threshold_, this, this);
return;
}
impl = impl_ref;

View File

@ -19,6 +19,7 @@
#include "rtc_base/criticalsection.h"
#include "rtc_base/rate_statistics.h"
#include "rtc_base/thread_annotations.h"
#include "system_wrappers/include/ntp_time.h"
namespace webrtc {
@ -29,6 +30,7 @@ class StreamStatisticianImpl : public StreamStatistician,
StreamStatisticianImpl(uint32_t ssrc,
Clock* clock,
bool enable_retransmit_detection,
int max_reordering_threshold,
RtcpStatisticsCallback* rtcp_callback,
StreamDataCountersCallback* rtp_callback);
~StreamStatisticianImpl() override;
@ -128,7 +130,9 @@ class ReceiveStatisticsImpl : public ReceiveStatistics,
Clock* const clock_;
rtc::CriticalSection receive_statistics_lock_;
uint32_t last_returned_ssrc_;
std::map<uint32_t, StreamStatisticianImpl*> statisticians_;
int max_reordering_threshold_ RTC_GUARDED_BY(receive_statistics_lock_);
std::map<uint32_t, StreamStatisticianImpl*> statisticians_
RTC_GUARDED_BY(receive_statistics_lock_);
RtcpStatisticsCallback* rtcp_stats_callback_;
StreamDataCountersCallback* rtp_stats_callback_;