Add implicit conversion between rtc:PacketTime and int64_t.
This is a preparation for deleting rtc::PacketTime. Next step, after downstream code has been updated to not access the |timestamp| member, is to make rtc::PacketTime an alias for int64_t. Also delete the unused member rtc::PacketTime::not_before. Bug: webrtc:9584 Change-Id: Iba9d2d55047d69565ad62b1beb525591fd432ae2 Reviewed-on: https://webrtc-review.googlesource.com/c/108860 Commit-Queue: Niels Moller <nisse@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25468}
This commit is contained in:
@ -699,6 +699,9 @@ rtc_static_library("rtc_base") {
|
||||
defines = []
|
||||
deps = [
|
||||
":checks",
|
||||
|
||||
# For deprecation of rtc::PacketTime, in asyncpacketsocket.h.
|
||||
":deprecation",
|
||||
":stringutils",
|
||||
"..:webrtc_common",
|
||||
"../api:array_view",
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
#define RTC_BASE_ASYNCPACKETSOCKET_H_
|
||||
|
||||
#include "rtc_base/constructormagic.h"
|
||||
#include "rtc_base/deprecation.h"
|
||||
#include "rtc_base/dscp.h"
|
||||
#include "rtc_base/socket.h"
|
||||
#include "rtc_base/third_party/sigslot/sigslot.h"
|
||||
@ -53,21 +54,21 @@ struct PacketOptions {
|
||||
// This structure will have the information about when packet is actually
|
||||
// received by socket.
|
||||
struct PacketTime {
|
||||
PacketTime() : timestamp(-1), not_before(-1) {}
|
||||
PacketTime(int64_t timestamp, int64_t not_before)
|
||||
: timestamp(timestamp), not_before(not_before) {}
|
||||
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.
|
||||
|
||||
// Earliest possible time the data could have arrived, indicating the
|
||||
// potential error in the |timestamp| value, in case the system, is busy. For
|
||||
// example, the time of the last select() call.
|
||||
// If unknown, this value will be set to zero.
|
||||
int64_t not_before;
|
||||
};
|
||||
|
||||
inline PacketTime CreatePacketTime(int64_t not_before) {
|
||||
return PacketTime(TimeMicros(), not_before);
|
||||
// Deprecated
|
||||
inline PacketTime CreatePacketTime(int64_t /* not_before */) {
|
||||
return TimeMicros();
|
||||
}
|
||||
|
||||
// Provides the ability to receive packets asynchronously. Sends are not
|
||||
|
||||
@ -321,7 +321,7 @@ void AsyncTCPSocket::ProcessInput(char* data, size_t* len) {
|
||||
return;
|
||||
|
||||
SignalReadPacket(this, data + kPacketLenSize, pkt_len, remote_addr,
|
||||
CreatePacketTime(0));
|
||||
TimeMicros());
|
||||
|
||||
*len -= kPacketLenSize + pkt_len;
|
||||
if (*len > 0) {
|
||||
|
||||
@ -122,9 +122,8 @@ void AsyncUDPSocket::OnReadEvent(AsyncSocket* socket) {
|
||||
|
||||
// TODO: Make sure that we got all of the packet.
|
||||
// If we did not, then we should resize our buffer to be large enough.
|
||||
SignalReadPacket(
|
||||
this, buf_, static_cast<size_t>(len), remote_addr,
|
||||
(timestamp > -1 ? PacketTime(timestamp, 0) : CreatePacketTime(0)));
|
||||
SignalReadPacket(this, buf_, static_cast<size_t>(len), remote_addr,
|
||||
(timestamp > -1 ? timestamp : TimeMicros()));
|
||||
}
|
||||
|
||||
void AsyncUDPSocket::OnWriteEvent(AsyncSocket* socket) {
|
||||
|
||||
@ -97,7 +97,7 @@ bool TestClient::CheckNextPacket(const char* buf,
|
||||
std::unique_ptr<Packet> packet = NextPacket(kTimeoutMs);
|
||||
if (packet) {
|
||||
res = (packet->size == size && memcmp(packet->buf, buf, size) == 0 &&
|
||||
CheckTimestamp(packet->packet_time.timestamp));
|
||||
CheckTimestamp(packet->packet_time));
|
||||
if (addr)
|
||||
*addr = packet->addr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user