OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2007 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2007 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 1020 matching lines...) Loading... |
1031 #endif | 1031 #endif |
1032 } | 1032 } |
1033 } | 1033 } |
1034 | 1034 |
1035 void SocketTest::SocketRecvTimestamp(const IPAddress& loopback) { | 1035 void SocketTest::SocketRecvTimestamp(const IPAddress& loopback) { |
1036 std::unique_ptr<Socket> socket( | 1036 std::unique_ptr<Socket> socket( |
1037 ss_->CreateSocket(loopback.family(), SOCK_DGRAM)); | 1037 ss_->CreateSocket(loopback.family(), SOCK_DGRAM)); |
1038 EXPECT_EQ(0, socket->Bind(SocketAddress(loopback, 0))); | 1038 EXPECT_EQ(0, socket->Bind(SocketAddress(loopback, 0))); |
1039 SocketAddress address = socket->GetLocalAddress(); | 1039 SocketAddress address = socket->GetLocalAddress(); |
1040 | 1040 |
1041 uint64_t send_time_1 = TimeMicros(); | 1041 int64_t send_time_1 = TimeMicros(); |
1042 socket->SendTo("foo", 3, address); | 1042 socket->SendTo("foo", 3, address); |
1043 int64_t recv_timestamp_1; | 1043 int64_t recv_timestamp_1; |
1044 char buffer[3]; | 1044 char buffer[3]; |
1045 socket->RecvFrom(buffer, 3, nullptr, &recv_timestamp_1); | 1045 socket->RecvFrom(buffer, 3, nullptr, &recv_timestamp_1); |
1046 EXPECT_GT(recv_timestamp_1, -1); | 1046 EXPECT_GT(recv_timestamp_1, -1); |
1047 | 1047 |
1048 const int64_t kTimeBetweenPacketsMs = 100; | 1048 const int64_t kTimeBetweenPacketsMs = 100; |
1049 Thread::SleepMs(kTimeBetweenPacketsMs); | 1049 Thread::SleepMs(kTimeBetweenPacketsMs); |
1050 | 1050 |
1051 uint64_t send_time_2 = TimeMicros(); | 1051 int64_t send_time_2 = TimeMicros(); |
1052 socket->SendTo("bar", 3, address); | 1052 socket->SendTo("bar", 3, address); |
1053 int64_t recv_timestamp_2; | 1053 int64_t recv_timestamp_2; |
1054 socket->RecvFrom(buffer, 3, nullptr, &recv_timestamp_2); | 1054 socket->RecvFrom(buffer, 3, nullptr, &recv_timestamp_2); |
1055 | 1055 |
1056 int64_t system_time_diff = send_time_2 - send_time_1; | 1056 int64_t system_time_diff = send_time_2 - send_time_1; |
1057 int64_t recv_timestamp_diff = recv_timestamp_2 - recv_timestamp_1; | 1057 int64_t recv_timestamp_diff = recv_timestamp_2 - recv_timestamp_1; |
1058 // Compare against the system time at the point of sending, because | 1058 // Compare against the system time at the point of sending, because |
1059 // SleepMs may not sleep for exactly the requested time. | 1059 // SleepMs may not sleep for exactly the requested time. |
1060 EXPECT_NEAR(system_time_diff, recv_timestamp_diff, 10000); | 1060 EXPECT_NEAR(system_time_diff, recv_timestamp_diff, 10000); |
1061 } | 1061 } |
1062 | 1062 |
1063 } // namespace rtc | 1063 } // namespace rtc |
OLD | NEW |