Index: webrtc/base/physicalsocketserver.cc |
diff --git a/webrtc/base/physicalsocketserver.cc b/webrtc/base/physicalsocketserver.cc |
index e2a0b6f14048b4007126ce9a13838f1858fbc1f8..7581280022cc83d8b00a00d4c8748579b778ecae 100644 |
--- a/webrtc/base/physicalsocketserver.cc |
+++ b/webrtc/base/physicalsocketserver.cc |
@@ -23,6 +23,7 @@ |
#include <string.h> |
#include <errno.h> |
#include <fcntl.h> |
+#include <sys/ioctl.h> |
#include <sys/time.h> |
#include <sys/select.h> |
#include <unistd.h> |
@@ -55,8 +56,28 @@ |
#include <netinet/tcp.h> // for TCP_NODELAY |
#define IP_MTU 14 // Until this is integrated from linux/in.h to netinet/in.h |
typedef void* SockOptArg; |
+ |
#endif // WEBRTC_POSIX |
+#if defined(WEBRTC_POSIX) && !defined(WEBRTC_MAC) |
+int64_t GetSocketRecvTimestamp(int socket) { |
+ struct timeval tv_ioctl; |
+ int ret = ioctl(socket, SIOCGSTAMP, &tv_ioctl); |
juberti2
2016/05/11 05:03:34
Do you need to set a socket option for this to wor
stefan-webrtc
2016/05/11 08:41:14
No. There are two ways of getting the timestamp fr
|
+ if (ret != 0) |
+ return -1; |
+ int64_t timestamp = |
+ rtc::kNumMicrosecsPerSec * static_cast<int64_t>(tv_ioctl.tv_sec) + |
+ static_cast<int64_t>(tv_ioctl.tv_usec); |
+ return timestamp; |
+} |
+ |
+#else |
+ |
+int64_t GetSocketRecvTimestamp(int socket) { |
+ return -1; |
+} |
+#endif |
+ |
#if defined(WEBRTC_WIN) |
typedef char* SockOptArg; |
#endif |
@@ -324,7 +345,7 @@ int PhysicalSocket::SendTo(const void* buffer, |
return sent; |
} |
-int PhysicalSocket::Recv(void* buffer, size_t length) { |
+int PhysicalSocket::Recv(void* buffer, size_t length, int64_t* timestamp) { |
int received = ::recv(s_, static_cast<char*>(buffer), |
static_cast<int>(length), 0); |
if ((received == 0) && (length != 0)) { |
@@ -338,6 +359,7 @@ int PhysicalSocket::Recv(void* buffer, size_t length) { |
SetError(EWOULDBLOCK); |
return SOCKET_ERROR; |
} |
+ *timestamp = GetSocketRecvTimestamp(s_); |
juberti2
2016/05/11 05:03:34
Allow NULL to be passed so that clients who don't
stefan-webrtc
2016/05/11 08:41:14
Done.
|
UpdateLastError(); |
int error = GetError(); |
bool success = (received >= 0) || IsBlockingError(error); |
@@ -352,12 +374,14 @@ int PhysicalSocket::Recv(void* buffer, size_t length) { |
int PhysicalSocket::RecvFrom(void* buffer, |
size_t length, |
- SocketAddress* out_addr) { |
+ SocketAddress* out_addr, |
+ int64_t* timestamp) { |
sockaddr_storage addr_storage; |
socklen_t addr_len = sizeof(addr_storage); |
sockaddr* addr = reinterpret_cast<sockaddr*>(&addr_storage); |
int received = ::recvfrom(s_, static_cast<char*>(buffer), |
static_cast<int>(length), 0, addr, &addr_len); |
+ *timestamp = GetSocketRecvTimestamp(s_); |
UpdateLastError(); |
if ((received >= 0) && (out_addr != nullptr)) |
SocketAddressFromSockAddrStorage(addr_storage, out_addr); |