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 |
11 #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ | 11 #ifndef WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ |
12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ | 12 #define WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ |
13 | 13 |
14 #include <list> | 14 #include <list> |
15 #include <limits> | 15 #include <limits> |
16 #include <string> | 16 #include <string> |
17 | 17 |
18 #include "webrtc/base/constructormagic.h" | 18 #include "webrtc/base/constructormagic.h" |
19 #include "webrtc/base/scoped_ptr.h" | 19 #include "webrtc/base/scoped_ptr.h" |
20 #include "webrtc/modules/interface/module.h" | 20 #include "webrtc/modules/interface/module.h" |
21 #include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" | 21 #include "webrtc/modules/remote_bitrate_estimator/test/bwe.h" |
22 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h" | 22 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h" |
23 | 23 |
24 namespace webrtc { | 24 namespace webrtc { |
25 namespace testing { | 25 namespace testing { |
26 namespace bwe { | 26 namespace bwe { |
27 | 27 |
| 28 class MetricRecorder; |
| 29 |
28 class PacketSender : public PacketProcessor { | 30 class PacketSender : public PacketProcessor { |
29 public: | 31 public: |
30 PacketSender(PacketProcessorListener* listener, int flow_id) | 32 PacketSender(PacketProcessorListener* listener, int flow_id) |
31 : PacketProcessor(listener, flow_id, kSender), | 33 : PacketProcessor(listener, flow_id, kSender), |
| 34 running_(true), |
32 // For Packet::send_time_us() to be comparable with timestamps from | 35 // For Packet::send_time_us() to be comparable with timestamps from |
33 // clock_, the clock of the PacketSender and the Source must be aligned. | 36 // clock_, the clock of the PacketSender and the Source must be aligned. |
34 // We assume that both start at time 0. | 37 // We assume that both start at time 0. |
35 clock_(0) {} | 38 clock_(0), |
| 39 metric_recorder_(nullptr) {} |
36 virtual ~PacketSender() {} | 40 virtual ~PacketSender() {} |
37 // Call GiveFeedback() with the returned interval in milliseconds, provided | 41 // Call GiveFeedback() with the returned interval in milliseconds, provided |
38 // there is a new estimate available. | 42 // there is a new estimate available. |
39 // Note that changing the feedback interval affects the timing of when the | 43 // 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 | 44 // output of the estimators is sampled and therefore the baseline files may |
41 // have to be regenerated. | 45 // have to be regenerated. |
42 virtual int GetFeedbackIntervalMs() const = 0; | 46 virtual int GetFeedbackIntervalMs() const = 0; |
43 void SetSenderTimestamps(Packets* in_out); | 47 void SetSenderTimestamps(Packets* in_out); |
44 | 48 |
45 virtual uint32_t TargetBitrateKbps() { return 0; } | 49 virtual uint32_t TargetBitrateKbps() { return 0; } |
46 | 50 |
| 51 virtual void Pause(); |
| 52 virtual void Resume(int64_t paused_time_ms); |
| 53 |
| 54 void set_metric_recorder(MetricRecorder* metric_recorder); |
| 55 virtual void RecordBitrate(); |
| 56 |
47 protected: | 57 protected: |
| 58 bool running_; // Initialized by default as true. |
48 SimulatedClock clock_; | 59 SimulatedClock clock_; |
| 60 |
| 61 private: |
| 62 MetricRecorder* metric_recorder_; |
49 }; | 63 }; |
50 | 64 |
51 class VideoSender : public PacketSender, public BitrateObserver { | 65 class VideoSender : public PacketSender, public BitrateObserver { |
52 public: | 66 public: |
53 VideoSender(PacketProcessorListener* listener, | 67 VideoSender(PacketProcessorListener* listener, |
54 VideoSource* source, | 68 VideoSource* source, |
55 BandwidthEstimatorType estimator); | 69 BandwidthEstimatorType estimator); |
56 virtual ~VideoSender(); | 70 virtual ~VideoSender(); |
57 | 71 |
58 int GetFeedbackIntervalMs() const override; | 72 int GetFeedbackIntervalMs() const override; |
59 void RunFor(int64_t time_ms, Packets* in_out) override; | 73 void RunFor(int64_t time_ms, Packets* in_out) override; |
60 | 74 |
61 virtual VideoSource* source() const { return source_; } | 75 virtual VideoSource* source() const { return source_; } |
62 | 76 |
63 uint32_t TargetBitrateKbps() override; | 77 uint32_t TargetBitrateKbps() override; |
64 | 78 |
65 // Implements BitrateObserver. | 79 // Implements BitrateObserver. |
66 void OnNetworkChanged(uint32_t target_bitrate_bps, | 80 void OnNetworkChanged(uint32_t target_bitrate_bps, |
67 uint8_t fraction_lost, | 81 uint8_t fraction_lost, |
68 int64_t rtt) override; | 82 int64_t rtt) override; |
69 | 83 |
70 void Pause(); | 84 void Pause() override; |
71 void Resume(); | 85 void Resume(int64_t paused_time_ms) override; |
72 | 86 |
73 protected: | 87 protected: |
74 void ProcessFeedbackAndGeneratePackets(int64_t time_ms, | 88 void ProcessFeedbackAndGeneratePackets(int64_t time_ms, |
75 std::list<FeedbackPacket*>* feedbacks, | 89 std::list<FeedbackPacket*>* feedbacks, |
76 Packets* generated); | 90 Packets* generated); |
77 | 91 |
78 bool running_; | |
79 VideoSource* source_; | 92 VideoSource* source_; |
80 rtc::scoped_ptr<BweSender> bwe_; | 93 rtc::scoped_ptr<BweSender> bwe_; |
81 int64_t start_of_run_ms_; | 94 int64_t start_of_run_ms_; |
82 std::list<Module*> modules_; | 95 std::list<Module*> modules_; |
83 | 96 |
84 private: | 97 private: |
85 uint32_t previous_sending_bitrate_; | 98 uint32_t previous_sending_bitrate_; |
86 DISALLOW_COPY_AND_ASSIGN(VideoSender); | 99 DISALLOW_COPY_AND_ASSIGN(VideoSender); |
87 }; | 100 }; |
88 | 101 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 int ssthresh_; | 177 int ssthresh_; |
165 std::set<InFlight> in_flight_; | 178 std::set<InFlight> in_flight_; |
166 bool ack_received_; | 179 bool ack_received_; |
167 uint16_t last_acked_seq_num_; | 180 uint16_t last_acked_seq_num_; |
168 uint16_t next_sequence_number_; | 181 uint16_t next_sequence_number_; |
169 int64_t offset_ms_; | 182 int64_t offset_ms_; |
170 int64_t last_reduction_time_ms_; | 183 int64_t last_reduction_time_ms_; |
171 int64_t last_rtt_ms_; | 184 int64_t last_rtt_ms_; |
172 int total_sent_bytes_; | 185 int total_sent_bytes_; |
173 int send_limit_bytes_; // Initialized by default as kNoLimit. | 186 int send_limit_bytes_; // Initialized by default as kNoLimit. |
174 bool running_; // Initialized by default as true. | |
175 int64_t last_generated_packets_ms_; | 187 int64_t last_generated_packets_ms_; |
176 size_t num_recent_sent_packets_; | 188 size_t num_recent_sent_packets_; |
177 uint32_t bitrate_kbps_; | 189 uint32_t bitrate_kbps_; |
178 }; | 190 }; |
179 } // namespace bwe | 191 } // namespace bwe |
180 } // namespace testing | 192 } // namespace testing |
181 } // namespace webrtc | 193 } // namespace webrtc |
182 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ | 194 #endif // WEBRTC_MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_PACKET_SENDER_H_ |
OLD | NEW |