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

Side by Side Diff: webrtc/modules/remote_bitrate_estimator/test/packet_sender.h

Issue 1202253003: More Simulation Framework features (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Using rtc::scoped_ptr on nada_unittest.cc Created 5 years, 5 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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 24 matching lines...) Expand all
35 clock_(0) {} 35 clock_(0) {}
36 virtual ~PacketSender() {} 36 virtual ~PacketSender() {}
37 // Call GiveFeedback() with the returned interval in milliseconds, provided 37 // Call GiveFeedback() with the returned interval in milliseconds, provided
38 // there is a new estimate available. 38 // there is a new estimate available.
39 // Note that changing the feedback interval affects the timing of when the 39 // Note that changing the feedback interval affects the timing of when the
40 // output of the estimators is sampled and therefore the baseline files may 40 // output of the estimators is sampled and therefore the baseline files may
41 // have to be regenerated. 41 // have to be regenerated.
42 virtual int GetFeedbackIntervalMs() const = 0; 42 virtual int GetFeedbackIntervalMs() const = 0;
43 void SetSenderTimestamps(Packets* in_out); 43 void SetSenderTimestamps(Packets* in_out);
44 44
45 virtual uint32_t TargetBitrateKbps() { return 0; }
46
45 protected: 47 protected:
46 SimulatedClock clock_; 48 SimulatedClock clock_;
47 }; 49 };
48 50
49 class VideoSender : public PacketSender, public BitrateObserver { 51 class VideoSender : public PacketSender, public BitrateObserver {
50 public: 52 public:
51 VideoSender(PacketProcessorListener* listener, 53 VideoSender(PacketProcessorListener* listener,
52 VideoSource* source, 54 VideoSource* source,
53 BandwidthEstimatorType estimator); 55 BandwidthEstimatorType estimator);
54 virtual ~VideoSender(); 56 virtual ~VideoSender();
55 57
56 int GetFeedbackIntervalMs() const override; 58 int GetFeedbackIntervalMs() const override;
57 void RunFor(int64_t time_ms, Packets* in_out) override; 59 void RunFor(int64_t time_ms, Packets* in_out) override;
58 60
59 virtual VideoSource* source() const { return source_; } 61 virtual VideoSource* source() const { return source_; }
60 62
63 uint32_t TargetBitrateKbps() override;
64
61 // Implements BitrateObserver. 65 // Implements BitrateObserver.
62 void OnNetworkChanged(uint32_t target_bitrate_bps, 66 void OnNetworkChanged(uint32_t target_bitrate_bps,
63 uint8_t fraction_lost, 67 uint8_t fraction_lost,
64 int64_t rtt) override; 68 int64_t rtt) override;
65 69
70 void Pause();
71 void Resume();
72
66 protected: 73 protected:
67 void ProcessFeedbackAndGeneratePackets(int64_t time_ms, 74 void ProcessFeedbackAndGeneratePackets(int64_t time_ms,
68 std::list<FeedbackPacket*>* feedbacks, 75 std::list<FeedbackPacket*>* feedbacks,
69 Packets* generated); 76 Packets* generated);
70 77
78 bool running_;
71 VideoSource* source_; 79 VideoSource* source_;
72 rtc::scoped_ptr<BweSender> bwe_; 80 rtc::scoped_ptr<BweSender> bwe_;
73 int64_t start_of_run_ms_; 81 int64_t start_of_run_ms_;
74 std::list<Module*> modules_; 82 std::list<Module*> modules_;
75 83
76 private: 84 private:
85 uint32_t previous_sending_bitrate_;
77 DISALLOW_COPY_AND_ASSIGN(VideoSender); 86 DISALLOW_COPY_AND_ASSIGN(VideoSender);
78 }; 87 };
79 88
80 class PacedVideoSender : public VideoSender, public PacedSender::Callback { 89 class PacedVideoSender : public VideoSender, public PacedSender::Callback {
81 public: 90 public:
82 PacedVideoSender(PacketProcessorListener* listener, 91 PacedVideoSender(PacketProcessorListener* listener,
83 VideoSource* source, 92 VideoSource* source,
84 BandwidthEstimatorType estimator); 93 BandwidthEstimatorType estimator);
85 virtual ~PacedVideoSender(); 94 virtual ~PacedVideoSender();
86 95
(...skipping 18 matching lines...) Expand all
105 114
106 PacedSender pacer_; 115 PacedSender pacer_;
107 Packets queue_; 116 Packets queue_;
108 Packets pacer_queue_; 117 Packets pacer_queue_;
109 118
110 DISALLOW_IMPLICIT_CONSTRUCTORS(PacedVideoSender); 119 DISALLOW_IMPLICIT_CONSTRUCTORS(PacedVideoSender);
111 }; 120 };
112 121
113 class TcpSender : public PacketSender { 122 class TcpSender : public PacketSender {
114 public: 123 public:
115 TcpSender(PacketProcessorListener* listener, int flow_id, int64_t offset_ms) 124 TcpSender(PacketProcessorListener* listener, int flow_id, int64_t offset_ms);
116 : PacketSender(listener, flow_id), 125 TcpSender(PacketProcessorListener* listener,
117 cwnd_(10), 126 int flow_id,
118 ssthresh_(std::numeric_limits<int>::max()), 127 int64_t offset_ms,
119 ack_received_(false), 128 int send_limit_bytes);
120 last_acked_seq_num_(0),
121 next_sequence_number_(0),
122 offset_ms_(offset_ms),
123 last_reduction_time_ms_(-1),
124 last_rtt_ms_(0) {}
125
126 virtual ~TcpSender() {} 129 virtual ~TcpSender() {}
127 130
128 void RunFor(int64_t time_ms, Packets* in_out) override; 131 void RunFor(int64_t time_ms, Packets* in_out) override;
129 int GetFeedbackIntervalMs() const override { return 10; } 132 int GetFeedbackIntervalMs() const override { return 10; }
130 133
134 uint32_t TargetBitrateKbps() override;
135
131 private: 136 private:
132 struct InFlight { 137 struct InFlight {
133 public: 138 public:
134 InFlight(const MediaPacket& packet) 139 InFlight(const MediaPacket& packet)
135 : sequence_number(packet.header().sequenceNumber), 140 : sequence_number(packet.header().sequenceNumber),
136 time_ms(packet.send_time_us() / 1000) {} 141 time_ms(packet.send_time_ms()) {}
137 142
138 InFlight(uint16_t seq_num, int64_t now_ms) 143 InFlight(uint16_t seq_num, int64_t now_ms)
139 : sequence_number(seq_num), time_ms(now_ms) {} 144 : sequence_number(seq_num), time_ms(now_ms) {}
140 145
141 bool operator<(const InFlight& rhs) const { 146 bool operator<(const InFlight& rhs) const {
142 return sequence_number < rhs.sequence_number; 147 return sequence_number < rhs.sequence_number;
143 } 148 }
144 149
145 uint16_t sequence_number; // Sequence number of a packet in flight, or a 150 uint16_t sequence_number; // Sequence number of a packet in flight, or a
146 // packet which has just been acked. 151 // packet which has just been acked.
147 int64_t time_ms; // Time of when the packet left the sender, or when the 152 int64_t time_ms; // Time of when the packet left the sender, or when the
148 // ack was received. 153 // ack was received.
149 }; 154 };
150 155
151 void SendPackets(Packets* in_out); 156 void SendPackets(Packets* in_out);
152 void UpdateCongestionControl(const FeedbackPacket* fb); 157 void UpdateCongestionControl(const FeedbackPacket* fb);
153 int TriggerTimeouts(); 158 int TriggerTimeouts();
154 void HandleLoss(); 159 void HandleLoss();
155 Packets GeneratePackets(size_t num_packets); 160 Packets GeneratePackets(size_t num_packets);
161 void UpdateSendBitrateEstimate(size_t num_packets);
156 162
157 float cwnd_; 163 float cwnd_;
158 int ssthresh_; 164 int ssthresh_;
159 std::set<InFlight> in_flight_; 165 std::set<InFlight> in_flight_;
160 bool ack_received_; 166 bool ack_received_;
161 uint16_t last_acked_seq_num_; 167 uint16_t last_acked_seq_num_;
162 uint16_t next_sequence_number_; 168 uint16_t next_sequence_number_;
163 int64_t offset_ms_; 169 int64_t offset_ms_;
164 int64_t last_reduction_time_ms_; 170 int64_t last_reduction_time_ms_;
165 int64_t last_rtt_ms_; 171 int64_t last_rtt_ms_;
172 int total_sent_bytes_;
173 int send_limit_bytes_; // Initialized by default as kNoLimit.
174 bool running_; // Initialized by default as true.
175 int64_t last_generated_packets_ms_;
176 size_t num_recent_sent_packets_;
177 uint32_t bitrate_kbps_;
166 }; 178 };
167 } // namespace bwe 179 } // namespace bwe
168 } // namespace testing 180 } // namespace testing
169 } // namespace webrtc 181 } // namespace webrtc
170 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ 182 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698