Change timestamps type from int64 to Timestamp in MediaReceiverInfo.
We should use the Timestamp type, rather then int64, to store timestamps. In https://webrtc-review.googlesource.com/c/src/+/365001/ an additional int64 timestamp was added (last_sender_report_timestamp_ms). This CL fixes the new timestamp, as well as other similar timestamps in MediaReceiverInfo (last_sender_report_utc_timestamp_ms and last_sender_report_remote_utc_timestamp_ms). Bug: webrtc:372393493 Change-Id: I0e473730e85a69ec595b421e2c3db920364008eb Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/365641 Reviewed-by: Harald Alvestrand <hta@webrtc.org> Commit-Queue: Olov Brändström <brandstrom@google.com> Reviewed-by: Danil Chapovalov <danilchap@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/main@{#43248}
This commit is contained in:
parent
9c21f6386f
commit
558c2dc539
@ -332,12 +332,11 @@ webrtc::AudioReceiveStreamInterface::Stats AudioReceiveStreamImpl::GetStats(
|
||||
stats.decoding_plc_cng = ds.decoded_plc_cng;
|
||||
stats.decoding_muted_output = ds.decoded_muted_output;
|
||||
|
||||
stats.last_sender_report_timestamp_ms =
|
||||
call_stats.last_sender_report_timestamp_ms;
|
||||
stats.last_sender_report_utc_timestamp_ms =
|
||||
call_stats.last_sender_report_utc_timestamp_ms;
|
||||
stats.last_sender_report_remote_utc_timestamp_ms =
|
||||
call_stats.last_sender_report_remote_utc_timestamp_ms;
|
||||
stats.last_sender_report_timestamp = call_stats.last_sender_report_timestamp;
|
||||
stats.last_sender_report_utc_timestamp =
|
||||
call_stats.last_sender_report_utc_timestamp;
|
||||
stats.last_sender_report_remote_utc_timestamp =
|
||||
call_stats.last_sender_report_remote_utc_timestamp;
|
||||
stats.sender_reports_packets_sent = call_stats.sender_reports_packets_sent;
|
||||
stats.sender_reports_bytes_sent = call_stats.sender_reports_bytes_sent;
|
||||
stats.sender_reports_reports_count = call_stats.sender_reports_reports_count;
|
||||
|
||||
@ -872,14 +872,13 @@ CallReceiveStatistics ChannelReceive::GetRTCPStatistics() const {
|
||||
std::optional<RtpRtcpInterface::SenderReportStats> rtcp_sr_stats =
|
||||
rtp_rtcp_->GetSenderReportStats();
|
||||
if (rtcp_sr_stats.has_value()) {
|
||||
stats.last_sender_report_timestamp_ms =
|
||||
rtcp_sr_stats->last_arrival_timestamp.ms<int64_t>();
|
||||
stats.last_sender_report_utc_timestamp_ms =
|
||||
rtcp_sr_stats->last_arrival_ntp_timestamp.ToMs() -
|
||||
rtc::kNtpJan1970Millisecs;
|
||||
stats.last_sender_report_remote_utc_timestamp_ms =
|
||||
rtcp_sr_stats->last_remote_ntp_timestamp.ToMs() -
|
||||
rtc::kNtpJan1970Millisecs;
|
||||
stats.last_sender_report_timestamp = rtcp_sr_stats->last_arrival_timestamp;
|
||||
stats.last_sender_report_utc_timestamp =
|
||||
Timestamp::Millis(rtcp_sr_stats->last_arrival_ntp_timestamp.ToMs() -
|
||||
rtc::kNtpJan1970Millisecs);
|
||||
stats.last_sender_report_remote_utc_timestamp =
|
||||
Timestamp::Millis(rtcp_sr_stats->last_remote_ntp_timestamp.ToMs() -
|
||||
rtc::kNtpJan1970Millisecs);
|
||||
stats.sender_reports_packets_sent = rtcp_sr_stats->packets_sent;
|
||||
stats.sender_reports_bytes_sent = rtcp_sr_stats->bytes_sent;
|
||||
stats.sender_reports_reports_count = rtcp_sr_stats->reports_count;
|
||||
|
||||
@ -67,13 +67,11 @@ struct CallReceiveStatistics {
|
||||
// Note that the timestamps below correspond to the time elapsed since the
|
||||
// Unix epoch.
|
||||
// https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict*
|
||||
// TODO: bugs.webrtc.org/372393493 - timestamps should use the type Timestamp,
|
||||
// not int64_t.
|
||||
std::optional<int64_t> last_sender_report_timestamp_ms;
|
||||
std::optional<Timestamp> last_sender_report_timestamp;
|
||||
// TODO: bugs.webrtc.org/370535296 - Remove the utc timestamp when linked
|
||||
// issue is fixed.
|
||||
std::optional<int64_t> last_sender_report_utc_timestamp_ms;
|
||||
std::optional<int64_t> last_sender_report_remote_utc_timestamp_ms;
|
||||
std::optional<Timestamp> last_sender_report_utc_timestamp;
|
||||
std::optional<Timestamp> last_sender_report_remote_utc_timestamp;
|
||||
uint64_t sender_reports_packets_sent = 0;
|
||||
uint64_t sender_reports_bytes_sent = 0;
|
||||
uint64_t sender_reports_reports_count = 0;
|
||||
|
||||
@ -100,11 +100,11 @@ class AudioReceiveStreamInterface : public MediaReceiveStreamInterface {
|
||||
std::optional<int64_t> estimated_playout_ntp_timestamp_ms;
|
||||
// Remote outbound stats derived by the received RTCP sender reports.
|
||||
// https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict*
|
||||
std::optional<int64_t> last_sender_report_timestamp_ms;
|
||||
std::optional<Timestamp> last_sender_report_timestamp;
|
||||
// TODO: bugs.webrtc.org/370535296 - Remove the utc timestamp when linked
|
||||
// issue is fixed.
|
||||
std::optional<int64_t> last_sender_report_utc_timestamp_ms;
|
||||
std::optional<int64_t> last_sender_report_remote_utc_timestamp_ms;
|
||||
std::optional<Timestamp> last_sender_report_utc_timestamp;
|
||||
std::optional<Timestamp> last_sender_report_remote_utc_timestamp;
|
||||
uint64_t sender_reports_packets_sent = 0;
|
||||
uint64_t sender_reports_bytes_sent = 0;
|
||||
uint64_t sender_reports_reports_count = 0;
|
||||
|
||||
@ -175,11 +175,11 @@ class VideoReceiveStreamInterface : public MediaReceiveStreamInterface {
|
||||
|
||||
// Remote outbound stats derived by the received RTCP sender reports.
|
||||
// https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict*
|
||||
std::optional<int64_t> last_sender_report_timestamp_ms;
|
||||
std::optional<Timestamp> last_sender_report_timestamp;
|
||||
// TODO: bugs.webrtc.org/370535296 - Remove the utc timestamp when linked
|
||||
// issue is fixed.
|
||||
std::optional<int64_t> last_sender_report_utc_timestamp_ms;
|
||||
std::optional<int64_t> last_sender_report_remote_utc_timestamp_ms;
|
||||
std::optional<Timestamp> last_sender_report_utc_timestamp;
|
||||
std::optional<Timestamp> last_sender_report_remote_utc_timestamp;
|
||||
uint32_t sender_reports_packets_sent = 0;
|
||||
uint64_t sender_reports_bytes_sent = 0;
|
||||
uint64_t sender_reports_reports_count = 0;
|
||||
|
||||
@ -482,13 +482,11 @@ struct MediaReceiverInfo {
|
||||
|
||||
// Remote outbound stats derived by the received RTCP sender reports.
|
||||
// https://w3c.github.io/webrtc-stats/#remoteoutboundrtpstats-dict*
|
||||
// TODO: bugs.webrtc.org/372393493 - timestamps should use the type Timestamp,
|
||||
// not int64_t.
|
||||
std::optional<int64_t> last_sender_report_timestamp_ms;
|
||||
std::optional<webrtc::Timestamp> last_sender_report_timestamp;
|
||||
// TODO: bugs.webrtc.org/370535296 - Remove the utc timestamp when linked
|
||||
// issue is fixed.
|
||||
std::optional<int64_t> last_sender_report_utc_timestamp_ms;
|
||||
std::optional<int64_t> last_sender_report_remote_utc_timestamp_ms;
|
||||
std::optional<webrtc::Timestamp> last_sender_report_utc_timestamp;
|
||||
std::optional<webrtc::Timestamp> last_sender_report_remote_utc_timestamp;
|
||||
uint64_t sender_reports_packets_sent = 0;
|
||||
uint64_t sender_reports_bytes_sent = 0;
|
||||
uint64_t sender_reports_reports_count = 0;
|
||||
|
||||
@ -3845,11 +3845,11 @@ WebRtcVideoReceiveChannel::WebRtcVideoReceiveStream::GetVideoReceiverInfo(
|
||||
}
|
||||
|
||||
// remote-outbound-rtp stats.
|
||||
info.last_sender_report_timestamp_ms = stats.last_sender_report_timestamp_ms;
|
||||
info.last_sender_report_utc_timestamp_ms =
|
||||
stats.last_sender_report_utc_timestamp_ms;
|
||||
info.last_sender_report_remote_utc_timestamp_ms =
|
||||
stats.last_sender_report_remote_utc_timestamp_ms;
|
||||
info.last_sender_report_timestamp = stats.last_sender_report_timestamp;
|
||||
info.last_sender_report_utc_timestamp =
|
||||
stats.last_sender_report_utc_timestamp;
|
||||
info.last_sender_report_remote_utc_timestamp =
|
||||
stats.last_sender_report_remote_utc_timestamp;
|
||||
info.sender_reports_packets_sent = stats.sender_reports_packets_sent;
|
||||
info.sender_reports_bytes_sent = stats.sender_reports_bytes_sent;
|
||||
info.sender_reports_reports_count = stats.sender_reports_reports_count;
|
||||
|
||||
@ -2697,12 +2697,11 @@ bool WebRtcVoiceReceiveChannel::GetStats(VoiceMediaReceiveInfo* info,
|
||||
stats.relative_packet_arrival_delay_seconds;
|
||||
rinfo.interruption_count = stats.interruption_count;
|
||||
rinfo.total_interruption_duration_ms = stats.total_interruption_duration_ms;
|
||||
rinfo.last_sender_report_timestamp_ms =
|
||||
stats.last_sender_report_timestamp_ms;
|
||||
rinfo.last_sender_report_utc_timestamp_ms =
|
||||
stats.last_sender_report_utc_timestamp_ms;
|
||||
rinfo.last_sender_report_remote_utc_timestamp_ms =
|
||||
stats.last_sender_report_remote_utc_timestamp_ms;
|
||||
rinfo.last_sender_report_timestamp = stats.last_sender_report_timestamp;
|
||||
rinfo.last_sender_report_utc_timestamp =
|
||||
stats.last_sender_report_utc_timestamp;
|
||||
rinfo.last_sender_report_remote_utc_timestamp =
|
||||
stats.last_sender_report_remote_utc_timestamp;
|
||||
rinfo.sender_reports_packets_sent = stats.sender_reports_packets_sent;
|
||||
rinfo.sender_reports_bytes_sent = stats.sender_reports_bytes_sent;
|
||||
rinfo.sender_reports_reports_count = stats.sender_reports_reports_count;
|
||||
|
||||
@ -523,11 +523,11 @@ CreateRemoteOutboundMediaStreamStats(
|
||||
const RTCInboundRtpStreamStats& inbound_audio_stats,
|
||||
const std::string& transport_id,
|
||||
const bool stats_timestamp_with_environment_clock) {
|
||||
std::optional<int64_t> last_sender_report_timestamp_ms =
|
||||
std::optional<Timestamp> last_sender_report_timestamp =
|
||||
stats_timestamp_with_environment_clock
|
||||
? media_receiver_info.last_sender_report_timestamp_ms
|
||||
: media_receiver_info.last_sender_report_utc_timestamp_ms;
|
||||
if (!last_sender_report_timestamp_ms.has_value()) {
|
||||
? media_receiver_info.last_sender_report_timestamp
|
||||
: media_receiver_info.last_sender_report_utc_timestamp;
|
||||
if (!last_sender_report_timestamp.has_value()) {
|
||||
// Cannot create `RTCRemoteOutboundRtpStreamStats` when the RTCP SR arrival
|
||||
// timestamp is not available - i.e., until the first sender report is
|
||||
// received.
|
||||
@ -539,7 +539,7 @@ CreateRemoteOutboundMediaStreamStats(
|
||||
auto stats = std::make_unique<RTCRemoteOutboundRtpStreamStats>(
|
||||
/*id=*/RTCRemoteOutboundRTPStreamStatsIDFromSSRC(
|
||||
media_type, media_receiver_info.ssrc()),
|
||||
Timestamp::Millis(*last_sender_report_timestamp_ms));
|
||||
*last_sender_report_timestamp);
|
||||
|
||||
// Populate.
|
||||
// - RTCRtpStreamStats.
|
||||
@ -556,10 +556,10 @@ CreateRemoteOutboundMediaStreamStats(
|
||||
stats->local_id = inbound_audio_stats.id();
|
||||
// last_sender_report_remote_utc_timestamp_ms is set together with
|
||||
// last_sender_report_utc_timestamp_ms.
|
||||
RTC_DCHECK(media_receiver_info.last_sender_report_remote_utc_timestamp_ms
|
||||
.has_value());
|
||||
stats->remote_timestamp = static_cast<double>(
|
||||
*media_receiver_info.last_sender_report_remote_utc_timestamp_ms);
|
||||
RTC_DCHECK(
|
||||
media_receiver_info.last_sender_report_remote_utc_timestamp.has_value());
|
||||
stats->remote_timestamp =
|
||||
media_receiver_info.last_sender_report_remote_utc_timestamp->ms<double>();
|
||||
stats->reports_sent = media_receiver_info.sender_reports_reports_count;
|
||||
if (media_receiver_info.round_trip_time.has_value()) {
|
||||
stats->round_trip_time =
|
||||
|
||||
@ -145,8 +145,9 @@ const int64_t kGetStatsReportTimeoutMs = 1000;
|
||||
|
||||
// Fake data used by `SetupExampleStatsVoiceGraph()` to fill in remote outbound
|
||||
// stats.
|
||||
constexpr int64_t kRemoteOutboundStatsTimestampMs = 123;
|
||||
constexpr int64_t kRemoteOutboundStatsRemoteTimestampMs = 456;
|
||||
constexpr Timestamp kRemoteOutboundStatsTimestamp = Timestamp::Millis(123);
|
||||
constexpr Timestamp kRemoteOutboundStatsRemoteTimestamp =
|
||||
Timestamp::Millis(456);
|
||||
constexpr uint32_t kRemoteOutboundStatsPacketsSent = 7u;
|
||||
constexpr uint64_t kRemoteOutboundStatsBytesSent = 8u;
|
||||
constexpr uint64_t kRemoteOutboundStatsReportsCount = 9u;
|
||||
@ -844,10 +845,10 @@ class RTCStatsCollectorTest : public ::testing::Test {
|
||||
// remote-outbound-rtp
|
||||
if (add_remote_outbound_stats) {
|
||||
graph.remote_outbound_rtp_id = "ROA4";
|
||||
media_info.receivers[0].last_sender_report_utc_timestamp_ms =
|
||||
kRemoteOutboundStatsTimestampMs;
|
||||
media_info.receivers[0].last_sender_report_remote_utc_timestamp_ms =
|
||||
kRemoteOutboundStatsRemoteTimestampMs;
|
||||
media_info.receivers[0].last_sender_report_utc_timestamp =
|
||||
kRemoteOutboundStatsTimestamp;
|
||||
media_info.receivers[0].last_sender_report_remote_utc_timestamp =
|
||||
kRemoteOutboundStatsRemoteTimestamp;
|
||||
media_info.receivers[0].sender_reports_packets_sent =
|
||||
kRemoteOutboundStatsPacketsSent;
|
||||
media_info.receivers[0].sender_reports_bytes_sent =
|
||||
@ -3533,10 +3534,9 @@ TEST_F(RTCStatsCollectorTest, RTCRemoteOutboundRtpAudioStreamStatsCollected) {
|
||||
const auto& remote_outbound_rtp =
|
||||
graph.full_report->Get(graph.remote_outbound_rtp_id)
|
||||
->cast_to<RTCRemoteOutboundRtpStreamStats>();
|
||||
EXPECT_EQ(remote_outbound_rtp.timestamp(),
|
||||
Timestamp::Millis(kRemoteOutboundStatsTimestampMs));
|
||||
EXPECT_EQ(remote_outbound_rtp.timestamp(), kRemoteOutboundStatsTimestamp);
|
||||
EXPECT_FLOAT_EQ(*remote_outbound_rtp.remote_timestamp,
|
||||
static_cast<double>(kRemoteOutboundStatsRemoteTimestampMs));
|
||||
kRemoteOutboundStatsRemoteTimestamp.ms<double>());
|
||||
EXPECT_EQ(*remote_outbound_rtp.packets_sent, kRemoteOutboundStatsPacketsSent);
|
||||
EXPECT_EQ(*remote_outbound_rtp.bytes_sent, kRemoteOutboundStatsBytesSent);
|
||||
EXPECT_EQ(*remote_outbound_rtp.reports_sent,
|
||||
|
||||
@ -572,12 +572,12 @@ VideoReceiveStreamInterface::Stats VideoReceiveStream2::GetStats() const {
|
||||
std::optional<RtpRtcpInterface::SenderReportStats> rtcp_sr_stats =
|
||||
rtp_video_stream_receiver_.GetSenderReportStats();
|
||||
if (rtcp_sr_stats) {
|
||||
stats.last_sender_report_utc_timestamp_ms =
|
||||
rtcp_sr_stats->last_arrival_ntp_timestamp.ToMs() -
|
||||
rtc::kNtpJan1970Millisecs;
|
||||
stats.last_sender_report_remote_utc_timestamp_ms =
|
||||
rtcp_sr_stats->last_remote_ntp_timestamp.ToMs() -
|
||||
rtc::kNtpJan1970Millisecs;
|
||||
stats.last_sender_report_utc_timestamp =
|
||||
Timestamp::Millis(rtcp_sr_stats->last_arrival_ntp_timestamp.ToMs() -
|
||||
rtc::kNtpJan1970Millisecs);
|
||||
stats.last_sender_report_remote_utc_timestamp =
|
||||
Timestamp::Millis(rtcp_sr_stats->last_remote_ntp_timestamp.ToMs() -
|
||||
rtc::kNtpJan1970Millisecs);
|
||||
stats.sender_reports_packets_sent = rtcp_sr_stats->packets_sent;
|
||||
stats.sender_reports_bytes_sent = rtcp_sr_stats->bytes_sent;
|
||||
stats.sender_reports_reports_count = rtcp_sr_stats->reports_count;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user