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 <math.h> | 5 #include <math.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "media/cast/test/utility/udp_proxy.h" | 9 #include "media/cast/test/utility/udp_proxy.h" |
10 | 10 |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 } | 179 } |
180 | 180 |
181 private: | 181 private: |
182 double random_delay_; | 182 double random_delay_; |
183 }; | 183 }; |
184 | 184 |
185 scoped_ptr<PacketPipe> NewRandomUnsortedDelay(double random_delay) { | 185 scoped_ptr<PacketPipe> NewRandomUnsortedDelay(double random_delay) { |
186 return scoped_ptr<PacketPipe>(new RandomUnsortedDelay(random_delay)).Pass(); | 186 return scoped_ptr<PacketPipe>(new RandomUnsortedDelay(random_delay)).Pass(); |
187 } | 187 } |
188 | 188 |
| 189 class DuplicateAndDelay : public RandomUnsortedDelay { |
| 190 public: |
| 191 DuplicateAndDelay(double delay_min, |
| 192 double random_delay) : |
| 193 RandomUnsortedDelay(random_delay), |
| 194 delay_min_(delay_min) { |
| 195 } |
| 196 virtual void Send(scoped_ptr<Packet> packet) OVERRIDE { |
| 197 pipe_->Send(scoped_ptr<Packet>(new Packet(*packet.get()))); |
| 198 RandomUnsortedDelay::Send(packet.Pass()); |
| 199 } |
| 200 virtual double GetDelay() OVERRIDE { |
| 201 return RandomUnsortedDelay::GetDelay() + delay_min_; |
| 202 } |
| 203 private: |
| 204 double delay_min_; |
| 205 }; |
| 206 |
| 207 scoped_ptr<PacketPipe> NewDuplicateAndDelay(double delay_min, |
| 208 double random_delay) { |
| 209 return scoped_ptr<PacketPipe>( |
| 210 new DuplicateAndDelay(delay_min, random_delay)).Pass(); |
| 211 } |
189 | 212 |
190 class RandomSortedDelay : public PacketPipe { | 213 class RandomSortedDelay : public PacketPipe { |
191 public: | 214 public: |
192 RandomSortedDelay(double random_delay, | 215 RandomSortedDelay(double random_delay, |
193 double extra_delay, | 216 double extra_delay, |
194 double seconds_between_extra_delay) | 217 double seconds_between_extra_delay) |
195 : random_delay_(random_delay), | 218 : random_delay_(random_delay), |
196 extra_delay_(extra_delay), | 219 extra_delay_(extra_delay), |
197 seconds_between_extra_delay_(seconds_between_extra_delay), | 220 seconds_between_extra_delay_(seconds_between_extra_delay), |
198 weak_factory_(this) {} | 221 weak_factory_(this) {} |
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 destination, | 831 destination, |
809 to_dest_pipe.Pass(), | 832 to_dest_pipe.Pass(), |
810 from_dest_pipe.Pass(), | 833 from_dest_pipe.Pass(), |
811 net_log)); | 834 net_log)); |
812 return ret.Pass(); | 835 return ret.Pass(); |
813 } | 836 } |
814 | 837 |
815 } // namespace test | 838 } // namespace test |
816 } // namespace cast | 839 } // namespace cast |
817 } // namespace media | 840 } // namespace media |
OLD | NEW |