Update talk to 58113193 together with https://webrtc-codereview.appspot.com/5309005/.
R=mallinath@webrtc.org, niklas.enbom@webrtc.org Review URL: https://webrtc-codereview.appspot.com/5719004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@5274 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -31,9 +31,30 @@
|
||||
#include "talk/base/dscp.h"
|
||||
#include "talk/base/sigslot.h"
|
||||
#include "talk/base/socket.h"
|
||||
#include "talk/base/timeutils.h"
|
||||
|
||||
namespace talk_base {
|
||||
|
||||
// This structure will have the information about when packet is actually
|
||||
// received by socket.
|
||||
struct PacketTime {
|
||||
PacketTime() : timestamp(-1), not_before(-1) {}
|
||||
PacketTime(int64 timestamp, int64 not_before)
|
||||
: timestamp(timestamp), not_before(not_before) {
|
||||
}
|
||||
|
||||
int64 timestamp; // Receive time after socket delivers the data.
|
||||
int64 not_before; // 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.
|
||||
};
|
||||
|
||||
inline PacketTime CreatePacketTime(int64 not_before) {
|
||||
return PacketTime(TimeMicros(), not_before);
|
||||
}
|
||||
|
||||
// Provides the ability to receive packets asynchronously. Sends are not
|
||||
// buffered since it is acceptable to drop packets under high load.
|
||||
class AsyncPacketSocket : public sigslot::has_slots<> {
|
||||
@@ -78,8 +99,9 @@ class AsyncPacketSocket : public sigslot::has_slots<> {
|
||||
|
||||
// Emitted each time a packet is read. Used only for UDP and
|
||||
// connected TCP sockets.
|
||||
sigslot::signal4<AsyncPacketSocket*, const char*, size_t,
|
||||
const SocketAddress&> SignalReadPacket;
|
||||
sigslot::signal5<AsyncPacketSocket*, const char*, size_t,
|
||||
const SocketAddress&,
|
||||
const PacketTime&> SignalReadPacket;
|
||||
|
||||
// Emitted when the socket is currently able to send.
|
||||
sigslot::signal1<AsyncPacketSocket*> SignalReadyToSend;
|
||||
|
@@ -300,7 +300,8 @@ void AsyncTCPSocket::ProcessInput(char * data, size_t* len) {
|
||||
if (*len < kPacketLenSize + pkt_len)
|
||||
return;
|
||||
|
||||
SignalReadPacket(this, data + kPacketLenSize, pkt_len, remote_addr);
|
||||
SignalReadPacket(this, data + kPacketLenSize, pkt_len, remote_addr,
|
||||
CreatePacketTime(0));
|
||||
|
||||
*len -= kPacketLenSize + pkt_len;
|
||||
if (*len > 0) {
|
||||
|
@@ -128,7 +128,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_, (size_t)len, remote_addr);
|
||||
SignalReadPacket(this, buf_, static_cast<size_t>(len), remote_addr,
|
||||
CreatePacketTime(0));
|
||||
}
|
||||
|
||||
void AsyncUDPSocket::OnWriteEvent(AsyncSocket* socket) {
|
||||
|
@@ -107,7 +107,7 @@ NATServer::~NATServer() {
|
||||
|
||||
void NATServer::OnInternalPacket(
|
||||
AsyncPacketSocket* socket, const char* buf, size_t size,
|
||||
const SocketAddress& addr) {
|
||||
const SocketAddress& addr, const PacketTime& packet_time) {
|
||||
|
||||
// Read the intended destination from the wire.
|
||||
SocketAddress dest_addr;
|
||||
@@ -132,7 +132,7 @@ void NATServer::OnInternalPacket(
|
||||
|
||||
void NATServer::OnExternalPacket(
|
||||
AsyncPacketSocket* socket, const char* buf, size_t size,
|
||||
const SocketAddress& remote_addr) {
|
||||
const SocketAddress& remote_addr, const PacketTime& packet_time) {
|
||||
|
||||
SocketAddress local_addr = socket->GetLocalAddress();
|
||||
|
||||
|
@@ -79,9 +79,11 @@ class NATServer : public sigslot::has_slots<> {
|
||||
|
||||
// Packets received on one of the networks.
|
||||
void OnInternalPacket(AsyncPacketSocket* socket, const char* buf,
|
||||
size_t size, const SocketAddress& addr);
|
||||
size_t size, const SocketAddress& addr,
|
||||
const PacketTime& packet_time);
|
||||
void OnExternalPacket(AsyncPacketSocket* socket, const char* buf,
|
||||
size_t size, const SocketAddress& remote_addr);
|
||||
size_t size, const SocketAddress& remote_addr,
|
||||
const PacketTime& packet_time);
|
||||
|
||||
private:
|
||||
typedef std::set<SocketAddress, AddrCmp> AddressSet;
|
||||
|
@@ -762,7 +762,7 @@ TEST_F(SSLStreamAdapterTestDTLS,
|
||||
};
|
||||
|
||||
// Test a handshake with small MTU
|
||||
TEST_F(SSLStreamAdapterTestDTLS, DISABLED_TestDTLSConnectWithSmallMtu) {
|
||||
TEST_F(SSLStreamAdapterTestDTLS, TestDTLSConnectWithSmallMtu) {
|
||||
MAYBE_SKIP_TEST(HaveDtls);
|
||||
SetMtu(700);
|
||||
SetHandshakeWait(20000);
|
||||
|
@@ -135,7 +135,8 @@ bool TestClient::ready_to_send() const {
|
||||
}
|
||||
|
||||
void TestClient::OnPacket(AsyncPacketSocket* socket, const char* buf,
|
||||
size_t size, const SocketAddress& remote_addr) {
|
||||
size_t size, const SocketAddress& remote_addr,
|
||||
const PacketTime& packet_time) {
|
||||
CritScope cs(&crit_);
|
||||
packets_->push_back(new Packet(remote_addr, buf, size));
|
||||
}
|
||||
|
@@ -94,7 +94,8 @@ class TestClient : public sigslot::has_slots<> {
|
||||
Socket::ConnState GetState();
|
||||
// Slot for packets read on the socket.
|
||||
void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t len,
|
||||
const SocketAddress& remote_addr);
|
||||
const SocketAddress& remote_addr,
|
||||
const PacketTime& packet_time);
|
||||
void OnReadyToSend(AsyncPacketSocket* socket);
|
||||
|
||||
CriticalSection crit_;
|
||||
|
@@ -67,7 +67,8 @@ class TestEchoServer : public sigslot::has_slots<> {
|
||||
}
|
||||
}
|
||||
void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t size,
|
||||
const SocketAddress& remote_addr) {
|
||||
const SocketAddress& remote_addr,
|
||||
const PacketTime& packet_time) {
|
||||
socket->Send(buf, size, DSCP_NO_CHANGE);
|
||||
}
|
||||
void OnClose(AsyncPacketSocket* socket, int err) {
|
||||
|
@@ -81,7 +81,8 @@ class SocketClient : public TestGenerator, public sigslot::has_slots<> {
|
||||
SocketAddress address() const { return socket_->GetLocalAddress(); }
|
||||
|
||||
void OnPacket(AsyncPacketSocket* socket, const char* buf, size_t size,
|
||||
const SocketAddress& remote_addr) {
|
||||
const SocketAddress& remote_addr,
|
||||
const PacketTime& packet_time) {
|
||||
EXPECT_EQ(size, sizeof(uint32));
|
||||
uint32 prev = reinterpret_cast<const uint32*>(buf)[0];
|
||||
uint32 result = Next(prev);
|
||||
|
@@ -94,6 +94,10 @@ uint32 Time() {
|
||||
return static_cast<uint32>(TimeNanos() / kNumNanosecsPerMillisec);
|
||||
}
|
||||
|
||||
uint64 TimeMicros() {
|
||||
return static_cast<uint64>(TimeNanos() / kNumNanosecsPerMicrosec);
|
||||
}
|
||||
|
||||
#if defined(WIN32)
|
||||
static const uint64 kFileTimeToUnixTimeEpochOffset = 116444736000000000ULL;
|
||||
|
||||
|
@@ -42,6 +42,8 @@ static const int64 kNumMicrosecsPerMillisec = kNumMicrosecsPerSec /
|
||||
kNumMillisecsPerSec;
|
||||
static const int64 kNumNanosecsPerMillisec = kNumNanosecsPerSec /
|
||||
kNumMillisecsPerSec;
|
||||
static const int64 kNumNanosecsPerMicrosec = kNumNanosecsPerSec /
|
||||
kNumMicrosecsPerSec;
|
||||
|
||||
// January 1970, in NTP milliseconds.
|
||||
static const int64 kJan1970AsNtpMillisecs = INT64_C(2208988800000);
|
||||
@@ -50,6 +52,8 @@ typedef uint32 TimeStamp;
|
||||
|
||||
// Returns the current time in milliseconds.
|
||||
uint32 Time();
|
||||
// Returns the current time in microseconds.
|
||||
uint64 TimeMicros();
|
||||
// Returns the current time in nanoseconds.
|
||||
uint64 TimeNanos();
|
||||
|
||||
|
@@ -97,7 +97,8 @@ struct Receiver : public MessageHandler, public sigslot::has_slots<> {
|
||||
}
|
||||
|
||||
void OnReadPacket(AsyncPacketSocket* s, const char* data, size_t size,
|
||||
const SocketAddress& remote_addr) {
|
||||
const SocketAddress& remote_addr,
|
||||
const PacketTime& packet_time) {
|
||||
ASSERT_EQ(socket.get(), s);
|
||||
ASSERT_GE(size, 4U);
|
||||
|
||||
|
Reference in New Issue
Block a user