OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2004 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2004 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 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 // route. | 887 // route. |
888 SocketAddress sender_addr = sender->local_addr_; | 888 SocketAddress sender_addr = sender->local_addr_; |
889 IPAddress default_ip = GetDefaultRoute(sender_addr.ipaddr().family()); | 889 IPAddress default_ip = GetDefaultRoute(sender_addr.ipaddr().family()); |
890 if (sender_addr.IsAnyIP() && !IPIsUnspec(default_ip)) { | 890 if (sender_addr.IsAnyIP() && !IPIsUnspec(default_ip)) { |
891 sender_addr.SetIP(default_ip); | 891 sender_addr.SetIP(default_ip); |
892 } | 892 } |
893 | 893 |
894 // Post the packet as a message to be delivered (on our own thread) | 894 // Post the packet as a message to be delivered (on our own thread) |
895 Packet* p = new Packet(data, data_size, sender_addr); | 895 Packet* p = new Packet(data, data_size, sender_addr); |
896 | 896 |
897 uint32_t ts = TimeAfter(send_delay + transit_delay); | 897 int64_t ts = TimeAfter(send_delay + transit_delay); |
898 if (ordered) { | 898 if (ordered) { |
899 // Ensure that new packets arrive after previous ones | 899 // Ensure that new packets arrive after previous ones |
900 // TODO: consider ordering on a per-socket basis, since this | 900 // TODO: consider ordering on a per-socket basis, since this |
901 // introduces artifical delay. | 901 // introduces artificial delay. |
902 ts = TimeMax(ts, network_delay_); | 902 ts = std::max(ts, network_delay_); |
903 } | 903 } |
904 msg_queue_->PostAt(ts, recipient, MSG_ID_PACKET, p); | 904 msg_queue_->PostAt(ts, recipient, MSG_ID_PACKET, p); |
905 network_delay_ = TimeMax(ts, network_delay_); | 905 network_delay_ = std::max(ts, network_delay_); |
906 } | 906 } |
907 | 907 |
908 void VirtualSocketServer::PurgeNetworkPackets(VirtualSocket* socket, | 908 void VirtualSocketServer::PurgeNetworkPackets(VirtualSocket* socket, |
909 uint32_t cur_time) { | 909 uint32_t cur_time) { |
910 while (!socket->network_.empty() && | 910 while (!socket->network_.empty() && |
911 (socket->network_.front().done_time <= cur_time)) { | 911 (socket->network_.front().done_time <= cur_time)) { |
912 ASSERT(socket->network_size_ >= socket->network_.front().size); | 912 ASSERT(socket->network_size_ >= socket->network_.front().size); |
913 socket->network_size_ -= socket->network_.front().size; | 913 socket->network_size_ -= socket->network_.front().size; |
914 socket->network_.pop_front(); | 914 socket->network_.pop_front(); |
915 } | 915 } |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1122 void VirtualSocketServer::SetDefaultRoute(const IPAddress& from_addr) { | 1122 void VirtualSocketServer::SetDefaultRoute(const IPAddress& from_addr) { |
1123 RTC_DCHECK(!IPIsAny(from_addr)); | 1123 RTC_DCHECK(!IPIsAny(from_addr)); |
1124 if (from_addr.family() == AF_INET) { | 1124 if (from_addr.family() == AF_INET) { |
1125 default_route_v4_ = from_addr; | 1125 default_route_v4_ = from_addr; |
1126 } else if (from_addr.family() == AF_INET6) { | 1126 } else if (from_addr.family() == AF_INET6) { |
1127 default_route_v6_ = from_addr; | 1127 default_route_v6_ = from_addr; |
1128 } | 1128 } |
1129 } | 1129 } |
1130 | 1130 |
1131 } // namespace rtc | 1131 } // namespace rtc |
OLD | NEW |