In ReceiveStatistics use monotonic clock instead of ntp clock
for all time difference calculations. Bug: None Change-Id: I37f4a3c73ab275e661bedf991a471a1c2928180a Reviewed-on: https://webrtc-review.googlesource.com/c/111884 Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25782}
This commit is contained in:
parent
22027b92d6
commit
856cf22996
@ -93,9 +93,6 @@ StreamDataCounters StreamStatisticianImpl::UpdateCounters(
|
||||
// Count only the new packets received. That is, if packets 1, 2, 3, 5, 4, 6
|
||||
// are received, 4 will be ignored.
|
||||
if (in_order) {
|
||||
// Current time in samples.
|
||||
NtpTime receive_time = clock_->CurrentNtpTime();
|
||||
|
||||
// Wrong if we use RetransmitOfOldPacket.
|
||||
if (receive_counters_.transmitted.packets > 1 &&
|
||||
received_seq_max_ > packet.SequenceNumber()) {
|
||||
@ -110,23 +107,22 @@ StreamDataCounters StreamStatisticianImpl::UpdateCounters(
|
||||
if (packet.Timestamp() != last_received_timestamp_ &&
|
||||
(receive_counters_.transmitted.packets -
|
||||
receive_counters_.retransmitted.packets) > 1) {
|
||||
UpdateJitter(packet, receive_time);
|
||||
UpdateJitter(packet, now_ms);
|
||||
}
|
||||
last_received_timestamp_ = packet.Timestamp();
|
||||
last_receive_time_ntp_ = receive_time;
|
||||
last_receive_time_ms_ = now_ms;
|
||||
}
|
||||
return receive_counters_;
|
||||
}
|
||||
|
||||
void StreamStatisticianImpl::UpdateJitter(const RtpPacketReceived& packet,
|
||||
NtpTime receive_time) {
|
||||
uint32_t receive_time_rtp =
|
||||
NtpToRtp(receive_time, packet.payload_type_frequency());
|
||||
uint32_t last_receive_time_rtp =
|
||||
NtpToRtp(last_receive_time_ntp_, packet.payload_type_frequency());
|
||||
int32_t time_diff_samples = (receive_time_rtp - last_receive_time_rtp) -
|
||||
(packet.Timestamp() - last_received_timestamp_);
|
||||
int64_t receive_time_ms) {
|
||||
int64_t receive_diff_ms = receive_time_ms - last_receive_time_ms_;
|
||||
RTC_DCHECK_GE(receive_diff_ms, 0);
|
||||
uint32_t receive_diff_rtp = static_cast<uint32_t>(
|
||||
(receive_diff_ms * packet.payload_type_frequency()) / 1000);
|
||||
int32_t time_diff_samples =
|
||||
receive_diff_rtp - (packet.Timestamp() - last_received_timestamp_);
|
||||
|
||||
time_diff_samples = std::abs(time_diff_samples);
|
||||
|
||||
@ -195,7 +191,7 @@ bool StreamStatisticianImpl::GetActiveStatisticsAndReset(
|
||||
RtcpStatistics* statistics) {
|
||||
{
|
||||
rtc::CritScope cs(&stream_lock_);
|
||||
if (clock_->CurrentNtpInMilliseconds() - last_receive_time_ntp_.ToMs() >=
|
||||
if (clock_->TimeInMilliseconds() - last_receive_time_ms_ >=
|
||||
kStatisticsTimeoutMs) {
|
||||
// Not active.
|
||||
return false;
|
||||
|
||||
@ -20,7 +20,6 @@
|
||||
#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 {
|
||||
|
||||
@ -57,7 +56,7 @@ class StreamStatisticianImpl : public StreamStatistician,
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(stream_lock_);
|
||||
RtcpStatistics CalculateRtcpStatistics()
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(stream_lock_);
|
||||
void UpdateJitter(const RtpPacketReceived& packet, NtpTime receive_time)
|
||||
void UpdateJitter(const RtpPacketReceived& packet, int64_t receive_time_ms)
|
||||
RTC_EXCLUSIVE_LOCKS_REQUIRED(stream_lock_);
|
||||
StreamDataCounters UpdateCounters(const RtpPacketReceived& packet);
|
||||
|
||||
@ -74,7 +73,6 @@ class StreamStatisticianImpl : public StreamStatistician,
|
||||
uint32_t cumulative_loss_ RTC_GUARDED_BY(&stream_lock_);
|
||||
|
||||
int64_t last_receive_time_ms_ RTC_GUARDED_BY(&stream_lock_);
|
||||
NtpTime last_receive_time_ntp_ RTC_GUARDED_BY(&stream_lock_);
|
||||
uint32_t last_received_timestamp_ RTC_GUARDED_BY(&stream_lock_);
|
||||
uint16_t received_seq_first_ RTC_GUARDED_BY(&stream_lock_);
|
||||
uint16_t received_seq_max_ RTC_GUARDED_BY(&stream_lock_);
|
||||
|
||||
@ -31,12 +31,6 @@ NtpTime TimeMicrosToNtp(int64_t time_us);
|
||||
// rtc::TimeMicros()
|
||||
int64_t NtpOffsetMs();
|
||||
|
||||
// Converts NTP timestamp to RTP timestamp.
|
||||
inline uint32_t NtpToRtp(NtpTime ntp, uint32_t freq) {
|
||||
uint32_t tmp = (static_cast<uint64_t>(ntp.fractions()) * freq) >> 32;
|
||||
return ntp.seconds() * freq + tmp;
|
||||
}
|
||||
|
||||
// Helper function for compact ntp representation:
|
||||
// RFC 3550, Section 4. Time Format.
|
||||
// Wallclock time is represented using the timestamp format of
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user