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 24 matching lines...) Expand all Loading... |
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: |
77 DISALLOW_COPY_AND_ASSIGN(VideoSender); | 85 DISALLOW_COPY_AND_ASSIGN(VideoSender); |
78 }; | 86 }; |
79 | 87 |
80 class PacedVideoSender : public VideoSender, public PacedSender::Callback { | 88 class PacedVideoSender : public VideoSender, public PacedSender::Callback { |
(...skipping 24 matching lines...) Expand all Loading... |
105 | 113 |
106 PacedSender pacer_; | 114 PacedSender pacer_; |
107 Packets queue_; | 115 Packets queue_; |
108 Packets pacer_queue_; | 116 Packets pacer_queue_; |
109 | 117 |
110 DISALLOW_IMPLICIT_CONSTRUCTORS(PacedVideoSender); | 118 DISALLOW_IMPLICIT_CONSTRUCTORS(PacedVideoSender); |
111 }; | 119 }; |
112 | 120 |
113 class TcpSender : public PacketSender { | 121 class TcpSender : public PacketSender { |
114 public: | 122 public: |
115 TcpSender(PacketProcessorListener* listener, int flow_id, int64_t offset_ms) | 123 TcpSender(PacketProcessorListener* listener, int flow_id, int64_t offset_ms); |
116 : PacketSender(listener, flow_id), | 124 TcpSender(PacketProcessorListener* listener, |
117 cwnd_(10), | 125 int flow_id, |
118 ssthresh_(std::numeric_limits<int>::max()), | 126 int64_t offset_ms, |
119 ack_received_(false), | 127 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() {} | 128 virtual ~TcpSender() {} |
127 | 129 |
128 void RunFor(int64_t time_ms, Packets* in_out) override; | 130 void RunFor(int64_t time_ms, Packets* in_out) override; |
129 int GetFeedbackIntervalMs() const override { return 10; } | 131 int GetFeedbackIntervalMs() const override { return 10; } |
130 | 132 |
| 133 uint32_t TargetBitrateKbps() override; |
| 134 |
131 private: | 135 private: |
132 struct InFlight { | 136 struct InFlight { |
133 public: | 137 public: |
134 InFlight(const MediaPacket& packet) | 138 InFlight(const MediaPacket& packet) |
135 : sequence_number(packet.header().sequenceNumber), | 139 : sequence_number(packet.header().sequenceNumber), |
136 time_ms(packet.send_time_us() / 1000) {} | 140 time_ms(packet.send_time_us() / 1000) {} |
137 | 141 |
138 InFlight(uint16_t seq_num, int64_t now_ms) | 142 InFlight(uint16_t seq_num, int64_t now_ms) |
139 : sequence_number(seq_num), time_ms(now_ms) {} | 143 : sequence_number(seq_num), time_ms(now_ms) {} |
140 | 144 |
141 bool operator<(const InFlight& rhs) const { | 145 bool operator<(const InFlight& rhs) const { |
142 return sequence_number < rhs.sequence_number; | 146 return sequence_number < rhs.sequence_number; |
143 } | 147 } |
144 | 148 |
145 uint16_t sequence_number; // Sequence number of a packet in flight, or a | 149 uint16_t sequence_number; // Sequence number of a packet in flight, or a |
146 // packet which has just been acked. | 150 // packet which has just been acked. |
147 int64_t time_ms; // Time of when the packet left the sender, or when the | 151 int64_t time_ms; // Time of when the packet left the sender, or when the |
148 // ack was received. | 152 // ack was received. |
149 }; | 153 }; |
150 | 154 |
151 void SendPackets(Packets* in_out); | 155 void SendPackets(Packets* in_out); |
152 void UpdateCongestionControl(const FeedbackPacket* fb); | 156 void UpdateCongestionControl(const FeedbackPacket* fb); |
153 int TriggerTimeouts(); | 157 int TriggerTimeouts(); |
154 void HandleLoss(); | 158 void HandleLoss(); |
155 Packets GeneratePackets(size_t num_packets); | 159 Packets GeneratePackets(size_t num_packets); |
| 160 void UpdateSendBitrateEstimate(size_t num_packets); |
156 | 161 |
157 float cwnd_; | 162 float cwnd_; |
158 int ssthresh_; | 163 int ssthresh_; |
159 std::set<InFlight> in_flight_; | 164 std::set<InFlight> in_flight_; |
160 bool ack_received_; | 165 bool ack_received_; |
161 uint16_t last_acked_seq_num_; | 166 uint16_t last_acked_seq_num_; |
162 uint16_t next_sequence_number_; | 167 uint16_t next_sequence_number_; |
163 int64_t offset_ms_; | 168 int64_t offset_ms_; |
164 int64_t last_reduction_time_ms_; | 169 int64_t last_reduction_time_ms_; |
165 int64_t last_rtt_ms_; | 170 int64_t last_rtt_ms_; |
| 171 int total_sent_bytes_; |
| 172 int send_limit_bytes_; // Initialized by default as kNoLimit. |
| 173 bool running_; // Initialized by default as true. |
| 174 int64_t last_generated_packets_ms_; |
| 175 size_t num_recent_sent_packets_; |
| 176 uint32_t bitrate_kbps_; |
166 }; | 177 }; |
167 } // namespace bwe | 178 } // namespace bwe |
168 } // namespace testing | 179 } // namespace testing |
169 } // namespace webrtc | 180 } // namespace webrtc |
170 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ | 181 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ |
OLD | NEW |