Don't use wall clock for stats
This uses the local NTP clock for RTCP report block stats. This code exists in the version that Mozilla is shipping, with a review here https://phabricator.services.mozilla.com/D127709 . Bug: webrtc:13484 Change-Id: I2f46ec02acab0bbb09040778b05b248c2d815bd1 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/240142 Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/main@{#35787}
This commit is contained in:

committed by
WebRTC LUCI CQ

parent
027c793c57
commit
7eac6caeee
@ -846,14 +846,11 @@ CallReceiveStatistics ChannelReceive::GetRTCPStatistics() const {
|
|||||||
absl::optional<RtpRtcpInterface::SenderReportStats> rtcp_sr_stats =
|
absl::optional<RtpRtcpInterface::SenderReportStats> rtcp_sr_stats =
|
||||||
rtp_rtcp_->GetSenderReportStats();
|
rtp_rtcp_->GetSenderReportStats();
|
||||||
if (rtcp_sr_stats.has_value()) {
|
if (rtcp_sr_stats.has_value()) {
|
||||||
// Number of seconds since 1900 January 1 00:00 GMT (see
|
|
||||||
// https://tools.ietf.org/html/rfc868).
|
|
||||||
constexpr int64_t kNtpJan1970Millisecs =
|
|
||||||
2208988800 * rtc::kNumMillisecsPerSec;
|
|
||||||
stats.last_sender_report_timestamp_ms =
|
stats.last_sender_report_timestamp_ms =
|
||||||
rtcp_sr_stats->last_arrival_timestamp.ToMs() - kNtpJan1970Millisecs;
|
rtcp_sr_stats->last_arrival_timestamp.ToMs() -
|
||||||
|
rtc::kNtpJan1970Millisecs;
|
||||||
stats.last_sender_report_remote_timestamp_ms =
|
stats.last_sender_report_remote_timestamp_ms =
|
||||||
rtcp_sr_stats->last_remote_timestamp.ToMs() - kNtpJan1970Millisecs;
|
rtcp_sr_stats->last_remote_timestamp.ToMs() - rtc::kNtpJan1970Millisecs;
|
||||||
stats.sender_reports_packets_sent = rtcp_sr_stats->packets_sent;
|
stats.sender_reports_packets_sent = rtcp_sr_stats->packets_sent;
|
||||||
stats.sender_reports_bytes_sent = rtcp_sr_stats->bytes_sent;
|
stats.sender_reports_bytes_sent = rtcp_sr_stats->bytes_sent;
|
||||||
stats.sender_reports_reports_count = rtcp_sr_stats->reports_count;
|
stats.sender_reports_reports_count = rtcp_sr_stats->reports_count;
|
||||||
|
@ -22,16 +22,13 @@
|
|||||||
#include "modules/rtp_rtcp/source/rtp_rtcp_config.h"
|
#include "modules/rtp_rtcp/source/rtp_rtcp_config.h"
|
||||||
#include "modules/rtp_rtcp/source/time_util.h"
|
#include "modules/rtp_rtcp/source/time_util.h"
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
#include "rtc_base/time_utils.h"
|
||||||
#include "system_wrappers/include/clock.h"
|
#include "system_wrappers/include/clock.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
namespace {
|
namespace {
|
||||||
constexpr int64_t kStatisticsTimeoutMs = 8000;
|
constexpr int64_t kStatisticsTimeoutMs = 8000;
|
||||||
constexpr int64_t kStatisticsProcessIntervalMs = 1000;
|
constexpr int64_t kStatisticsProcessIntervalMs = 1000;
|
||||||
|
|
||||||
// Number of seconds since 1900 January 1 00:00 GMT (see
|
|
||||||
// https://tools.ietf.org/html/rfc868).
|
|
||||||
constexpr int64_t kNtpJan1970Millisecs = 2'208'988'800'000;
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
StreamStatistician::~StreamStatistician() {}
|
StreamStatistician::~StreamStatistician() {}
|
||||||
@ -43,7 +40,7 @@ StreamStatisticianImpl::StreamStatisticianImpl(uint32_t ssrc,
|
|||||||
clock_(clock),
|
clock_(clock),
|
||||||
delta_internal_unix_epoch_ms_(clock_->CurrentNtpInMilliseconds() -
|
delta_internal_unix_epoch_ms_(clock_->CurrentNtpInMilliseconds() -
|
||||||
clock_->TimeInMilliseconds() -
|
clock_->TimeInMilliseconds() -
|
||||||
kNtpJan1970Millisecs),
|
rtc::kNtpJan1970Millisecs),
|
||||||
incoming_bitrate_(kStatisticsProcessIntervalMs,
|
incoming_bitrate_(kStatisticsProcessIntervalMs,
|
||||||
RateStatistics::kBpsScale),
|
RateStatistics::kBpsScale),
|
||||||
max_reordering_threshold_(max_reordering_threshold),
|
max_reordering_threshold_(max_reordering_threshold),
|
||||||
|
@ -662,7 +662,12 @@ void RTCPReceiver::HandleReportBlock(const ReportBlock& report_block,
|
|||||||
rtcp_report_block.delay_since_last_sender_report =
|
rtcp_report_block.delay_since_last_sender_report =
|
||||||
report_block.delay_since_last_sr();
|
report_block.delay_since_last_sr();
|
||||||
rtcp_report_block.last_sender_report_timestamp = report_block.last_sr();
|
rtcp_report_block.last_sender_report_timestamp = report_block.last_sr();
|
||||||
report_block_data->SetReportBlock(rtcp_report_block, rtc::TimeUTCMicros());
|
// Number of seconds since 1900 January 1 00:00 GMT (see
|
||||||
|
// https://tools.ietf.org/html/rfc868).
|
||||||
|
report_block_data->SetReportBlock(
|
||||||
|
rtcp_report_block,
|
||||||
|
(clock_->CurrentNtpInMilliseconds() - rtc::kNtpJan1970Millisecs) *
|
||||||
|
rtc::kNumMicrosecsPerMillisec);
|
||||||
|
|
||||||
int64_t rtt_ms = 0;
|
int64_t rtt_ms = 0;
|
||||||
uint32_t send_time_ntp = report_block.last_sr();
|
uint32_t send_time_ntp = report_block.last_sr();
|
||||||
|
@ -1573,12 +1573,8 @@ TEST(RtcpReceiverTest,
|
|||||||
const uint32_t kCumulativeLoss = 7;
|
const uint32_t kCumulativeLoss = 7;
|
||||||
const uint32_t kJitter = 9;
|
const uint32_t kJitter = 9;
|
||||||
const uint16_t kSequenceNumber = 1234;
|
const uint16_t kSequenceNumber = 1234;
|
||||||
const int64_t kUtcNowUs = 42;
|
const int64_t kNtpNowMs =
|
||||||
|
mocks.clock.CurrentNtpInMilliseconds() - rtc::kNtpJan1970Millisecs;
|
||||||
// The "report_block_timestamp_utc_us" is obtained from the global UTC clock
|
|
||||||
// (not the simulcated `mocks.clock`) and requires a scoped fake clock.
|
|
||||||
rtc::ScopedFakeClock fake_clock;
|
|
||||||
fake_clock.SetTime(Timestamp::Micros(kUtcNowUs));
|
|
||||||
|
|
||||||
rtcp::ReportBlock rtcp_block;
|
rtcp::ReportBlock rtcp_block;
|
||||||
rtcp_block.SetMediaSsrc(kReceiverMainSsrc);
|
rtcp_block.SetMediaSsrc(kReceiverMainSsrc);
|
||||||
@ -1601,7 +1597,8 @@ TEST(RtcpReceiverTest,
|
|||||||
EXPECT_EQ(rtcp_block.extended_high_seq_num(),
|
EXPECT_EQ(rtcp_block.extended_high_seq_num(),
|
||||||
report_block.extended_highest_sequence_number);
|
report_block.extended_highest_sequence_number);
|
||||||
EXPECT_EQ(rtcp_block.jitter(), report_block.jitter);
|
EXPECT_EQ(rtcp_block.jitter(), report_block.jitter);
|
||||||
EXPECT_EQ(kUtcNowUs, report_block_data.report_block_timestamp_utc_us());
|
EXPECT_EQ(kNtpNowMs * rtc::kNumMicrosecsPerMillisec,
|
||||||
|
report_block_data.report_block_timestamp_utc_us());
|
||||||
// No RTT is calculated in this test.
|
// No RTT is calculated in this test.
|
||||||
EXPECT_EQ(0u, report_block_data.num_rtts());
|
EXPECT_EQ(0u, report_block_data.num_rtts());
|
||||||
});
|
});
|
||||||
|
@ -31,6 +31,12 @@ static const int64_t kNumNanosecsPerMillisec =
|
|||||||
static const int64_t kNumNanosecsPerMicrosec =
|
static const int64_t kNumNanosecsPerMicrosec =
|
||||||
kNumNanosecsPerSec / kNumMicrosecsPerSec;
|
kNumNanosecsPerSec / kNumMicrosecsPerSec;
|
||||||
|
|
||||||
|
// Elapsed milliseconds between NTP base, 1900 January 1 00:00 GMT
|
||||||
|
// (see https://tools.ietf.org/html/rfc868), and January 1 00:00 GMT 1970
|
||||||
|
// epoch. This is useful when converting between the NTP time base and the
|
||||||
|
// time base used in RTCP reports.
|
||||||
|
constexpr int64_t kNtpJan1970Millisecs = 2'208'988'800 * kNumMillisecsPerSec;
|
||||||
|
|
||||||
// TODO(honghaiz): Define a type for the time value specifically.
|
// TODO(honghaiz): Define a type for the time value specifically.
|
||||||
|
|
||||||
class ClockInterface {
|
class ClockInterface {
|
||||||
|
Reference in New Issue
Block a user