Add set_timestamp() method to RTCStats.

Useful for when creating aggregate stats objects, seems like an
oversight that we don't have it already.

Bug: None
Change-Id: Ied36afd2122464a81c7d725825353f9af59fe632
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/376220
Auto-Submit: Henrik Boström <hbos@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#43844}
diff --git a/api/stats/rtc_stats.h b/api/stats/rtc_stats.h
index 1310b3a..1ffb431 100644
--- a/api/stats/rtc_stats.h
+++ b/api/stats/rtc_stats.h
@@ -63,6 +63,7 @@
   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 4918a14..0757fb7 100644
--- a/stats/rtc_stats_unittest.cc
+++ b/stats/rtc_stats_unittest.cc
@@ -484,6 +484,12 @@
             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.