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) {} |
43 void SetSenderTimestamps(Packets* in_out); | 44 void SetSenderTimestamps(Packets* in_out); |
44 | 45 |
45 protected: | 46 protected: |
46 SimulatedClock clock_; | 47 SimulatedClock clock_; |
47 }; | 48 }; |
48 | 49 |
49 class VideoSender : public PacketSender, public BitrateObserver { | 50 class VideoSender : public PacketSender, public BitrateObserver { |
50 public: | 51 public: |
51 VideoSender(PacketProcessorListener* listener, | 52 VideoSender(PacketProcessorListener* listener, |
52 VideoSource* source, | 53 VideoSource* source, |
53 BandwidthEstimatorType estimator); | 54 BandwidthEstimatorType estimator); |
54 virtual ~VideoSender(); | 55 virtual ~VideoSender(); |
55 | 56 |
56 int GetFeedbackIntervalMs() const override; | 57 int GetFeedbackIntervalMs() const override; |
57 void RunFor(int64_t time_ms, Packets* in_out) override; | 58 void RunFor(int64_t time_ms, Packets* in_out) override; |
58 | 59 |
59 virtual VideoSource* source() const { return source_; } | 60 virtual VideoSource* source() const { return source_; } |
60 | 61 |
61 // Implements BitrateObserver. | 62 // Implements BitrateObserver. |
62 void OnNetworkChanged(uint32_t target_bitrate_bps, | 63 void OnNetworkChanged(uint32_t target_bitrate_bps, |
63 uint8_t fraction_lost, | 64 uint8_t fraction_lost, |
64 int64_t rtt) override; | 65 int64_t rtt) override; |
65 | 66 |
| 67 void Pause(); |
| 68 void Resume(); |
| 69 |
66 protected: | 70 protected: |
67 void ProcessFeedbackAndGeneratePackets(int64_t time_ms, | 71 void ProcessFeedbackAndGeneratePackets(int64_t time_ms, |
68 std::list<FeedbackPacket*>* feedbacks, | 72 std::list<FeedbackPacket*>* feedbacks, |
69 Packets* generated); | 73 Packets* generated); |
70 | 74 |
| 75 bool running_; |
71 VideoSource* source_; | 76 VideoSource* source_; |
72 rtc::scoped_ptr<BweSender> bwe_; | 77 rtc::scoped_ptr<BweSender> bwe_; |
73 int64_t start_of_run_ms_; | 78 int64_t start_of_run_ms_; |
74 std::list<Module*> modules_; | 79 std::list<Module*> modules_; |
75 | 80 |
76 private: | 81 private: |
77 DISALLOW_COPY_AND_ASSIGN(VideoSender); | 82 DISALLOW_COPY_AND_ASSIGN(VideoSender); |
78 }; | 83 }; |
79 | 84 |
80 class PacedVideoSender : public VideoSender, public PacedSender::Callback { | 85 class PacedVideoSender : public VideoSender, public PacedSender::Callback { |
(...skipping 24 matching lines...) Expand all Loading... |
105 | 110 |
106 PacedSender pacer_; | 111 PacedSender pacer_; |
107 Packets queue_; | 112 Packets queue_; |
108 Packets pacer_queue_; | 113 Packets pacer_queue_; |
109 | 114 |
110 DISALLOW_IMPLICIT_CONSTRUCTORS(PacedVideoSender); | 115 DISALLOW_IMPLICIT_CONSTRUCTORS(PacedVideoSender); |
111 }; | 116 }; |
112 | 117 |
113 class TcpSender : public PacketSender { | 118 class TcpSender : public PacketSender { |
114 public: | 119 public: |
115 TcpSender(PacketProcessorListener* listener, int flow_id, int64_t offset_ms) | 120 TcpSender(PacketProcessorListener* listener, int flow_id, int64_t offset_ms); |
116 : PacketSender(listener, flow_id), | 121 TcpSender(PacketProcessorListener* listener, |
117 cwnd_(10), | 122 int flow_id, |
118 ssthresh_(std::numeric_limits<int>::max()), | 123 int64_t offset_ms, |
119 ack_received_(false), | 124 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() {} | 125 virtual ~TcpSender() {} |
127 | 126 |
128 void RunFor(int64_t time_ms, Packets* in_out) override; | 127 void RunFor(int64_t time_ms, Packets* in_out) override; |
129 int GetFeedbackIntervalMs() const override { return 10; } | 128 int GetFeedbackIntervalMs() const override { return 10; } |
| 129 void set_choke_filter(ChokeFilter* choke_filter) override; |
130 | 130 |
131 private: | 131 private: |
132 struct InFlight { | 132 struct InFlight { |
133 public: | 133 public: |
134 InFlight(const MediaPacket& packet) | 134 InFlight(const MediaPacket& packet) |
135 : sequence_number(packet.header().sequenceNumber), | 135 : sequence_number(packet.header().sequenceNumber), |
136 time_ms(packet.send_time_us() / 1000) {} | 136 time_ms(packet.send_time_us() / 1000) {} |
137 | 137 |
138 InFlight(uint16_t seq_num, int64_t now_ms) | 138 InFlight(uint16_t seq_num, int64_t now_ms) |
139 : sequence_number(seq_num), time_ms(now_ms) {} | 139 : sequence_number(seq_num), time_ms(now_ms) {} |
(...skipping 16 matching lines...) Expand all Loading... |
156 | 156 |
157 float cwnd_; | 157 float cwnd_; |
158 int ssthresh_; | 158 int ssthresh_; |
159 std::set<InFlight> in_flight_; | 159 std::set<InFlight> in_flight_; |
160 bool ack_received_; | 160 bool ack_received_; |
161 uint16_t last_acked_seq_num_; | 161 uint16_t last_acked_seq_num_; |
162 uint16_t next_sequence_number_; | 162 uint16_t next_sequence_number_; |
163 int64_t offset_ms_; | 163 int64_t offset_ms_; |
164 int64_t last_reduction_time_ms_; | 164 int64_t last_reduction_time_ms_; |
165 int64_t last_rtt_ms_; | 165 int64_t last_rtt_ms_; |
| 166 int total_sent_bytes_; |
| 167 int send_limit_bytes_; // Initialized by default as kNoLimit. |
| 168 bool running_; // Initialized by default as true. |
| 169 ChokeFilter* choke_filter_; |
| 170 int64_t last_generated_packets_ms_; |
| 171 uint32_t estimated_kbps_; |
| 172 size_t num_recent_sent_packets_; |
166 }; | 173 }; |
167 } // namespace bwe | 174 } // namespace bwe |
168 } // namespace testing | 175 } // namespace testing |
169 } // namespace webrtc | 176 } // namespace webrtc |
170 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ | 177 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ |
OLD | NEW |