| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdint.h> | 5 #include <stdint.h> |
| 6 #include <cstdio> | 6 #include <cstdio> |
| 7 #include <cstdlib> | 7 #include <cstdlib> |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 base::CommandLine::Init(argc, argv); | 136 base::CommandLine::Init(argc, argv); |
| 137 logging::LoggingSettings settings; | 137 logging::LoggingSettings settings; |
| 138 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; | 138 settings.logging_dest = logging::LOG_TO_SYSTEM_DEBUG_LOG; |
| 139 InitLogging(settings); | 139 InitLogging(settings); |
| 140 | 140 |
| 141 if (argc != 5 && argc != 3) { | 141 if (argc != 5 && argc != 3) { |
| 142 fprintf(stderr, | 142 fprintf(stderr, |
| 143 "Usage: udp_proxy <localport> <remotehost> <remoteport> <type>\n" | 143 "Usage: udp_proxy <localport> <remotehost> <remoteport> <type>\n" |
| 144 "or:\n" | 144 "or:\n" |
| 145 " udp_proxy <localport> <type>\n" | 145 " udp_proxy <localport> <type>\n" |
| 146 "Where type is one of: perfect, wifi, bad, evil, poisson-wifi\n"); | 146 "Where type is one of:\n" |
| 147 " perfect, wifi, slow, bad, evil, poisson-wifi\n"); |
| 147 exit(1); | 148 exit(1); |
| 148 } | 149 } |
| 149 | 150 |
| 150 net::IPAddress remote_ip_address; | 151 net::IPAddress remote_ip_address; |
| 151 std::string network_type; | 152 std::string network_type; |
| 152 int local_port = atoi(argv[1]); | 153 int local_port = atoi(argv[1]); |
| 153 int remote_port = 0; | 154 int remote_port = 0; |
| 154 | 155 |
| 155 if (argc == 5) { | 156 if (argc == 5) { |
| 156 // V2 proxy | 157 // V2 proxy |
| (...skipping 15 matching lines...) Expand all Loading... |
| 172 static_cast<uint16_t>(local_port)); | 173 static_cast<uint16_t>(local_port)); |
| 173 std::unique_ptr<media::cast::test::PacketPipe> in_pipe, out_pipe; | 174 std::unique_ptr<media::cast::test::PacketPipe> in_pipe, out_pipe; |
| 174 std::unique_ptr<media::cast::test::InterruptedPoissonProcess> ipp( | 175 std::unique_ptr<media::cast::test::InterruptedPoissonProcess> ipp( |
| 175 media::cast::test::DefaultInterruptedPoissonProcess()); | 176 media::cast::test::DefaultInterruptedPoissonProcess()); |
| 176 | 177 |
| 177 if (network_type == "perfect") { | 178 if (network_type == "perfect") { |
| 178 // No action needed. | 179 // No action needed. |
| 179 } else if (network_type == "wifi") { | 180 } else if (network_type == "wifi") { |
| 180 in_pipe = media::cast::test::WifiNetwork(); | 181 in_pipe = media::cast::test::WifiNetwork(); |
| 181 out_pipe = media::cast::test::WifiNetwork(); | 182 out_pipe = media::cast::test::WifiNetwork(); |
| 183 } else if (network_type == "slow") { |
| 184 in_pipe = media::cast::test::SlowNetwork(); |
| 185 out_pipe = media::cast::test::SlowNetwork(); |
| 182 } else if (network_type == "bad") { | 186 } else if (network_type == "bad") { |
| 183 in_pipe = media::cast::test::BadNetwork(); | 187 in_pipe = media::cast::test::BadNetwork(); |
| 184 out_pipe = media::cast::test::BadNetwork(); | 188 out_pipe = media::cast::test::BadNetwork(); |
| 185 } else if (network_type == "evil") { | 189 } else if (network_type == "evil") { |
| 186 in_pipe = media::cast::test::EvilNetwork(); | 190 in_pipe = media::cast::test::EvilNetwork(); |
| 187 out_pipe = media::cast::test::EvilNetwork(); | 191 out_pipe = media::cast::test::EvilNetwork(); |
| 188 } else if (network_type == "poisson-wifi") { | 192 } else if (network_type == "poisson-wifi") { |
| 189 in_pipe = ipp->NewBuffer(128 * 1024); | 193 in_pipe = ipp->NewBuffer(128 * 1024); |
| 190 out_pipe = ipp->NewBuffer(128 * 1024); | 194 out_pipe = ipp->NewBuffer(128 * 1024); |
| 191 } else { | 195 } else { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 204 std::unique_ptr<media::cast::test::UDPProxy> proxy( | 208 std::unique_ptr<media::cast::test::UDPProxy> proxy( |
| 205 media::cast::test::UDPProxy::Create(local_endpoint, remote_endpoint, | 209 media::cast::test::UDPProxy::Create(local_endpoint, remote_endpoint, |
| 206 std::move(in_pipe), | 210 std::move(in_pipe), |
| 207 std::move(out_pipe), NULL)); | 211 std::move(out_pipe), NULL)); |
| 208 base::MessageLoop message_loop; | 212 base::MessageLoop message_loop; |
| 209 counter->last_printout = base::TimeTicks::Now(); | 213 counter->last_printout = base::TimeTicks::Now(); |
| 210 CheckByteCounters(); | 214 CheckByteCounters(); |
| 211 base::RunLoop().Run(); | 215 base::RunLoop().Run(); |
| 212 return 1; | 216 return 1; |
| 213 } | 217 } |
| OLD | NEW |