OLD | NEW |
---|---|
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 22 matching lines...) Expand all Loading... | |
33 // clock_, the clock of the PacketSender and the Source must be aligned. | 33 // clock_, the clock of the PacketSender and the Source must be aligned. |
34 // We assume that both start at time 0. | 34 // We assume that both start at time 0. |
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 virtual void set_choke_filter(ChokeFilter* choke_filter) {} | |
stefan-webrtc
2015/07/02 11:03:42
Remove? Why is it needed?
magalhaesc
2015/07/02 17:17:02
Done.
| |
43 void SetSenderTimestamps(Packets* in_out); | 44 void SetSenderTimestamps(Packets* in_out); |
44 | 45 |
46 virtual uint32_t TargetBitrateKbps() { return 0; } | |
47 | |
45 protected: | 48 protected: |
46 SimulatedClock clock_; | 49 SimulatedClock clock_; |
47 }; | 50 }; |
48 | 51 |
49 class VideoSender : public PacketSender, public BitrateObserver { | 52 class VideoSender : public PacketSender, public BitrateObserver { |
50 public: | 53 public: |
51 VideoSender(PacketProcessorListener* listener, | 54 VideoSender(PacketProcessorListener* listener, |
52 VideoSource* source, | 55 VideoSource* source, |
53 BandwidthEstimatorType estimator); | 56 BandwidthEstimatorType estimator); |
54 virtual ~VideoSender(); | 57 virtual ~VideoSender(); |
55 | 58 |
56 int GetFeedbackIntervalMs() const override; | 59 int GetFeedbackIntervalMs() const override; |
57 void RunFor(int64_t time_ms, Packets* in_out) override; | 60 void RunFor(int64_t time_ms, Packets* in_out) override; |
58 | 61 |
59 virtual VideoSource* source() const { return source_; } | 62 virtual VideoSource* source() const { return source_; } |
60 | 63 |
64 uint32_t TargetBitrateKbps() override; | |
65 | |
61 // Implements BitrateObserver. | 66 // Implements BitrateObserver. |
62 void OnNetworkChanged(uint32_t target_bitrate_bps, | 67 void OnNetworkChanged(uint32_t target_bitrate_bps, |
63 uint8_t fraction_lost, | 68 uint8_t fraction_lost, |
64 int64_t rtt) override; | 69 int64_t rtt) override; |
65 | 70 |
71 void Pause(); | |
72 void Resume(); | |
73 | |
66 protected: | 74 protected: |
67 void ProcessFeedbackAndGeneratePackets(int64_t time_ms, | 75 void ProcessFeedbackAndGeneratePackets(int64_t time_ms, |
68 std::list<FeedbackPacket*>* feedbacks, | 76 std::list<FeedbackPacket*>* feedbacks, |
69 Packets* generated); | 77 Packets* generated); |
70 | 78 |
79 bool running_; | |
71 VideoSource* source_; | 80 VideoSource* source_; |
72 rtc::scoped_ptr<BweSender> bwe_; | 81 rtc::scoped_ptr<BweSender> bwe_; |
73 int64_t start_of_run_ms_; | 82 int64_t start_of_run_ms_; |
74 std::list<Module*> modules_; | 83 std::list<Module*> modules_; |
75 | 84 |
76 private: | 85 private: |
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 { |
(...skipping 24 matching lines...) Expand all Loading... | |
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; } |
133 void set_choke_filter(ChokeFilter* choke_filter) override; | |
134 | |
135 uint32_t TargetBitrateKbps() override; | |
130 | 136 |
131 private: | 137 private: |
132 struct InFlight { | 138 struct InFlight { |
133 public: | 139 public: |
134 InFlight(const MediaPacket& packet) | 140 InFlight(const MediaPacket& packet) |
135 : sequence_number(packet.header().sequenceNumber), | 141 : sequence_number(packet.header().sequenceNumber), |
136 time_ms(packet.send_time_us() / 1000) {} | 142 time_ms(packet.send_time_us() / 1000) {} |
137 | 143 |
138 InFlight(uint16_t seq_num, int64_t now_ms) | 144 InFlight(uint16_t seq_num, int64_t now_ms) |
139 : sequence_number(seq_num), time_ms(now_ms) {} | 145 : sequence_number(seq_num), time_ms(now_ms) {} |
140 | 146 |
141 bool operator<(const InFlight& rhs) const { | 147 bool operator<(const InFlight& rhs) const { |
142 return sequence_number < rhs.sequence_number; | 148 return sequence_number < rhs.sequence_number; |
143 } | 149 } |
144 | 150 |
145 uint16_t sequence_number; // Sequence number of a packet in flight, or a | 151 uint16_t sequence_number; // Sequence number of a packet in flight, or a |
146 // packet which has just been acked. | 152 // packet which has just been acked. |
147 int64_t time_ms; // Time of when the packet left the sender, or when the | 153 int64_t time_ms; // Time of when the packet left the sender, or when the |
148 // ack was received. | 154 // ack was received. |
149 }; | 155 }; |
150 | 156 |
151 void SendPackets(Packets* in_out); | 157 void SendPackets(Packets* in_out); |
152 void UpdateCongestionControl(const FeedbackPacket* fb); | 158 void UpdateCongestionControl(const FeedbackPacket* fb); |
153 int TriggerTimeouts(); | 159 int TriggerTimeouts(); |
154 void HandleLoss(); | 160 void HandleLoss(); |
155 Packets GeneratePackets(size_t num_packets); | 161 Packets GeneratePackets(size_t num_packets); |
162 void UpdateSendBitrateEstimate(size_t num_packets); | |
156 | 163 |
157 float cwnd_; | 164 float cwnd_; |
158 int ssthresh_; | 165 int ssthresh_; |
159 std::set<InFlight> in_flight_; | 166 std::set<InFlight> in_flight_; |
160 bool ack_received_; | 167 bool ack_received_; |
161 uint16_t last_acked_seq_num_; | 168 uint16_t last_acked_seq_num_; |
162 uint16_t next_sequence_number_; | 169 uint16_t next_sequence_number_; |
163 int64_t offset_ms_; | 170 int64_t offset_ms_; |
164 int64_t last_reduction_time_ms_; | 171 int64_t last_reduction_time_ms_; |
165 int64_t last_rtt_ms_; | 172 int64_t last_rtt_ms_; |
173 int total_sent_bytes_; | |
174 int send_limit_bytes_; // Initialized by default as kNoLimit. | |
175 bool running_; // Initialized by default as true. | |
176 ChokeFilter* choke_filter_; | |
177 int64_t last_generated_packets_ms_; | |
178 size_t num_recent_sent_packets_; | |
179 uint32_t bitrate_kbps_; | |
166 }; | 180 }; |
167 } // namespace bwe | 181 } // namespace bwe |
168 } // namespace testing | 182 } // namespace testing |
169 } // namespace webrtc | 183 } // namespace webrtc |
170 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ | 184 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ |
OLD | NEW |