diff --git a/api/stats/rtc_stats.h b/api/stats/rtc_stats.h index 1310b3ae67..1ffb4316f3 100644 --- a/api/stats/rtc_stats.h +++ b/api/stats/rtc_stats.h @@ -63,6 +63,7 @@ class RTC_EXPORT RTCStats { const std::string& id() const { return id_; } // Time relative to the UNIX epoch (Jan 1, 1970, UTC), in microseconds. Timestamp timestamp() const { return timestamp_; } + void set_timestamp(Timestamp timestamp) { timestamp_ = timestamp; } // Returns the static member variable `kType` of the implementing class. virtual const char* type() const = 0; diff --git a/stats/rtc_stats_unittest.cc b/stats/rtc_stats_unittest.cc index 4918a14eaa..0757fb7940 100644 --- a/stats/rtc_stats_unittest.cc +++ b/stats/rtc_stats_unittest.cc @@ -484,6 +484,12 @@ TEST(RTCStatsTest, AttributeToString) { stats.GetAttribute(stats.m_map_string_double).ToString()); } +TEST(RTCStatsTest, SetTimestamp) { + RTCTestStats test_stats("testId", Timestamp::Micros(123)); + test_stats.set_timestamp(Timestamp::Micros(321)); + EXPECT_EQ(test_stats.timestamp(), Timestamp::Micros(321)); +} + // Death tests. // Disabled on Android because death tests misbehave on Android, see // base/test/gtest_util.h.