Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: webrtc/test/fake_network_pipe.h

Issue 2784543002: Revert of Don't hardcode MediaType::ANY in FakeNetworkPipe. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/test/direct_transport.cc ('k') | webrtc/test/fake_network_pipe.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
11 #ifndef WEBRTC_TEST_FAKE_NETWORK_PIPE_H_ 11 #ifndef WEBRTC_TEST_FAKE_NETWORK_PIPE_H_
12 #define WEBRTC_TEST_FAKE_NETWORK_PIPE_H_ 12 #define WEBRTC_TEST_FAKE_NETWORK_PIPE_H_
13 13
14 #include <memory> 14 #include <memory>
15 #include <set> 15 #include <set>
16 #include <string.h> 16 #include <string.h>
17 #include <queue> 17 #include <queue>
18 18
19 #include "webrtc/base/constructormagic.h" 19 #include "webrtc/base/constructormagic.h"
20 #include "webrtc/base/criticalsection.h" 20 #include "webrtc/base/criticalsection.h"
21 #include "webrtc/base/random.h" 21 #include "webrtc/base/random.h"
22 #include "webrtc/typedefs.h" 22 #include "webrtc/typedefs.h"
23 23
24 namespace webrtc { 24 namespace webrtc {
25 25
26 class Clock; 26 class Clock;
27 class CriticalSectionWrapper; 27 class CriticalSectionWrapper;
28 class PacketReceiver; 28 class PacketReceiver;
29 enum class MediaType;
30 29
31 class NetworkPacket { 30 class NetworkPacket {
32 public: 31 public:
33 NetworkPacket(const uint8_t* data, 32 NetworkPacket(const uint8_t* data,
34 size_t length, 33 size_t length,
35 int64_t send_time, 34 int64_t send_time,
36 int64_t arrival_time) 35 int64_t arrival_time)
37 : data_(new uint8_t[length]), 36 : data_(new uint8_t[length]),
38 data_length_(length), 37 data_length_(length),
39 send_time_(send_time), 38 send_time_(send_time),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // Link capacity in kbps. 76 // Link capacity in kbps.
78 int link_capacity_kbps = 0; 77 int link_capacity_kbps = 0;
79 // Random packet loss. 78 // Random packet loss.
80 int loss_percent = 0; 79 int loss_percent = 0;
81 // If packets are allowed to be reordered. 80 // If packets are allowed to be reordered.
82 bool allow_reordering = false; 81 bool allow_reordering = false;
83 // The average length of a burst of lost packets. 82 // The average length of a burst of lost packets.
84 int avg_burst_loss_length = -1; 83 int avg_burst_loss_length = -1;
85 }; 84 };
86 85
87 FakeNetworkPipe(Clock* clock, const FakeNetworkPipe::Config& config, 86 FakeNetworkPipe(Clock* clock, const FakeNetworkPipe::Config& config);
88 MediaType media_type);
89 FakeNetworkPipe(Clock* clock, 87 FakeNetworkPipe(Clock* clock,
90 const FakeNetworkPipe::Config& config, MediaType media_type, 88 const FakeNetworkPipe::Config& config,
91 uint64_t seed); 89 uint64_t seed);
92 ~FakeNetworkPipe(); 90 ~FakeNetworkPipe();
93 91
94 // Must not be called in parallel with SendPacket or Process. 92 // Must not be called in parallel with SendPacket or Process.
95 void SetReceiver(PacketReceiver* receiver); 93 void SetReceiver(PacketReceiver* receiver);
96 94
97 // Sets a new configuration. This won't affect packets already in the pipe. 95 // Sets a new configuration. This won't affect packets already in the pipe.
98 void SetConfig(const FakeNetworkPipe::Config& config); 96 void SetConfig(const FakeNetworkPipe::Config& config);
99 97
100 // Sends a new packet to the link. 98 // Sends a new packet to the link.
101 void SendPacket(const uint8_t* packet, size_t packet_length); 99 void SendPacket(const uint8_t* packet, size_t packet_length);
102 100
103 // Processes the network queues and trigger PacketReceiver::IncomingPacket for 101 // Processes the network queues and trigger PacketReceiver::IncomingPacket for
104 // packets ready to be delivered. 102 // packets ready to be delivered.
105 void Process(); 103 void Process();
106 int64_t TimeUntilNextProcess() const; 104 int64_t TimeUntilNextProcess() const;
107 105
108 // Get statistics. 106 // Get statistics.
109 float PercentageLoss(); 107 float PercentageLoss();
110 int AverageDelay(); 108 int AverageDelay();
111 size_t dropped_packets() { return dropped_packets_; } 109 size_t dropped_packets() { return dropped_packets_; }
112 size_t sent_packets() { return sent_packets_; } 110 size_t sent_packets() { return sent_packets_; }
113 111
114 private: 112 private:
115 Clock* const clock_; 113 Clock* const clock_;
116 const MediaType media_type_;
117 rtc::CriticalSection lock_; 114 rtc::CriticalSection lock_;
118 PacketReceiver* packet_receiver_; 115 PacketReceiver* packet_receiver_;
119 std::queue<NetworkPacket*> capacity_link_; 116 std::queue<NetworkPacket*> capacity_link_;
120 Random random_; 117 Random random_;
121 118
122 // Since we need to access both the packet with the earliest and latest 119 // Since we need to access both the packet with the earliest and latest
123 // arrival time we need to use a multiset to keep all packets sorted, 120 // arrival time we need to use a multiset to keep all packets sorted,
124 // hence, we cannot use a priority queue. 121 // hence, we cannot use a priority queue.
125 struct PacketArrivalTimeComparator { 122 struct PacketArrivalTimeComparator {
126 bool operator()(const NetworkPacket* p1, const NetworkPacket* p2) { 123 bool operator()(const NetworkPacket* p1, const NetworkPacket* p2) {
(...skipping 23 matching lines...) Expand all
150 int64_t next_process_time_; 147 int64_t next_process_time_;
151 148
152 int64_t last_log_time_; 149 int64_t last_log_time_;
153 150
154 RTC_DISALLOW_COPY_AND_ASSIGN(FakeNetworkPipe); 151 RTC_DISALLOW_COPY_AND_ASSIGN(FakeNetworkPipe);
155 }; 152 };
156 153
157 } // namespace webrtc 154 } // namespace webrtc
158 155
159 #endif // WEBRTC_TEST_FAKE_NETWORK_PIPE_H_ 156 #endif // WEBRTC_TEST_FAKE_NETWORK_PIPE_H_
OLDNEW
« no previous file with comments | « webrtc/test/direct_transport.cc ('k') | webrtc/test/fake_network_pipe.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698