Delete struct rtc::PacketTime.
Replaced by a int64_t representing time in us. To aid transition of
downstream code, rtc::PacketTime is made an alias for int64_t.
Bug: webrtc:9584
Change-Id: Ic3a5ee87d6de2aad7712894906dab074f1443df9
Reviewed-on: https://webrtc-review.googlesource.com/c/91860
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25503}diff --git a/rtc_base/asyncpacketsocket.h b/rtc_base/asyncpacketsocket.h
index e671f0d..44d6c67 100644
--- a/rtc_base/asyncpacketsocket.h
+++ b/rtc_base/asyncpacketsocket.h
@@ -51,25 +51,9 @@
PacketInfo info_signaled_after_sent;
};
-// This structure will have the information about when packet is actually
-// received by socket.
-struct PacketTime {
- PacketTime() : timestamp(-1) {}
- // Intentionally implicit.
- PacketTime(int64_t timestamp) : timestamp(timestamp) {}
- // Deprecated
- PacketTime(int64_t timestamp, int64_t /* not_before */)
- : timestamp(timestamp) {}
-
- operator int64_t() const { return timestamp; }
-
- int64_t timestamp; // Receive time after socket delivers the data.
-};
-
-// Deprecated
-inline PacketTime CreatePacketTime(int64_t /* not_before */) {
- return TimeMicros();
-}
+// TODO(bugs.webrtc.org/9584): Compatibility alias, delete as soon as downstream
+// code is updated.
+typedef int64_t PacketTime;
// Provides the ability to receive packets asynchronously. Sends are not
// buffered since it is acceptable to drop packets under high load.
@@ -121,7 +105,9 @@
const char*,
size_t,
const SocketAddress&,
- const PacketTime&>
+ // TODO(bugs.webrtc.org/9584): Change to passing the int64_t
+ // timestamp by value.
+ const int64_t&>
SignalReadPacket;
// Emitted each time a packet is sent.
diff --git a/rtc_base/natserver.cc b/rtc_base/natserver.cc
index 8119376..b005eca 100644
--- a/rtc_base/natserver.cc
+++ b/rtc_base/natserver.cc
@@ -158,7 +158,7 @@
const char* buf,
size_t size,
const SocketAddress& addr,
- const PacketTime& packet_time) {
+ const int64_t& /* packet_time_us */) {
// Read the intended destination from the wire.
SocketAddress dest_addr;
size_t length = UnpackAddressFromNAT(buf, size, &dest_addr);
@@ -184,7 +184,7 @@
const char* buf,
size_t size,
const SocketAddress& remote_addr,
- const PacketTime& packet_time) {
+ const int64_t& /* packet_time_us */) {
SocketAddress local_addr = socket->GetLocalAddress();
// Find the translation for this addresses.
diff --git a/rtc_base/natserver.h b/rtc_base/natserver.h
index f4cabcf..d16b537 100644
--- a/rtc_base/natserver.h
+++ b/rtc_base/natserver.h
@@ -81,12 +81,12 @@
const char* buf,
size_t size,
const SocketAddress& addr,
- const PacketTime& packet_time);
+ const int64_t& packet_time_us);
void OnExternalUDPPacket(AsyncPacketSocket* socket,
const char* buf,
size_t size,
const SocketAddress& remote_addr,
- const PacketTime& packet_time);
+ const int64_t& packet_time_us);
private:
typedef std::set<SocketAddress, AddrCmp> AddressSet;
diff --git a/rtc_base/testclient.cc b/rtc_base/testclient.cc
index 56a9f8c..a5b90dd 100644
--- a/rtc_base/testclient.cc
+++ b/rtc_base/testclient.cc
@@ -97,7 +97,7 @@
std::unique_ptr<Packet> packet = NextPacket(kTimeoutMs);
if (packet) {
res = (packet->size == size && memcmp(packet->buf, buf, size) == 0 &&
- CheckTimestamp(packet->packet_time));
+ CheckTimestamp(packet->packet_time_us));
if (addr)
*addr = packet->addr;
}
@@ -144,10 +144,10 @@
const char* buf,
size_t size,
const SocketAddress& remote_addr,
- const PacketTime& packet_time) {
+ const int64_t& packet_time_us) {
CritScope cs(&crit_);
packets_.push_back(
- absl::make_unique<Packet>(remote_addr, buf, size, packet_time));
+ absl::make_unique<Packet>(remote_addr, buf, size, packet_time_us));
}
void TestClient::OnReadyToSend(AsyncPacketSocket* socket) {
@@ -157,14 +157,14 @@
TestClient::Packet::Packet(const SocketAddress& a,
const char* b,
size_t s,
- const PacketTime& packet_time)
- : addr(a), buf(0), size(s), packet_time(packet_time) {
+ int64_t packet_time_us)
+ : addr(a), buf(0), size(s), packet_time_us(packet_time_us) {
buf = new char[size];
memcpy(buf, b, size);
}
TestClient::Packet::Packet(const Packet& p)
- : addr(p.addr), buf(0), size(p.size), packet_time(p.packet_time) {
+ : addr(p.addr), buf(0), size(p.size), packet_time_us(p.packet_time_us) {
buf = new char[size];
memcpy(buf, p.buf, size);
}
diff --git a/rtc_base/testclient.h b/rtc_base/testclient.h
index a0d98b3..16fb6ba 100644
--- a/rtc_base/testclient.h
+++ b/rtc_base/testclient.h
@@ -29,14 +29,14 @@
Packet(const SocketAddress& a,
const char* b,
size_t s,
- const PacketTime& packet_time);
+ int64_t packet_time_us);
Packet(const Packet& p);
virtual ~Packet();
SocketAddress addr;
char* buf;
size_t size;
- PacketTime packet_time;
+ int64_t packet_time_us;
};
// Default timeout for NextPacket reads.
@@ -97,7 +97,7 @@
const char* buf,
size_t len,
const SocketAddress& remote_addr,
- const PacketTime& packet_time);
+ const int64_t& packet_time_us);
void OnReadyToSend(AsyncPacketSocket* socket);
bool CheckTimestamp(int64_t packet_timestamp);
void AdvanceTime(int ms);
diff --git a/rtc_base/testechoserver.h b/rtc_base/testechoserver.h
index 5e714eb6..9ffd786 100644
--- a/rtc_base/testechoserver.h
+++ b/rtc_base/testechoserver.h
@@ -44,7 +44,7 @@
const char* buf,
size_t size,
const SocketAddress& remote_addr,
- const PacketTime& packet_time) {
+ const int64_t& /* packet_time_us */) {
rtc::PacketOptions options;
socket->Send(buf, size, options);
}
diff --git a/rtc_base/thread_unittest.cc b/rtc_base/thread_unittest.cc
index d5c53f8..dc509b5 100644
--- a/rtc_base/thread_unittest.cc
+++ b/rtc_base/thread_unittest.cc
@@ -69,7 +69,7 @@
const char* buf,
size_t size,
const SocketAddress& remote_addr,
- const PacketTime& packet_time) {
+ const int64_t& packet_time_us) {
EXPECT_EQ(size, sizeof(uint32_t));
uint32_t prev = reinterpret_cast<const uint32_t*>(buf)[0];
uint32_t result = Next(prev);
diff --git a/rtc_base/virtualsocket_unittest.cc b/rtc_base/virtualsocket_unittest.cc
index d2bff54..d44f46a 100644
--- a/rtc_base/virtualsocket_unittest.cc
+++ b/rtc_base/virtualsocket_unittest.cc
@@ -104,7 +104,7 @@
const char* data,
size_t size,
const SocketAddress& remote_addr,
- const PacketTime& packet_time) {
+ const int64_t& /* packet_time_us */) {
ASSERT_EQ(socket.get(), s);
ASSERT_GE(size, 4U);