stats: use Timestamp instead of uint64_t
making it clear what unit is being used.
BUG=webrtc:13756
Change-Id: I6354d35a8e02bb93a905ccf32cb0b294b4813e41
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/289460
Commit-Queue: Philipp Hancke <phancke@microsoft.com>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#39008}
diff --git a/stats/rtcstats_objects.cc b/stats/rtcstats_objects.cc
index 9d9498e..5051475 100644
--- a/stats/rtcstats_objects.cc
+++ b/stats/rtcstats_objects.cc
@@ -89,12 +89,14 @@
&issuer_certificate_id)
// clang-format on
-RTCCertificateStats::RTCCertificateStats(std::string id, int64_t timestamp_us)
- : RTCStats(std::move(id), timestamp_us),
+RTCCertificateStats::RTCCertificateStats(std::string id, Timestamp timestamp)
+ : RTCStats(std::move(id), timestamp),
fingerprint("fingerprint"),
fingerprint_algorithm("fingerprintAlgorithm"),
base64_certificate("base64Certificate"),
issuer_certificate_id("issuerCertificateId") {}
+RTCCertificateStats::RTCCertificateStats(std::string id, int64_t timestamp_us)
+ : RTCCertificateStats(std::move(id), Timestamp::Micros(timestamp_us)) {}
RTCCertificateStats::RTCCertificateStats(const RTCCertificateStats& other) =
default;
@@ -110,14 +112,16 @@
&sdp_fmtp_line)
// clang-format on
-RTCCodecStats::RTCCodecStats(std::string id, int64_t timestamp_us)
- : RTCStats(std::move(id), timestamp_us),
+RTCCodecStats::RTCCodecStats(std::string id, Timestamp timestamp)
+ : RTCStats(std::move(id), timestamp),
transport_id("transportId"),
payload_type("payloadType"),
mime_type("mimeType"),
clock_rate("clockRate"),
channels("channels"),
sdp_fmtp_line("sdpFmtpLine") {}
+RTCCodecStats::RTCCodecStats(std::string id, int64_t timestamp_us)
+ : RTCCodecStats(std::move(id), Timestamp::Micros(timestamp_us)) {}
RTCCodecStats::RTCCodecStats(const RTCCodecStats& other) = default;
@@ -135,8 +139,8 @@
&bytes_received)
// clang-format on
-RTCDataChannelStats::RTCDataChannelStats(std::string id, int64_t timestamp_us)
- : RTCStats(std::move(id), timestamp_us),
+RTCDataChannelStats::RTCDataChannelStats(std::string id, Timestamp timestamp)
+ : RTCStats(std::move(id), timestamp),
label("label"),
protocol("protocol"),
data_channel_identifier("dataChannelIdentifier"),
@@ -145,6 +149,8 @@
bytes_sent("bytesSent"),
messages_received("messagesReceived"),
bytes_received("bytesReceived") {}
+RTCDataChannelStats::RTCDataChannelStats(std::string id, int64_t timestamp_us)
+ : RTCDataChannelStats(std::move(id), Timestamp::Micros(timestamp_us)) {}
RTCDataChannelStats::RTCDataChannelStats(const RTCDataChannelStats& other) =
default;
@@ -180,8 +186,8 @@
// clang-format on
RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string id,
- int64_t timestamp_us)
- : RTCStats(std::move(id), timestamp_us),
+ Timestamp timestamp)
+ : RTCStats(std::move(id), timestamp),
transport_id("transportId"),
local_candidate_id("localCandidateId"),
remote_candidate_id("remoteCandidateId"),
@@ -206,6 +212,10 @@
bytes_discarded_on_send("bytesDiscardedOnSend"),
last_packet_received_timestamp("lastPacketReceivedTimestamp"),
last_packet_sent_timestamp("lastPacketSentTimestamp") {}
+RTCIceCandidatePairStats::RTCIceCandidatePairStats(std::string id,
+ int64_t timestamp_us)
+ : RTCIceCandidatePairStats(std::move(id), Timestamp::Micros(timestamp_us)) {
+}
RTCIceCandidatePairStats::RTCIceCandidatePairStats(
const RTCIceCandidatePairStats& other) = default;
@@ -235,9 +245,9 @@
// clang-format on
RTCIceCandidateStats::RTCIceCandidateStats(std::string id,
- int64_t timestamp_us,
+ Timestamp timestamp,
bool is_remote)
- : RTCStats(std::move(id), timestamp_us),
+ : RTCStats(std::move(id), timestamp),
transport_id("transportId"),
is_remote("isRemote", is_remote),
network_type("networkType"),
@@ -256,6 +266,12 @@
tcp_type("tcpType"),
vpn("vpn"),
network_adapter_type("networkAdapterType") {}
+RTCIceCandidateStats::RTCIceCandidateStats(std::string id,
+ int64_t timestamp_us,
+ bool is_remote)
+ : RTCIceCandidateStats(std::move(id),
+ Timestamp::Micros(timestamp_us),
+ is_remote) {}
RTCIceCandidateStats::RTCIceCandidateStats(const RTCIceCandidateStats& other) =
default;
@@ -265,8 +281,12 @@
const char RTCLocalIceCandidateStats::kType[] = "local-candidate";
RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(std::string id,
+ Timestamp timestamp)
+ : RTCIceCandidateStats(std::move(id), timestamp, false) {}
+RTCLocalIceCandidateStats::RTCLocalIceCandidateStats(std::string id,
int64_t timestamp_us)
- : RTCIceCandidateStats(std::move(id), timestamp_us, false) {}
+ : RTCLocalIceCandidateStats(std::move(id),
+ Timestamp::Micros(timestamp_us)) {}
std::unique_ptr<RTCStats> RTCLocalIceCandidateStats::copy() const {
return std::make_unique<RTCLocalIceCandidateStats>(*this);
@@ -279,8 +299,12 @@
const char RTCRemoteIceCandidateStats::kType[] = "remote-candidate";
RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(std::string id,
+ Timestamp timestamp)
+ : RTCIceCandidateStats(std::move(id), timestamp, true) {}
+RTCRemoteIceCandidateStats::RTCRemoteIceCandidateStats(std::string id,
int64_t timestamp_us)
- : RTCIceCandidateStats(std::move(id), timestamp_us, true) {}
+ : RTCRemoteIceCandidateStats(std::move(id),
+ Timestamp::Micros(timestamp_us)) {}
std::unique_ptr<RTCStats> RTCRemoteIceCandidateStats::copy() const {
return std::make_unique<RTCRemoteIceCandidateStats>(*this);
@@ -298,10 +322,15 @@
DEPRECATED_RTCMediaStreamStats::DEPRECATED_RTCMediaStreamStats(
std::string id,
- int64_t timestamp_us)
- : RTCStats(std::move(id), timestamp_us),
+ Timestamp timestamp)
+ : RTCStats(std::move(id), timestamp),
stream_identifier("streamIdentifier"),
track_ids("trackIds") {}
+DEPRECATED_RTCMediaStreamStats::DEPRECATED_RTCMediaStreamStats(
+ std::string id,
+ int64_t timestamp_us)
+ : DEPRECATED_RTCMediaStreamStats(std::move(id),
+ Timestamp::Micros(timestamp_us)) {}
DEPRECATED_RTCMediaStreamStats::DEPRECATED_RTCMediaStreamStats(
const DEPRECATED_RTCMediaStreamStats& other) = default;
@@ -340,9 +369,9 @@
DEPRECATED_RTCMediaStreamTrackStats::DEPRECATED_RTCMediaStreamTrackStats(
std::string id,
- int64_t timestamp_us,
+ Timestamp timestamp,
const char* kind)
- : RTCStats(std::move(id), timestamp_us),
+ : RTCStats(std::move(id), timestamp),
track_identifier("trackIdentifier"),
media_source_id("mediaSourceId"),
remote_source("remoteSource"),
@@ -372,6 +401,13 @@
RTC_DCHECK(kind == RTCMediaStreamTrackKind::kAudio ||
kind == RTCMediaStreamTrackKind::kVideo);
}
+DEPRECATED_RTCMediaStreamTrackStats::DEPRECATED_RTCMediaStreamTrackStats(
+ std::string id,
+ int64_t timestamp_us,
+ const char* kind)
+ : DEPRECATED_RTCMediaStreamTrackStats(std::move(id),
+ Timestamp::Micros(timestamp_us),
+ kind) {}
DEPRECATED_RTCMediaStreamTrackStats::DEPRECATED_RTCMediaStreamTrackStats(
const DEPRECATED_RTCMediaStreamTrackStats& other) = default;
@@ -385,10 +421,13 @@
// clang-format on
RTCPeerConnectionStats::RTCPeerConnectionStats(std::string id,
- int64_t timestamp_us)
- : RTCStats(std::move(id), timestamp_us),
+ Timestamp timestamp)
+ : RTCStats(std::move(id), timestamp),
data_channels_opened("dataChannelsOpened"),
data_channels_closed("dataChannelsClosed") {}
+RTCPeerConnectionStats::RTCPeerConnectionStats(std::string id,
+ int64_t timestamp_us)
+ : RTCPeerConnectionStats(std::move(id), Timestamp::Micros(timestamp_us)) {}
RTCPeerConnectionStats::RTCPeerConnectionStats(
const RTCPeerConnectionStats& other) = default;
@@ -405,14 +444,16 @@
&media_type)
// clang-format on
-RTCRTPStreamStats::RTCRTPStreamStats(std::string id, int64_t timestamp_us)
- : RTCStats(std::move(id), timestamp_us),
+RTCRTPStreamStats::RTCRTPStreamStats(std::string id, Timestamp timestamp)
+ : RTCStats(std::move(id), timestamp),
ssrc("ssrc"),
kind("kind"),
track_id("trackId"),
transport_id("transportId"),
codec_id("codecId"),
media_type("mediaType") {}
+RTCRTPStreamStats::RTCRTPStreamStats(std::string id, int64_t timestamp_us)
+ : RTCRTPStreamStats(std::move(id), Timestamp::Micros(timestamp_us)) {}
RTCRTPStreamStats::RTCRTPStreamStats(const RTCRTPStreamStats& other) = default;
@@ -426,10 +467,14 @@
// clang-format on
RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(std::string id,
- int64_t timestamp_us)
- : RTCRTPStreamStats(std::move(id), timestamp_us),
+ Timestamp timestamp)
+ : RTCRTPStreamStats(std::move(id), timestamp),
jitter("jitter"),
packets_lost("packetsLost") {}
+RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(std::string id,
+ int64_t timestamp_us)
+ : RTCReceivedRtpStreamStats(std::move(id),
+ Timestamp::Micros(timestamp_us)) {}
RTCReceivedRtpStreamStats::RTCReceivedRtpStreamStats(
const RTCReceivedRtpStreamStats& other) = default;
@@ -444,10 +489,13 @@
// clang-format on
RTCSentRtpStreamStats::RTCSentRtpStreamStats(std::string id,
- int64_t timestamp_us)
- : RTCRTPStreamStats(std::move(id), timestamp_us),
+ Timestamp timestamp)
+ : RTCRTPStreamStats(std::move(id), timestamp),
packets_sent("packetsSent"),
bytes_sent("bytesSent") {}
+RTCSentRtpStreamStats::RTCSentRtpStreamStats(std::string(id),
+ int64_t timestamp_us)
+ : RTCSentRtpStreamStats(std::move(id), Timestamp::Micros(timestamp_us)) {}
RTCSentRtpStreamStats::RTCSentRtpStreamStats(
const RTCSentRtpStreamStats& other) = default;
@@ -515,8 +563,8 @@
// clang-format on
RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string id,
- int64_t timestamp_us)
- : RTCReceivedRtpStreamStats(std::move(id), timestamp_us),
+ Timestamp timestamp)
+ : RTCReceivedRtpStreamStats(std::move(id), timestamp),
track_identifier("trackIdentifier"),
mid("mid"),
remote_id("remoteId"),
@@ -580,6 +628,10 @@
interruption_count("interruptionCount"),
total_interruption_duration("totalInterruptionDuration"),
min_playout_delay("minPlayoutDelay") {}
+RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(std::string id,
+ int64_t timestamp_us)
+ : RTCInboundRTPStreamStats(std::move(id), Timestamp::Micros(timestamp_us)) {
+}
RTCInboundRTPStreamStats::RTCInboundRTPStreamStats(
const RTCInboundRTPStreamStats& other) = default;
@@ -623,8 +675,8 @@
// clang-format on
RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(std::string id,
- int64_t timestamp_us)
- : RTCRTPStreamStats(std::move(id), timestamp_us),
+ Timestamp timestamp)
+ : RTCRTPStreamStats(std::move(id), timestamp),
media_source_id("mediaSourceId"),
remote_id("remoteId"),
mid("mid"),
@@ -658,6 +710,10 @@
active("active"),
power_efficient_encoder("powerEfficientEncoder"),
scalability_mode("scalabilityMode") {}
+RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(std::string id,
+ int64_t timestamp_us)
+ : RTCOutboundRTPStreamStats(std::move(id),
+ Timestamp::Micros(timestamp_us)) {}
RTCOutboundRTPStreamStats::RTCOutboundRTPStreamStats(
const RTCOutboundRTPStreamStats& other) = default;
@@ -677,13 +733,18 @@
RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
std::string id,
- int64_t timestamp_us)
- : RTCReceivedRtpStreamStats(std::move(id), timestamp_us),
+ Timestamp timestamp)
+ : RTCReceivedRtpStreamStats(std::move(id), timestamp),
local_id("localId"),
round_trip_time("roundTripTime"),
fraction_lost("fractionLost"),
total_round_trip_time("totalRoundTripTime"),
round_trip_time_measurements("roundTripTimeMeasurements") {}
+RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
+ std::string id,
+ int64_t timestamp_us)
+ : RTCRemoteInboundRtpStreamStats(std::move(id),
+ Timestamp::Micros(timestamp_us)) {}
RTCRemoteInboundRtpStreamStats::RTCRemoteInboundRtpStreamStats(
const RTCRemoteInboundRtpStreamStats& other) = default;
@@ -704,14 +765,19 @@
RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats(
std::string id,
- int64_t timestamp_us)
- : RTCSentRtpStreamStats(std::move(id), timestamp_us),
+ Timestamp timestamp)
+ : RTCSentRtpStreamStats(std::move(id), timestamp),
local_id("localId"),
remote_timestamp("remoteTimestamp"),
reports_sent("reportsSent"),
round_trip_time("roundTripTime"),
round_trip_time_measurements("roundTripTimeMeasurements"),
total_round_trip_time("totalRoundTripTime") {}
+RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats(
+ std::string id,
+ int64_t timestamp)
+ : RTCRemoteOutboundRtpStreamStats(std::move(id),
+ Timestamp::Micros(timestamp)) {}
RTCRemoteOutboundRtpStreamStats::RTCRemoteOutboundRtpStreamStats(
const RTCRemoteOutboundRtpStreamStats& other) = default;
@@ -724,10 +790,12 @@
&kind)
// clang-format on
-RTCMediaSourceStats::RTCMediaSourceStats(std::string id, int64_t timestamp_us)
- : RTCStats(std::move(id), timestamp_us),
+RTCMediaSourceStats::RTCMediaSourceStats(std::string id, Timestamp timestamp)
+ : RTCStats(std::move(id), timestamp),
track_identifier("trackIdentifier"),
kind("kind") {}
+RTCMediaSourceStats::RTCMediaSourceStats(std::string id, int64_t timestamp_us)
+ : RTCMediaSourceStats(std::move(id), Timestamp::Micros(timestamp_us)) {}
RTCMediaSourceStats::RTCMediaSourceStats(const RTCMediaSourceStats& other) =
default;
@@ -743,13 +811,15 @@
&echo_return_loss_enhancement)
// clang-format on
-RTCAudioSourceStats::RTCAudioSourceStats(std::string id, int64_t timestamp_us)
- : RTCMediaSourceStats(std::move(id), timestamp_us),
+RTCAudioSourceStats::RTCAudioSourceStats(std::string id, Timestamp timestamp)
+ : RTCMediaSourceStats(std::move(id), timestamp),
audio_level("audioLevel"),
total_audio_energy("totalAudioEnergy"),
total_samples_duration("totalSamplesDuration"),
echo_return_loss("echoReturnLoss"),
echo_return_loss_enhancement("echoReturnLossEnhancement") {}
+RTCAudioSourceStats::RTCAudioSourceStats(std::string id, int64_t timestamp_us)
+ : RTCAudioSourceStats(std::move(id), Timestamp::Micros(timestamp_us)) {}
RTCAudioSourceStats::RTCAudioSourceStats(const RTCAudioSourceStats& other) =
default;
@@ -764,12 +834,14 @@
&frames_per_second)
// clang-format on
-RTCVideoSourceStats::RTCVideoSourceStats(std::string id, int64_t timestamp_us)
- : RTCMediaSourceStats(std::move(id), timestamp_us),
+RTCVideoSourceStats::RTCVideoSourceStats(std::string id, Timestamp timestamp)
+ : RTCMediaSourceStats(std::move(id), timestamp),
width("width"),
height("height"),
frames("frames"),
frames_per_second("framesPerSecond") {}
+RTCVideoSourceStats::RTCVideoSourceStats(std::string id, int64_t timestamp_us)
+ : RTCVideoSourceStats(std::move(id), Timestamp::Micros(timestamp_us)) {}
RTCVideoSourceStats::RTCVideoSourceStats(const RTCVideoSourceStats& other) =
default;
@@ -797,8 +869,8 @@
&ice_state)
// clang-format on
-RTCTransportStats::RTCTransportStats(std::string id, int64_t timestamp_us)
- : RTCStats(std::move(id), timestamp_us),
+RTCTransportStats::RTCTransportStats(std::string id, Timestamp timestamp)
+ : RTCStats(std::move(id), timestamp),
bytes_sent("bytesSent"),
packets_sent("packetsSent"),
bytes_received("bytesReceived"),
@@ -816,6 +888,8 @@
ice_role("iceRole"),
ice_local_username_fragment("iceLocalUsernameFragment"),
ice_state("iceState") {}
+RTCTransportStats::RTCTransportStats(std::string id, int64_t timestamp_us)
+ : RTCTransportStats(std::move(id), Timestamp::Micros(timestamp_us)) {}
RTCTransportStats::RTCTransportStats(const RTCTransportStats& other) = default;