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 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.h" | 11 #include "webrtc/modules/remote_bitrate_estimator/test/estimators/send_side.h" |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 | 14 |
15 #include "webrtc/base/logging.h" | 15 #include "webrtc/base/logging.h" |
16 #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_s
end_time.h" | 16 #include "webrtc/modules/congestion_controller/delay_based_bwe.h" |
17 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" | 17 #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" |
18 | 18 |
19 namespace webrtc { | 19 namespace webrtc { |
20 namespace testing { | 20 namespace testing { |
21 namespace bwe { | 21 namespace bwe { |
22 | 22 |
23 const int kFeedbackIntervalMs = 50; | 23 const int kFeedbackIntervalMs = 50; |
24 | 24 |
25 FullBweSender::FullBweSender(int kbps, BitrateObserver* observer, Clock* clock) | 25 SendSideBweSender::SendSideBweSender(int kbps, |
| 26 BitrateObserver* observer, |
| 27 Clock* clock) |
26 : bitrate_controller_( | 28 : bitrate_controller_( |
27 BitrateController::CreateBitrateController(clock, | 29 BitrateController::CreateBitrateController(clock, |
28 observer, | 30 observer, |
29 &event_log_)), | 31 &event_log_)), |
30 rbe_(new RemoteBitrateEstimatorAbsSendTime(this, clock)), | 32 bwe_(new DelayBasedBwe(clock)), |
31 feedback_observer_(bitrate_controller_->CreateRtcpBandwidthObserver()), | 33 feedback_observer_(bitrate_controller_->CreateRtcpBandwidthObserver()), |
32 clock_(clock), | 34 clock_(clock), |
33 send_time_history_(clock_, 10000), | 35 send_time_history_(clock_, 10000), |
34 has_received_ack_(false), | 36 has_received_ack_(false), |
35 last_acked_seq_num_(0), | 37 last_acked_seq_num_(0), |
36 last_log_time_ms_(0) { | 38 last_log_time_ms_(0) { |
37 assert(kbps >= kMinBitrateKbps); | 39 assert(kbps >= kMinBitrateKbps); |
38 assert(kbps <= kMaxBitrateKbps); | 40 assert(kbps <= kMaxBitrateKbps); |
39 bitrate_controller_->SetStartBitrate(1000 * kbps); | 41 bitrate_controller_->SetStartBitrate(1000 * kbps); |
40 bitrate_controller_->SetMinMaxBitrate(1000 * kMinBitrateKbps, | 42 bitrate_controller_->SetMinMaxBitrate(1000 * kMinBitrateKbps, |
41 1000 * kMaxBitrateKbps); | 43 1000 * kMaxBitrateKbps); |
42 rbe_->SetMinBitrate(1000 * kMinBitrateKbps); | 44 bwe_->SetMinBitrate(1000 * kMinBitrateKbps); |
43 } | 45 } |
44 | 46 |
45 FullBweSender::~FullBweSender() { | 47 SendSideBweSender::~SendSideBweSender() {} |
46 } | |
47 | 48 |
48 int FullBweSender::GetFeedbackIntervalMs() const { | 49 int SendSideBweSender::GetFeedbackIntervalMs() const { |
49 return kFeedbackIntervalMs; | 50 return kFeedbackIntervalMs; |
50 } | 51 } |
51 | 52 |
52 void FullBweSender::GiveFeedback(const FeedbackPacket& feedback) { | 53 void SendSideBweSender::GiveFeedback(const FeedbackPacket& feedback) { |
53 const SendSideBweFeedback& fb = | 54 const SendSideBweFeedback& fb = |
54 static_cast<const SendSideBweFeedback&>(feedback); | 55 static_cast<const SendSideBweFeedback&>(feedback); |
55 if (fb.packet_feedback_vector().empty()) | 56 if (fb.packet_feedback_vector().empty()) |
56 return; | 57 return; |
57 std::vector<PacketInfo> packet_feedback_vector(fb.packet_feedback_vector()); | 58 std::vector<PacketInfo> packet_feedback_vector(fb.packet_feedback_vector()); |
58 for (PacketInfo& packet_info : packet_feedback_vector) { | 59 for (PacketInfo& packet_info : packet_feedback_vector) { |
59 if (!send_time_history_.GetInfo(&packet_info, true)) { | 60 if (!send_time_history_.GetInfo(&packet_info, true)) { |
60 int64_t now_ms = clock_->TimeInMilliseconds(); | 61 int64_t now_ms = clock_->TimeInMilliseconds(); |
61 if (now_ms - last_log_time_ms_ > 5000) { | 62 if (now_ms - last_log_time_ms_ > 5000) { |
62 LOG(LS_WARNING) << "Ack arrived too late."; | 63 LOG(LS_WARNING) << "Ack arrived too late."; |
63 last_log_time_ms_ = now_ms; | 64 last_log_time_ms_ = now_ms; |
64 } | 65 } |
65 } | 66 } |
66 } | 67 } |
67 | 68 |
68 int64_t rtt_ms = | 69 int64_t rtt_ms = |
69 clock_->TimeInMilliseconds() - feedback.latest_send_time_ms(); | 70 clock_->TimeInMilliseconds() - feedback.latest_send_time_ms(); |
70 rbe_->OnRttUpdate(rtt_ms, rtt_ms); | 71 bwe_->OnRttUpdate(rtt_ms, rtt_ms); |
71 BWE_TEST_LOGGING_PLOT(1, "RTT", clock_->TimeInMilliseconds(), rtt_ms); | 72 BWE_TEST_LOGGING_PLOT(1, "RTT", clock_->TimeInMilliseconds(), rtt_ms); |
72 | 73 |
73 rbe_->IncomingPacketFeedbackVector(packet_feedback_vector); | 74 DelayBasedBwe::Result result = |
| 75 bwe_->IncomingPacketFeedbackVector(packet_feedback_vector); |
| 76 if (result.updated) |
| 77 bitrate_controller_->OnDelayBasedBweResult(result); |
| 78 |
74 if (has_received_ack_) { | 79 if (has_received_ack_) { |
75 int expected_packets = fb.packet_feedback_vector().back().sequence_number - | 80 int expected_packets = fb.packet_feedback_vector().back().sequence_number - |
76 last_acked_seq_num_; | 81 last_acked_seq_num_; |
77 // Assuming no reordering for now. | 82 // Assuming no reordering for now. |
78 if (expected_packets > 0) { | 83 if (expected_packets > 0) { |
79 int lost_packets = expected_packets - | 84 int lost_packets = expected_packets - |
80 static_cast<int>(fb.packet_feedback_vector().size()); | 85 static_cast<int>(fb.packet_feedback_vector().size()); |
81 report_block_.fractionLost = (lost_packets << 8) / expected_packets; | 86 report_block_.fractionLost = (lost_packets << 8) / expected_packets; |
82 report_block_.cumulativeLost += lost_packets; | 87 report_block_.cumulativeLost += lost_packets; |
83 uint32_t unwrapped = seq_num_unwrapper_.Unwrap( | 88 uint32_t unwrapped = seq_num_unwrapper_.Unwrap( |
84 packet_feedback_vector.back().sequence_number); | 89 packet_feedback_vector.back().sequence_number); |
85 report_block_.extendedHighSeqNum = | 90 report_block_.extendedHighSeqNum = |
86 std::max(unwrapped, report_block_.extendedHighSeqNum); | 91 std::max(unwrapped, report_block_.extendedHighSeqNum); |
87 ReportBlockList report_blocks; | 92 ReportBlockList report_blocks; |
88 report_blocks.push_back(report_block_); | 93 report_blocks.push_back(report_block_); |
89 feedback_observer_->OnReceivedRtcpReceiverReport( | 94 feedback_observer_->OnReceivedRtcpReceiverReport( |
90 report_blocks, rtt_ms, clock_->TimeInMilliseconds()); | 95 report_blocks, rtt_ms, clock_->TimeInMilliseconds()); |
91 } | 96 } |
92 bitrate_controller_->Process(); | 97 bitrate_controller_->Process(); |
93 | 98 |
94 last_acked_seq_num_ = LatestSequenceNumber( | 99 last_acked_seq_num_ = LatestSequenceNumber( |
95 packet_feedback_vector.back().sequence_number, last_acked_seq_num_); | 100 packet_feedback_vector.back().sequence_number, last_acked_seq_num_); |
96 } else { | 101 } else { |
97 last_acked_seq_num_ = packet_feedback_vector.back().sequence_number; | 102 last_acked_seq_num_ = packet_feedback_vector.back().sequence_number; |
98 has_received_ack_ = true; | 103 has_received_ack_ = true; |
99 } | 104 } |
100 } | 105 } |
101 | 106 |
102 void FullBweSender::OnPacketsSent(const Packets& packets) { | 107 void SendSideBweSender::OnPacketsSent(const Packets& packets) { |
103 for (Packet* packet : packets) { | 108 for (Packet* packet : packets) { |
104 if (packet->GetPacketType() == Packet::kMedia) { | 109 if (packet->GetPacketType() == Packet::kMedia) { |
105 MediaPacket* media_packet = static_cast<MediaPacket*>(packet); | 110 MediaPacket* media_packet = static_cast<MediaPacket*>(packet); |
106 // TODO(philipel): Add probe_cluster_id to Packet class in order | 111 // TODO(philipel): Add probe_cluster_id to Packet class in order |
107 // to create tests for probing using cluster ids. | 112 // to create tests for probing using cluster ids. |
108 send_time_history_.AddAndRemoveOld(media_packet->header().sequenceNumber, | 113 send_time_history_.AddAndRemoveOld(media_packet->header().sequenceNumber, |
109 media_packet->payload_size(), | 114 media_packet->payload_size(), |
110 PacketInfo::kNotAProbe); | 115 PacketInfo::kNotAProbe); |
111 send_time_history_.OnSentPacket(media_packet->header().sequenceNumber, | 116 send_time_history_.OnSentPacket(media_packet->header().sequenceNumber, |
112 media_packet->sender_timestamp_ms()); | 117 media_packet->sender_timestamp_ms()); |
113 } | 118 } |
114 } | 119 } |
115 } | 120 } |
116 | 121 |
117 void FullBweSender::OnReceiveBitrateChanged(const std::vector<uint32_t>& ssrcs, | 122 void SendSideBweSender::OnReceiveBitrateChanged( |
118 uint32_t bitrate) { | 123 const std::vector<uint32_t>& ssrcs, |
| 124 uint32_t bitrate) { |
119 feedback_observer_->OnReceivedEstimatedBitrate(bitrate); | 125 feedback_observer_->OnReceivedEstimatedBitrate(bitrate); |
120 } | 126 } |
121 | 127 |
122 int64_t FullBweSender::TimeUntilNextProcess() { | 128 int64_t SendSideBweSender::TimeUntilNextProcess() { |
123 return bitrate_controller_->TimeUntilNextProcess(); | 129 return bitrate_controller_->TimeUntilNextProcess(); |
124 } | 130 } |
125 | 131 |
126 void FullBweSender::Process() { | 132 void SendSideBweSender::Process() { |
127 rbe_->Process(); | |
128 bitrate_controller_->Process(); | 133 bitrate_controller_->Process(); |
129 } | 134 } |
130 | 135 |
131 SendSideBweReceiver::SendSideBweReceiver(int flow_id) | 136 SendSideBweReceiver::SendSideBweReceiver(int flow_id) |
132 : BweReceiver(flow_id), last_feedback_ms_(0) { | 137 : BweReceiver(flow_id), last_feedback_ms_(0) { |
133 } | 138 } |
134 | 139 |
135 SendSideBweReceiver::~SendSideBweReceiver() { | 140 SendSideBweReceiver::~SendSideBweReceiver() { |
136 } | 141 } |
137 | 142 |
(...skipping 16 matching lines...) Expand all Loading... |
154 packet_feedback_vector_.back().arrival_time_ms; | 159 packet_feedback_vector_.back().arrival_time_ms; |
155 FeedbackPacket* fb = new SendSideBweFeedback( | 160 FeedbackPacket* fb = new SendSideBweFeedback( |
156 flow_id_, now_ms * 1000, corrected_send_time_ms, packet_feedback_vector_); | 161 flow_id_, now_ms * 1000, corrected_send_time_ms, packet_feedback_vector_); |
157 packet_feedback_vector_.clear(); | 162 packet_feedback_vector_.clear(); |
158 return fb; | 163 return fb; |
159 } | 164 } |
160 | 165 |
161 } // namespace bwe | 166 } // namespace bwe |
162 } // namespace testing | 167 } // namespace testing |
163 } // namespace webrtc | 168 } // namespace webrtc |
OLD | NEW |