Cleanup ReportBlockData class: use Timestamp and TimeDelta
Bug: webrtc:13757 Change-Id: Ic3ddb05413f58cedd12bf0f32c852befb9bd40f4 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/300940 Reviewed-by: Erik Språng <sprang@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Commit-Queue: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Cr-Commit-Position: refs/heads/main@{#39841}
This commit is contained in:
parent
26d1b26277
commit
ec2670e631
@ -895,7 +895,7 @@ int64_t ChannelSend::GetRTT() const {
|
|||||||
|
|
||||||
// We don't know in advance the remote ssrc used by the other end's receiver
|
// We don't know in advance the remote ssrc used by the other end's receiver
|
||||||
// reports, so use the first report block for the RTT.
|
// reports, so use the first report block for the RTT.
|
||||||
return report_blocks.front().last_rtt_ms();
|
return report_blocks.front().last_rtt().ms();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChannelSend::SetFrameEncryptor(
|
void ChannelSend::SetFrameEncryptor(
|
||||||
|
|||||||
@ -275,13 +275,10 @@ ChannelStatistics AudioIngress::GetChannelStatistics() {
|
|||||||
static_cast<double>(rtcp_report.jitter) / clockrate_hz;
|
static_cast<double>(rtcp_report.jitter) / clockrate_hz;
|
||||||
}
|
}
|
||||||
if (block_data.has_rtt()) {
|
if (block_data.has_rtt()) {
|
||||||
remote_stat.round_trip_time =
|
remote_stat.round_trip_time = block_data.last_rtt().seconds<double>();
|
||||||
static_cast<double>(block_data.last_rtt_ms()) /
|
|
||||||
rtc::kNumMillisecsPerSec;
|
|
||||||
}
|
}
|
||||||
remote_stat.last_report_received_timestamp_ms =
|
remote_stat.last_report_received_timestamp_ms =
|
||||||
block_data.report_block_timestamp_utc_us() /
|
block_data.report_block_timestamp_utc().ms();
|
||||||
rtc::kNumMicrosecsPerMillisec;
|
|
||||||
channel_stats.remote_rtcp = remote_stat;
|
channel_stats.remote_rtcp = remote_stat;
|
||||||
|
|
||||||
// Receive only channel won't send any RTP packets.
|
// Receive only channel won't send any RTP packets.
|
||||||
|
|||||||
@ -5867,12 +5867,12 @@ TEST_F(WebRtcVideoChannelTest, GetAggregatedStatsReportForSubStreams) {
|
|||||||
substream.rtcp_packet_type_counts.fir_packets = 14;
|
substream.rtcp_packet_type_counts.fir_packets = 14;
|
||||||
substream.rtcp_packet_type_counts.nack_packets = 15;
|
substream.rtcp_packet_type_counts.nack_packets = 15;
|
||||||
substream.rtcp_packet_type_counts.pli_packets = 16;
|
substream.rtcp_packet_type_counts.pli_packets = 16;
|
||||||
webrtc::RTCPReportBlock report_block;
|
webrtc::rtcp::ReportBlock report_block;
|
||||||
report_block.packets_lost = 17;
|
report_block.SetCumulativeLost(17);
|
||||||
report_block.fraction_lost = 18;
|
report_block.SetFractionLost(18);
|
||||||
webrtc::ReportBlockData report_block_data;
|
webrtc::ReportBlockData report_block_data;
|
||||||
report_block_data.SetReportBlock(report_block, 0);
|
report_block_data.SetReportBlock(0, report_block, webrtc::Timestamp::Zero());
|
||||||
report_block_data.AddRoundTripTimeSample(19);
|
report_block_data.AddRoundTripTimeSample(webrtc::TimeDelta::Millis(19));
|
||||||
substream.report_block_data = report_block_data;
|
substream.report_block_data = report_block_data;
|
||||||
substream.encode_frame_rate = 20.0;
|
substream.encode_frame_rate = 20.0;
|
||||||
substream.frames_encoded = 21;
|
substream.frames_encoded = 21;
|
||||||
@ -5993,12 +5993,12 @@ TEST_F(WebRtcVideoChannelTest, GetPerLayerStatsReportForSubStreams) {
|
|||||||
substream.rtcp_packet_type_counts.fir_packets = 14;
|
substream.rtcp_packet_type_counts.fir_packets = 14;
|
||||||
substream.rtcp_packet_type_counts.nack_packets = 15;
|
substream.rtcp_packet_type_counts.nack_packets = 15;
|
||||||
substream.rtcp_packet_type_counts.pli_packets = 16;
|
substream.rtcp_packet_type_counts.pli_packets = 16;
|
||||||
webrtc::RTCPReportBlock report_block;
|
webrtc::rtcp::ReportBlock report_block;
|
||||||
report_block.packets_lost = 17;
|
report_block.SetCumulativeLost(17);
|
||||||
report_block.fraction_lost = 18;
|
report_block.SetFractionLost(18);
|
||||||
webrtc::ReportBlockData report_block_data;
|
webrtc::ReportBlockData report_block_data;
|
||||||
report_block_data.SetReportBlock(report_block, 0);
|
report_block_data.SetReportBlock(0, report_block, webrtc::Timestamp::Zero());
|
||||||
report_block_data.AddRoundTripTimeSample(19);
|
report_block_data.AddRoundTripTimeSample(webrtc::TimeDelta::Millis(19));
|
||||||
substream.report_block_data = report_block_data;
|
substream.report_block_data = report_block_data;
|
||||||
substream.encode_frame_rate = 20.0;
|
substream.encode_frame_rate = 20.0;
|
||||||
substream.frames_encoded = 21;
|
substream.frames_encoded = 21;
|
||||||
|
|||||||
@ -12,32 +12,34 @@
|
|||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
ReportBlockData::ReportBlockData()
|
TimeDelta ReportBlockData::AvgRtt() const {
|
||||||
: report_block_(),
|
return num_rtts_ > 0 ? sum_rtt_ / num_rtts_ : TimeDelta::Zero();
|
||||||
report_block_timestamp_utc_us_(0),
|
|
||||||
last_rtt_ms_(0),
|
|
||||||
min_rtt_ms_(0),
|
|
||||||
max_rtt_ms_(0),
|
|
||||||
sum_rtt_ms_(0),
|
|
||||||
num_rtts_(0) {}
|
|
||||||
|
|
||||||
double ReportBlockData::AvgRttMs() const {
|
|
||||||
return num_rtts_ ? static_cast<double>(sum_rtt_ms_) / num_rtts_ : 0.0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportBlockData::SetReportBlock(RTCPReportBlock report_block,
|
void ReportBlockData::SetReportBlock(uint32_t sender_ssrc,
|
||||||
int64_t report_block_timestamp_utc_us) {
|
const rtcp::ReportBlock& report_block,
|
||||||
report_block_ = report_block;
|
Timestamp report_block_timestamp_utc) {
|
||||||
report_block_timestamp_utc_us_ = report_block_timestamp_utc_us;
|
report_block_.sender_ssrc = sender_ssrc;
|
||||||
|
report_block_.source_ssrc = report_block.source_ssrc();
|
||||||
|
report_block_.fraction_lost = report_block.fraction_lost();
|
||||||
|
report_block_.packets_lost = report_block.cumulative_lost_signed();
|
||||||
|
report_block_.extended_highest_sequence_number =
|
||||||
|
report_block.extended_high_seq_num();
|
||||||
|
report_block_.jitter = report_block.jitter();
|
||||||
|
report_block_.delay_since_last_sender_report =
|
||||||
|
report_block.delay_since_last_sr();
|
||||||
|
report_block_.last_sender_report_timestamp = report_block.last_sr();
|
||||||
|
|
||||||
|
report_block_timestamp_utc_ = report_block_timestamp_utc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReportBlockData::AddRoundTripTimeSample(int64_t rtt_ms) {
|
void ReportBlockData::AddRoundTripTimeSample(TimeDelta rtt) {
|
||||||
if (rtt_ms > max_rtt_ms_)
|
if (rtt > max_rtt_)
|
||||||
max_rtt_ms_ = rtt_ms;
|
max_rtt_ = rtt;
|
||||||
if (num_rtts_ == 0 || rtt_ms < min_rtt_ms_)
|
if (num_rtts_ == 0 || rtt < min_rtt_)
|
||||||
min_rtt_ms_ = rtt_ms;
|
min_rtt_ = rtt;
|
||||||
last_rtt_ms_ = rtt_ms;
|
last_rtt_ = rtt;
|
||||||
sum_rtt_ms_ += rtt_ms;
|
sum_rtt_ += rtt;
|
||||||
++num_rtts_;
|
++num_rtts_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -11,40 +11,56 @@
|
|||||||
#ifndef MODULES_RTP_RTCP_INCLUDE_REPORT_BLOCK_DATA_H_
|
#ifndef MODULES_RTP_RTCP_INCLUDE_REPORT_BLOCK_DATA_H_
|
||||||
#define MODULES_RTP_RTCP_INCLUDE_REPORT_BLOCK_DATA_H_
|
#define MODULES_RTP_RTCP_INCLUDE_REPORT_BLOCK_DATA_H_
|
||||||
|
|
||||||
|
#include "api/units/time_delta.h"
|
||||||
|
#include "api/units/timestamp.h"
|
||||||
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
#include "modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||||
|
#include "modules/rtp_rtcp/source/rtcp_packet/report_block.h"
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
class ReportBlockData {
|
class ReportBlockData {
|
||||||
public:
|
public:
|
||||||
ReportBlockData();
|
ReportBlockData() = default;
|
||||||
|
|
||||||
|
ReportBlockData(const ReportBlockData&) = default;
|
||||||
|
ReportBlockData& operator=(const ReportBlockData&) = default;
|
||||||
|
|
||||||
const RTCPReportBlock& report_block() const { return report_block_; }
|
const RTCPReportBlock& report_block() const { return report_block_; }
|
||||||
int64_t report_block_timestamp_utc_us() const {
|
|
||||||
return report_block_timestamp_utc_us_;
|
[[deprecated]] int64_t report_block_timestamp_utc_us() const {
|
||||||
|
return report_block_timestamp_utc_.us();
|
||||||
}
|
}
|
||||||
int64_t last_rtt_ms() const { return last_rtt_ms_; }
|
[[deprecated]] int64_t last_rtt_ms() const { return last_rtt_.ms(); }
|
||||||
int64_t min_rtt_ms() const { return min_rtt_ms_; }
|
[[deprecated]] int64_t min_rtt_ms() const { return min_rtt_.ms(); }
|
||||||
int64_t max_rtt_ms() const { return max_rtt_ms_; }
|
[[deprecated]] int64_t max_rtt_ms() const { return max_rtt_.ms(); }
|
||||||
int64_t sum_rtt_ms() const { return sum_rtt_ms_; }
|
[[deprecated]] int64_t sum_rtt_ms() const { return sum_rtt_.ms(); }
|
||||||
|
[[deprecated]] double AvgRttMs() const { return AvgRtt().ms<double>(); }
|
||||||
|
|
||||||
|
Timestamp report_block_timestamp_utc() const {
|
||||||
|
return report_block_timestamp_utc_;
|
||||||
|
}
|
||||||
|
TimeDelta last_rtt() const { return last_rtt_; }
|
||||||
|
TimeDelta min_rtt() const { return min_rtt_; }
|
||||||
|
TimeDelta max_rtt() const { return max_rtt_; }
|
||||||
|
TimeDelta sum_rtts() const { return sum_rtt_; }
|
||||||
size_t num_rtts() const { return num_rtts_; }
|
size_t num_rtts() const { return num_rtts_; }
|
||||||
bool has_rtt() const { return num_rtts_ != 0; }
|
bool has_rtt() const { return num_rtts_ != 0; }
|
||||||
|
|
||||||
double AvgRttMs() const;
|
TimeDelta AvgRtt() const;
|
||||||
|
|
||||||
void SetReportBlock(RTCPReportBlock report_block,
|
void SetReportBlock(uint32_t sender_ssrc,
|
||||||
int64_t report_block_timestamp_utc_us);
|
const rtcp::ReportBlock& report_block,
|
||||||
void AddRoundTripTimeSample(int64_t rtt_ms);
|
Timestamp report_block_timestamp_utc_us);
|
||||||
|
void AddRoundTripTimeSample(TimeDelta rtt);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RTCPReportBlock report_block_;
|
RTCPReportBlock report_block_;
|
||||||
int64_t report_block_timestamp_utc_us_;
|
Timestamp report_block_timestamp_utc_ = Timestamp::Zero();
|
||||||
|
TimeDelta last_rtt_ = TimeDelta::Zero();
|
||||||
int64_t last_rtt_ms_;
|
TimeDelta min_rtt_ = TimeDelta::Zero();
|
||||||
int64_t min_rtt_ms_;
|
TimeDelta max_rtt_ = TimeDelta::Zero();
|
||||||
int64_t max_rtt_ms_;
|
TimeDelta sum_rtt_ = TimeDelta::Zero();
|
||||||
int64_t sum_rtt_ms_;
|
size_t num_rtts_ = 0;
|
||||||
size_t num_rtts_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class ReportBlockDataObserver {
|
class ReportBlockDataObserver {
|
||||||
|
|||||||
@ -606,33 +606,23 @@ void RTCPReceiver::HandleReportBlock(const ReportBlock& report_block,
|
|||||||
if (!registered_ssrcs_.contains(report_block.source_ssrc()))
|
if (!registered_ssrcs_.contains(report_block.source_ssrc()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
last_received_rb_ = clock_->CurrentTime();
|
Timestamp now = clock_->CurrentTime();
|
||||||
|
last_received_rb_ = now;
|
||||||
|
|
||||||
ReportBlockData* report_block_data =
|
ReportBlockData* report_block_data =
|
||||||
&received_report_blocks_[report_block.source_ssrc()];
|
&received_report_blocks_[report_block.source_ssrc()];
|
||||||
RTCPReportBlock rtcp_report_block;
|
|
||||||
rtcp_report_block.sender_ssrc = remote_ssrc;
|
|
||||||
rtcp_report_block.source_ssrc = report_block.source_ssrc();
|
|
||||||
rtcp_report_block.fraction_lost = report_block.fraction_lost();
|
|
||||||
rtcp_report_block.packets_lost = report_block.cumulative_lost_signed();
|
|
||||||
if (report_block.extended_high_seq_num() >
|
if (report_block.extended_high_seq_num() >
|
||||||
report_block_data->report_block().extended_highest_sequence_number) {
|
report_block_data->report_block().extended_highest_sequence_number) {
|
||||||
// We have successfully delivered new RTP packets to the remote side after
|
// We have successfully delivered new RTP packets to the remote side after
|
||||||
// the last RR was sent from the remote side.
|
// the last RR was sent from the remote side.
|
||||||
last_increased_sequence_number_ = last_received_rb_;
|
last_increased_sequence_number_ = last_received_rb_;
|
||||||
}
|
}
|
||||||
rtcp_report_block.extended_highest_sequence_number =
|
NtpTime now_ntp = clock_->ConvertTimestampToNtpTime(now);
|
||||||
report_block.extended_high_seq_num();
|
|
||||||
rtcp_report_block.jitter = report_block.jitter();
|
|
||||||
rtcp_report_block.delay_since_last_sender_report =
|
|
||||||
report_block.delay_since_last_sr();
|
|
||||||
rtcp_report_block.last_sender_report_timestamp = report_block.last_sr();
|
|
||||||
// Number of seconds since 1900 January 1 00:00 GMT (see
|
// Number of seconds since 1900 January 1 00:00 GMT (see
|
||||||
// https://tools.ietf.org/html/rfc868).
|
// https://tools.ietf.org/html/rfc868).
|
||||||
report_block_data->SetReportBlock(
|
report_block_data->SetReportBlock(
|
||||||
rtcp_report_block,
|
remote_ssrc, report_block,
|
||||||
(clock_->CurrentNtpInMilliseconds() - rtc::kNtpJan1970Millisecs) *
|
Timestamp::Millis(now_ntp.ToMs() - rtc::kNtpJan1970Millisecs));
|
||||||
rtc::kNumMicrosecsPerMillisec);
|
|
||||||
|
|
||||||
uint32_t send_time_ntp = report_block.last_sr();
|
uint32_t send_time_ntp = report_block.last_sr();
|
||||||
// RFC3550, section 6.4.1, LSR field discription states:
|
// RFC3550, section 6.4.1, LSR field discription states:
|
||||||
@ -642,14 +632,13 @@ void RTCPReceiver::HandleReportBlock(const ReportBlock& report_block,
|
|||||||
if (send_time_ntp != 0) {
|
if (send_time_ntp != 0) {
|
||||||
uint32_t delay_ntp = report_block.delay_since_last_sr();
|
uint32_t delay_ntp = report_block.delay_since_last_sr();
|
||||||
// Local NTP time.
|
// Local NTP time.
|
||||||
uint32_t receive_time_ntp =
|
uint32_t receive_time_ntp = CompactNtp(now_ntp);
|
||||||
CompactNtp(clock_->ConvertTimestampToNtpTime(last_received_rb_));
|
|
||||||
|
|
||||||
// RTT in 1/(2^16) seconds.
|
// RTT in 1/(2^16) seconds.
|
||||||
uint32_t rtt_ntp = receive_time_ntp - delay_ntp - send_time_ntp;
|
uint32_t rtt_ntp = receive_time_ntp - delay_ntp - send_time_ntp;
|
||||||
// Convert to 1/1000 seconds (milliseconds).
|
// Convert to 1/1000 seconds (milliseconds).
|
||||||
TimeDelta rtt = CompactNtpRttToTimeDelta(rtt_ntp);
|
TimeDelta rtt = CompactNtpRttToTimeDelta(rtt_ntp);
|
||||||
report_block_data->AddRoundTripTimeSample(rtt.ms());
|
report_block_data->AddRoundTripTimeSample(rtt);
|
||||||
if (report_block.source_ssrc() == local_media_ssrc()) {
|
if (report_block.source_ssrc() == local_media_ssrc()) {
|
||||||
rtts_[remote_ssrc].AddRtt(rtt);
|
rtts_[remote_ssrc].AddRtt(rtt);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1584,8 +1584,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(kNtpNowMs * rtc::kNumMicrosecsPerMillisec,
|
EXPECT_EQ(report_block_data.report_block_timestamp_utc(),
|
||||||
report_block_data.report_block_timestamp_utc_us());
|
Timestamp::Millis(kNtpNowMs));
|
||||||
// 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());
|
||||||
});
|
});
|
||||||
@ -1602,8 +1602,12 @@ TEST(RtcpReceiverTest, VerifyRttObtainedFromReportBlockDataObserver) {
|
|||||||
RTCPReceiver receiver(config, &mocks.rtp_rtcp_impl);
|
RTCPReceiver receiver(config, &mocks.rtp_rtcp_impl);
|
||||||
receiver.SetRemoteSSRC(kSenderSsrc);
|
receiver.SetRemoteSSRC(kSenderSsrc);
|
||||||
|
|
||||||
const TimeDelta kRtt = TimeDelta::Millis(120);
|
// To avoid issues with rounding due to different way to represent time units,
|
||||||
const uint32_t kDelayNtp = 123000;
|
// use RTT that can be precisly represented both with
|
||||||
|
// TimeDelta units (i.e. integer number of microseconds), and
|
||||||
|
// ntp units (i.e. integer number of 2^(-32) seconds)
|
||||||
|
const TimeDelta kRtt = TimeDelta::Millis(125);
|
||||||
|
const uint32_t kDelayNtp = 123'000;
|
||||||
const TimeDelta kDelay = CompactNtpRttToTimeDelta(kDelayNtp);
|
const TimeDelta kDelay = CompactNtpRttToTimeDelta(kDelayNtp);
|
||||||
|
|
||||||
uint32_t sent_ntp = CompactNtp(mocks.clock.CurrentNtpTime());
|
uint32_t sent_ntp = CompactNtp(mocks.clock.CurrentNtpTime());
|
||||||
@ -1628,10 +1632,10 @@ TEST(RtcpReceiverTest, VerifyRttObtainedFromReportBlockDataObserver) {
|
|||||||
EXPECT_EQ(kReceiverMainSsrc,
|
EXPECT_EQ(kReceiverMainSsrc,
|
||||||
report_block_data.report_block().source_ssrc);
|
report_block_data.report_block().source_ssrc);
|
||||||
EXPECT_EQ(1u, report_block_data.num_rtts());
|
EXPECT_EQ(1u, report_block_data.num_rtts());
|
||||||
EXPECT_EQ(kRtt.ms(), report_block_data.min_rtt_ms());
|
EXPECT_EQ(kRtt, report_block_data.min_rtt());
|
||||||
EXPECT_EQ(kRtt.ms(), report_block_data.max_rtt_ms());
|
EXPECT_EQ(kRtt, report_block_data.max_rtt());
|
||||||
EXPECT_EQ(kRtt.ms(), report_block_data.sum_rtt_ms());
|
EXPECT_EQ(kRtt, report_block_data.sum_rtts());
|
||||||
EXPECT_EQ(kRtt.ms(), report_block_data.last_rtt_ms());
|
EXPECT_EQ(kRtt, report_block_data.last_rtt());
|
||||||
});
|
});
|
||||||
EXPECT_CALL(observer, OnReportBlockDataUpdated)
|
EXPECT_CALL(observer, OnReportBlockDataUpdated)
|
||||||
.WillOnce([](ReportBlockData report_block_data) {
|
.WillOnce([](ReportBlockData report_block_data) {
|
||||||
|
|||||||
@ -851,7 +851,7 @@ ProduceRemoteInboundRtpStreamStatsFromReportBlockData(
|
|||||||
auto remote_inbound = std::make_unique<RTCRemoteInboundRtpStreamStats>(
|
auto remote_inbound = std::make_unique<RTCRemoteInboundRtpStreamStats>(
|
||||||
RTCRemoteInboundRtpStreamStatsIdFromSourceSsrc(media_type,
|
RTCRemoteInboundRtpStreamStatsIdFromSourceSsrc(media_type,
|
||||||
report_block.source_ssrc),
|
report_block.source_ssrc),
|
||||||
Timestamp::Micros(report_block_data.report_block_timestamp_utc_us()));
|
report_block_data.report_block_timestamp_utc());
|
||||||
remote_inbound->ssrc = report_block.source_ssrc;
|
remote_inbound->ssrc = report_block.source_ssrc;
|
||||||
remote_inbound->kind =
|
remote_inbound->kind =
|
||||||
media_type == cricket::MEDIA_TYPE_AUDIO ? "audio" : "video";
|
media_type == cricket::MEDIA_TYPE_AUDIO ? "audio" : "video";
|
||||||
@ -860,12 +860,10 @@ ProduceRemoteInboundRtpStreamStatsFromReportBlockData(
|
|||||||
static_cast<double>(report_block.fraction_lost) / (1 << 8);
|
static_cast<double>(report_block.fraction_lost) / (1 << 8);
|
||||||
if (report_block_data.num_rtts() > 0) {
|
if (report_block_data.num_rtts() > 0) {
|
||||||
remote_inbound->round_trip_time =
|
remote_inbound->round_trip_time =
|
||||||
static_cast<double>(report_block_data.last_rtt_ms()) /
|
report_block_data.last_rtt().seconds<double>();
|
||||||
rtc::kNumMillisecsPerSec;
|
|
||||||
}
|
}
|
||||||
remote_inbound->total_round_trip_time =
|
remote_inbound->total_round_trip_time =
|
||||||
static_cast<double>(report_block_data.sum_rtt_ms()) /
|
report_block_data.sum_rtts().seconds<double>();
|
||||||
rtc::kNumMillisecsPerSec;
|
|
||||||
remote_inbound->round_trip_time_measurements =
|
remote_inbound->round_trip_time_measurements =
|
||||||
report_block_data.num_rtts();
|
report_block_data.num_rtts();
|
||||||
|
|
||||||
|
|||||||
@ -3599,31 +3599,29 @@ class RTCStatsCollectorTestWithParamKind
|
|||||||
// RTCCodecStats (codecId, jitter) and without setting up an RTCP transport.
|
// RTCCodecStats (codecId, jitter) and without setting up an RTCP transport.
|
||||||
TEST_P(RTCStatsCollectorTestWithParamKind,
|
TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||||
RTCRemoteInboundRtpStreamStatsCollectedFromReportBlock) {
|
RTCRemoteInboundRtpStreamStatsCollectedFromReportBlock) {
|
||||||
const int64_t kReportBlockTimestampUtcUs = 123456789;
|
const Timestamp kReportBlockTimestampUtc = Timestamp::Micros(123456789);
|
||||||
const uint8_t kFractionLost = 12;
|
const uint8_t kFractionLost = 12;
|
||||||
const int64_t kRoundTripTimeSample1Ms = 1234;
|
const TimeDelta kRoundTripTimeSample1 = TimeDelta::Millis(1'234);
|
||||||
const double kRoundTripTimeSample1Seconds = 1.234;
|
const TimeDelta kRoundTripTimeSample2 = TimeDelta::Seconds(13);
|
||||||
const int64_t kRoundTripTimeSample2Ms = 13000;
|
|
||||||
const double kRoundTripTimeSample2Seconds = 13;
|
|
||||||
|
|
||||||
// The report block's timestamp cannot be from the future, set the fake clock
|
// The report block's timestamp cannot be from the future, set the fake clock
|
||||||
// to match.
|
// to match.
|
||||||
fake_clock_.SetTime(Timestamp::Micros(kReportBlockTimestampUtcUs));
|
fake_clock_.SetTime(kReportBlockTimestampUtc);
|
||||||
auto ssrcs = {12, 13};
|
auto ssrcs = {12, 13};
|
||||||
std::vector<ReportBlockData> report_block_datas;
|
std::vector<ReportBlockData> report_block_datas;
|
||||||
for (auto ssrc : ssrcs) {
|
for (auto ssrc : ssrcs) {
|
||||||
RTCPReportBlock report_block;
|
rtcp::ReportBlock report_block;
|
||||||
// The remote-inbound-rtp SSRC and the outbound-rtp SSRC is the same as the
|
// The remote-inbound-rtp SSRC and the outbound-rtp SSRC is the same as the
|
||||||
// `source_ssrc`, "SSRC of the RTP packet sender".
|
// `source_ssrc`, "SSRC of the RTP packet sender".
|
||||||
report_block.source_ssrc = ssrc;
|
report_block.SetMediaSsrc(ssrc);
|
||||||
report_block.packets_lost = 7;
|
report_block.SetCumulativeLost(7);
|
||||||
report_block.fraction_lost = kFractionLost;
|
report_block.SetFractionLost(kFractionLost);
|
||||||
ReportBlockData report_block_data;
|
ReportBlockData report_block_data;
|
||||||
report_block_data.SetReportBlock(report_block, kReportBlockTimestampUtcUs);
|
report_block_data.SetReportBlock(0, report_block, kReportBlockTimestampUtc);
|
||||||
report_block_data.AddRoundTripTimeSample(kRoundTripTimeSample1Ms);
|
report_block_data.AddRoundTripTimeSample(kRoundTripTimeSample1);
|
||||||
// Only the last sample should be exposed as the
|
// Only the last sample should be exposed as the
|
||||||
// `RTCRemoteInboundRtpStreamStats::round_trip_time`.
|
// `RTCRemoteInboundRtpStreamStats::round_trip_time`.
|
||||||
report_block_data.AddRoundTripTimeSample(kRoundTripTimeSample2Ms);
|
report_block_data.AddRoundTripTimeSample(kRoundTripTimeSample2);
|
||||||
report_block_datas.push_back(report_block_data);
|
report_block_datas.push_back(report_block_data);
|
||||||
}
|
}
|
||||||
AddSenderInfoAndMediaChannel("TransportName", report_block_datas,
|
AddSenderInfoAndMediaChannel("TransportName", report_block_datas,
|
||||||
@ -3633,8 +3631,7 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
|||||||
for (auto ssrc : ssrcs) {
|
for (auto ssrc : ssrcs) {
|
||||||
std::string stream_id = "" + std::to_string(ssrc);
|
std::string stream_id = "" + std::to_string(ssrc);
|
||||||
RTCRemoteInboundRtpStreamStats expected_remote_inbound_rtp(
|
RTCRemoteInboundRtpStreamStats expected_remote_inbound_rtp(
|
||||||
"RI" + MediaTypeCharStr() + stream_id,
|
"RI" + MediaTypeCharStr() + stream_id, kReportBlockTimestampUtc);
|
||||||
Timestamp::Micros(kReportBlockTimestampUtcUs));
|
|
||||||
expected_remote_inbound_rtp.ssrc = ssrc;
|
expected_remote_inbound_rtp.ssrc = ssrc;
|
||||||
expected_remote_inbound_rtp.fraction_lost =
|
expected_remote_inbound_rtp.fraction_lost =
|
||||||
static_cast<double>(kFractionLost) / (1 << 8);
|
static_cast<double>(kFractionLost) / (1 << 8);
|
||||||
@ -3645,9 +3642,10 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
|||||||
expected_remote_inbound_rtp.packets_lost = 7;
|
expected_remote_inbound_rtp.packets_lost = 7;
|
||||||
expected_remote_inbound_rtp.local_id =
|
expected_remote_inbound_rtp.local_id =
|
||||||
"OTTransportName1" + MediaTypeCharStr() + stream_id;
|
"OTTransportName1" + MediaTypeCharStr() + stream_id;
|
||||||
expected_remote_inbound_rtp.round_trip_time = kRoundTripTimeSample2Seconds;
|
expected_remote_inbound_rtp.round_trip_time =
|
||||||
|
kRoundTripTimeSample2.seconds<double>();
|
||||||
expected_remote_inbound_rtp.total_round_trip_time =
|
expected_remote_inbound_rtp.total_round_trip_time =
|
||||||
kRoundTripTimeSample1Seconds + kRoundTripTimeSample2Seconds;
|
(kRoundTripTimeSample1 + kRoundTripTimeSample2).seconds<double>();
|
||||||
expected_remote_inbound_rtp.round_trip_time_measurements = 2;
|
expected_remote_inbound_rtp.round_trip_time_measurements = 2;
|
||||||
// This test does not set up RTCCodecStats, so `codec_id` and `jitter` are
|
// This test does not set up RTCCodecStats, so `codec_id` and `jitter` are
|
||||||
// expected to be missing. These are tested separately.
|
// expected to be missing. These are tested separately.
|
||||||
@ -3668,14 +3666,14 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
|||||||
|
|
||||||
TEST_P(RTCStatsCollectorTestWithParamKind,
|
TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||||
RTCRemoteInboundRtpStreamStatsRttMissingBeforeMeasurement) {
|
RTCRemoteInboundRtpStreamStatsRttMissingBeforeMeasurement) {
|
||||||
constexpr int64_t kReportBlockTimestampUtcUs = 123456789;
|
constexpr Timestamp kReportBlockTimestampUtc = Timestamp::Micros(123456789);
|
||||||
|
|
||||||
RTCPReportBlock report_block;
|
rtcp::ReportBlock report_block;
|
||||||
// The remote-inbound-rtp SSRC and the outbound-rtp SSRC is the same as the
|
// The remote-inbound-rtp SSRC and the outbound-rtp SSRC is the same as the
|
||||||
// `source_ssrc`, "SSRC of the RTP packet sender".
|
// `source_ssrc`, "SSRC of the RTP packet sender".
|
||||||
report_block.source_ssrc = 12;
|
report_block.SetMediaSsrc(12);
|
||||||
ReportBlockData report_block_data; // AddRoundTripTimeSample() not called.
|
ReportBlockData report_block_data; // AddRoundTripTimeSample() not called.
|
||||||
report_block_data.SetReportBlock(report_block, kReportBlockTimestampUtcUs);
|
report_block_data.SetReportBlock(0, report_block, kReportBlockTimestampUtc);
|
||||||
|
|
||||||
AddSenderInfoAndMediaChannel("TransportName", {report_block_data},
|
AddSenderInfoAndMediaChannel("TransportName", {report_block_data},
|
||||||
absl::nullopt);
|
absl::nullopt);
|
||||||
@ -3694,15 +3692,15 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
|||||||
|
|
||||||
TEST_P(RTCStatsCollectorTestWithParamKind,
|
TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||||
RTCRemoteInboundRtpStreamStatsWithTimestampFromReportBlock) {
|
RTCRemoteInboundRtpStreamStatsWithTimestampFromReportBlock) {
|
||||||
const int64_t kReportBlockTimestampUtcUs = 123456789;
|
const Timestamp kReportBlockTimestampUtc = Timestamp::Micros(123456789);
|
||||||
fake_clock_.SetTime(Timestamp::Micros(kReportBlockTimestampUtcUs));
|
fake_clock_.SetTime(kReportBlockTimestampUtc);
|
||||||
|
|
||||||
RTCPReportBlock report_block;
|
rtcp::ReportBlock report_block;
|
||||||
// The remote-inbound-rtp SSRC and the outbound-rtp SSRC is the same as the
|
// The remote-inbound-rtp SSRC and the outbound-rtp SSRC is the same as the
|
||||||
// `source_ssrc`, "SSRC of the RTP packet sender".
|
// `source_ssrc`, "SSRC of the RTP packet sender".
|
||||||
report_block.source_ssrc = 12;
|
report_block.SetMediaSsrc(12);
|
||||||
ReportBlockData report_block_data;
|
ReportBlockData report_block_data;
|
||||||
report_block_data.SetReportBlock(report_block, kReportBlockTimestampUtcUs);
|
report_block_data.SetReportBlock(0, report_block, kReportBlockTimestampUtc);
|
||||||
|
|
||||||
AddSenderInfoAndMediaChannel("TransportName", {report_block_data},
|
AddSenderInfoAndMediaChannel("TransportName", {report_block_data},
|
||||||
absl::nullopt);
|
absl::nullopt);
|
||||||
@ -3719,24 +3717,23 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
|||||||
|
|
||||||
// Even though the report time is different, the remote-inbound-rtp timestamp
|
// Even though the report time is different, the remote-inbound-rtp timestamp
|
||||||
// is of the time that the report block was received.
|
// is of the time that the report block was received.
|
||||||
EXPECT_EQ(Timestamp::Micros(kReportBlockTimestampUtcUs + 1234),
|
EXPECT_EQ(report->timestamp(),
|
||||||
report->timestamp());
|
kReportBlockTimestampUtc + TimeDelta::Micros(1234));
|
||||||
EXPECT_EQ(Timestamp::Micros(kReportBlockTimestampUtcUs),
|
EXPECT_EQ(remote_inbound_rtp.timestamp(), kReportBlockTimestampUtc);
|
||||||
remote_inbound_rtp.timestamp());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_P(RTCStatsCollectorTestWithParamKind,
|
TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||||
RTCRemoteInboundRtpStreamStatsWithCodecBasedMembers) {
|
RTCRemoteInboundRtpStreamStatsWithCodecBasedMembers) {
|
||||||
const int64_t kReportBlockTimestampUtcUs = 123456789;
|
const Timestamp kReportBlockTimestampUtc = Timestamp::Micros(123456789);
|
||||||
fake_clock_.SetTime(Timestamp::Micros(kReportBlockTimestampUtcUs));
|
fake_clock_.SetTime(kReportBlockTimestampUtc);
|
||||||
|
|
||||||
RTCPReportBlock report_block;
|
rtcp::ReportBlock report_block;
|
||||||
// The remote-inbound-rtp SSRC and the outbound-rtp SSRC is the same as the
|
// The remote-inbound-rtp SSRC and the outbound-rtp SSRC is the same as the
|
||||||
// `source_ssrc`, "SSRC of the RTP packet sender".
|
// `source_ssrc`, "SSRC of the RTP packet sender".
|
||||||
report_block.source_ssrc = 12;
|
report_block.SetMediaSsrc(12);
|
||||||
report_block.jitter = 5000;
|
report_block.SetJitter(5000);
|
||||||
ReportBlockData report_block_data;
|
ReportBlockData report_block_data;
|
||||||
report_block_data.SetReportBlock(report_block, kReportBlockTimestampUtcUs);
|
report_block_data.SetReportBlock(0, report_block, kReportBlockTimestampUtc);
|
||||||
|
|
||||||
RtpCodecParameters codec;
|
RtpCodecParameters codec;
|
||||||
codec.payload_type = 3;
|
codec.payload_type = 3;
|
||||||
@ -3763,15 +3760,15 @@ TEST_P(RTCStatsCollectorTestWithParamKind,
|
|||||||
|
|
||||||
TEST_P(RTCStatsCollectorTestWithParamKind,
|
TEST_P(RTCStatsCollectorTestWithParamKind,
|
||||||
RTCRemoteInboundRtpStreamStatsWithRtcpTransport) {
|
RTCRemoteInboundRtpStreamStatsWithRtcpTransport) {
|
||||||
const int64_t kReportBlockTimestampUtcUs = 123456789;
|
const Timestamp kReportBlockTimestampUtc = Timestamp::Micros(123456789);
|
||||||
fake_clock_.SetTime(Timestamp::Micros(kReportBlockTimestampUtcUs));
|
fake_clock_.SetTime(kReportBlockTimestampUtc);
|
||||||
|
|
||||||
RTCPReportBlock report_block;
|
rtcp::ReportBlock report_block;
|
||||||
// The remote-inbound-rtp SSRC and the outbound-rtp SSRC is the same as the
|
// The remote-inbound-rtp SSRC and the outbound-rtp SSRC is the same as the
|
||||||
// `source_ssrc`, "SSRC of the RTP packet sender".
|
// `source_ssrc`, "SSRC of the RTP packet sender".
|
||||||
report_block.source_ssrc = 12;
|
report_block.SetMediaSsrc(12);
|
||||||
ReportBlockData report_block_data;
|
ReportBlockData report_block_data;
|
||||||
report_block_data.SetReportBlock(report_block, kReportBlockTimestampUtcUs);
|
report_block_data.SetReportBlock(0, report_block, kReportBlockTimestampUtc);
|
||||||
|
|
||||||
cricket::TransportChannelStats rtp_transport_channel_stats;
|
cricket::TransportChannelStats rtp_transport_channel_stats;
|
||||||
rtp_transport_channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP;
|
rtp_transport_channel_stats.component = cricket::ICE_CANDIDATE_COMPONENT_RTP;
|
||||||
|
|||||||
@ -194,14 +194,14 @@ TEST_F(SendStatisticsProxyTest, ReportBlockDataObserver) {
|
|||||||
for (uint32_t ssrc : config_.rtp.ssrcs) {
|
for (uint32_t ssrc : config_.rtp.ssrcs) {
|
||||||
// Add statistics with some arbitrary, but unique, numbers.
|
// Add statistics with some arbitrary, but unique, numbers.
|
||||||
uint32_t offset = ssrc * 4;
|
uint32_t offset = ssrc * 4;
|
||||||
RTCPReportBlock report_block;
|
rtcp::ReportBlock report_block;
|
||||||
report_block.source_ssrc = ssrc;
|
report_block.SetMediaSsrc(ssrc);
|
||||||
report_block.packets_lost = offset;
|
report_block.SetCumulativeLost(offset);
|
||||||
report_block.extended_highest_sequence_number = offset + 1;
|
report_block.SetExtHighestSeqNum(offset + 1);
|
||||||
report_block.fraction_lost = offset + 2;
|
report_block.SetFractionLost(offset + 2);
|
||||||
report_block.jitter = offset + 3;
|
report_block.SetJitter(offset + 3);
|
||||||
ReportBlockData data;
|
ReportBlockData data;
|
||||||
data.SetReportBlock(report_block, 0);
|
data.SetReportBlock(/*sender_ssrc=*/0, report_block, Timestamp::Zero());
|
||||||
expected_.substreams[ssrc].report_block_data = data;
|
expected_.substreams[ssrc].report_block_data = data;
|
||||||
|
|
||||||
callback->OnReportBlockDataUpdated(data);
|
callback->OnReportBlockDataUpdated(data);
|
||||||
@ -209,14 +209,14 @@ TEST_F(SendStatisticsProxyTest, ReportBlockDataObserver) {
|
|||||||
for (uint32_t ssrc : config_.rtp.rtx.ssrcs) {
|
for (uint32_t ssrc : config_.rtp.rtx.ssrcs) {
|
||||||
// Add statistics with some arbitrary, but unique, numbers.
|
// Add statistics with some arbitrary, but unique, numbers.
|
||||||
uint32_t offset = ssrc * 4;
|
uint32_t offset = ssrc * 4;
|
||||||
RTCPReportBlock report_block;
|
rtcp::ReportBlock report_block;
|
||||||
report_block.source_ssrc = ssrc;
|
report_block.SetMediaSsrc(ssrc);
|
||||||
report_block.packets_lost = offset;
|
report_block.SetCumulativeLost(offset);
|
||||||
report_block.extended_highest_sequence_number = offset + 1;
|
report_block.SetExtHighestSeqNum(offset + 1);
|
||||||
report_block.fraction_lost = offset + 2;
|
report_block.SetFractionLost(offset + 2);
|
||||||
report_block.jitter = offset + 3;
|
report_block.SetJitter(offset + 3);
|
||||||
ReportBlockData data;
|
ReportBlockData data;
|
||||||
data.SetReportBlock(report_block, 0);
|
data.SetReportBlock(/*sender_ssrc=*/0, report_block, Timestamp::Zero());
|
||||||
expected_.substreams[ssrc].report_block_data = data;
|
expected_.substreams[ssrc].report_block_data = data;
|
||||||
|
|
||||||
callback->OnReportBlockDataUpdated(data);
|
callback->OnReportBlockDataUpdated(data);
|
||||||
@ -2311,10 +2311,10 @@ TEST_F(SendStatisticsProxyTest, NoSubstreams) {
|
|||||||
1;
|
1;
|
||||||
// From ReportBlockDataObserver.
|
// From ReportBlockDataObserver.
|
||||||
ReportBlockDataObserver* rtcp_callback = statistics_proxy_.get();
|
ReportBlockDataObserver* rtcp_callback = statistics_proxy_.get();
|
||||||
RTCPReportBlock report_block;
|
rtcp::ReportBlock report_block;
|
||||||
report_block.source_ssrc = excluded_ssrc;
|
report_block.SetMediaSsrc(excluded_ssrc);
|
||||||
ReportBlockData data;
|
ReportBlockData data;
|
||||||
data.SetReportBlock(report_block, 0);
|
data.SetReportBlock(0, report_block, Timestamp::Zero());
|
||||||
rtcp_callback->OnReportBlockDataUpdated(data);
|
rtcp_callback->OnReportBlockDataUpdated(data);
|
||||||
|
|
||||||
// From BitrateStatisticsObserver.
|
// From BitrateStatisticsObserver.
|
||||||
@ -2363,10 +2363,10 @@ TEST_F(SendStatisticsProxyTest, EncodedResolutionTimesOut) {
|
|||||||
// Update the first SSRC with bogus RTCP stats to make sure that encoded
|
// Update the first SSRC with bogus RTCP stats to make sure that encoded
|
||||||
// resolution still times out (no global timeout for all stats).
|
// resolution still times out (no global timeout for all stats).
|
||||||
ReportBlockDataObserver* rtcp_callback = statistics_proxy_.get();
|
ReportBlockDataObserver* rtcp_callback = statistics_proxy_.get();
|
||||||
RTCPReportBlock report_block;
|
rtcp::ReportBlock report_block;
|
||||||
report_block.source_ssrc = config_.rtp.ssrcs[0];
|
report_block.SetMediaSsrc(config_.rtp.ssrcs[0]);
|
||||||
ReportBlockData data;
|
ReportBlockData data;
|
||||||
data.SetReportBlock(report_block, 0);
|
data.SetReportBlock(0, report_block, Timestamp::Zero());
|
||||||
rtcp_callback->OnReportBlockDataUpdated(data);
|
rtcp_callback->OnReportBlockDataUpdated(data);
|
||||||
|
|
||||||
// Report stats for second SSRC to make sure it's not outdated along with the
|
// Report stats for second SSRC to make sure it's not outdated along with the
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user